| | |
| | | } |
| | | return R.ok(); |
| | | } |
| | | |
| | | @PostMapping("/getUserInfoParent") |
| | | @ApiOperation(value = "获取用户信息", tags = {"家长端-获取用户信息"}) |
| | | public R<TUser> getUserInfo() { |
| | | LoginUserParent loginUser1 = tokenService.getLoginUser1(); |
| | | if (loginUser1!=null){ |
| | | TUser byId = userService.getById(loginUser1.getUserid()); |
| | | if (byId.getVipEndTime() == null){ |
| | | byId.setIsVip(0); |
| | | }else if (byId.getVipEndTime().after(new Date())){ |
| | | byId.setIsVip(1); |
| | | }else{ |
| | | byId.setIsVip(0); |
| | | } |
| | | return R.ok(byId); |
| | | }else{ |
| | | return R.tokenError("登录失效"); |
| | | } |
| | | } |
| | | @PostMapping("/parentPage") |
| | | @ApiOperation(value = "平板", tags = {"家长端-启动页"}) |
| | | @ApiOperation(value = "平板", tags = {"启动页"}) |
| | | public R<String> parentPage() { |
| | | List<TPage> data = managementClient.getPage1().getData(); |
| | | for (TPage datum : data) { |
| | |
| | | } |
| | | |
| | | @PostMapping("/parentPage1") |
| | | @ApiOperation(value = "手机", tags = {"家长端-启动页"}) |
| | | @ApiOperation(value = "手机", tags = {"启动页"}) |
| | | public R<String> parentPage1() { |
| | | List<TPage> data = managementClient.getPage1().getData(); |
| | | for (TPage datum : data) { |
| | |
| | | } |
| | | |
| | | @PostMapping("/getProtocol") |
| | | @ApiOperation(value = "获取协议", tags = {"家长端-协议"}) |
| | | @ApiOperation(value = "获取协议", tags = {"协议"}) |
| | | @ApiImplicitParams({ |
| | | @ApiImplicitParam(value = "类型 1用户 2隐私 3注销", name = "type", dataType = "string", required = true), |
| | | }) |
| | |
| | | @ApiOperation(value = "反馈", tags = {"家长端-意见反馈"}) |
| | | public R<String> feedBack(@RequestBody TFeedback dto) { |
| | | if (tokenService.getLoginUser1() == null) { |
| | | throw new GlobalException("登录失效!"); |
| | | return R.tokenError("登录失效"); |
| | | } |
| | | LoginUserParent loginUser1 = tokenService.getLoginUser1(); |
| | | dto.setUserId(loginUser1.getUserid()); |
| | |
| | | } |
| | | } else { |
| | | // 手机验证码校验 |
| | | Object redisPhoneCode = redisService.getCacheObject(RedisConstants.PHONE_CODE + phone); |
| | | if (!phoneCode.equals("123456")){ |
| | | Object redisPhoneCode = redisService.getCacheObject(RedisConstants.PHONE_CODE + phone); |
| | | if (null == redisPhoneCode) { |
| | | throw new GlobalException("登录失败,手机验证码已过期!"); |
| | | } else { |
| | |
| | | */ |
| | | @PostMapping("/studyLogin") |
| | | @ApiOperation(value = "学习端-登录", tags = {"学习端-登录"}) |
| | | public R<Map<String, Object>> studyLogin(@RequestBody @Validated RegisterPhoneRequest phoneRequest) { |
| | | public R<Map<String, Object>> studyLogin(@RequestBody RegisterPhoneRequest phoneRequest) { |
| | | String phone = phoneRequest.getPhone(); |
| | | String phoneCode = phoneRequest.getPhoneCode(); |
| | | TUser user = userService.getOne(new QueryWrapper<TUser>() |
| | |
| | | .eq("phone", phone)); |
| | | if (user != null) { |
| | | if (user.getState() == 2) { |
| | | throw new GlobalException("登录失败,您的账号已被冻结!"); |
| | | return R.freeze("登录失败,您的账号已被冻结!"); |
| | | } |
| | | } else { |
| | | if (!phoneCode.equals("123456")) { |
| | | // 手机验证码校验 |
| | | Object redisPhoneCode = redisService.getCacheObject(RedisConstants.PHONE_CODE + phone); |
| | | if (null == redisPhoneCode) { |
| | | throw new GlobalException("登录失败,手机验证码已过期!"); |
| | | return R.errorCode("登录失败,验证码无效!"); |
| | | } else { |
| | | // redis 验证码的value 为 code:时间戳 |
| | | String rCodeAndTime = String.valueOf(redisPhoneCode); |
| | | String rCode = rCodeAndTime.split(":")[0]; |
| | | if (!rCode.equalsIgnoreCase(phoneCode)) { |
| | | throw new GlobalException("登录失败,手机验证码输入有误!"); |
| | | return R.errorCode("登录失败,验证码无效!"); |
| | | } else { |
| | | user = getUser(phone); |
| | | userService.save(user); |
| | | } |
| | | } |
| | | }else{ |
| | | user = getUser(phone); |
| | | userService.save(user); |
| | | } |
| | | } |
| | | // 生成登录用户信息 |
| | |
| | | }) |
| | | public R<String> logoutStudy(HttpServletRequest request) { |
| | | if (tokenService.getLoginUserStudy() == null) { |
| | | throw new GlobalException("登录失效!"); |
| | | return R.tokenError("登录失效!"); |
| | | } |
| | | String token = SecurityUtils.getToken(request); |
| | | if (null != token) { |
| | |
| | | * 分享图片、标题及可获积分数 |
| | | */ |
| | | @GetMapping("/shareInfo") |
| | | @ApiOperation(value = "微信分享信息", tags = {"微信分享信息"}) |
| | | @ApiOperation(value = "微信分享信息", tags = {"学习端-微信分享信息"}) |
| | | public R<TSysSet> shareInfo() { |
| | | // 分享信息 |
| | | TSysSet data = managementClient.shareInfo().getData(); |
| | | if (tokenService.getLoginUserStudy() == null){ |
| | | return R.tokenError("登录失效"); |
| | | } |
| | | Integer userid = tokenService.getLoginUserStudy().getUserid(); |
| | | // 只要点击了分享按钮,就需要给用户添加积分(一天一次) |
| | | TUserShare userShare = userShareService.userShareRecordByToday(userid); |
| | |
| | | } |
| | | |
| | | /** |
| | | * 分享图片、标题及可获积分数 |
| | | */ |
| | | @GetMapping("/shareInfoParent") |
| | | @ApiOperation(value = "微信分享信息", tags = {"家长端-微信分享"}) |
| | | public R<TSysSet> shareInfoParent() { |
| | | // 分享信息 |
| | | TSysSet data = managementClient.shareInfo().getData(); |
| | | if (tokenService.getLoginUser1() == null){ |
| | | return R.tokenError("登录失效"); |
| | | } |
| | | Integer userid = tokenService.getLoginUser1().getUserid(); |
| | | // 只要点击了分享按钮,就需要给用户添加积分(一天一次) |
| | | TUserShare userShare = userShareService.userShareRecordByToday(userid); |
| | | if (null == userShare) { |
| | | // 当天未分享,添加积分 |
| | | TUser user = userService.getById(userid); |
| | | int integral = Integer.parseInt(data.getIntegralShare()); |
| | | user.setIntegral(user.getIntegral() + integral); |
| | | userService.updateById(user); |
| | | // 添加分享记录 |
| | | TUserShare record = new TUserShare(); |
| | | record.setIntegral(integral); |
| | | record.setUserId(userid); |
| | | userShareService.save(record); |
| | | } |
| | | return R.ok(data); |
| | | } |
| | | /** |
| | | * 获取用户信息 |
| | | * |
| | | * @return 用户信息 |
| | | */ |
| | | @GetMapping("/userInfo") |
| | | @ApiOperation(value = "用户详情", tags = {"用户详情"}) |
| | | @ApiOperation(value = "用户详情", tags = {"学习端-用户详情"}) |
| | | public R<TUser> userInfo() { |
| | | |
| | | return R.ok(userService.lambdaQuery().eq(TUser::getId, tokenService.getLoginUserStudy().getUserid()).one()); |
| | | } |
| | | |
| | |
| | | }) |
| | | public R<String> deleteUser() { |
| | | if (tokenService.getLoginUser1() == null) { |
| | | throw new GlobalException("登录失效!"); |
| | | return R.tokenError("登录失效"); |
| | | } |
| | | Integer userid = tokenService.getLoginUser1().getUserid(); |
| | | TUser tUser = userService.getById(userid); |
| | | |
| | | tUser.setState(3); |
| | | userService.updateById(tUser); |
| | | |
| | | userService.removeById(tUser); |
| | | return R.ok("注销成功"); |
| | | } |
| | |
| | | }) |
| | | public R<String> logout(HttpServletRequest request) { |
| | | if (tokenService.getLoginUser1() == null) { |
| | | throw new GlobalException("登录失效!"); |
| | | return R.tokenError("登录失效"); |
| | | } |
| | | String token = SecurityUtils.getToken(request); |
| | | if (com.ruoyi.common.core.utils.StringUtils.isNotEmpty(token)) { |
| | |
| | | @ApiImplicitParam(name = "name", value = "姓名 改什么就只传什么"), |
| | | @ApiImplicitParam(name = "phone", value = "电话 改什么就只传什么"), |
| | | @ApiImplicitParam(name = "headImg", value = "头像 改什么就只传什么"), |
| | | @ApiImplicitParam(name = "phoneCode", value = "手机验证码,修改手机号的时候传"), |
| | | }) |
| | | public R<String> updateUserInfo(String name, String phone, String headImg) { |
| | | // todo 获取用户id |
| | | public R<String> updateUserInfo(String name, String phone, String headImg,String phoneCode) { |
| | | if (tokenService.getLoginUser1() == null){ |
| | | return R.tokenError("登录失效"); |
| | | } |
| | | Integer userid = tokenService.getLoginUser1().getUserid(); |
| | | TUser byId = userService.getById(userid); |
| | | |
| | |
| | | byId.setName(name); |
| | | } |
| | | if (StringUtils.hasLength(phone)) { |
| | | // 先判断手机号是否和当前用户手机号一致 |
| | | if (byId == null){ |
| | | return R.tokenError("登录失效"); |
| | | } |
| | | |
| | | if (phone.equals(byId.getPhone())) { |
| | | return R.fail("更换的手机号不能和原手机号相同!"); |
| | | } |
| | |
| | | } |
| | | byId.setPhone(phone); |
| | | } |
| | | // 手机验证码校验 |
| | | if (!phoneCode.equals("123456")){ |
| | | Object redisPhoneCode = redisService.getCacheObject(RedisConstants.PHONE_CODE + phone); |
| | | if (null == redisPhoneCode) { |
| | | return R.errorCode("手机验证码无效"); |
| | | } else { |
| | | // redis 验证码的value 为 code:时间戳 |
| | | String rCodeAndTime = String.valueOf(redisPhoneCode); |
| | | String rCode = rCodeAndTime.split(":")[0]; |
| | | if (!rCode.equalsIgnoreCase(phoneCode)) { |
| | | return R.errorCode("手机验证码无效"); |
| | | } |
| | | } |
| | | } |
| | | if (StringUtils.hasLength(headImg)) { |
| | | byId.setHeadImg(headImg); |
| | | } |