Java+SpringBoot+JSP实现在线心理评测与咨询系统

发布于:2023-01-09 ⋅ 阅读:(443) ⋅ 点赞:(0)

文末获取源码

开发语言:Java

框架:SpringBoot

技术:JSP

JDK版本:JDK1.8

服务器:tomcat7

数据库:mysql 5.7/8.0

数据库工具:Navicat11

开发软件:eclipse/myeclipse/idea

Maven包:Maven3.3.9

浏览器:谷歌浏览器

前言介绍 

随着互联网技术的高速发展,人们生活的各方面都受到互联网技术的影响。现在人们可以通过互联网技术就能实现不出家门就可以通过网络进行系统管理,交易等,而且过程简单、快捷。同样的,在人们的工作生活中,也就需要互联网技术来方便人们的日常工作生活,实现工作办公的自动化处理,实现信息化,无纸化办公。

本课题在充分研究了在ssm框架基础上,采用B/S模式,以Java为开发语言,MyEclipse为开发工具,MySQL为数据管理平台,实现的内容主要包括个人中心,学生管理,心理辅导员管理,心理测评管理,心理测试管理,在线咨询,试题管理,在线探讨,系统管理,考试管理等功能。

功能需求分析

根据一般在线心理评测与咨询管理系统的功能需求分析,本系统的功能模块如下:

(1)在个人中心,管理员可以修改自己的用户名和登录密码。

(2)在系统前台可以查看首页,心理测评,在线探讨,心理测试,在线咨询,个人中心等功能。

(3)在心理辅导员管理模块中,可以对个人中心,心理测评管理,试题管理,在线探讨,我的收藏管理,心理测试管理,考试管理等功能进行详细操作。

(3)在管理员模块中,管理员可以对个人中心,学生管理,心理辅导员管理,心理测评管理,心理测试管理,在线咨询,试题管理,在线探讨,系统管理,考试管理等功能进行查看,修改和删除等操作。

系统总体设计图

数据库设计 

数据可设计要遵循职责分离原则,即在设计时应该要考虑系统独立性,即每个系统之间互不干预不能混乱数据表和系统关系。

数据库命名也要遵循一定规范,否则容易混淆,数据库字段名要尽量做到与表名类似,多使用小写英文字母和下划线来命名并尽量使用简单单词。

概念模型是对现实中的问题出现的事物的进行描述,ER图是由实体及其关系构成的图,通过E-R图可以清楚地描述系统涉及到的实体之间的相互关系。

学生注册实体图如图

心理辅导员管理实体图如图 

在线咨询管理实体图如图

系统功能模块

在线心理评测与咨询系统,在系统首页可以查看首页,心理测评,在线探讨,心理测试,在线咨询,个人中心等内容,并进行详细操作;如图 

学生注册

在学生注册页面通过填写学生账号,学生姓名,密码,确认密码,联系方式等信息进行注册操作,如图 

心理测评

在心理测评页面可以查看标题,发布时间等内容,并进行收藏和评论操作,如图 

心理测试 

个人中心

在个人中心页面通过填写学生账号,学生姓名,密码,性别,联系方式等内容进行更新信息操作,并根据需要对我的发布,我的收藏,考试记录,错题本进行详细操作;如图 

管理员功能

管理员进入系统前在登录页面根据要求填写用户名,密码等信息,点击登录进行登录操作,如图

管理员登录进入在线心理评测与咨询系统可以对查看个人中心,学生管理,心理辅导员管理,心理测评管理,心理测试管理,在线咨询,试题管理,在线探讨,系统管理,考试管理等功能,还能对每个功能逐一进行相应操作,如图 

心理辅导员管理

在心理辅导员管理页面可以对辅导账号,辅导姓名,性别,联系方式,头像等内容进行查看,修改和删除操作,如图 

心理测评管理

在心理测评管理页面可以对标题,封面,发布时间等内容进行查看,修改,查看评论和删除等操作,如图 

在线咨询管理

在在线咨询管理页面可以对用户名,留言内容,留言图片,回复内容,回复图片等内容进行查看,修改,回复和删除等操作,如图 

试题管理

在试题管理页面可以对心理测评,试题,类型,答案,分数等内容进行修改和删除等操作,如图 

在线探讨管理

在在线探讨管理页面可以对贴子标题,用户名,状态等内容进行查看,修改和删除等操作,如图

系统管理

在轮播图管理页面可以对名称,值等内容进行查看和修改等操作,如图 

心理辅导员功能模块

心理辅导员登录进入在线心理评测与咨询系统可以对个人中心,心理测评管理,试题管理,在线探讨,我的收藏管理,心理测试管理,考试管理等功能进行相应操作,如图 

心理测试管理

在心理测试管理页面可以对心理测试名称,考试时长(分钟),心理测试状态等内容进行查看,修改和删除等操作,如图 

部分核心代码

上传文件映射表

/**
 * 上传文件映射表
 */
@RestController
@RequestMapping("file")
@SuppressWarnings({"unchecked","rawtypes"})
public class FileController{
	@Autowired
    private ConfigService configService;
	/**
	 * 上传文件
	 */
	@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);
		/**
		* 如果使用idea或者eclipse重启项目,发现之前上传的图片或者文件丢失,将下面一行代码注释打开
		* 请将以下的"D:\\ssmpiv99\\src\\main\\webapp\\upload"替换成你本地项目的upload路径,
		* 并且项目路径不能存在中文、空格等特殊字符
		*/
		//FileUtils.copyFile(dest, new File("D:\\ssmpiv99\\src\\main\\webapp\\upload"+"/"+fileName)); /**修改了路径以后请将该行最前面的//注释去掉**/
		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);
	}
	
	/**
	 * 下载文件
	 */
	@IgnoreAuth
	@RequestMapping("/download")
	public void download(@RequestParam String fileName, HttpServletRequest request, HttpServletResponse response) {
		try {
			File file = new File(request.getSession().getServletContext().getRealPath("/upload")+"/"+fileName);
			if (file.exists()) {
				response.reset();
				response.setHeader("Content-Disposition", "attachment; filename=\"" + fileName+"\"");
				response.setHeader("Cache-Control", "no-cache");
				response.setHeader("Access-Control-Allow-Credentials", "true");
				response.setContentType("application/octet-stream; charset=UTF-8");
				IOUtils.write(FileUtils.readFileToByteArray(file), response.getOutputStream());
			}

		} catch (IOException e) {
			e.printStackTrace();
		}
	}
	
}
/**
 * 心理测评
 * 后端接口
 * @author 
 * @email 
 * @date 2022-04-16 11:47:06
 */
@RestController
@RequestMapping("/xinliceping")
public class XinlicepingController {
    @Autowired
    private XinlicepingService xinlicepingService;


    @Autowired
    private StoreupService storeupService;

    


    /**
     * 后端列表
     */
    @RequestMapping("/page")
    public R page(@RequestParam Map<String, Object> params,XinlicepingEntity xinliceping, 
		HttpServletRequest request){

        EntityWrapper<XinlicepingEntity> ew = new EntityWrapper<XinlicepingEntity>();
    	PageUtils page = xinlicepingService.queryPage(params, MPUtil.sort(MPUtil.between(MPUtil.likeOrEq(ew, xinliceping), params), params));
		request.setAttribute("data", page);
        return R.ok().put("data", page);
    }
    
    /**
     * 前端列表
     */
	@IgnoreAuth
    @RequestMapping("/list")
    public R list(@RequestParam Map<String, Object> params,XinlicepingEntity xinliceping, 
		HttpServletRequest request){
        EntityWrapper<XinlicepingEntity> ew = new EntityWrapper<XinlicepingEntity>();
    	PageUtils page = xinlicepingService.queryPage(params, MPUtil.sort(MPUtil.between(MPUtil.likeOrEq(ew, xinliceping), params), params));
		request.setAttribute("data", page);
        return R.ok().put("data", page);
    }

	/**
     * 列表
     */
    @RequestMapping("/lists")
    public R list( XinlicepingEntity xinliceping){
       	EntityWrapper<XinlicepingEntity> ew = new EntityWrapper<XinlicepingEntity>();
      	ew.allEq(MPUtil.allEQMapPre( xinliceping, "xinliceping")); 
        return R.ok().put("data", xinlicepingService.selectListView(ew));
    }

	 /**
     * 查询
     */
    @RequestMapping("/query")
    public R query(XinlicepingEntity xinliceping){
        EntityWrapper< XinlicepingEntity> ew = new EntityWrapper< XinlicepingEntity>();
 		ew.allEq(MPUtil.allEQMapPre( xinliceping, "xinliceping")); 
		XinlicepingView xinlicepingView =  xinlicepingService.selectView(ew);
		return R.ok("查询心理测评成功").put("data", xinlicepingView);
    }
	
    /**
     * 后端详情
     */
    @RequestMapping("/info/{id}")
    public R info(@PathVariable("id") Long id){
        XinlicepingEntity xinliceping = xinlicepingService.selectById(id);
		xinliceping.setClicktime(new Date());
		xinlicepingService.updateById(xinliceping);
        return R.ok().put("data", xinliceping);
    }

    /**
     * 前端详情
     */
	@IgnoreAuth
    @RequestMapping("/detail/{id}")
    public R detail(@PathVariable("id") Long id){
        XinlicepingEntity xinliceping = xinlicepingService.selectById(id);
		xinliceping.setClicktime(new Date());
		xinlicepingService.updateById(xinliceping);
        return R.ok().put("data", xinliceping);
    }
    


    /**
     * 赞或踩
     */
    @RequestMapping("/thumbsup/{id}")
    public R vote(@PathVariable("id") String id,String type){
        XinlicepingEntity xinliceping = xinlicepingService.selectById(id);
        if(type.equals("1")) {
        	xinliceping.setThumbsupnum(xinliceping.getThumbsupnum()+1);
        } else {
        	xinliceping.setCrazilynum(xinliceping.getCrazilynum()+1);
        }
        xinlicepingService.updateById(xinliceping);
        return R.ok("投票成功");
    }

    /**
     * 后端保存
     */
    @RequestMapping("/save")
    public R save(@RequestBody XinlicepingEntity xinliceping, HttpServletRequest request){
    	xinliceping.setId(new Date().getTime()+new Double(Math.floor(Math.random()*1000)).longValue());
    	//ValidatorUtils.validateEntity(xinliceping);

        xinlicepingService.insert(xinliceping);
        return R.ok();
    }
    
    /**
     * 前端保存
     */
	@IgnoreAuth
    @RequestMapping("/add")
    public R add(@RequestBody XinlicepingEntity xinliceping, HttpServletRequest request){
    	xinliceping.setId(new Date().getTime()+new Double(Math.floor(Math.random()*1000)).longValue());
    	//ValidatorUtils.validateEntity(xinliceping);

        xinlicepingService.insert(xinliceping);
        return R.ok();
    }

    /**
     * 修改
     */
    @RequestMapping("/update")
    public R update(@RequestBody XinlicepingEntity xinliceping, HttpServletRequest request){
        //ValidatorUtils.validateEntity(xinliceping);
        xinlicepingService.updateById(xinliceping);//全部更新
        return R.ok();
    }
    

    /**
     * 删除
     */
    @RequestMapping("/delete")
    public R delete(@RequestBody Long[] ids){
        xinlicepingService.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<XinlicepingEntity> wrapper = new EntityWrapper<XinlicepingEntity>();
		if(map.get("remindstart")!=null) {
			wrapper.ge(columnName, map.get("remindstart"));
		}
		if(map.get("remindend")!=null) {
			wrapper.le(columnName, map.get("remindend"));
		}


		int count = xinlicepingService.selectCount(wrapper);
		return R.ok().put("count", count);
	}
	
	
	/**
     * 前端智能排序
     */
	@IgnoreAuth
    @RequestMapping("/autoSort")
    public R autoSort(@RequestParam Map<String, Object> params,XinlicepingEntity xinliceping, HttpServletRequest request,String pre){
        EntityWrapper<XinlicepingEntity> ew = new EntityWrapper<XinlicepingEntity>();
        Map<String, Object> newMap = new HashMap<String, Object>();
        Map<String, Object> param = new HashMap<String, Object>();
		Iterator<Map.Entry<String, Object>> it = param.entrySet().iterator();
		while (it.hasNext()) {
			Map.Entry<String, Object> entry = it.next();
			String key = entry.getKey();
			String newKey = entry.getKey();
			if (pre.endsWith(".")) {
				newMap.put(pre + newKey, entry.getValue());
			} else if (StringUtils.isEmpty(pre)) {
				newMap.put(newKey, entry.getValue());
			} else {
				newMap.put(pre + "." + newKey, entry.getValue());
			}
		}
		params.put("sort", "clicktime");
        params.put("order", "desc");
		PageUtils page = xinlicepingService.queryPage(params, MPUtil.sort(MPUtil.between(MPUtil.likeOrEq(ew, xinliceping), params), params));
        return R.ok().put("data", page);
    }





}


网站公告

今日签到

点亮在社区的每一天
去签到