文末获取源码
开发语言:Java
框架:SSM
JDK版本:JDK1.8
服务器:tomcat7
数据库:mysql 5.7/8.0
数据库工具:Navicat11
开发软件:eclipse/myeclipse/idea
Maven包:Maven3.3.9
浏览器:谷歌浏览器
一、前言介绍
本系统主要论述了如何使用JAVA语言开发一个大学生心理健康系统 ,本系统将严格按照软件开发流程进行各个阶段的工作,采用B/S架构,面向对象编程思想进行项目开发。在引言中,作者将论述心灵治愈交流平台的当前背景以及系统开发的目的,后续章节将严格按照软件开发流程,对系统进行各个阶段分析设计。
大学生心理健康系统的主要使用者分为管理员和学生、心理咨询师,实现功能包括(1)管理员:首页、个人中心、学生管理、心理知识管理、心理咨询师管理、在线预约管理、在线留言管理、心理问卷管理、问卷测评管理、问卷评分管理、系统管理,(2)学生:首页、个人中心、在线预约管理、在线留言管理、问卷测评管理、问卷评分管理、我的收藏管理;(3)心理咨询师:首页、个人中心、心理知识管理、在线预约管理、在线留言管理、心理问卷管理、问卷测评管理、问卷评分管理,(4)前台首页;首页、心理知识、心理咨询师、心理问卷、系统公告、个人中心、后台管理等功能。由于本网站的功能模块设计比较全面,所以使得整个心灵治愈交流平台信息管理的过程得以实现。
本系统的使用可以实现本大学生心理健康系统管理的信息化,可以方便管理员进行更加方便快捷的管理,可以提高管理人员的工作效率。
二、系统功能分析
本大学生心理健康系统主要包括三大功能模块,即学生功能模块、心理咨询师功能模块和管理员功能模块。
(1)管理员模块:系统中的核心用户是管理员,管理员登录后,通过管理员来管理后台系统。主要功能有:首页、个人中心、学生管理、心理知识管理、心理咨询师管理、在线预约管理、在线留言管理、心理问卷管理、问卷测评管理、问卷评分管理、系统管理等功能。
(2)学生:首页、个人中心、在线预约管理、在线留言管理、问卷测评管理、问卷评分管理、我的收藏管理。
(3)心理咨询师:页、个人中心、心理知识管理、在线预约管理、在线留言管理、心理问卷管理、问卷测评管理、问卷评分管理。
三、系统展示
首页
心理知识![](https://i-blog.csdnimg.cn/blog_migrate/4fe20a8a2887bf8d0461eb76ae64e257.png)
心理咨询师
心理问卷
管理员功能模块 ![](https://i-blog.csdnimg.cn/blog_migrate/14b4b2e3e6d4c2471c879f6f2bea3ed7.png)
心理问卷管理
问卷测评管理![](https://i-blog.csdnimg.cn/blog_migrate/fcd24ca5231f002b8384d41fca54f5f8.png)
部分核心代码
上传文件
/**
* 上传文件
*/
@RequestMapping("/upload")
public R upload(@RequestParam("file") MultipartFile file, String type,HttpServletRequest request) throws Exception {
if (file.isEmpty()) {
throw new EIException("上传文件不能为空");
}
String fileExt = file.getOriginalFilename().substring(file.getOriginalFilename().lastIndexOf(".")+1);
String fileName = new Date().getTime()+"."+fileExt;
File dest = new File(request.getSession().getServletContext().getRealPath("/upload")+"/"+fileName);
file.transferTo(dest);
if(StringUtils.isNotBlank(type) && type.equals("1")) {
ConfigEntity configEntity = configService.selectOne(new EntityWrapper<ConfigEntity>().eq("name", "faceFile"));
if(configEntity==null) {
configEntity = new ConfigEntity();
configEntity.setName("faceFile");
configEntity.setValue(fileName);
} else {
configEntity.setValue(fileName);
}
configService.insertOrUpdate(configEntity);
}
return R.ok().put("file", fileName);
}
问卷测评
/**
* 问卷测评
* 后端接口
* @author
* @email
* @date 2021-03-25 11:38:38
*/
@RestController
@RequestMapping("/wenjuanceping")
public class WenjuancepingController {
@Autowired
private WenjuancepingService wenjuancepingService;
/**
* 后端列表
*/
@RequestMapping("/page")
public R page(@RequestParam Map<String, Object> params,WenjuancepingEntity wenjuanceping,
HttpServletRequest request){
String tableName = request.getSession().getAttribute("tableName").toString();
if(tableName.equals("xinlizixunshi")) {
wenjuanceping.setZixunshizhanghao((String)request.getSession().getAttribute("username"));
}
if(tableName.equals("xuesheng")) {
wenjuanceping.setXueshengzhanghao((String)request.getSession().getAttribute("username"));
}
EntityWrapper<WenjuancepingEntity> ew = new EntityWrapper<WenjuancepingEntity>();
PageUtils page = wenjuancepingService.queryPage(params, MPUtil.sort(MPUtil.between(MPUtil.likeOrEq(ew, wenjuanceping), params), params));
return R.ok().put("data", page);
}
/**
* 前端列表
*/
@RequestMapping("/list")
public R list(@RequestParam Map<String, Object> params,WenjuancepingEntity wenjuanceping, HttpServletRequest request){
EntityWrapper<WenjuancepingEntity> ew = new EntityWrapper<WenjuancepingEntity>();
PageUtils page = wenjuancepingService.queryPage(params, MPUtil.sort(MPUtil.between(MPUtil.likeOrEq(ew, wenjuanceping), params), params));
return R.ok().put("data", page);
}
/**
* 列表
*/
@RequestMapping("/lists")
public R list( WenjuancepingEntity wenjuanceping){
EntityWrapper<WenjuancepingEntity> ew = new EntityWrapper<WenjuancepingEntity>();
ew.allEq(MPUtil.allEQMapPre( wenjuanceping, "wenjuanceping"));
return R.ok().put("data", wenjuancepingService.selectListView(ew));
}
/**
* 查询
*/
@RequestMapping("/query")
public R query(WenjuancepingEntity wenjuanceping){
EntityWrapper< WenjuancepingEntity> ew = new EntityWrapper< WenjuancepingEntity>();
ew.allEq(MPUtil.allEQMapPre( wenjuanceping, "wenjuanceping"));
WenjuancepingView wenjuancepingView = wenjuancepingService.selectView(ew);
return R.ok("查询问卷测评成功").put("data", wenjuancepingView);
}
/**
* 后端详情
*/
@RequestMapping("/info/{id}")
public R info(@PathVariable("id") Long id){
WenjuancepingEntity wenjuanceping = wenjuancepingService.selectById(id);
return R.ok().put("data", wenjuanceping);
}
/**
* 前端详情
*/
@RequestMapping("/detail/{id}")
public R detail(@PathVariable("id") Long id){
WenjuancepingEntity wenjuanceping = wenjuancepingService.selectById(id);
return R.ok().put("data", wenjuanceping);
}
/**
* 后端保存
*/
@RequestMapping("/save")
public R save(@RequestBody WenjuancepingEntity wenjuanceping, HttpServletRequest request){
wenjuanceping.setId(new Date().getTime()+new Double(Math.floor(Math.random()*1000)).longValue());
//ValidatorUtils.validateEntity(wenjuanceping);
wenjuancepingService.insert(wenjuanceping);
return R.ok();
}
/**
* 前端保存
*/
@RequestMapping("/add")
public R add(@RequestBody WenjuancepingEntity wenjuanceping, HttpServletRequest request){
wenjuanceping.setId(new Date().getTime()+new Double(Math.floor(Math.random()*1000)).longValue());
//ValidatorUtils.validateEntity(wenjuanceping);
wenjuancepingService.insert(wenjuanceping);
return R.ok();
}
/**
* 修改
*/
@RequestMapping("/update")
public R update(@RequestBody WenjuancepingEntity wenjuanceping, HttpServletRequest request){
//ValidatorUtils.validateEntity(wenjuanceping);
wenjuancepingService.updateById(wenjuanceping);//全部更新
return R.ok();
}
/**
* 删除
*/
@RequestMapping("/delete")
public R delete(@RequestBody Long[] ids){
wenjuancepingService.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<WenjuancepingEntity> wrapper = new EntityWrapper<WenjuancepingEntity>();
if(map.get("remindstart")!=null) {
wrapper.ge(columnName, map.get("remindstart"));
}
if(map.get("remindend")!=null) {
wrapper.le(columnName, map.get("remindend"));
}
String tableName = request.getSession().getAttribute("tableName").toString();
if(tableName.equals("xinlizixunshi")) {
wrapper.eq("zixunshizhanghao", (String)request.getSession().getAttribute("username"));
}
if(tableName.equals("xuesheng")) {
wrapper.eq("xueshengzhanghao", (String)request.getSession().getAttribute("username"));
}
int count = wenjuancepingService.selectCount(wrapper);
return R.ok().put("count", count);
}
}
学生登录
/**
* 登录
*/
@IgnoreAuth
@RequestMapping(value = "/login")
public R login(String username, String password, String captcha, HttpServletRequest request) {
XueshengEntity user = xueshengService.selectOne(new EntityWrapper<XueshengEntity>().eq("xueshengzhanghao", username));
if(user==null || !user.getMima().equals(password)) {
return R.error("账号或密码不正确");
}
String token = tokenService.generateToken(user.getId(), username,"xuesheng", "学生" );
return R.ok().put("token", token);
}