源码获取:博客首页 "资源" 里下载!

一、项目简述

本系统主要实现的功能有:
社区疫情流动人员管理系统,住户管理,出入管理,访客管理,体温录入,高风险警示等等。

二、项目运行

环境配置:

Jdk1.8 + Tomcat8.5 + mysql + Eclispe(IntelliJ IDEA,Eclispe,MyEclispe,Sts都支持)

项目技术:

Springboot+ SpringMVC + MyBatis + Jsp + Html+ JavaScript + JQuery + Ajax +
maven等等
 

 

 

 

 

 

系统用户后台管理代码:
/** * 系统用户 * * @author Mark */ @RestController @RequestMapping("/sys/user")
public class SysUserController extends AbstractController { @Autowired private
SysUserService sysUserService; @Autowired private SysUserRoleService
sysUserRoleService; /** * 所有用户列表 */ @GetMapping("/list")
@RequiresPermissions("sys:user:list") public R list(@RequestParam Map<String,
Object> params){ //只有超级管理员,才能查看所有管理员列表 if(getUserId() != Constant.SUPER_ADMIN){
params.put("createUserId", getUserId()); } PageUtils page =
sysUserService.queryPage(params); return R.ok().put("page", page); } /** *
获取登录的用户信息 */ @GetMapping("/info") public R info(){ return R.ok().put("user",
getUser()); } /** * 修改登录用户密码 */ @SysLog("修改密码") @PostMapping("/password")
public R password(@RequestBody PasswordForm form){
Assert.isBlank(form.getNewPassword(), "新密码不为能空"); //sha256加密 String password =
new Sha256Hash(form.getPassword(), getUser().getSalt()).toHex(); //sha256加密
String newPassword = new Sha256Hash(form.getNewPassword(),
getUser().getSalt()).toHex(); //更新密码 boolean flag =
sysUserService.updatePassword(getUserId(), password, newPassword); if(!flag){
return R.error("原密码不正确"); } return R.ok(); } /** * 用户信息 */
@GetMapping("/info/{userId}") @RequiresPermissions("sys:user:info") public R
info(@PathVariable("userId") Long userId){ SysUserEntity user =
sysUserService.getById(userId); //获取用户所属的角色列表 List<Long> roleIdList =
sysUserRoleService.queryRoleIdList(userId); user.setRoleIdList(roleIdList);
return R.ok().put("user", user); } /** * 保存用户 */ @SysLog("保存用户")
@PostMapping("/save") @RequiresPermissions("sys:user:save") public R
save(@RequestBody SysUserEntity user){ ValidatorUtils.validateEntity(user,
AddGroup.class); user.setCreateUserId(getUserId());
sysUserService.saveUser(user); return R.ok(); } /** * 修改用户 */ @SysLog("修改用户")
@PostMapping("/update") @RequiresPermissions("sys:user:update") public R
update(@RequestBody SysUserEntity user){ ValidatorUtils.validateEntity(user,
UpdateGroup.class); user.setCreateUserId(getUserId());
sysUserService.update(user); return R.ok(); } /** * 删除用户 */ @SysLog("删除用户")
@PostMapping("/delete") @RequiresPermissions("sys:user:delete") public R
delete(@RequestBody Long[] userIds){ if(ArrayUtils.contains(userIds, 1L)){
return R.error("系统管理员不能删除"); } if(ArrayUtils.contains(userIds, getUserId())){
return R.error("当前用户不能删除"); } sysUserService.deleteBatch(userIds); return
R.ok(); } }

主要负责用户的密码找回和注册功能:
/** * 主要负责用户的密码找回和注册功能 */ @Slf4j @RestController @RequestMapping("/User")
@Api(tags = "登录相关接口") public class UserLoginController { @Autowired private
UserService userService; //发送验证码 @PostMapping("/sendSms") public Result
sendSms(@RequestParam String account, @RequestParam String userPhone) { return
userService.sendSms(account, userPhone); } //验证验证码
@PostMapping("/lookForPwdSubmit") public Result lookForPwd(RetrievePwdDto
retrievePwdDto) { return userService.checkVesCode(retrievePwdDto); } //重置密码
@PostMapping("/retrievePwdSubmit") public Result
retrievePwdSubmit(RetrievePwdDto retrievePwdDto) {
System.out.println(retrievePwdDto); return
userService.updateUserPwd(retrievePwdDto.getAccount(),
retrievePwdDto.getNewPwd()); } //用户注册 @PostMapping("/registerUser") public
Result registerUser(UserDto userDto) { return
userService.registerUser(userDto); } }

登录控制器:
/** * * 登录控制器 */ @Slf4j @Controller @RequestMapping("/User") @Api(value =
"用户登录模块,进行个人信息管理",tags = "用户登录相关信息接口") public class LoginController {
@Autowired private UserService userService; @Resource private MyShiroRealm
shiroRealm; @RequestMapping("/main") public String mainPage(HttpServletRequest
request,Model model) { String account = CookieUtil.getCookieValue(request,
"account"); UserDto user = userService.queryUserDtoByAccount(account);
model.addAttribute("user",user);
request.getSession().setAttribute("user",user); return "index"; }
@PostMapping("/doLogin") @ResponseBody public Result doLoginPage(@RequestParam
String loginAccount, @RequestParam String password, @RequestParam(defaultValue
= "false") Boolean remeber) { Subject subject = SecurityUtils.getSubject();
UsernamePasswordToken token = new UsernamePasswordToken();
token.setUsername(loginAccount); token.setPassword(password.toCharArray());
//开启RememberMe token.setRememberMe(remeber); try { //进行登录的认证
subject.login(token); //登录认证成功后,将shiro中保存的用户对象取出,放到session中 String userAccount
= (String)subject.getPrincipal(); UserDto user =
userService.queryUserDtoByAccount(userAccount); //将用户对象的ID放到session域中 Session
session = SecurityUtils.getSubject().getSession();
session.setAttribute("userSession",user); return Result.ok("登录成功",user); }catch
(UnknownAccountException e){ return Result.fail("账号不存在!"); }catch
(IncorrectCredentialsException e){ return Result.fail("密码错误!"); } catch
(ExcessiveAttemptsException e) { return Result.fail("登录失败!"); } } //修改密码
@PostMapping("/pwdSubmit") @ResponseBody public Result
pwdSubmit(HttpServletRequest request,@RequestParam String oldPwd, @RequestParam
String newPwd){ String account = CookieUtil.getCookieValue(request, "account");
UserDto user = userService.queryUserDtoByAccount(account); String updateUserPwd
= userService.updateUserPwd(user.getAccount(),oldPwd,newPwd); if
("true".equals(updateUserPwd)){ //修改密码后需要将当前用户shiro缓存中的数据清空
shiroRealm.clearCachedAuthenticationInfo(SecurityUtils.getSubject().getPrincipals());
//清除授权信息
shiroRealm.clearCachedAuthorizationInfo(SecurityUtils.getSubject().getPrincipals());
return Result.ok(user.getUserName()+"密码修改成功"); }else { return
Result.fail(updateUserPwd); } } @PostMapping("/infoSubmit") @ResponseBody
public Result infoSubmit(UserDto userDto) { Boolean info =
userService.updateUserInfo(userDto); System.out.println(info); if (info) {
return Result.ok(); }else { return Result.fail("保存个人信息失败!"); } } // 用户注销
@ApiOperation("用户注销方法") @GetMapping("/logout") public String logout() { Subject
subject = SecurityUtils.getSubject(); subject.logout(); return
"redirect:login"; } }
源码获取:博客首页 "资源" 里下载!

技术
今日推荐
下载桌面版
GitHub
百度网盘(提取码:draw)
Gitee
云服务器优惠
阿里云优惠券
腾讯云优惠券
华为云优惠券
站点信息
问题反馈
邮箱:[email protected]
QQ群:766591547
关注微信