一、项目简介
本项目是一套基于springboot心理树洞管理系统,主要针对计算机相关专业的正在做毕设的学生与需要项目实战练习的Java学习者。
包含:项目源码、数据库脚本等,该项目附带全部源码可作为毕设使用。
项目都经过严格调试,eclipse或者idea 确保可以运行!
该系统功能完善、界面美观、操作简单、功能齐全、管理便捷,具有很高的实际应用价值
二、技术实现
springboot+mybatis+mysql+maven+vue+echarts
三、开发运行环境
jdk1.8
Mysql
maven
idea或者eclipse
四、系统功能
系统登录用户角色分为:管理员,学生,心理老师
前台包括:
用户登录
用户注册
首页
文章信息
个人资料
帖子信息
心理资讯
点我收藏
取消收藏
评论
个人中心
我的收藏
留言等
后台包括:
系统首页
注册心理老师
个人中心
学生管理
心理老师管理
文章分类管理
文章信息管理
个人资料管理
预约信息管理
在线咨询管理
分区管理
帖子信息管理
留言信息管理
系统管理
轮播图管理
心理资讯
关于我们
系统简介等
五、页面功能
前台
后台
六、数据库表
一共19张表
七、项目结构
八、部分代码
登录相关
package com.controller; import java.util.Arrays; import java.util.Calendar; import java.util.Date; import java.util.Map; import javax.servlet.http.HttpServletRequest; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Controller; import org.springframework.web.bind.annotation.GetMapping; import org.springframework.web.bind.annotation.PathVariable; import org.springframework.web.bind.annotation.PostMapping; import org.springframework.web.bind.annotation.RequestBody; import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.bind.annotation.RequestParam; import org.springframework.web.bind.annotation.ResponseBody; import org.springframework.web.bind.annotation.RestController; import com.annotation.IgnoreAuth; import com.baomidou.mybatisplus.mapper.EntityWrapper; import com.entity.TokenEntity; import com.entity.UsersEntity; import com.service.TokenService; import com.service.UsersService; import com.utils.CommonUtil; import com.utils.MPUtil; import com.utils.PageUtils; import com.utils.R; import com.utils.ValidatorUtils; /** * 登录相关 */ @RequestMapping("users") @RestController public class UsersController{ @Autowired private UsersService userService; @Autowired private TokenService tokenService; /** * 登录 */ @IgnoreAuth @PostMapping(value = "/login") public R login(String username, String password, String captcha, HttpServletRequest request) { UsersEntity user = userService.selectOne(new EntityWrapper<UsersEntity>().eq("username", username)); if(user==null || !user.getPassword().equals(password)) { return R.error("账号或密码不正确"); } String token = tokenService.generateToken(user.getId(),username, "users", user.getRole()); return R.ok().put("token", token); } /** * 注册 */ @IgnoreAuth @PostMapping(value = "/register") public R register(@RequestBody UsersEntity user){ // ValidatorUtils.validateEntity(user); if(userService.selectOne(new EntityWrapper<UsersEntity>().eq("username", user.getUsername())) !=null) { return R.error("用户已存在"); } userService.insert(user); return R.ok(); } /** * 退出 */ @GetMapping(value = "logout") public R logout(HttpServletRequest request) { request.getSession().invalidate(); return R.ok("退出成功"); } /** * 密码重置 */ @IgnoreAuth @RequestMapping(value = "/resetPass") public R resetPass(String username, HttpServletRequest request){ UsersEntity user = userService.selectOne(new EntityWrapper<UsersEntity>().eq("username", username)); if(user==null) { return R.error("账号不存在"); } user.setPassword("123456"); userService.update(user,null); return R.ok("密码已重置为:123456"); } /** * 列表 */ @RequestMapping("/page") public R page(@RequestParam Map<String, Object> params,UsersEntity user){ EntityWrapper<UsersEntity> ew = new EntityWrapper<UsersEntity>(); PageUtils page = userService.queryPage(params, MPUtil.sort(MPUtil.between(MPUtil.allLike(ew, user), params), params)); return R.ok().put("data", page); } /** * 列表 */ @RequestMapping("/list") public R list( UsersEntity user){ EntityWrapper<UsersEntity> ew = new EntityWrapper<UsersEntity>(); ew.allEq(MPUtil.allEQMapPre( user, "user")); return R.ok().put("data", userService.selectListView(ew)); } /** * 信息 */ @RequestMapping("/info/{id}") public R info(@PathVariable("id") String id){ UsersEntity user = userService.selectById(id); return R.ok().put("data", user); } /** * 获取用户的session用户信息 */ @RequestMapping("/session") public R getCurrUser(HttpServletRequest request){ Long id = (Long)request.getSession().getAttribute("userId"); UsersEntity user = userService.selectById(id); return R.ok().put("data", user); } /** * 保存 */ @PostMapping("/save") public R save(@RequestBody UsersEntity user){ // ValidatorUtils.validateEntity(user); if(userService.selectOne(new EntityWrapper<UsersEntity>().eq("username", user.getUsername())) !=null) { return R.error("用户已存在"); } userService.insert(user); return R.ok(); } /** * 修改 */ @RequestMapping("/update") public R update(@RequestBody UsersEntity user){ // ValidatorUtils.validateEntity(user); UsersEntity u = userService.selectOne(new EntityWrapper<UsersEntity>().eq("username", user.getUsername())); if(u!=null && u.getId()!=user.getId() && u.getUsername().equals(user.getUsername())) { return R.error("用户名已存在。"); } userService.updateById(user);//全部更新 return R.ok(); } /** * 删除 */ @RequestMapping("/delete") public R delete(@RequestBody Long[] ids){ userService.deleteBatchIds(Arrays.asList(ids)); return R.ok(); } }
留言信息
package com.controller; import java.math.BigDecimal; import java.text.SimpleDateFormat; import java.text.ParseException; import java.util.ArrayList; import java.util.Arrays; import java.util.Calendar; import java.util.Map; import java.util.HashMap; import java.util.Iterator; import java.util.Date; import java.util.List; import javax.servlet.http.HttpServletRequest; import com.utils.ValidatorUtils; import org.apache.commons.lang3.StringUtils; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.transaction.annotation.Transactional; import org.springframework.format.annotation.DateTimeFormat; import org.springframework.web.bind.annotation.PathVariable; import org.springframework.web.bind.annotation.RequestBody; import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.bind.annotation.RequestParam; import org.springframework.web.bind.annotation.RestController; import com.baomidou.mybatisplus.mapper.EntityWrapper; import com.baomidou.mybatisplus.mapper.Wrapper; import com.annotation.IgnoreAuth; import com.entity.LiuyanxinxiEntity; import com.entity.view.LiuyanxinxiView; import com.service.LiuyanxinxiService; import com.service.TokenService; import com.utils.PageUtils; import com.utils.R; import com.utils.MD5Util; import com.utils.MPUtil; import com.utils.CommonUtil; import java.io.IOException; /** * 留言信息 * 后端接口 * @author * @email * @date 2023-03-26 12:44:42 */ @RestController @RequestMapping("/liuyanxinxi") public class LiuyanxinxiController { @Autowired private LiuyanxinxiService liuyanxinxiService; /** * 后端列表 */ @RequestMapping("/page") public R page(@RequestParam Map<String, Object> params,LiuyanxinxiEntity liuyanxinxi, HttpServletRequest request){ EntityWrapper<LiuyanxinxiEntity> ew = new EntityWrapper<LiuyanxinxiEntity>(); String tableName = request.getSession().getAttribute("tableName").toString(); ew.andNew(); if(tableName.equals("xuesheng")) { ew.eq("xuehao", (String)request.getSession().getAttribute("username")); } if(tableName.equals("xuesheng")) { ew.or(); ew.eq("liuyanxuehao", (String)request.getSession().getAttribute("username")); } PageUtils page = liuyanxinxiService.queryPage(params, MPUtil.sort(MPUtil.between(MPUtil.likeOrEq(ew, liuyanxinxi), params), params)); return R.ok().put("data", page); } /** * 前端列表 */ @IgnoreAuth @RequestMapping("/list") public R list(@RequestParam Map<String, Object> params,LiuyanxinxiEntity liuyanxinxi, HttpServletRequest request){ EntityWrapper<LiuyanxinxiEntity> ew = new EntityWrapper<LiuyanxinxiEntity>(); PageUtils page = liuyanxinxiService.queryPage(params, MPUtil.sort(MPUtil.between(MPUtil.likeOrEq(ew, liuyanxinxi), params), params)); return R.ok().put("data", page); } /** * 列表 */ @RequestMapping("/lists") public R list( LiuyanxinxiEntity liuyanxinxi){ EntityWrapper<LiuyanxinxiEntity> ew = new EntityWrapper<LiuyanxinxiEntity>(); ew.allEq(MPUtil.allEQMapPre( liuyanxinxi, "liuyanxinxi")); return R.ok().put("data", liuyanxinxiService.selectListView(ew)); } /** * 查询 */ @RequestMapping("/query") public R query(LiuyanxinxiEntity liuyanxinxi){ EntityWrapper< LiuyanxinxiEntity> ew = new EntityWrapper< LiuyanxinxiEntity>(); ew.allEq(MPUtil.allEQMapPre( liuyanxinxi, "liuyanxinxi")); LiuyanxinxiView liuyanxinxiView = liuyanxinxiService.selectView(ew); return R.ok("查询留言信息成功").put("data", liuyanxinxiView); } /** * 后端详情 */ @RequestMapping("/info/{id}") public R info(@PathVariable("id") Long id){ LiuyanxinxiEntity liuyanxinxi = liuyanxinxiService.selectById(id); return R.ok().put("data", liuyanxinxi); } /** * 前端详情 */ @IgnoreAuth @RequestMapping("/detail/{id}") public R detail(@PathVariable("id") Long id){ LiuyanxinxiEntity liuyanxinxi = liuyanxinxiService.selectById(id); return R.ok().put("data", liuyanxinxi); } /** * 后端保存 */ @RequestMapping("/save") public R save(@RequestBody LiuyanxinxiEntity liuyanxinxi, HttpServletRequest request){ liuyanxinxi.setId(new Date().getTime()+new Double(Math.floor(Math.random()*1000)).longValue()); //ValidatorUtils.validateEntity(liuyanxinxi); liuyanxinxiService.insert(liuyanxinxi); return R.ok(); } /** * 前端保存 */ @RequestMapping("/add") public R add(@RequestBody LiuyanxinxiEntity liuyanxinxi, HttpServletRequest request){ liuyanxinxi.setId(new Date().getTime()+new Double(Math.floor(Math.random()*1000)).longValue()); //ValidatorUtils.validateEntity(liuyanxinxi); liuyanxinxiService.insert(liuyanxinxi); return R.ok(); } /** * 修改 */ @RequestMapping("/update") @Transactional public R update(@RequestBody LiuyanxinxiEntity liuyanxinxi, HttpServletRequest request){ //ValidatorUtils.validateEntity(liuyanxinxi); liuyanxinxiService.updateById(liuyanxinxi);//全部更新 return R.ok(); } /** * 删除 */ @RequestMapping("/delete") public R delete(@RequestBody Long[] ids){ liuyanxinxiService.deleteBatchIds(Arrays.asList(ids)); return R.ok(); } /** * 提醒接口 */ @RequestMapping("/remind/{columnName}/{type}") public R remindCount(@PathVariable("columnName") String columnName, HttpServletRequest request, @PathVariable("type") String type,@RequestParam Map<String, Object> map) { map.put("column", columnName); map.put("type", type); if(type.equals("2")) { SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd"); Calendar c = Calendar.getInstance(); Date remindStartDate = null; Date remindEndDate = null; if(map.get("remindstart")!=null) { Integer remindStart = Integer.parseInt(map.get("remindstart").toString()); c.setTime(new Date()); c.add(Calendar.DAY_OF_MONTH,remindStart); remindStartDate = c.getTime(); map.put("remindstart", sdf.format(remindStartDate)); } if(map.get("remindend")!=null) { Integer remindEnd = Integer.parseInt(map.get("remindend").toString()); c.setTime(new Date()); c.add(Calendar.DAY_OF_MONTH,remindEnd); remindEndDate = c.getTime(); map.put("remindend", sdf.format(remindEndDate)); } } Wrapper<LiuyanxinxiEntity> wrapper = new EntityWrapper<LiuyanxinxiEntity>(); if(map.get("remindstart")!=null) { wrapper.ge(columnName, map.get("remindstart")); } if(map.get("remindend")!=null) { wrapper.le(columnName, map.get("remindend")); } int count = liuyanxinxiService.selectCount(wrapper); return R.ok().put("count", count); } /** * (按值统计) */ @RequestMapping("/value/{xColumnName}/{yColumnName}") public R value(@PathVariable("yColumnName") String yColumnName, @PathVariable("xColumnName") String xColumnName,HttpServletRequest request) { Map<String, Object> params = new HashMap<String, Object>(); params.put("xColumn", xColumnName); params.put("yColumn", yColumnName); EntityWrapper<LiuyanxinxiEntity> ew = new EntityWrapper<LiuyanxinxiEntity>(); List<Map<String, Object>> result = liuyanxinxiService.selectValue(params, ew); SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd"); for(Map<String, Object> m : result) { for(String k : m.keySet()) { if(m.get(k) instanceof Date) { m.put(k, sdf.format((Date)m.get(k))); } } } return R.ok().put("data", result); } /** * (按值统计)时间统计类型 */ @RequestMapping("/value/{xColumnName}/{yColumnName}/{timeStatType}") public R valueDay(@PathVariable("yColumnName") String yColumnName, @PathVariable("xColumnName") String xColumnName, @PathVariable("timeStatType") String timeStatType,HttpServletRequest request) { Map<String, Object> params = new HashMap<String, Object>(); params.put("xColumn", xColumnName); params.put("yColumn", yColumnName); params.put("timeStatType", timeStatType); EntityWrapper<LiuyanxinxiEntity> ew = new EntityWrapper<LiuyanxinxiEntity>(); List<Map<String, Object>> result = liuyanxinxiService.selectTimeStatValue(params, ew); SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd"); for(Map<String, Object> m : result) { for(String k : m.keySet()) { if(m.get(k) instanceof Date) { m.put(k, sdf.format((Date)m.get(k))); } } } return R.ok().put("data", result); } /** * 分组统计 */ @RequestMapping("/group/{columnName}") public R group(@PathVariable("columnName") String columnName,HttpServletRequest request) { Map<String, Object> params = new HashMap<String, Object>(); params.put("column", columnName); EntityWrapper<LiuyanxinxiEntity> ew = new EntityWrapper<LiuyanxinxiEntity>(); List<Map<String, Object>> result = liuyanxinxiService.selectGroup(params, ew); SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd"); for(Map<String, Object> m : result) { for(String k : m.keySet()) { if(m.get(k) instanceof Date) { m.put(k, sdf.format((Date)m.get(k))); } } } return R.ok().put("data", result); } /** * 总数量 */ @RequestMapping("/count") public R count(@RequestParam Map<String, Object> params,LiuyanxinxiEntity liuyanxinxi, HttpServletRequest request){ EntityWrapper<LiuyanxinxiEntity> ew = new EntityWrapper<LiuyanxinxiEntity>(); int count = liuyanxinxiService.selectCount(MPUtil.sort(MPUtil.between(MPUtil.likeOrEq(ew, liuyanxinxi), params), params)); return R.ok().put("data", count); } }
九、源码地址
https://download.csdn.net/download/weixin_43860634/87814276