开发工具:idea
数据库mysql5.7+
数据库链接工具:navcat,小海豚等
开发技术:springboot layui
伴随着社会的迅速发展,电子计算机对世界的作用影响是全面并且长久的。人们日常生活消费综合应用水平的持续增高,生活中人们对生活公共社区疫情防范全面控制综合管理方面的各项需求也能够在持续提升,伴随着生活公共社区疫情防范全面控制受到广大公民的重视,促使生活公共社区疫情防范全面控制综合管理应用体系的研发,逐渐发展成为必需并且危急的具体事务。生活公共社区疫病防护综合治理,通常都是经过电子计算机网络,经过对社会疫病防护综合治理要求的数据信息进一步集合和综合管理,增长用户的数据信息,与此同时也便捷了对所有客户数据信息的及时迅速查找、修整以及对客户数据信息的及时、全面、深入地了解和掌握。该应用操作体系用户供应了更多的简洁便利,该应用操作体系将和数据信息资料库综合管理操控应用软件合作,以服务好客户的要求。计算机技术在现代社会各个邻域管理中的广泛应用,也使得计算机技术成为了我们现在日常使用的现代信息技术必不可少手段。可以高效快捷的实现信息精细化、全面化的技术难题,提高生产管理的效率。
演示视频:
【java毕业设计】基于springboot layui疫苗接种信息管理系统源码
package com.vaccination.controller;
import com.alibaba.fastjson.JSONObject;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.vaccination.entity.InoculationRecord;
import com.vaccination.entity.User;
import com.vaccination.service.InoculationRecordService;
import com.vaccination.service.UserService;
import com.vaccination.util.PageRequest;
import com.vaccination.util.PageResponse;
import com.vaccination.util.Result;
import org.apache.commons.lang3.StringUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.*;
import org.springframework.web.servlet.ModelAndView;
import javax.servlet.http.HttpServletRequest;
import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.List;
@RestController
public class InoculationController {
@Autowired
private InoculationRecordService inoculationRecordService;
@Autowired
private UserService userService;
@PostMapping("/listInoculations")
public PageResponse listInoculations(HttpServletRequest request, PageRequest page) {
String loginUser = (String) request.getSession().getAttribute("loginUser");
User user = JSONObject.parseObject(loginUser, User.class);
if (user == null) {
PageResponse pageResponse = new PageResponse();
pageResponse.setMsg("请登陆");
return pageResponse;
}
if (user.getRole() == 2) {
user.setId(-1L);
}
SimpleDateFormat dateFormat = new SimpleDateFormat("yyyy-MM-dd");
IPage<InoculationRecord> iPage = inoculationRecordService.listInoculations(new Page<>(page.getPage(), page.getLimit()), user.getId());
List<InoculationRecord> records = iPage.getRecords();
records.forEach(item -> {
if (StringUtils.isBlank(item.getUsername()) && item.getUserId() != null) {
User byId = userService.getById(item.getUserId());
if (byId != null) {
item.setUsername(byId.getName());
item.setUserIdentity(byId.getIdentityNum());
}
}
if (item.getInoculationTimeOne() != null) {
item.setInoculationTimeStrOne(dateFormat.format(item.getInoculationTimeOne()));
}
if (item.getInoculationTimeTwo() != null) {
item.setInoculationTimeStrTwo(dateFormat.format(item.getInoculationTimeTwo()));
}
if (item.getInoculationTimeThree() != null) {
item.setInoculationTimeStrThree(dateFormat.format(item.getInoculationTimeThree()));
}
});
return new PageResponse("0", "请求成功", iPage.getTotal(), records);
}
@GetMapping("/delInoculation")
public Result delInoculation(Long id) {
inoculationRecordService.removeById(id);
return Result.success("删除成功");
}
@PostMapping("/saveInoculation")
public Result saveInoculation(InoculationRecord record, HttpServletRequest request) throws ParseException {
String loginUser = (String) request.getSession().getAttribute("loginUser");
User user = JSONObject.parseObject(loginUser, User.class);
if (user == null) {
return Result.error("请登陆");
}
if(record.getStatusThree() == 1 && (record.getStatusTwo() == 2 || record.getStatusOne() == 2)) {
return Result.error("请先接种第一二针");
}
if(record.getStatusTwo() == 1 && record.getStatusTwo() == 2) {
return Result.error("请先接种第一针");
}
record.setUserId(user.getId());
if (StringUtils.isNoneBlank(record.getUsername())){
User byUsername = userService.getByUsername(record.getUsername());
if(byUsername == null) {
User newUser = new User();
newUser.setUsername(record.getUsername());
newUser.setName(record.getUsername());
newUser.setPassword("123456");
newUser.setRole(1);
newUser.setStatus(1);
userService.save(newUser);
byUsername = newUser;
}
record.setUserId(byUsername.getId());
}
if (StringUtils.isNoneBlank(record.getInoculationTimeStrOne())) {
SimpleDateFormat dateFormat = new SimpleDateFormat("yyyy-MM-dd");
record.setInoculationTimeOne(dateFormat.parse(record.getInoculationTimeStrOne()));
}
if (StringUtils.isNoneBlank(record.getInoculationTimeStrTwo())) {
SimpleDateFormat dateFormat = new SimpleDateFormat("yyyy-MM-dd");
record.setInoculationTimeTwo(dateFormat.parse(record.getInoculationTimeStrTwo()));
}
if (StringUtils.isNoneBlank(record.getInoculationTimeStrThree())) {
SimpleDateFormat dateFormat = new SimpleDateFormat("yyyy-MM-dd");
record.setInoculationTimeThree(dateFormat.parse(record.getInoculationTimeStrThree()));
}
inoculationRecordService.save(record);
return Result.success("添加成功");
}
@PostMapping("/updateInoculation")
public Result updateInoculation(InoculationRecord record) throws ParseException {
if (record.getId() == null) {
return Result.error("更新失败");
}
if(record.getStatusThree() == 1 && (record.getStatusTwo() == 2 || record.getStatusOne() == 2)) {
return Result.error("请先接种第一二针");
}
if(record.getStatusTwo() == 1 && record.getStatusTwo() == 2) {
return Result.error("请先接种第一针");
}
if (StringUtils.isNoneBlank(record.getInoculationTimeStrOne())) {
SimpleDateFormat dateFormat = new SimpleDateFormat("yyyy-MM-dd");
record.setInoculationTimeOne(dateFormat.parse(record.getInoculationTimeStrOne()));
}
if (StringUtils.isNoneBlank(record.getInoculationTimeStrTwo())) {
SimpleDateFormat dateFormat = new SimpleDateFormat("yyyy-MM-dd");
record.setInoculationTimeTwo(dateFormat.parse(record.getInoculationTimeStrTwo()));
}
if (StringUtils.isNoneBlank(record.getInoculationTimeStrThree())) {
SimpleDateFormat dateFormat = new SimpleDateFormat("yyyy-MM-dd");
record.setInoculationTimeThree(dateFormat.parse(record.getInoculationTimeStrThree()));
}
inoculationRecordService.updateById(record);
return Result.success("更新成功");
}
}
package com.vaccination.controller;
import com.alibaba.fastjson.JSONObject;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.vaccination.entity.InoculationRecord;
import com.vaccination.entity.User;
import com.vaccination.service.UserService;
import com.vaccination.util.PageRequest;
import com.vaccination.util.PageResponse;
import com.vaccination.util.Result;
import net.sf.jsqlparser.Model;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import org.springframework.web.servlet.ModelAndView;
import javax.servlet.http.HttpServletRequest;
import java.util.ArrayList;
@RestController
public class UserController {
@Autowired
private UserService userService;
@PostMapping("/login")
public ModelAndView login(User request, ModelAndView mv, HttpServletRequest servletRequest) {
User user = userService.getOne(new QueryWrapper<User>().eq("username", request.getUsername()).eq("password", request.getPassword()));
if (user == null){
mv.addObject("msg", "登陆失败,请检查账号或密码");
mv.setViewName("login");
return mv;
}
if (user.getStatus() == 2) {
mv.addObject("msg", "账号被封禁,请联系管理员");
mv.setViewName("login");
return mv;
}
mv.addObject("username", request.getUsername());
mv.setViewName("user");
mv.addObject("isAdmin", user.getRole() == 2);
servletRequest.getSession().setAttribute("loginUser", JSONObject.toJSONString(user));
return mv;
}
@GetMapping("/logout")
public ModelAndView logout(ModelAndView mv, HttpServletRequest request) {
mv.setViewName("login");
mv.addObject("msg", "退出成功");
request.getSession().removeAttribute("loginUser");
return mv;
}
@PostMapping("/reg")
public ModelAndView reg(User request, ModelAndView mv) {
User user = userService.getOne(new QueryWrapper<User>().eq("username", request.getUsername()));
if (user != null){
mv.addObject("msg", "注册失败,用户名已存在");
mv.setViewName("reg");
return mv;
}
request.setName(request.getUsername());
mv.addObject("username", request.getUsername());
mv.addObject("msg", "注册成功,请登陆");
userService.save(request);
mv.setViewName("login");
return mv;
}
@GetMapping("/userInfo")
public ModelAndView userInfo(ModelAndView mv, HttpServletRequest request){
mv.setViewName("userInfo");
String user = (String) request.getSession().getAttribute("loginUser");
User byId = userService.getById(JSONObject.parseObject(user, User.class).getId());
mv.addObject("user",byId);
request.getSession().setAttribute("loginUser", JSONObject.toJSONString(byId));
return mv;
}
@PostMapping("/saveUserInfo")
public Result saveUserInfo(User request, HttpServletRequest servletRequest) {
User user = JSONObject.parseObject((String) servletRequest.getSession().getAttribute("loginUser"), User.class);
request.setId(user.getId());
userService.updateById(request);
servletRequest.getSession().setAttribute("loginUser", JSONObject.toJSONString(request));
return Result.success("修改成功");
}
@PostMapping("/listUser")
public PageResponse listUser(PageRequest page, HttpServletRequest request) {
String loginUser = (String) request.getSession().getAttribute("loginUser");
User user = JSONObject.parseObject(loginUser, User.class);
if (user == null) {
return new PageResponse("500","请登陆",0L, new ArrayList<>());
}
if (user.getRole() == 1) {
return new PageResponse("500","没有权限",0L, new ArrayList<>());
}
IPage<User> iPage = userService.listPage(new Page<>(page.getPage(), page.getLimit()));
return new PageResponse("0", "请求成功", iPage.getTotal(), iPage.getRecords());
}
@GetMapping("/getUserById/{id}")
public ModelAndView getUserById(@PathVariable("id") Long userId, ModelAndView mv) {
User byId = userService.getById(userId);
mv.addObject("user", byId);
mv.setViewName("editUser");
return mv;
}
@GetMapping("/enableUser")
public Result enableUser(Long id) {
User byId = userService.getById(id);
byId.setStatus(1);
userService.updateById(byId);
return Result.success("启用成功");
}
@GetMapping("/disableUser")
public Result disableUser(Long id) {
User byId = userService.getById(id);
byId.setStatus(2);
userService.updateById(byId);
return Result.success("禁用成功");
}
@GetMapping("delUser")
public Result delUser(Long id) {
userService.removeAll(id);
return Result.success("删除成功");
}
@PostMapping("/updateUser")
public Result updateUser(User user) {
User username = userService.getOne(new QueryWrapper<User>().eq("username", user.getUsername()));
if (username != null && !username.getId().equals(user.getId())) {
return Result.error("用户名已存在");
}
userService.updateById(user);
return Result.success("修改成功");
}
}
package com.vaccination.controller;
import com.alibaba.fastjson.JSONObject;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.vaccination.entity.Travel;
import com.vaccination.entity.User;
import com.vaccination.service.TravelService;
import com.vaccination.service.UserService;
import com.vaccination.util.PageRequest;
import com.vaccination.util.PageResponse;
import com.vaccination.util.Result;
import org.apache.commons.lang3.StringUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RestController;
import javax.servlet.http.HttpServletRequest;
import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.List;
@RestController
public class TravelController {
@Autowired
private TravelService travelService;
@Autowired
private UserService userService;
@PostMapping("/listTravel")
public PageResponse listTravel(HttpServletRequest request, PageRequest page) {
String loginUser = (String) request.getSession().getAttribute("loginUser");
User user = JSONObject.parseObject(loginUser, User.class);
if (user == null) {
PageResponse pageResponse = new PageResponse();
pageResponse.setMsg("请登陆");
return pageResponse;
}
if (user.getRole() == 2) {
user.setId(-1L);
}
SimpleDateFormat dateFormat = new SimpleDateFormat("yyyy-MM-dd");
IPage<Travel> iPage = travelService.listTravel(new Page<>(page.getPage(), page.getLimit()), user.getId());
List<Travel> records = iPage.getRecords();
records.forEach(item -> {
if (StringUtils.isBlank(item.getUsername()) && item.getUserId() != null) {
User byId = userService.getById(item.getUserId());
if (byId != null) {
item.setUsername(byId.getName());
item.setUserIdentity(byId.getIdentityNum());
}
}
if (item.getHappenTime() != null) {
item.setHappenTimeStr(dateFormat.format(item.getHappenTime()));
}
});
return new PageResponse("0", "请求成功", iPage.getTotal(), records);
}
@GetMapping("/delTravel")
public Result delCaseHistory(Long id) {
travelService.removeById(id);
return Result.success("删除成功");
}
@PostMapping("/saveTravel")
public Result saveInoculation(Travel record, HttpServletRequest request) throws ParseException {
String loginUser = (String) request.getSession().getAttribute("loginUser");
User user = JSONObject.parseObject(loginUser, User.class);
if (user == null) {
return Result.error("请登陆");
}
record.setUserId(user.getId());
if (StringUtils.isNoneBlank(record.getUsername())){
User byUsername = userService.getByUsername(record.getUsername());
if(byUsername == null) {
User newUser = new User();
newUser.setUsername(record.getUsername());
newUser.setName(record.getUsername());
newUser.setPassword("123456");
newUser.setRole(1);
newUser.setStatus(1);
userService.save(newUser);
byUsername = newUser;
}
record.setUserId(byUsername.getId());
}
if (StringUtils.isNoneBlank(record.getHappenTimeStr())) {
SimpleDateFormat dateFormat = new SimpleDateFormat("yyyy-MM-dd");
record.setHappenTime(dateFormat.parse(record.getHappenTimeStr()));
}
travelService.save(record);
return Result.success("添加成功");
}
@PostMapping("/updateTravel")
public Result updateInoculation(Travel record) throws ParseException {
if (record.getId() == null) {
return Result.error("更新失败");
}
if (StringUtils.isNoneBlank(record.getHappenTimeStr())) {
SimpleDateFormat dateFormat = new SimpleDateFormat("yyyy-MM-dd");
record.setHappenTime(dateFormat.parse(record.getHappenTimeStr()));
}else {
record.setHappenTime(null);
}
travelService.updateById(record);
return Result.success("更新成功");
}
}