Java项目:(小程序)疫苗预约系统(java+weixin-java-mp+spring+spring mvc+mybatis+layui+微信小程序)

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

一、项目简述

本系统功能包括:

1 .疫苗管理

2 .接种点管理(接种点、工作人员)

3 .预约跟进(预约、签到、预检、接种、留观、留观历史)

4 .用户管理

二、项目运行

环境配置: jdk8+tomcat8+mysql5.7+lntelliJ IDEA+maven( Eclispe ,sts myEclispe 都支持)

项目技术: weixin-java-mp+spring+spring mvc+mybatis+layui+微信小程序。

Java项目:(小程序)疫苗预约系统(java+weixin-java-mp+spring+spring mvc+mybatis+layui+微信小程序)_第1张图片

 Java项目:(小程序)疫苗预约系统(java+weixin-java-mp+spring+spring mvc+mybatis+layui+微信小程序)_第2张图片

 Java项目:(小程序)疫苗预约系统(java+weixin-java-mp+spring+spring mvc+mybatis+layui+微信小程序)_第3张图片

 Java项目:(小程序)疫苗预约系统(java+weixin-java-mp+spring+spring mvc+mybatis+layui+微信小程序)_第4张图片

 Java项目:(小程序)疫苗预约系统(java+weixin-java-mp+spring+spring mvc+mybatis+layui+微信小程序)_第5张图片

 Java项目:(小程序)疫苗预约系统(java+weixin-java-mp+spring+spring mvc+mybatis+layui+微信小程序)_第6张图片

 Java项目:(小程序)疫苗预约系统(java+weixin-java-mp+spring+spring mvc+mybatis+layui+微信小程序)_第7张图片

 

系统用户后台管理代码:

/**
 * 系统用户
 *
 * @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 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 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";
    }
}

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

你可能感兴趣的:(Java毕业设计项目实战篇,java,mysql,weixin-java-mp,微信小程序,ssm)