Java项目:springboot在线心理咨询系统

作者主页:夜未央5788

 简介:Java领域优质创作者、Java项目、学习资料、技术互助

文末获取源码

项目介绍

在线心理咨询系统,该项目分为前后台。

前台主要功能包括:首页、文章、心理评测、留言、公告等;用户登录系统后可在心理评测页面进行答题评分,系统会根据答题情况进行性格分析,包括内向、外向、外内混合等性格;
后台主要功能包括:
文章管理:文章查询、添加文章、编辑、删除等;
留言管理:留言列表的查看、回复、删除等;
用户管理:用户列表、查询、编辑、删除、重置密码等;
心理测评:测评题目查询、修改、删除;测评管理;
公告管理:公告查询、公告添加、查看、编辑、删除等;

系统设置:密码修改等;

环境需要

1.运行环境:最好是java jdk 1.8,我们在这个平台上运行的。其他版本理论上也可以。
2.IDE环境:IDEA,Eclipse,Myeclipse都可以。推荐IDEA;
3.tomcat环境:Tomcat 7.x,8.x,9.x版本均可
4.硬件环境:windows 7/8/10 1G内存以上;或者 Mac OS;
5.是否Maven项目: 是;查看源码目录中是否包含pom.xml;若包含,则为maven项目,否则为非maven项目 

6.数据库:MySql 5.7版本;

技术栈

1. 后端:SpringBoot

2. 前端:Thymeleaf+html+layui

使用说明

1. 使用Navicat或者其它工具,在mysql中创建对应名称的数据库,并导入项目的sql文件;
2. 将项目中application.properties配置文件中的数据库配置改为自己的配置;
3. 使用IDEA/Eclipse/MyEclipse导入项目,Eclipse/MyEclipse导入时,若为maven项目请选择maven;

若为maven项目,导入成功后请执行maven clean;maven install命令,配置tomcat,然后运行;

运行截图

 

 

 

 

 

 

后台页面 

 

 

 

 

 

代码相关

公告管理控制器

/**
 * 公告管理
 */
@Controller
public class NoticeController {

    private Logger logger = LoggerFactory.getLogger(this.getClass());

    @Autowired
    private NoticeService noticeService;

    @RequestMapping("/noticeUi")
    public String articleListUi() {
        if (!LoginSession.getCurrentUser().getUsername().equals("admin")) {
            return "client/html/index";
        }
        return "admin/notice/noticeList";
    }

    @RequestMapping("/noticeUiAdd")
    public String articleAddUi() {
        if (!LoginSession.getCurrentUser().getUsername().equals("admin")) {
            return "client/html/index";
        }
        return "admin/notice/noticeAdd";
    }


    /**
     * 高级查询公告列表
     *
     * @param page
     * @param limit
     * @param keyword1
     * @param keyword2
     * @return
     */
    @ResponseBody
    @RequestMapping("/admin/notice/list")
    public ServerLayResult<Notice> list(@RequestParam(value = "page", defaultValue = "1") Integer page,
                                        @RequestParam(value = "limit", defaultValue = "10") Integer limit,
                                        String keyword1, String keyword2) {
        logger.info("" + keyword1 + "---->" + keyword2);
        if (keyword1 != null && keyword1 != "" || keyword2 != null && keyword2 != "") {
            List<Notice> notices = noticeService.selectByKeyWord(page, limit, keyword1, keyword2);
            ServerLayResult result = new ServerLayResult(0, "", notices.size(), notices);
            return result;
        }
        //封装数据
        ServerLayResult result = new ServerLayResult(0, "", noticeService.count(), noticeService.selectAll(page, limit));
        return result;
    }


    /**
     * 根据ID删除公告
     *
     * @param id
     * @return
     */
    @ResponseBody
    @RequestMapping("/admin/notice/del")
    public Map<String, Object> delNotice(@RequestParam("id") int id) {
        Map<String, Object> dataMap = new HashMap<>();
        boolean isSuccess = noticeService.deleteByPrimaryKey(id);
        dataMap.put("success", isSuccess);
        return dataMap;
    }


    /**
     * 更新公告
     *
     * @param notice
     * @return
     */
    @ResponseBody
    @RequestMapping("/admin/notice/save")
    public Map<String, Object> saveNotice(@RequestBody Notice notice) {
        Map<String, Object> dataMap = new HashMap<>();
        boolean isSuccess = noticeService.insert(notice);
        dataMap.put("success", isSuccess);
        return dataMap;
    }


    @ResponseBody
    @RequestMapping("/admin/notice/update")
    public Map<String, Object> updateNotice(@RequestBody Notice notice) {
        Map<String, Object> dataMap = new HashMap<>();
        boolean isSuccess = noticeService.updateByPrimaryKey(notice);
        dataMap.put("success", isSuccess);
        return dataMap;
    }
}

文章标签管理控制器

/**
 * 文章标签
 */
@RestController
public class LabelController {

    @Autowired
    private LabelService labelService;

    @RequestMapping("/admin/label/list")
    public List<Label> list() {
        List<Label> labels = labelService.selectAll();
        return labels;
    }


}

 留言管理控制器

/**
 * 后台留言控制器
 */
@Controller
public class LeacotController {

    @Autowired
    private LeacotService leacotService;

    @Autowired
    private ReplyService replyService;

    @RequestMapping("/leacotsView")
    public String leacotUi() {
        if (!LoginSession.getCurrentUser().getUsername().equals("admin")) {
            return "client/html/index";
        }
        return "admin/leacots/leacotsList";
    }

    /**
     * 用户留言列表
     *
     * @param page
     * @param limit
     * @param keyword1
     * @return
     */
    @ResponseBody
    @RequestMapping("/admin/leacots/list")
    public ServerLayResult leacotsList(@RequestParam(value = "page", defaultValue = "1") Integer page,
                                       @RequestParam(value = "limit", defaultValue = "10") Integer limit, String keyword1) {
        if (keyword1 != null) {
            List<Leacot> leacots = leacotService.selectByKeyWord(page, limit, keyword1);
            ServerLayResult result = new ServerLayResult(0, "", leacots.size(), leacots);
            return result;
        }
        ServerLayResult result = new ServerLayResult(0, "", leacotService
                .count(), leacotService.selectAll(page, limit));
        return result;
    }

    /**
     * 根据ID删除 并且删除关联
     *
     * @param id
     * @return
     */
    @ResponseBody
    @RequestMapping("/admin/leacots/del")
    public Map<String, Object> del(@RequestParam("id") int id) {
        Map<String, Object> dataMap = new HashMap<>();
        boolean isSuccess = false;
        Leacot leacot = leacotService.selectByPrimaryKey(id);
        //删除关联
        if (leacot != null) {
            boolean delReply = replyService.deleteByPrimaryKey(leacot.getId());
            if (delReply) {
                boolean delete = leacotService.deleteByPrimaryKey(id);
                isSuccess = true;
                dataMap.put("success", isSuccess);
                return dataMap;
            }
        }
        dataMap.put("success", isSuccess);
        return dataMap;
    }

    /**
     * {id: "4", leacotsUser: "test", content: "测试留言内容", replyContent: "fsafsf", status: "on"}
     *
     * @param json
     * @return
     */
    @ResponseBody
    @RequestMapping("/admin/leacots/update")
    public Map<String, Object> update(@RequestBody JSONObject json) {
        Map<String, Object> dataMap = new HashMap<>();
        boolean isSuccess = false;
        JSONObject data = JSON.parseObject(json.toJSONString());
        Integer id = data.getInteger("id");
        String leacotsUser = data.getString("leacotsUser");
        String content = data.getString("content");
        //回复内容
        String replyContent = data.getString("replyContent");
        //回复状态
        String status = data.getString("status");
        int temp = 0;
        if (status != null) {
            if (status.equals("on")) {
                temp = 1;
            }
        }
        //默认从session获得replyUser
        Reply reply = new Reply(id, replyContent, new Date(), "admin");
        //更新回复表
        boolean updateReply = replyService.updateByPrimaryKey(reply);
        Leacot leacot = new Leacot(id, content, new Date(), leacotsUser, reply, temp);
        //更新留言表
        boolean updateLeacot = leacotService.updateByPrimaryKey(leacot);
        if (updateLeacot && updateReply) {
            isSuccess = true;
            dataMap.put("success", isSuccess);
            return dataMap;
        }
        dataMap.put("success", isSuccess);
        return dataMap;
    }

}

如果也想学习本系统,下面领取。回复:049springboot

  • 0
    点赞
  • 19
    收藏
    觉得还不错? 一键收藏
  • 打赏
    打赏
  • 17
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论 17
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

夜未央5788

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值