毕业设计:基于java的在线问卷调查系统的设计与实现(源码)

发布时间:2026/5/25 23:11:14

毕业设计:基于java的在线问卷调查系统的设计与实现(源码) 第4章 系统设计系统的设计一切都是为了用户的使用虽然用户使用过程中可能只是面对着浏览器进行各种操作但是不代表着系统对于用户在浏览器上的操作不进行处理所以说设计一个系统需要考虑到方方面面。4.1 功能结构设计图4.1即为设计的管理员功能结构管理员权限操作的功能包括对注册用户信息的管理对问卷题目问卷调查新闻资讯等信息的管理。添加图片注释不超过 140 字可选图4.1 管理员功能结构 图4.2即为设计的用户功能结构用户权限操作的功能包括参与问卷调查查看新闻查看问卷调查记录。添加图片注释不超过 140 字可选图4.2 用户功能结构4.2 数据库设计在线问卷调查系统运行中产生的数据需要按照提前设置的存储规则进行保存而这个存储规则则是在数据库的设计中进行设置的。通常情况下为了更好的配合系统运行也要给用户带来良好的使用体验设计一个很好的数据库是必须的因为它能减少用户的等待时间还可以对系统的请求在最短时间内进行响应。所以对数据库设计时需要花费一定的时间来分析系统对于数据存储的要求以及存储的具体数据然后设计具体的存储规则保证数据库能够对系统的各种数据请求进行及时回应缩短数据处理时间并在一定程度上降低数据冗余节省存储空间。4.2.1 数据库概念设计实体-联系图还有一个名称即E-R图是Entity Relationship Diagram各英文单词首字母的缩写它这种概念模型通常用于对现实世界进行描述。同时它还是一种能够直观表达数据中实体联系属性的有效手段。绘制E-R图能够选择的工具也有很多但是Office Visio 这款软件在E-R图的绘制上一般都是作为首选工具因为它是基于可视化处理使用它创建E-R图非常简单。使用基本的E-R图构成元素比如椭圆菱形矩形还有实线段来表达对应的信息椭圆代表属性即实体的特征矩形代表实体即数据库中的一个具体数据表菱形代表实体中相互关系实线段主要是完成椭圆矩形菱形的连接基于这样的方式即可完成对本系统的E-R图进行完整绘制。1图4.4即为题目这个实体所拥有的属性值。添加图片注释不超过 140 字可选图4.4 题目实体属性图 2图4.5即为用户这个实体所拥有的属性值。添加图片注释不超过 140 字可选图4.5 用户实体属性图3图4.6即为问卷这个实体所拥有的属性值。添加图片注释不超过 140 字可选图4.6 问卷实体属性图图4.7即为问卷调查记录这个实体所拥有的属性值。添加图片注释不超过 140 字可选图4.7 问卷调查记录实体属性图图4.8即为上面介绍的实体中存在的联系。添加图片注释不超过 140 字可选图4.8 实体间关系E-R图4.2.2 数据库物理设计本小节主要任务即是根据上述内容进行数据存储结构的设计也就是在数据库中设计存放本系统的数据的数据表设计数据表时需要对各个字段进行确定通常来说一个实体与一张数据表相对应实体的属性就用来表示字段名称不同的字段表示的数据类型以及取值都不相同这里需要根据系统实际数据的情况进行设置同时也需要在具体表中确定该表的主键以及该表各个字段是否能够保持空等进行说明设计完成一张数据表的结构之后在保存时同样要命名尽量选择英文名称进行命名并保存方便今后系统对数据表进行数据存储访问时在提高数据存储效率的同时还不容易导致系统出错。接下来就对设计的数据表进行展示。表4.1 问卷表字段注释类型空id (主键)主键int(20)否exampaper_name问卷名称varchar(200)否exampaper_date时长(分钟)int(11)否exampaper_jieshuyu结束语varchar(255)是exampaper_types问卷状态int(11)否create_time创建时间timestamp否表4.2 题目表字段注释类型空id (主键)主键int(20)否exampaper_id所属问卷id外键int(20)否examquestion_name试题名称varchar(200)否examquestion_options选项longtext是examquestion_types试题类型int(20)是examquestion_sequence试题排序值越大排越前面int(20)是create_time创建时间timestamp否表4.3 问卷调查记录表字段注释类型空id (主键)主键int(20)否examrecord_uuid_number问卷调查编号varchar(200)是yonghu_id问卷调查用户int(20)否exampaper_id所属问卷id外键int(20)否insert_time问卷调查时间timestamp否create_time创建时间timestamp否表4.4 管理员表字段注释类型空id (主键)主键bigint(20)否username用户名varchar(100)否password密码varchar(100)否role角色varchar(100)是addtime新增时间timestamp否表4.5 新闻资讯表字段注释类型空id (主键)主键int(11)否news_name新闻资讯名称varchar(200)是news_types新闻类型int(11)是news_photo新闻资讯图片varchar(200)是insert_time新闻资讯时间timestamp是news_content新闻资讯详情text是create_time创建时间timestamp是表4.6 答题详情表字段注释类型空id (主键)主键int(20)否examredetails_uuid_number问卷编号varchar(200)是yonghu_id用户idint(20)否examquestion_id试题id外键int(20)否examredetails_myanswer用户选项varchar(200)是create_time创建时间timestamp否表4.7 用户表字段注释类型空id (主键)主键int(11)否username账户varchar(200)是password密码varchar(200)是yonghu_name用户姓名varchar(200)是sex_types性别int(11)是yonghu_id_number身份证号varchar(200)是yonghu_phone手机号varchar(200)是yonghu_photo照片varchar(200)是create_time创建时间timestamp是第5章 系统实现编程人员在搭建的开发环境中运用编程技术实现本系统设计的各个操作权限的功能。在本节中就展示部分操作权限的功能与界面。5.1 管理员功能实现5.1.1 问卷管理图5.1 即为编码实现的问卷管理界面管理员在该界面中可以对已有问卷进行启用或禁用可以新增问卷编辑更改已有问卷的资料包括问卷名称结束语等信息可以删除需要删除的问卷可以根据问卷名称问卷的状态来获取需要的问卷信息。添加图片注释不超过 140 字可选图5.1 问卷管理界面核心代码/*** 后端修改*/RequestMapping(/update)public R update(RequestBody ExampaperEntity exampaper, HttpServletRequest request){logger.debug(update方法:,,Controller:{},,exampaper:{},this.getClass().getName(),exampaper.toString());String role String.valueOf(request.getSession().getAttribute(role));if(StringUtil.isEmpty(role))return R.error(511,权限为空);//根据字段查询是否有相同数据WrapperExampaperEntity queryWrapper new EntityWrapperExampaperEntity().notIn(id,exampaper.getId()).andNew().eq(exampaper_name, exampaper.getExampaperName()).eq(exampaper_date, exampaper.getExampaperDate()).eq(exampaper_types, exampaper.getExampaperTypes());logger.info(sql语句:queryWrapper.getSqlSegment());ExampaperEntity exampaperEntity exampaperService.selectOne(queryWrapper);if(exampaperEntitynull){// String role String.valueOf(request.getSession().getAttribute(role));// if(.equals(role)){// exampaper.set// }exampaperService.updateById(exampaper);//根据id更新return R.ok();}else {return R.error(511,表中有相同数据);}}/*** 删除*/RequestMapping(/delete)public R delete(RequestBody Integer[] ids){logger.debug(delete:,,Controller:{},,ids:{},this.getClass().getName(),ids.toString());exampaperService.deleteBatchIds(Arrays.asList(ids));return R.ok();}5.1.2 问卷调查管理图5.2 即为编码实现的问卷调查管理界面管理员在该界面中对用户提交的问卷调查信息进行查看管理员可以直接查看每条问卷调查的调查详情信息同时可以删除问卷调查信息。添加图片注释不超过 140 字可选图5.2 问卷调查管理界面核心代码/*** 批量上传*/RequestMapping(/batchInsert)public R save( String fileName){logger.debug(batchInsert方法:,,Controller:{},,fileName:{},this.getClass().getName(),fileName);try {ListExampaperEntity exampaperList new ArrayList();//上传的东西MapString, ListString seachFields new HashMap();//要查询的字段Date date new Date();int lastIndexOf fileName.lastIndexOf(.);if(lastIndexOf -1){return R.error(511,该文件没有后缀);}else{String suffix fileName.substring(lastIndexOf);if(!.xls.equals(suffix)){return R.error(511,只支持后缀为xls的excel文件);}else{URL resource this.getClass().getClassLoader().getResource(static/upload/ fileName);//获取文件路径File file new File(resource.getFile());if(!file.exists()){return R.error(511,找不到上传文件请联系管理员);}else{ListListString dataList PoiUtil.poiImport(file.getPath());//读取xls文件dataList.remove(0);//删除第一行因为第一行是提示for(ListString data:dataList){//循环ExampaperEntity exampaperEntity new ExampaperEntity();// exampaperEntity.setExampaperName(data.get(0)); //问卷名称 要改的// exampaperEntity.setExampaperDate(Integer.valueOf(data.get(0))); //时长(分钟) 要改的// exampaperEntity.setExampaperTypes(Integer.valueOf(data.get(0))); //问卷状态 要改的// exampaperEntity.setCreateTime(date);//时间exampaperList.add(exampaperEntity);//把要查询是否重复的字段放入map中}//查询是否重复exampaperService.insertBatch(exampaperList);return R.ok();}}}}catch (Exception e){return R.error(511,批量插入数据异常请联系管理员);}}/*** 前端列表*/IgnoreAuthRequestMapping(/list)public R list(RequestParam MapString, Object params, HttpServletRequest request){logger.debug(list方法:,,Controller:{},,params:{},this.getClass().getName(),JSONObject.toJSONString(params));// 没有指定排序字段就默认id倒序if(StringUtil.isEmpty(String.valueOf(params.get(orderBy)))){params.put(orderBy,id);}PageUtils page exampaperService.queryPage(params);//字典表数据转换ListExampaperView list (ListExampaperView)page.getList();for(ExampaperView c:list)dictionaryService.dictionaryConvert(c, request); //修改对应字典表字段return R.ok().put(data, page);}/*** 前端详情*/RequestMapping(/detail/{id})public R detail(PathVariable(id) Long id, HttpServletRequest request){logger.debug(detail方法:,,Controller:{},,id:{},this.getClass().getName(),id);ExampaperEntity exampaper exampaperService.selectById(id);if(exampaper !null){//entity转viewExampaperView view new ExampaperView();BeanUtils.copyProperties( exampaper , view );//把实体数据重构到view中//修改对应字典表字段dictionaryService.dictionaryConvert(view, request);return R.ok().put(data, view);}else {return R.error(511,查不到数据);}}5.1.3 题目管理图5.3 即为编码实现的题目管理界面管理员在该界面中可以导出题目可以新增题目可以对指定的题目信息进行修改删除同时可以查看用户对各个题目选项的统计信息该统计信息是以饼图进行展示。添加图片注释不超过 140 字可选图5.3 题目管理界面核心代码/*** 后端详情*/RequestMapping(/info/{id})public R info(PathVariable(id) Long id, HttpServletRequest request){logger.debug(info方法:,,Controller:{},,id:{},this.getClass().getName(),id);ExamquestionEntity examquestion examquestionService.selectById(id);if(examquestion !null){//entity转viewExamquestionView view new ExamquestionView();BeanUtils.copyProperties( examquestion , view );//把实体数据重构到view中//级联表ExampaperEntity exampaper exampaperService.selectById(examquestion.getExampaperId());if(exampaper ! null){BeanUtils.copyProperties( exampaper , view ,new String[]{ id, createDate});//把级联的数据添加到view中,并排除id和创建时间字段view.setExampaperId(exampaper.getId());}//修改对应字典表字段dictionaryService.dictionaryConvert(view, request);return R.ok().put(data, view);}else {return R.error(511,查不到数据);}}/*** 后端保存*/RequestMapping(/save)public R save(RequestBody ExamquestionEntity examquestion, HttpServletRequest request){logger.debug(save方法:,,Controller:{},,examquestion:{},this.getClass().getName(),examquestion.toString());String role String.valueOf(request.getSession().getAttribute(role));if(StringUtil.isEmpty(role))return R.error(511,权限为空);WrapperExamquestionEntity queryWrapper new EntityWrapperExamquestionEntity().eq(exampaper_id, examquestion.getExampaperId()).eq(examquestion_name, examquestion.getExamquestionName()).eq(examquestion_options, examquestion.getExamquestionOptions()).eq(examquestion_types, examquestion.getExamquestionTypes()).eq(examquestion_sequence, examquestion.getExamquestionSequence());logger.info(sql语句:queryWrapper.getSqlSegment());ExamquestionEntity examquestionEntity examquestionService.selectOne(queryWrapper);if(examquestionEntitynull){examquestion.setCreateTime(new Date());examquestionService.insert(examquestion);return R.ok();}else {return R.error(511,表中有相同数据);}}5.1.4 用户管理图5.4 即为编码实现的用户管理界面管理员在该界面中为用户重置密码修改用户基本信息新增用户删除需要删除的用户信息。添加图片注释不超过 140 字可选图5.4 用户管理界面核心代码/*** 后端修改*/RequestMapping(/update)public R update(RequestBody YonghuEntity yonghu, HttpServletRequest request){logger.debug(update方法:,,Controller:{},,yonghu:{},this.getClass().getName(),yonghu.toString());String role String.valueOf(request.getSession().getAttribute(role));if(StringUtil.isEmpty(role))return R.error(511,权限为空);//根据字段查询是否有相同数据WrapperYonghuEntity queryWrapper new EntityWrapperYonghuEntity().notIn(id,yonghu.getId()).andNew().eq(username, yonghu.getUsername()).or().eq(yonghu_id_number, yonghu.getYonghuIdNumber()).or().eq(yonghu_phone, yonghu.getYonghuPhone());logger.info(sql语句:queryWrapper.getSqlSegment());YonghuEntity yonghuEntity yonghuService.selectOne(queryWrapper);if(.equals(yonghu.getYonghuPhoto()) || null.equals(yonghu.getYonghuPhoto())){yonghu.setYonghuPhoto(null);}if(yonghuEntitynull){// String role String.valueOf(request.getSession().getAttribute(role));// if(.equals(role)){// yonghu.set// }yonghuService.updateById(yonghu);//根据id更新return R.ok();}else {return R.error(511,账户或者手机号或者身份证号已经被使用);}}5.1.5 新闻资讯管理图5.5 即为编码实现的新闻资讯管理界面管理员在该界面中负责发布新闻资讯更改新闻资讯的部分信息删除需要删除的新闻资讯信息。添加图片注释不超过 140 字可选图5.5 新闻资讯管理界面核心代码/*** 后端列表*/RequestMapping(/page)public R page(RequestParam MapString, Object params, HttpServletRequest request){logger.debug(page方法:,,Controller:{},,params:{},this.getClass().getName(),JSONObject.toJSONString(params));String role String.valueOf(request.getSession().getAttribute(role));if(StringUtil.isEmpty(role))return R.error(511,权限为空);else if(用户.equals(role))params.put(yonghuId,request.getSession().getAttribute(userId));if(params.get(orderBy)null || params.get(orderBy)){params.put(orderBy,id);}PageUtils page newsService.queryPage(params);//字典表数据转换ListNewsView list (ListNewsView)page.getList();for(NewsView c:list){//修改对应字典表字段dictionaryService.dictionaryConvert(c, request);}return R.ok().put(data, page);}5.2 用户功能实现5.2.1 问卷列表图5.6 即为编码实现的问卷列表界面用户在该界面中选择问卷并参与问卷调查。添加图片注释不超过 140 字可选图5.6 问卷列表界面核心代码/*** 前端列表*/IgnoreAuthRequestMapping(/list)public R list(RequestParam MapString, Object params, HttpServletRequest request){logger.debug(list方法:,,Controller:{},,params:{},this.getClass().getName(),JSONObject.toJSONString(params));// 没有指定排序字段就默认id倒序if(StringUtil.isEmpty(String.valueOf(params.get(orderBy)))){params.put(orderBy,id);}PageUtils page examrecordService.queryPage(params);//字典表数据转换ListExamrecordView list (ListExamrecordView)page.getList();for(ExamrecordView c:list)dictionaryService.dictionaryConvert(c, request); //修改对应字典表字段return R.ok().put(data, page);}/*** 前端详情*/RequestMapping(/detail/{id})public R detail(PathVariable(id) Long id, HttpServletRequest request){logger.debug(detail方法:,,Controller:{},,id:{},this.getClass().getName(),id);ExamrecordEntity examrecord examrecordService.selectById(id);if(examrecord !null){//entity转viewExamrecordView view new ExamrecordView();BeanUtils.copyProperties( examrecord , view );//把实体数据重构到view中//级联表ExampaperEntity exampaper exampaperService.selectById(examrecord.getExampaperId());if(exampaper ! null){BeanUtils.copyProperties( exampaper , view ,new String[]{ id, createDate});//把级联的数据添加到view中,并排除id和创建时间字段view.setExampaperId(exampaper.getId());}//级联表YonghuEntity yonghu yonghuService.selectById(examrecord.getYonghuId());if(yonghu ! null){BeanUtils.copyProperties( yonghu , view ,new String[]{ id, createDate});//把级联的数据添加到view中,并排除id和创建时间字段view.setYonghuId(yonghu.getId());}//修改对应字典表字段dictionaryService.dictionaryConvert(view, request);return R.ok().put(data, view);}else {return R.error(511,查不到数据);}}5.2.2 问卷调查图5.7 即为编码实现的问卷调查界面用户在该界面中主要根据问卷调查题目信息进行选项答题答题结束可以选择界面顶端的结束问卷调查按钮离开问卷调查界面。添加图片注释不超过 140 字可选图5.7 问卷调查界面核心代码/*** 前端详情*/RequestMapping(/detail/{id})public R detail(PathVariable(id) Long id, HttpServletRequest request){logger.debug(detail方法:,,Controller:{},,id:{},this.getClass().getName(),id);ExamredetailsEntity examredetails examredetailsService.selectById(id);if(examredetails !null){//entity转viewExamredetailsView view new ExamredetailsView();BeanUtils.copyProperties( examredetails , view );//把实体数据重构到view中//级联表ExamquestionEntity examquestion examquestionService.selectById(examredetails.getExamquestionId());if(examquestion ! null){BeanUtils.copyProperties( examquestion , view ,new String[]{ id, createDate});//把级联的数据添加到view中,并排除id和创建时间字段view.setExamquestionId(examquestion.getId());}//级联表YonghuEntity yonghu yonghuService.selectById(examredetails.getYonghuId());if(yonghu ! null){BeanUtils.copyProperties( yonghu , view ,new String[]{ id, createDate});//把级联的数据添加到view中,并排除id和创建时间字段view.setYonghuId(yonghu.getId());}//修改对应字典表字段dictionaryService.dictionaryConvert(view, request);return R.ok().put(data, view);}else {return R.error(511,查不到数据);}}5.2.3 新闻资讯图5.8 即为编码实现的新闻资讯界面用户在该界面中浏览新闻资讯在界面右上角的搜索框中编辑新闻标题可以获取匹配的新闻资讯信息。添加图片注释不超过 140 字可选图5.8 新闻资讯界面核心代码/*** 前端详情*/RequestMapping(/detail/{id})public R detail(PathVariable(id) Long id, HttpServletRequest request){logger.debug(detail方法:,,Controller:{},,id:{},this.getClass().getName(),id);NewsEntity news newsService.selectById(id);if(news !null){//entity转viewNewsView view new NewsView();BeanUtils.copyProperties( news , view );//把实体数据重构到view中//修改对应字典表字段dictionaryService.dictionaryConvert(view, request);return R.ok().put(data, view);}else {return R.error(511,查不到数据);}}5.2.4 问卷调查记录图5.9 即为编码实现的问卷调查记录界面用户在该界面中可以对参与问卷调查的记录信息进行查看。添加图片注释不超过 140 字可选图5.9 问卷调查记录界面核心代码RequestMapping(/saveExamredetails)public R saveExamredetails(RequestBody ExamredetailsEntity examredetails,Integer examrecordId, HttpServletRequest request){logger.debug(save方法:,,Controller:{},,examredetails:{},this.getClass().getName(),examredetails.toString());String role String.valueOf(request.getSession().getAttribute(role));if(StringUtil.isEmpty(role)){return R.error(511,权限为空);}else if(role.contains(用户id)){examredetails.setYonghuId(Integer.valueOf(String.valueOf(request.getSession().getAttribute(userId))));}examredetails.setCreateTime(new Date());boolean insert examredetailsService.insert(examredetails);if(!insert){return R.error();}return R.ok();}

相关新闻