基于springboot的在线问卷调查系统-老师满意

  博主介绍:👉全网个人号和企业号粉丝40W+,每年辅导几千名大学生较好的完成毕业设计,专注计算机软件领域的项目研发,不断的进行新技术的项目实战👈
⭐️热门专栏推荐订阅⭐️ 订阅收藏起来,防止下次找不到

🔎千套JAVA项目实战持续更新中~

🔎百套小程序APP项目实战持续更新中~

🔎百套Python实战项目持续更新中~
有需求的各位可以先收藏起来,还有大家在毕设选题,开题报告有疑惑的都可以找我,给你参考意见,需要开题模板的可以私信留言告诉我

❤️文末获取源码联系❤️        ⚠️一定要先收藏⚠️

 

4 系统设计

系统的设计一切都是为了用户的使用,虽然用户使用过程中可能只是面对着浏览器进行各种操作,但是不代表着系统对于用户在浏览器上的操作不进行处理,所以说,设计一个系统需要考虑到方方面面。

4.1 功能结构设计

图4.1即为设计的管理员功能结构,管理员权限操作的功能包括对注册用户信息的管理,对问卷,题目,问卷调查,新闻资讯等信息的管理。

图4.1 管理员功能结构

图4.2即为设计的用户功能结构,用户权限操作的功能包括参与问卷调查,查看新闻,查看问卷调查记录。

图4.2 用户功能结构

4.2 数据库设计

在线问卷调查系统运行中产生的数据需要按照提前设置的存储规则进行保存,而这个存储规则则是在数据库的设计中进行设置的。通常情况下,为了更好的配合系统运行,也要给用户带来良好的使用体验,设计一个很好的数据库是必须的,因为它能减少用户的等待时间,还可以对系统的请求在最短时间内进行响应。所以,对数据库设计时,需要花费一定的时间来分析系统对于数据存储的要求以及存储的具体数据,然后设计具体的存储规则,保证数据库能够对系统的各种数据请求进行及时回应,缩短数据处理时间,并在一定程度上降低数据冗余,节省存储空间。

4.2.1 数据库概念设计

实体-联系图还有一个名称即E-R图,是Entity Relationship Diagram各英文单词首字母的缩写,它这种概念模型通常用于对现实世界进行描述。同时它还是一种能够直观表达数据中实体,联系,属性的有效手段。绘制E-R图能够选择的工具也有很多,但是Office Visio 这款软件在E-R图的绘制上一般都是作为首选工具,因为它是基于可视化处理,使用它创建E-R图非常简单。使用基本的E-R图构成元素,比如椭圆,菱形,矩形,还有实线段来表达对应的信息,椭圆代表属性,即实体的特征,矩形代表实体,即数据库中的一个具体数据表,菱形代表实体中相互关系,实线段主要是完成椭圆,矩形,菱形的连接,基于这样的方式即可完成对本系统的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

用户id

int(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 即为编码实现的问卷管理界面,管理员在该界面中可以对已有问卷进行启用或禁用,可以新增问卷,编辑更改已有问卷的资料,包括问卷名称,结束语等信息,可以删除需要删除的问卷,可以根据问卷名称,问卷的状态来获取需要的问卷信息。

图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,"权限为空");

        //根据字段查询是否有相同数据

        Wrapper<ExampaperEntity> queryWrapper = new EntityWrapper<ExampaperEntity>()

            .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(exampaperEntity==null){

            //  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 即为编码实现的问卷调查管理界面,管理员在该界面中对用户提交的问卷调查信息进行查看,管理员可以直接查看每条问卷调查的调查详情信息,同时可以删除问卷调查信息。

图5.2 问卷调查管理界面

核心代码:

/**

     * 批量上传

     */

    @RequestMapping("/batchInsert")

    public R save( String fileName){

        logger.debug("batchInsert方法:,,Controller:{},,fileName:{}",this.getClass().getName(),fileName);

        try {

            List<ExampaperEntity> exampaperList = new ArrayList<>();//上传的东西

            Map<String, List<String>> 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{

                        List<List<String>> dataList = PoiUtil.poiImport(file.getPath());//读取xls文件

                        dataList.remove(0);//删除第一行,因为第一行是提示

                        for(List<String> 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,"批量插入数据异常,请联系管理员");

        }

    }

    /**

    * 前端列表

    */

    @IgnoreAuth

    @RequestMapping("/list")

    public R list(@RequestParam Map<String, 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);

        //字典表数据转换

        List<ExampaperView> list =(List<ExampaperView>)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转view

                ExampaperView 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 即为编码实现的题目管理界面,管理员在该界面中可以导出题目,可以新增题目,可以对指定的题目信息进行修改,删除,同时可以查看用户对各个题目选项的统计信息,该统计信息是以饼图进行展示。

图5.3 题目管理界面

JAVA后端代码实现

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.UserEntity;
import com.service.TokenService;
import com.service.UserService;
import com.utils.CommonUtil;
import com.utils.MD5Util;
import com.utils.MPUtil;
import com.utils.PageUtils;
import com.utils.R;
import com.utils.ValidatorUtils;
 
/**
 * 登录相关
 */
@RequestMapping("users")
@RestController
public class UserController{
	
	@Autowired
	private UserService userService;
	
	@Autowired
	private TokenService tokenService;
 
	/**
	 * 登录
	 */
	@IgnoreAuth
	@PostMapping(value = "/login")
	public R login(String username, String password, String captcha, HttpServletRequest request) {
		UserEntity user = userService.selectOne(new EntityWrapper<UserEntity>().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 UserEntity user){
//    	ValidatorUtils.validateEntity(user);
    	if(userService.selectOne(new EntityWrapper<UserEntity>().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){
    	UserEntity user = userService.selectOne(new EntityWrapper<UserEntity>().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,UserEntity user){
        EntityWrapper<UserEntity> ew = new EntityWrapper<UserEntity>();
    	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( UserEntity user){
       	EntityWrapper<UserEntity> ew = new EntityWrapper<UserEntity>();
      	ew.allEq(MPUtil.allEQMapPre( user, "user")); 
        return R.ok().put("data", userService.selectListView(ew));
    }
 
    /**
     * 信息
     */
    @RequestMapping("/info/{id}")
    public R info(@PathVariable("id") String id){
        UserEntity 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");
        UserEntity user = userService.selectById(id);
        return R.ok().put("data", user);
    }
 
    /**
     * 保存
     */
    @PostMapping("/save")
    public R save(@RequestBody UserEntity user){
//    	ValidatorUtils.validateEntity(user);
    	if(userService.selectOne(new EntityWrapper<UserEntity>().eq("username", user.getUsername())) !=null) {
    		return R.error("用户已存在");
    	}
        userService.insert(user);
        return R.ok();
    }
 
    /**
     * 修改
     */
    @RequestMapping("/update")
    public R update(@RequestBody UserEntity user){
//        ValidatorUtils.validateEntity(user);
    	UserEntity u = userService.selectOne(new EntityWrapper<UserEntity>().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();
    }
}

源码获取

大家点赞、收藏、关注 ,让更多需要的同学看到

不同开发语言专栏推荐订阅

 🔎千套JAVA项目实战持续更新中~

🔎百套小程序APP项目实战持续更新中~

🔎百套Python实战项目持续更新中~

👇下方有我的微信名片👇

  • 35
    点赞
  • 23
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

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

余额充值