毕业设计:基于Springboot+Vue+ElementUI实现疫情社区管理系统

Posted 编程指南针

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了毕业设计:基于Springboot+Vue+ElementUI实现疫情社区管理系统相关的知识,希望对你有一定的参考价值。

作者主页:编程指南针

作者简介:Java领域优质创作者、CSDN博客专家 、掘金特邀作者、多年架构师设计经验、腾讯课堂常驻讲师

主要内容:Java项目、毕业设计、简历模板、学习资料、面试题库、技术互助

文末获取源码 

项目编号:BS-XX-132

一,项目简介

   本次开发设计的社区疫情管理系统,主要为一线的社区人员更好的管理辖区内人员疫情风险信息提供信息化的管理手段。本系统基于Springboot+Vue开发实现了用于疫情防控的信息化管理系统。系统功能完整,界面简洁大方。系统用户主要分为居民用户和管理员用户:

居民注册登陆后主要可以在线提交自己的报备信息,在线购买防疫物资,查看系统通告,查看外来人员不同风险区的要求通知,管理购物车,查看订单信息,实现在付款、退款、退货、在线充值的功能,以及对商品的点赞和己购买商品的评价操作等。

管理员登陆后可以实现的主要功能有,管理员管理,用户管理,在线交流管理,人员检测信息管理,外来人员报备管理,防疫须知管理,公告管理,商品类型管理,防疫商品管理,订单管理,评价管理等等。

二,环境介绍

语言环境:Java:  jdk1.8

数据库:mysql: mysql5.7

应用服务器:Tomcat:  tomcat8.5.31

开发工具:IDEA或eclipse

后台开发技术:Springboot+Mybatis

前端开发技术:Vue+ElementUI+Axios

三,系统展示

下面展示一下社区疫情防控系统:

外来人员报备

防疫须知

购物车管理

订单管理

商品评价:对己完成订单的商品进行评价

个人信息管理及充值

后台管理功能

销售统计

人员检测信息管理

人员报备管理

疫情用户分类管理

疫情用户详情管理

订单管理

评价管理

其它不再一一展示相关功能

四,核心代码展示

package com.example.controller;

import cn.hutool.core.util.StrUtil;
import cn.hutool.crypto.SecureUtil;
import cn.hutool.json.JSONArray;
import cn.hutool.json.JSONObject;
import com.example.common.Result;
import com.example.common.ResultCode;
import com.example.entity.Account;
import com.example.entity.AuthorityInfo;
import com.example.exception.CustomException;
import com.example.entity.AdminInfo;
import com.example.entity.BusinessInfo;
import com.example.entity.UserInfo;

import com.example.service.AdminInfoService;
import com.example.service.BusinessInfoService;
import com.example.service.UserInfoService;

import org.springframework.web.bind.annotation.*;
import org.springframework.beans.BeanUtils;
import org.springframework.beans.factory.annotation.Value;

import javax.annotation.Resource;
import javax.servlet.http.HttpServletRequest;
import cn.hutool.json.JSONUtil;

import java.util.*;
import java.util.stream.Collectors;

@RestController
public class AccountController 

    @Value("$authority.info")
    private String authorityStr;

	@Resource
	private AdminInfoService adminInfoService;
	@Resource
	private BusinessInfoService businessInfoService;
	@Resource
	private UserInfoService userInfoService;


    @PostMapping("/login")
    public Result<Account> login(@RequestBody Account account, HttpServletRequest request) 
        if (StrUtil.isBlank(account.getName()) || StrUtil.isBlank(account.getPassword()) || account.getLevel() == null) 
            throw new CustomException(ResultCode.PARAM_LOST_ERROR);
        
        Integer level = account.getLevel();
        Account login = new Account();
		if (1 == level) 
			login = adminInfoService.login(account.getName(), account.getPassword());
		
		if (2 == level) 
			login = businessInfoService.login(account.getName(), account.getPassword());
		
		if (3 == level) 
			login = userInfoService.login(account.getName(), account.getPassword());
		

        request.getSession().setAttribute("user", login);//设置session
        return Result.success(login);
    

    @PostMapping("/register")//注册
    public Result<Account> register(@RequestBody Account account) 
        Integer level = account.getLevel();
        Account login = new Account();
		if (1 == level) //超级管理员
			AdminInfo info = new AdminInfo();
			BeanUtils.copyProperties(account, info);//将account的属性copy到info对象中
			login = adminInfoService.add(info);
		
		if (2 == level) //普通管理员
			BusinessInfo info = new BusinessInfo();
			BeanUtils.copyProperties(account, info);
			login = businessInfoService.add(info);
		
		if (3 == level) //普通社区用户
			UserInfo info = new UserInfo();
			BeanUtils.copyProperties(account, info);
			login = userInfoService.add(info);
		

        return Result.success(login);
    

    @GetMapping("/logout")
    public Result logout(HttpServletRequest request) 
        request.getSession().setAttribute("user", null);
        return Result.success();
    

    @GetMapping("/auth")
    public Result getAuth(HttpServletRequest request) 
        Object user = request.getSession().getAttribute("user");
        if(user == null) 
            return Result.error("401", "未登录");
        
        return Result.success(user);
    

    @GetMapping("/getAccountInfo")
    public Result<Object> getAccountInfo(HttpServletRequest request) 
        Account account = (Account) request.getSession().getAttribute("user");
        if (account == null) 
            return Result.success(new Object());
        
        Integer level = account.getLevel();
		if (1 == level) 
			return Result.success(adminInfoService.findById(account.getId()));
		
		if (2 == level) 
			return Result.success(businessInfoService.findById(account.getId()));
		
		if (3 == level) 
			return Result.success(userInfoService.findById(account.getId()));
		

        return Result.success(new Object());
    

    @GetMapping("/getSession")
    public Result<Map<String, String>> getSession(HttpServletRequest request) 
        Account account = (Account) request.getSession().getAttribute("user");
        if (account == null) 
            return Result.success(new HashMap<>(1));
        
        Map<String, String> map = new HashMap<>(1);
        map.put("username", account.getName());
        return Result.success(map);
    

    @GetMapping("/getAuthority")//获取登录身份级别信息
    public Result<List<AuthorityInfo>> getAuthorityInfo() 
        List<AuthorityInfo> authorityInfoList = JSONUtil.toList(JSONUtil.parseArray(authorityStr), AuthorityInfo.class);
        return Result.success(authorityInfoList);
    

    /**
    * 获取当前用户所能看到的模块信息
    * @param request
    * @return
    */
    @GetMapping("/authority")
    public Result<List<Integer>> getAuthorityInfo(HttpServletRequest request) 
        Account user = (Account) request.getSession().getAttribute("user");
        if (user == null) 
            return Result.success(new ArrayList<>());
        
        JSONArray objects = JSONUtil.parseArray(authorityStr);
        for (Object object : objects) 
            JSONObject jsonObject = (JSONObject) object;
            if (user.getLevel().equals(jsonObject.getInt("level"))) 
                JSONArray array = JSONUtil.parseArray(jsonObject.getStr("models"));
                List<Integer> modelIdList = array.stream().map((o -> 
                    JSONObject obj = (JSONObject) o;
                    return obj.getInt("modelId");
                    )).collect(Collectors.toList());
                return Result.success(modelIdList);
            
        
        return Result.success(new ArrayList<>());
    

    @GetMapping("/permission/modelId")
    public Result<List<Integer>> getPermission(@PathVariable Integer modelId, HttpServletRequest request) 
        List<AuthorityInfo> authorityInfoList = JSONUtil.toList(JSONUtil.parseArray(authorityStr), AuthorityInfo.class);
        Account user = (Account) request.getSession().getAttribute("user");
        if (user == null) 
            return Result.success(new ArrayList<>());
        
        Optional<AuthorityInfo> optional = authorityInfoList.stream().filter(x -> x.getLevel().equals(user.getLevel())).findFirst();
        if (optional.isPresent()) 
            Optional<AuthorityInfo.Model> firstOption = optional.get().getModels().stream().filter(x -> x.getModelId().equals(modelId)).findFirst();
            if (firstOption.isPresent()) 
                List<Integer> info = firstOption.get().getOperation();
                return Result.success(info);
            
        
        return Result.success(new ArrayList<>());
    

    @PutMapping("/updatePassword")
    public Result updatePassword(@RequestBody Account info, HttpServletRequest request) 
        Account account = (Account) request.getSession().getAttribute("user");
        if (account == null) 
            return Result.error(ResultCode.USER_NOT_EXIST_ERROR.code, ResultCode.USER_NOT_EXIST_ERROR.msg);
        
        String oldPassword = SecureUtil.md5(info.getPassword());
        if (!oldPassword.equals(account.getPassword())) 
            return Result.error(ResultCode.PARAM_PASSWORD_ERROR.code, ResultCode.PARAM_PASSWORD_ERROR.msg);
        
        info.setPassword(SecureUtil.md5(info.getNewPassword()));
        Integer level = account.getLevel();
		if (1 == level) 
			AdminInfo adminInfo = new AdminInfo();
			BeanUtils.copyProperties(info, adminInfo);
			adminInfoService.update(adminInfo);
		
		if (2 == level) 
			BusinessInfo businessInfo = new BusinessInfo();
			BeanUtils.copyProperties(info, businessInfo);
			businessInfoService.update(businessInfo);
		
		if (3 == level) 
			UserInfo userInfo = new UserInfo();
			BeanUtils.copyProperties(info, userInfo);
			userInfoService.update(userInfo);
		

        info.setLevel(level);
        info.setName(account.getName());
        // 清空session,让用户重新登录
        request.getSession().setAttribute("user", null);
        return Result.success();
    

    @PostMapping("/resetPassword")
    public Result resetPassword(@RequestBody Account account) 
        Integer level = account.getLevel();
		if (1 == level) 
			AdminInfo info = adminInfoService.findByUserName(account.getName());
			if (info == null) 
				return Result.error(ResultCode.USER_NOT_EXIST_ERROR.code, ResultCode.USER_NOT_EXIST_ERROR.msg);
			
			info.setPassword(SecureUtil.md5("123456"));
			adminInfoService.update(info);
		
		if (2 == level) 
			BusinessInfo info = businessInfoService.findByUserName(account.getName());
			if (info == null) 
				return Result.error(ResultCode.USER_NOT_EXIST_ERROR.code, ResultCode.USER_NOT_EXIST_ERROR.msg);
			
			info.setPassword(SecureUtil.md5("123456"));
			businessInfoService.update(info);
		
		if (3 == level) 
			UserInfo info = userInfoService.findByUserName(account.getName());
			if (info == null) 
				return Result.error(ResultCode.USER_NOT_EXIST_ERROR.code, ResultCode.USER_NOT_EXIST_ERROR.msg);
			
			info.setPassword(SecureUtil.md5("123456"));
			userInfoService.update(info);
		

        return Result.success();
    

package com.example.controller;

import cn.hutool.core.collection.CollUtil;
import cn.hutool.core.collection.CollectionUtil;
import cn.hutool.core.io.IoUtil;
import cn.hutool.core.util.ObjectUtil;
import cn.hutool.core.util.StrUtil;
import cn.hutool.poi.excel.ExcelUtil;
import cn.hutool.poi.excel.ExcelWriter;
import com.example.common.Result;
import com.example.common.ResultCode;
import com.example.entity.AdminInfo;
import com.example.service.AdminInfoService;
import com.example.exception.CustomException;
import com.example.common.ResultCode;
import com.example.vo.AdminInfoVo;

import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import com.example.service.*;
import org.springframework.web.bind.annotation.*;
import org.springframework.beans.factory.annotation.Value;
import cn.hutool.core.util.StrUtil;
import org.springframework.web.multipart.MultipartFile;

import javax.annotation.Resource;
import javax.servlet.ServletOutputStream;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;
import java.util.LinkedHashMap;
import java.util.List;
import java.util.Map;
import java.util.stream.Collectors;

@RestController
@RequestMapping(value = "/adminInfo")
public class AdminInfoController 

    @Resource
    private AdminInfoService adminInfoService;

    @PostMapping
    public Result<AdminInfo> add(@RequestBody AdminInfoVo adminInfo) 
        adminInfoService.add(adminInfo);
        return Result.success(adminInfo);
    

    @DeleteMapping("/id")
    public Result delete(@PathVariable Long id) 
        adminInfoService.delete(id);
        return Result.success();
    

    @PutMapping
    public Result update(@RequestBody AdminInfoVo adminInfo) 
        adminInfoService.update(adminInfo);
        return Result.success();
    

    @GetMapping("/id")
    public Result<AdminInfo> detail(@PathVariable Long id) 
        AdminInfo adminInfo = adminInfoService.findById(id);
        return Result.success(adminInfo);
    

    @GetMapping
    public Result<List<AdminInfoVo>> all() 
        return Result.success(adminInfoService.findAll());
    

    @GetMapping("/page/name")
    public Result<PageInfo<AdminInfoVo>> page(@PathVariable String name,
                                                @RequestParam(defaultValue = "1") Integer pageNum,
                                                @RequestParam(defaultValue = "5") Integer pageSize,
                                                HttpServletRequest request) 
        return Result.success(adminInfoService.findPage(name, pageNum, pageSize, request));
    

    @PostMapping("/register")
    public Result<AdminInfo> register(@RequestBody AdminInfo adminInfo) 
        if (StrUtil.isBlank(adminInfo.getName()) || StrUtil.isBlank(adminInfo.getPassword())) 
            throw new CustomException(ResultCode.PARAM_ERROR);
        
        return Result.success(adminInfoService.add(adminInfo));
    

    /**
    * 批量通过excel添加信息
    * @param file excel文件
    * @throws IOException
    */
    @PostMapping("/upload")
    public Result upload(MultipartFile file) throws IOException 

        List<AdminInfo> infoList = ExcelUtil.getReader(file.getInputStream()).readAll(AdminInfo.class);
        if (!CollectionUtil.isEmpty(infoList)) 
            // 处理一下空数据
            List<AdminInfo> resultList = infoList.stream().filter(x -> ObjectUtil.isNotEmpty(x.getName())).collect(Collectors.toList());
            for (AdminInfo info : resultList) 
                adminInfoService.add(info);
            
        
        return Result.success();
    

    @GetMapping("/getExcelModel")
    public void getExcelModel(HttpServletResponse response) throws IOException 
        // 1. 生成excel
        Map<String, Object> row = new LinkedHashMap<>();
		row.put("name", "admin");
		row.put("password", "123456");
		row.put("nickName", "管理员");
		row.put("sex", "男");
		row.put("age", 22);
		row.put("birthday", "TIME");
		row.put("phone", "18843232356");
		row.put("address", "上海市");
		row.put("code", "111");
		row.put("email", "aa@163.com");
		row.put("cardId", "342425199001116372");
		row.put("level", 1);

        List<Map<String, Object>> list = CollUtil.newArrayList(row);

        // 2. 写excel
        ExcelWriter writer = ExcelUtil.getWriter(true);
        writer.write(list, true);

        response.setContentType("application/vnd.openxmlformats-officedocument.spreadsheetml.sheet;charset=utf-8");
        response.setHeader("Content-Disposition","attachment;filename=adminInfoModel.xlsx");

        ServletOutputStream out = response.getOutputStream();
        writer.flush(out, true);
        writer.close();
        IoUtil.close(System.out);
    

package com.example.controller;

import cn.hutool.core.collection.CollUtil;
import cn.hutool.core.collection.CollectionUtil;
import cn.hutool.core.io.IoUtil;
import cn.hutool.core.util.ObjectUtil;
import cn.hutool.core.util.StrUtil;
import cn.hutool.poi.excel.ExcelUtil;
import cn.hutool.poi.excel.ExcelWriter;
import com.example.common.Result;
import com.example.common.ResultCode;
import com.example.entity.AdvertiserInfo;
import com.example.service.*;
import com.example.vo.AdvertiserInfoVo;

import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import org.springframework.web.bind.annotation.*;
import org.springframework.web.multipart.MultipartFile;

import javax.annotation.Resource;
import javax.servlet.ServletOutputStream;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;
import java.util.LinkedHashMap;
import java.util.List;
import java.util.Map;
import java.util.stream.Collectors;

@RestController
@RequestMapping(value = "/advertiserInfo")
public class AdvertiserInfoController 
    @Resource
    private AdvertiserInfoService advertiserInfoService;

    @PostMapping
    public Result<AdvertiserInfo> add(@RequestBody AdvertiserInfoVo advertiserInfo) 
        advertiserInfoService.add(advertiserInfo);
        return Result.success(advertiserInfo);
    

    @DeleteMapping("/id")
    public Result delete(@PathVariable Long id) 
        advertiserInfoService.delete(id);
        return Result.success();
    

    @PutMapping
    public Result update(@RequestBody AdvertiserInfoVo advertiserInfo) 
        advertiserInfoService.update(advertiserInfo);
        return Result.success();
    

    @GetMapping("/id")
    public Result<AdvertiserInfo> detail(@PathVariable Long id) 
        AdvertiserInfo advertiserInfo = advertiserInfoService.findById(id);
        return Result.success(advertiserInfo);
    

    @GetMapping
    public Result<List<AdvertiserInfoVo>> all() 
        return Result.success(advertiserInfoService.findAll());
    

    @GetMapping("/page/name")
    public Result<PageInfo<AdvertiserInfoVo>> page(@PathVariable String name,
                                                @RequestParam(defaultValue = "1") Integer pageNum,
                                                @RequestParam(defaultValue = "5") Integer pageSize,
                                                HttpServletRequest request) 
        return Result.success(advertiserInfoService.findPage(name, pageNum, pageSize, request));
    

    /**
    * 批量通过excel添加信息
    * @param file excel文件
    * @throws IOException
    */
    @PostMapping("/upload")
    public Result upload(MultipartFile file) throws IOException 

        List<AdvertiserInfo> infoList = ExcelUtil.getReader(file.getInputStream()).readAll(AdvertiserInfo.class);
        if (!CollectionUtil.isEmpty(infoList)) 
            // 处理一下空数据
            List<AdvertiserInfo> resultList = infoList.stream().filter(x -> ObjectUtil.isNotEmpty(x.getName())).collect(Collectors.toList());
            for (AdvertiserInfo info : resultList) 
                advertiserInfoService.add(info);
            
        
        return Result.success();
    

    @GetMapping("/getExcelModel")
    public void getExcelModel(HttpServletResponse response) throws IOException 
        // 1. 生成excel
        Map<String, Object> row = new LinkedHashMap<>();
		row.put("name", "系统公告");
		row.put("content", "这是系统公告,管理员可以在后台修改");
		row.put("time", "TIME");

        List<Map<String, Object>> list = CollUtil.newArrayList(row);

        // 2. 写excel
        ExcelWriter writer = ExcelUtil.getWriter(true);
        writer.write(list, true);

        response.setContentType("application/vnd.openxmlformats-officedocument.spreadsheetml.sheet;charset=utf-8");
        response.setHeader("Content-Disposition","attachment;filename=advertiserInfoModel.xlsx");

        ServletOutputStream out = response.getOutputStream();
        writer.flush(out, true);
        writer.close();
        IoUtil.close(System.out);
    

五,项目总结

    项目功能完整,设计简约大方,利用springboot和vue搭建了一个具有前端展示和物品购买的前端系统,以及后台用于管理相关信息的后台管理系统,可以用做毕业设计使用。

以上是关于毕业设计:基于Springboot+Vue+ElementUI实现疫情社区管理系统的主要内容,如果未能解决你的问题,请参考以下文章

Java+MySQL 基于Springboot+vue的旧物置换网站#毕业设计

Java+MySQL 基于Springboot+vue的疫情网课管理系统#毕业设计

Java+MySQL基于Springboot+vue的酒店民宿管理系统前后台#毕业设计

计算机毕业设计之java+springboot基于vue的学习平台

Java项目毕业设计:基于springboot+vue的旧物置换网站

毕业设计:基于Springboot + Vue仿网易云音乐网站开源