基于springboot心理树洞管理系统(分前后台springboot+mybatis+mysql+maven+vue+echarts)

本文涉及的产品
RDS MySQL DuckDB 分析主实例,基础系列 4核8GB
RDS AI 助手,专业版
RDS MySQL DuckDB 分析主实例,集群系列 4核8GB
简介: 基于springboot心理树洞管理系统(分前后台springboot+mybatis+mysql+maven+vue+echarts)

一、项目简介

本项目是一套基于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


相关实践学习
自建数据库迁移到云数据库
本场景将引导您将网站的自建数据库平滑迁移至云数据库RDS。通过使用RDS,您可以获得稳定、可靠和安全的企业级数据库服务,可以更加专注于发展核心业务,无需过多担心数据库的管理和维护。
MySQL数据库入门学习
本课程通过最流行的开源数据库MySQL带你了解数据库的世界。 &nbsp; 相关的阿里云产品:云数据库RDS MySQL 版 阿里云关系型数据库RDS(Relational Database Service)是一种稳定可靠、可弹性伸缩的在线数据库服务,提供容灾、备份、恢复、迁移等方面的全套解决方案,彻底解决数据库运维的烦恼。 了解产品详情:&nbsp;https://www.aliyun.com/product/rds/mysql&nbsp;
相关文章
|
11月前
|
人工智能 运维 Java
SpringBoot+MySQL实现动态定时任务
这是一个基于Spring Boot的动态定时任务Demo,利用spring-context模块实现任务调度功能。服务启动时会扫描数据库中的任务表,将任务添加到调度器中,并通过固定频率运行的ScheduleUpdater任务动态更新任务状态和Cron表达式。核心功能包括任务的新增、删除与Cron调整,支持通过ScheduledFuture对象控制任务执行。项目依赖Spring Boot 2.2.10.RELEASE,使用MySQL存储任务信息,包含任务基类ITask及具体实现(如FooTask),便于用户扩展运维界面以增强灵活性。
358 10
|
Java 关系型数据库 MySQL
SpringBoot 通过集成 Flink CDC 来实时追踪 MySql 数据变动
通过详细的步骤和示例代码,您可以在 SpringBoot 项目中成功集成 Flink CDC,并实时追踪 MySQL 数据库的变动。
3212 45
|
12月前
|
监控 Java 关系型数据库
Spring Boot整合MySQL主从集群同步延迟解决方案
本文针对电商系统在Spring Boot+MyBatis架构下的典型问题(如大促时订单状态延迟、库存超卖误判及用户信息更新延迟)提出解决方案。核心内容包括动态数据源路由(强制读主库)、大事务拆分优化以及延迟感知补偿机制,配合MySQL参数调优和监控集成,有效将主从延迟控制在1秒内。实际测试表明,在10万QPS场景下,订单查询延迟显著降低,超卖误判率下降98%。
498 5
|
Java 关系型数据库 MySQL
如何将Spring Boot + MySQL应用程序部署到Pivotal Cloud Foundry (PCF)
如何将Spring Boot + MySQL应用程序部署到Pivotal Cloud Foundry (PCF)
288 5
|
JavaScript 安全 Java
java版药品不良反应智能监测系统源码,采用SpringBoot、Vue、MySQL技术开发
基于B/S架构,采用Java、SpringBoot、Vue、MySQL等技术自主研发的ADR智能监测系统,适用于三甲医院,支持二次开发。该系统能自动监测全院患者药物不良反应,通过移动端和PC端实时反馈,提升用药安全。系统涵盖规则管理、监测报告、系统管理三大模块,确保精准、高效地处理ADR事件。
593 1
|
SQL 前端开发 关系型数据库
SpringBoot使用mysql查询昨天、今天、过去一周、过去半年、过去一年数据
SpringBoot使用mysql查询昨天、今天、过去一周、过去半年、过去一年数据
452 9
|
分布式计算 关系型数据库 MySQL
SpringBoot项目中mysql字段映射使用JSONObject和JSONArray类型
SpringBoot项目中mysql字段映射使用JSONObject和JSONArray类型 图像处理 光通信 分布式计算 算法语言 信息技术 计算机应用
349 8
|
Java 关系型数据库 MySQL
springboot学习五:springboot整合Mybatis 连接 mysql数据库
这篇文章是关于如何使用Spring Boot整合MyBatis来连接MySQL数据库,并进行基本的增删改查操作的教程。
2983 0
springboot学习五:springboot整合Mybatis 连接 mysql数据库
|
Java 关系型数据库 MySQL
springboot学习四:springboot链接mysql数据库,使用JdbcTemplate 操作mysql
这篇文章是关于如何使用Spring Boot框架通过JdbcTemplate操作MySQL数据库的教程。
1333 0
springboot学习四:springboot链接mysql数据库,使用JdbcTemplate 操作mysql
|
前端开发 Java 数据库连接
表白墙/留言墙 —— 中级SpringBoot项目,MyBatis技术栈MySQL数据库开发,练手项目前后端开发(带完整源码) 全方位全步骤手把手教学
本文是一份全面的表白墙/留言墙项目教程,使用SpringBoot + MyBatis技术栈和MySQL数据库开发,涵盖了项目前后端开发、数据库配置、代码实现和运行的详细步骤。
394 0
表白墙/留言墙 —— 中级SpringBoot项目,MyBatis技术栈MySQL数据库开发,练手项目前后端开发(带完整源码) 全方位全步骤手把手教学

热门文章

最新文章

推荐镜像

更多