Source code acquisition : Blog home page " resources " Download in !

one , Project brief

The main functions of this system are :
Community epidemic floating personnel management system , Household management , Access management , Visitor management , Body temperature entry , High risk warning, etc .

two , Project operation

Environment configuration :

Jdk1.8 + Tomcat8.5 + mysql + Eclispe(IntelliJ IDEA,Eclispe,MyEclispe,Sts All support )

Project technology :

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

 

 

 

 

 

System user background management code :
/** * System user * * @author Mark */ @RestController @RequestMapping("/sys/user")
public class SysUserController extends AbstractController { @Autowired private
SysUserService sysUserService; @Autowired private SysUserRoleService
sysUserRoleService; /** * List of all users */ @GetMapping("/list")
@RequiresPermissions("sys:user:list") public R list(@RequestParam Map<String,
Object> params){ // Only super administrators , To view the list of all administrators if(getUserId() != Constant.SUPER_ADMIN){
params.put("createUserId", getUserId()); } PageUtils page =
sysUserService.queryPage(params); return R.ok().put("page", page); } /** *
Get login user information */ @GetMapping("/info") public R info(){ return R.ok().put("user",
getUser()); } /** * Modify login user password */ @SysLog(" Change Password ") @PostMapping("/password")
public R password(@RequestBody PasswordForm form){
Assert.isBlank(form.getNewPassword(), " New password cannot be empty "); //sha256 encryption String password =
new Sha256Hash(form.getPassword(), getUser().getSalt()).toHex(); //sha256 encryption
String newPassword = new Sha256Hash(form.getNewPassword(),
getUser().getSalt()).toHex(); // Update password boolean flag =
sysUserService.updatePassword(getUserId(), password, newPassword); if(!flag){
return R.error(" The original password is incorrect "); } return R.ok(); } /** * User information */
@GetMapping("/info/{userId}") @RequiresPermissions("sys:user:info") public R
info(@PathVariable("userId") Long userId){ SysUserEntity user =
sysUserService.getById(userId); // Get the list of roles to which the user belongs List<Long> roleIdList =
sysUserRoleService.queryRoleIdList(userId); user.setRoleIdList(roleIdList);
return R.ok().put("user", user); } /** * Save user */ @SysLog(" Save user ")
@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(); } /** * Modify user */ @SysLog(" Modify user ")
@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(); } /** * delete user */ @SysLog(" delete user ")
@PostMapping("/delete") @RequiresPermissions("sys:user:delete") public R
delete(@RequestBody Long[] userIds){ if(ArrayUtils.contains(userIds, 1L)){
return R.error(" System administrator cannot delete "); } if(ArrayUtils.contains(userIds, getUserId())){
return R.error(" The current user cannot be deleted "); } sysUserService.deleteBatch(userIds); return
R.ok(); } }

It is mainly responsible for the password retrieval and registration functions of users :
/** * It is mainly responsible for the password retrieval and registration functions of users */ @Slf4j @RestController @RequestMapping("/User")
@Api(tags = " Login related interface ") public class UserLoginController { @Autowired private
UserService userService; // Send verification code @PostMapping("/sendSms") public Result
sendSms(@RequestParam String account, @RequestParam String userPhone) { return
userService.sendSms(account, userPhone); } // Verification code
@PostMapping("/lookForPwdSubmit") public Result lookForPwd(RetrievePwdDto
retrievePwdDto) { return userService.checkVesCode(retrievePwdDto); } // reset password
@PostMapping("/retrievePwdSubmit") public Result
retrievePwdSubmit(RetrievePwdDto retrievePwdDto) {
System.out.println(retrievePwdDto); return
userService.updateUserPwd(retrievePwdDto.getAccount(),
retrievePwdDto.getNewPwd()); } // User registration @PostMapping("/registerUser") public
Result registerUser(UserDto userDto) { return
userService.registerUser(userDto); } }

Login controller :
/** * * Login controller */ @Slf4j @Controller @RequestMapping("/User") @Api(value =
" User login module , Manage personal information ",tags = " User login related information interface ") 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());
// open RememberMe token.setRememberMe(remeber); try { // Authentication for login
subject.login(token); // After successful login authentication , take shiro User objects saved in , put to session in String userAccount
= (String)subject.getPrincipal(); UserDto user =
userService.queryUserDtoByAccount(userAccount); // The user object's ID put to session In domain Session
session = SecurityUtils.getSubject().getSession();
session.setAttribute("userSession",user); return Result.ok(" Login successful ",user); }catch
(UnknownAccountException e){ return Result.fail(" Account does not exist !"); }catch
(IncorrectCredentialsException e){ return Result.fail(" Password error !"); } catch
(ExcessiveAttemptsException e) { return Result.fail(" Login failed !"); } } // Change Password
@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)){ // After changing the password, you need to change the current user shiro Data emptying in cache
shiroRealm.clearCachedAuthenticationInfo(SecurityUtils.getSubject().getPrincipals());
// Clear authorization information
shiroRealm.clearCachedAuthorizationInfo(SecurityUtils.getSubject().getPrincipals());
return Result.ok(user.getUserName()+" Password modified successfully "); }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(" Failed to save personal information !"); } } // User logout
@ApiOperation(" User logoff method ") @GetMapping("/logout") public String logout() { Subject
subject = SecurityUtils.getSubject(); subject.logout(); return
"redirect:login"; } }
Source code acquisition : Blog home page " resources " Download in !

Technology