项目编号:BS-PT-114
一,环境介绍
语言环境:Java: jdk1.8
数据库:Mysql: mysql5.7
应用服务器:Tomcat: tomcat8.5.31
开发工具:IDEA或eclipse
开发技术:Springboot+Vue
二,项目简介
本项目基于Springboot+Vue开发实现一个前后端分离的社区志愿者管理平台系统。前端用户注册登录后可以查看相关活动信息、培训信息、新闻咨询信息等,并申请参与活动和参加志愿者的培训活动,在线在线论坛的讨论,在个人中心处可以查看自己参与的活动和培训。后台管理员主要管理人员信息、活动信息、培训信息、资讯信息、留言信息和轮播图信息等,具体参看下面系统功能展示。
三,系统展示
系统首页
志愿活动
培训信息
活动报名
在线论坛
用户管理
新闻管理
轮播图管理
志愿查询
活动报名管理
培训管理
论坛管理
四,核心代码展示
package com.spring.controller; import com.jntoo.db.*; import com.jntoo.db.utils.*; import com.spring.dao.*; import com.spring.entity.*; import com.spring.service.*; import com.spring.util.*; import java.util.*; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Controller; import org.springframework.web.bind.annotation.RequestMapping; import tk.mybatis.mapper.entity.Example; /** * 报名 */ @Controller public class BaomingController extends BaseController { @Autowired private BaomingMapper dao; @Autowired private BaomingService service; @Autowired private ZhiyuanService serviceRead; /** * 后台列表页 * */ @RequestMapping("/baoming_list") public String list() { // 检测是否有登录,没登录则跳转到登录页面 if (!checkLogin()) { return showError("尚未登录", "./login.do"); } String order = Request.get("order", "id"); // 获取前台提交的URL参数 order 如果没有则设置为id String sort = Request.get("sort", "desc"); // 获取前台提交的URL参数 sort 如果没有则设置为desc Example example = new Example(Baoming.class); // 创建一个扩展搜索类 Example.Criteria criteria = example.createCriteria(); // 创建一个扩展搜索条件类 String where = " 1=1 "; // 创建初始条件为:1=1 where += getWhere(); // 从方法中获取url 上的参数,并写成 sql条件语句 criteria.andCondition(where); // 将条件写进上面的扩展条件类中 if (sort.equals("desc")) { // 判断前台提交的sort 参数是否等于 desc倒序 是则使用倒序,否则使用正序 example.orderBy(order).desc(); // 把sql 语句设置成倒序 } else { example.orderBy(order).asc(); // 把 sql 设置成正序 } int page = request.getParameter("page") == null ? 1 : Integer.valueOf(request.getParameter("page")); // 获取前台提交的URL参数 page 如果没有则设置为1 page = Math.max(1, page); // 取两个数的最大值,防止page 小于1 List<Baoming> list = service.selectPageExample(example, page, 12); // 获取当前页的行数 // 将列表写给界面使用 assign("list", list); assign("orderby", order); // 把当前排序结果写进前台 assign("sort", sort); // 把当前排序结果写进前台 assign("where", where); // 把当前条件写给前台 return "baoming_list"; // 使用视图文件:WebRoot\baoming_list.jsp } /** * 获取前台搜索框填写的内容,并组成where 语句 */ public String getWhere() { String where = " "; // 判断URL 参数zhiyuanid是否大于0 if (Request.getInt("zhiyuanid") > 0) { // 大于0 则写入条件 where += " AND zhiyuanid='" + Request.getInt("zhiyuanid") + "' "; } // 以下是判断搜索框中是否有输入内容,判断是否前台是否有填写相关条件,符合则写入sql搜索语句 if (!Request.get("biaoti").equals("")) { where += " AND biaoti LIKE '%" + Request.get("biaoti") + "%' "; } if (!Request.get("fenlei").equals("")) { where += " AND fenlei ='" + Request.get("fenlei") + "' "; } return where; } /** * 报名人列表 */ @RequestMapping("/baoming_list_baomingren") public String listbaomingren() { // 检测是否有登录,没登录则跳转到登录页面 if (!checkLogin()) { return showError("尚未登录", "./login.do"); } String order = Request.get("order", "id"); // 获取前台提交的URL参数 order 如果没有则设置为id String sort = Request.get("sort", "desc"); // 获取前台提交的URL参数 sort 如果没有则设置为desc Example example = new Example(Baoming.class); // 创建一个扩展搜索类 Example.Criteria criteria = example.createCriteria(); // 创建一个扩展搜索条件类 // 初始化一个条件,条件为:报名人=当前登录用户 String where = " baomingren='" + session.getAttribute("username") + "' "; where += getWhere(); criteria.andCondition(where); // 将条件写入 if (sort.equals("desc")) { // 注释同list example.orderBy(order).desc(); // 注释同list } else { example.orderBy(order).asc(); // 注释同list } int page = request.getParameter("page") == null ? 1 : Integer.valueOf(request.getParameter("page")); // 注释同list page = Math.max(1, page); // 注释同list List<Baoming> list = service.selectPageExample(example, page, 12); request.setAttribute("list", list); assign("orderby", order); assign("sort", sort); assign("where", where); return "baoming_list_baomingren"; } @RequestMapping("/baoming_add") public String add() { int id = Request.getInt("id"); // 根据id 获取 志愿模块中的数据 Zhiyuan readMap = serviceRead.find(id); // 将数据行写入给前台jsp页面 request.setAttribute("readMap", readMap); return "baoming_add"; } @RequestMapping("/baomingadd") public String addWeb() { if (!checkLogin()) { return showError("尚未登录", "./"); } int id = Request.getInt("id"); // 根据id 获取 志愿模块中的数据 Zhiyuan readMap = serviceRead.find(id); request.setAttribute("readMap", readMap); return "baomingadd"; } @RequestMapping("/baoming_updt") public String updt() { int id = Request.getInt("id"); // 获取行数据,并赋值给前台jsp页面 Baoming mmm = service.find(id); request.setAttribute("mmm", mmm); request.setAttribute("updtself", 0); return "baoming_updt"; } /** * 添加内容 * @return */ @RequestMapping("/baominginsert") public String insert() { String tmp = ""; Baoming post = new Baoming(); // 创建实体类 // 设置前台提交上来的数据到实体类中 post.setZhiyuanid(Request.getInt("zhiyuanid")); post.setBiaoti(Request.get("biaoti")); post.setFenlei(Request.get("fenlei")); post.setKaishishijian(Request.get("kaishishijian")); post.setJieshushijian(Request.get("jieshushijian")); post.setDidian(Request.get("didian")); post.setLianxiren(Request.get("lianxiren")); post.setLianxidianhua(Request.get("lianxidianhua")); post.setZhiyuanzhexingming(Request.get("zhiyuanzhexingming")); post.setShouji(Request.get("shouji")); post.setBaomingren(Request.get("baomingren")); post.setZhiyuanid(Request.getInt("zhiyuanid")); service.insert(post); // 插入数据 int charuid = post.getId().intValue(); Query.execute("UPDATE zhiyuan SET yibaoming=yibaoming+1 WHERE id='" + request.getParameter("zhiyuanid") + "'"); return showSuccess("保存成功", Request.get("referer").equals("") ? request.getHeader("referer") : Request.get("referer")); } /** * 更新内容 * @return */ @RequestMapping("/baomingupdate") public String update() { // 创建实体类 Baoming post = new Baoming(); // 将前台表单数据填充到实体类 if (!Request.get("zhiyuanid").equals("")) post.setZhiyuanid(Request.getInt("zhiyuanid")); if (!Request.get("biaoti").equals("")) post.setBiaoti(Request.get("biaoti")); if (!Request.get("fenlei").equals("")) post.setFenlei(Request.get("fenlei")); if (!Request.get("kaishishijian").equals("")) post.setKaishishijian(Request.get("kaishishijian")); if (!Request.get("jieshushijian").equals("")) post.setJieshushijian(Request.get("jieshushijian")); if (!Request.get("didian").equals("")) post.setDidian(Request.get("didian")); if (!Request.get("lianxiren").equals("")) post.setLianxiren(Request.get("lianxiren")); if (!Request.get("lianxidianhua").equals("")) post.setLianxidianhua(Request.get("lianxidianhua")); if (!Request.get("zhiyuanzhexingming").equals("")) post.setZhiyuanzhexingming(Request.get("zhiyuanzhexingming")); if (!Request.get("shouji").equals("")) post.setShouji(Request.get("shouji")); if (!Request.get("baomingren").equals("")) post.setBaomingren(Request.get("baomingren")); post.setId(Request.getInt("id")); service.update(post); // 更新数据 int charuid = post.getId().intValue(); return showSuccess("保存成功", Request.get("referer")); // 弹出保存成功,并跳转到前台提交的 referer 页面 } /** * 后台详情 */ @RequestMapping("/baoming_detail") public String detail() { int id = Request.getInt("id"); Baoming map = service.find(id); // 根据前台url 参数中的id获取行数据 request.setAttribute("map", map); // 把数据写到前台 return "baoming_detail"; // 详情页面:WebRoot\baoming_detail.jsp } /** * 删除 */ @RequestMapping("/baoming_delete") public String delete() { if (!checkLogin()) { return showError("尚未登录"); } int id = Request.getInt("id"); // 根据id 删除某行数据 Map map = Query.make("baoming").find(id); service.delete(id); // 根据id 删除某行数据 return showSuccess("删除成功", request.getHeader("referer")); //弹出删除成功,并跳回上一页 } }
package com.spring.controller; import com.alibaba.fastjson.*; import com.spring.util.*; import com.spring.util.Request; import java.util.List; import java.util.Map; import org.springframework.stereotype.Controller; import org.springframework.web.bind.annotation.*; /** * 公共路由 */ @Controller public class CommonController extends BaseController { /** * 使用ajax 检测某表中某个字段是否已存在,已存在则无法提交 * @return */ @RequestMapping(value = "/checkno") @ResponseBody public String checkon() { String table = request.getParameter("table"); String col = request.getParameter("col"); String checktype = request.getParameter("checktype"); String value = request.getParameter(col); if (checktype.equals("insert")) { if (Query.make(table).where(col, value).count() > 0) { return "false"; } else { return "true"; } } else if (checktype.equals("update")) { String id = request.getParameter("id") == null ? "" : request.getParameter("id"); if (Query.make(table).where(col, value).where("id", "neq", id).count() > 0) { return "false"; } else { return "true"; } } return "false"; } /** * 审核数据,将是否审核改为已审核状态,点击一下 是 则变否, 点击一下 否 变为是 * @return */ @RequestMapping("/sh") @ResponseBody public String sh() { String yuan = request.getParameter("yuan"); String id = request.getParameter("id"); String tablename = request.getParameter("tablename"); String sql = ""; if (yuan.equals("是")) { sql = "update " + tablename + " set issh='否' where id=" + id; } else { sql = "update " + tablename + " set issh='是' where id=" + id; } Query.execute(sql); if (isAjax()) { jsonResult("ok"); return ""; } return "<script>location.href='" + request.getHeader("Referer") + "';</script>"; } /** * 获取表的某行数据 * @return */ @RequestMapping("/tableAjax") @ResponseBody public String tableFind() { String table = request.getParameter("table"); String id = request.getParameter("id"); Map map = Query.make(table).where("id", id).find(); //JSONObject json = JSONObject.parse(map); return JSON.toJSONString(map); //.toString(); } /** * 获取某表得某行数据 * */ @RequestMapping("/selectView") public String selectView() { String key = request.getParameter("key"); String table = request.getParameter("table"); String value = request.getParameter("value"); Map data = Query.make(table).where(key, value).find(); return jsonResult(data); } /** * 获取某表得所有数据 * */ @RequestMapping("/selectAll") public String selectAll() { String table = request.getParameter("table"); Query query = Query.make(table); if (request.getParameter("where") != null) { JSONObject where = JSON.parseObject(Request.get("where")); for (Map.Entry entry : where.entrySet()) { String key = (String) entry.getKey(); Object value = entry.getValue(); if (value instanceof JSONObject) { JSONObject w = (JSONObject) value; query.where(key, w.getString("exp"), w.getString("value")); } else if (value instanceof JSONArray) { JSONArray w = (JSONArray) value; query.where(key, (String) w.get(0), w.get(1)); } else { query.where(key, value); } } } if (request.getParameter("limit") != null) { query.limit(Request.get("limit")); } if (request.getParameter("order") != null) { query.order(Request.get("order")); } if (request.getParameter("field") != null) { query.field(Request.get("field")); } List list = query.select(); return jsonResult(list); } /** * 搜索下拉某表的数据 * @return */ @RequestMapping("/selectUpdateSearch") @ResponseBody public String selectUpdateSearch() { String table = Request.get("table"); Query query = Query.make(table); String limit = "50"; JSONObject where = JSON.parseObject(Request.get("where")); for (Map.Entry entry : where.entrySet()) { String key = (String) entry.getKey(); Object value = entry.getValue(); if ("limit".equals(key)) { limit = String.valueOf(value); } else { if (value instanceof JSONObject) { JSONObject w = (JSONObject) value; query.where(key, w.getString("exp"), w.getString("value")); } else if (value instanceof JSONArray) { JSONArray w = (JSONArray) value; query.where(key, (String) w.get(0), w.get(1)); } else { query.where(key, value); } } } List list = query.order("id desc").limit(limit).select(); return JSON.toJSONString(list); } }
五,相关作品展示
基于Java开发、Python开发、PHP开发、C#开发等相关语言开发的实战项目
基于Nodejs、Vue等前端技术开发的前端实战项目
基于微信小程序和安卓APP应用开发的相关作品
基于51单片机等嵌入式物联网开发应用
基于各类算法实现的AI智能应用
基于大数据实现的各类数据管理和推荐系统