当前位置:
首页 >
基于springboot社区疫情防控管理系统
发布时间:2023/12/9
54
豆豆
生活随笔
收集整理的这篇文章主要介绍了
基于springboot社区疫情防控管理系统
小编觉得挺不错的,现在分享给大家,帮大家做个参考.
随着社会的发展,社会的各行各业都在利用信息化时代的优势。计算机的优势和普及使得各种信息系统的开发成为必需。
社区疫情防控管理系统,主要的模块包括用户管理,在线交流信息,人员检测信息,外来人员报备,防疫须知信息,公告信息,疫情用品信息,订单信息,评价信息功能。系统中管理员主要是为了安全有效地存储和管理各类信息,还可以对系统进行管理与更新维护等操作,并且对后台有相应的操作权限。
开发工具:idea (eclipse) 环境:jdk1.8 mysql
基于springboot mybatis 开发
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.UserInfo; import com.example.service.UserInfoService; import com.example.exception.CustomException; import com.example.common.ResultCode; import com.example.vo.UserInfoVo;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 = "/userInfo") public class UserInfoController {@Resourceprivate UserInfoService userInfoService;@PostMappingpublic Result<UserInfo> add(@RequestBody UserInfoVo userInfo) {userInfoService.add(userInfo);return Result.success(userInfo);}@DeleteMapping("/{id}")public Result delete(@PathVariable Long id) {userInfoService.delete(id);return Result.success();}@PutMappingpublic Result update(@RequestBody UserInfoVo userInfo) {userInfoService.update(userInfo);return Result.success();}@GetMapping("/{id}")public Result<UserInfo> detail(@PathVariable Long id) {UserInfo userInfo = userInfoService.findById(id);return Result.success(userInfo);}@GetMappingpublic Result<List<UserInfoVo>> all() {return Result.success(userInfoService.findAll());}@GetMapping("/page/{name}")public Result<PageInfo<UserInfoVo>> page(@PathVariable String name,@RequestParam(defaultValue = "1") Integer pageNum,@RequestParam(defaultValue = "5") Integer pageSize,HttpServletRequest request) {return Result.success(userInfoService.findPage(name, pageNum, pageSize, request));}@PostMapping("/register")public Result<UserInfo> register(@RequestBody UserInfo userInfo) {if (StrUtil.isBlank(userInfo.getName()) || StrUtil.isBlank(userInfo.getPassword())) {throw new CustomException(ResultCode.PARAM_ERROR);}return Result.success(userInfoService.add(userInfo));}/*** 批量通过excel添加信息* @param file excel文件* @throws IOException*/@PostMapping("/upload")public Result upload(MultipartFile file) throws IOException {List<UserInfo> infoList = ExcelUtil.getReader(file.getInputStream()).readAll(UserInfo.class);if (!CollectionUtil.isEmpty(infoList)) {// 处理一下空数据List<UserInfo> resultList = infoList.stream().filter(x -> ObjectUtil.isNotEmpty(x.getName())).collect(Collectors.toList());for (UserInfo info : resultList) {userInfoService.add(info);}}return Result.success();}@GetMapping("/getExcelModel")public void getExcelModel(HttpServletResponse response) throws IOException {// 1. 生成excelMap<String, Object> row = new LinkedHashMap<>();row.put("name", "张天志");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("email", "aa@163.com");row.put("cardId", "342425199001116372");row.put("level", 3);List<Map<String, Object>> list = CollUtil.newArrayList(row);// 2. 写excelExcelWriter 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=userInfoModel.xlsx");ServletOutputStream out = response.getOutputStream();writer.flush(out, true);writer.close();IoUtil.close(System.out);} }
总结
以上是生活随笔为你收集整理的基于springboot社区疫情防控管理系统的全部内容,希望文章能够帮你解决所遇到的问题。
- 上一篇: Angular 2.x 从0到1 (五)
- 下一篇: win10自动停用打印服务器,技术员详解