| | |
| | | |
| | | import com.alipay.api.AlipayApiException; |
| | | import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; |
| | | import com.ruoyi.common.core.constant.RedisConstants; |
| | | import com.ruoyi.common.core.domain.R; |
| | | import com.ruoyi.common.core.utils.JwtUtils; |
| | | import com.ruoyi.common.core.web.domain.AjaxResult; |
| | | import com.ruoyi.common.core.web.page.PageInfo; |
| | | import com.ruoyi.common.redis.service.RedisService; |
| | |
| | | import com.ruoyi.study.domain.TVipOrder; |
| | | import com.ruoyi.study.dto.AppUserQuery; |
| | | import com.ruoyi.study.dto.UserInfoQuery; |
| | | import com.ruoyi.study.request.RegisterPhoneRequest; |
| | | import com.ruoyi.study.service.ITUserService; |
| | | import com.ruoyi.study.service.IVipOrderService; |
| | | import com.ruoyi.study.utils.PayMoneyUtil; |
| | | import com.ruoyi.study.utils.UUIDUtil; |
| | | import com.ruoyi.study.vo.*; |
| | | import com.ruoyi.system.api.domain.SysRole; |
| | | import com.ruoyi.system.api.domain.SysUser; |
| | | import com.ruoyi.system.api.model.LoginUser; |
| | | import com.ruoyi.system.api.model.LoginUserParent; |
| | | import io.jsonwebtoken.Claims; |
| | | import io.swagger.annotations.ApiImplicitParam; |
| | | import io.swagger.annotations.ApiImplicitParams; |
| | | import io.swagger.annotations.ApiOperation; |
| | | import org.apache.poi.ss.formula.functions.T; |
| | | import org.springframework.beans.factory.annotation.Autowired; |
| | | import org.springframework.util.CollectionUtils; |
| | | import org.springframework.util.StringUtils; |
| | | import org.springframework.validation.annotation.Validated; |
| | | import org.springframework.web.bind.annotation.*; |
| | | |
| | | import javax.annotation.Resource; |
| | | import javax.servlet.http.HttpServletRequest; |
| | | import javax.servlet.http.HttpServletResponse; |
| | | import java.io.PrintWriter; |
| | |
| | | private ManagementClient managementClient; |
| | | @Autowired |
| | | private TokenService tokenService; |
| | | @Resource |
| | | private RedisService redisService; |
| | | |
| | | @PostMapping("/vipInfo") |
| | | @ApiOperation(value = "会员中心-获取会员说明、当前登录用户是否为会员、会员购买规格", tags = {"家长端-个人中心"}) |
| | |
| | | } |
| | | return AjaxResult.ok(vipInfoVOS); |
| | | } |
| | | |
| | | @Autowired |
| | | private PayMoneyUtil payMoneyUtil; |
| | | |
| | |
| | | } |
| | | return AjaxResult.success(); |
| | | } |
| | | |
| | | @ResponseBody |
| | | @PostMapping("/base/aliPayBuyVip") |
| | | public void addVipPaymentAliCallback(HttpServletRequest request, HttpServletResponse response) { |
| | |
| | | e.printStackTrace(); |
| | | } |
| | | } |
| | | |
| | | @ResponseBody |
| | | @PostMapping("/base/wxPayBuyVip") |
| | | public void wxPayBuyPackage(HttpServletRequest request, HttpServletResponse response) { |
| | |
| | | e.printStackTrace(); |
| | | } |
| | | } |
| | | |
| | | @PostMapping("/getPage") |
| | | @ApiOperation(value = "获取注意事项", tags = {"家长端-注意事项"}) |
| | | public AjaxResult<String> getPage() { |
| | | List<TPage> data = managementClient.getPage1().getData(); |
| | | for (TPage datum : data) { |
| | | if (datum.getType() == 4){ |
| | | return AjaxResult.success(datum.getImg()); |
| | | return AjaxResult.success(datum); |
| | | } |
| | | } |
| | | return AjaxResult.success(); |
| | | } |
| | | |
| | | @PostMapping("/useGuide") |
| | | @ApiOperation(value = "使用指南", tags = {"家长端-使用指南"}) |
| | | public AjaxResult<PageInfo<TUseGuide>> useGuide(@RequestBody UseGuideQuery query) { |
| | | PageInfo<TUseGuide> data = managementClient.useGuide1(query).getData(); |
| | | return AjaxResult.success(data); |
| | | } |
| | | |
| | | @PostMapping("/feedBack") |
| | | @ApiOperation(value = "反馈", tags = {"家长端-意见反馈"}) |
| | | public AjaxResult feedBack(@RequestBody TFeedback dto) { |
| | |
| | | managementClient.addFeedBack(dto); |
| | | return AjaxResult.success("反馈成功"); |
| | | } |
| | | |
| | | @PostMapping("/parentLogin") |
| | | @ApiOperation(value = "登录", tags = {"家长端-登录"}) |
| | | @ApiImplicitParams({ |
| | | @ApiImplicitParam(value = "手机号", name = "phone", dataType = "string", required = true), |
| | | @ApiImplicitParam(value = "验证码", name = "phoneCode", dataType = "string", required = true) |
| | | }) |
| | | public AjaxResult login(String phone, String phoneCode) |
| | | { |
| | | public AjaxResult login(String phone, String phoneCode) { |
| | | TUser tUser1 = userService.getOne(new QueryWrapper<TUser>() |
| | | .ne("state", 3) |
| | | .eq("phone",phone)); |
| | |
| | | } |
| | | }else{ |
| | | // todo 验证码校验 |
| | | tUser1 = new TUser(); |
| | | // 注册 |
| | | tUser1.setName(phone); |
| | | tUser1.setAccount(phone); |
| | | tUser1.setState(1); |
| | | tUser1.setInsertTime(new Date()); |
| | | tUser1.setCreateTime(new Date()); |
| | | tUser1.setPhone(phone); |
| | | tUser1 = getUser(phone); |
| | | userService.save(tUser1); |
| | | } |
| | | LoginUserParent loginUserParent = new LoginUserParent(); |
| | |
| | | return AjaxResult.success(map); |
| | | } |
| | | |
| | | /** |
| | | * 学生端登录 |
| | | * |
| | | * @param phoneRequest 手机号及手机验证码 |
| | | */ |
| | | @PostMapping("/studyLogin") |
| | | @ApiOperation(value = "学习端-登录", tags = {"学习端-登录"}) |
| | | public AjaxResult studyLogin(@RequestBody @Validated RegisterPhoneRequest phoneRequest) { |
| | | String phone = phoneRequest.getPhone(); |
| | | String phoneCode = phoneRequest.getPhoneCode(); |
| | | TUser user = userService.getOne(new QueryWrapper<TUser>() |
| | | .ne("state", 3) |
| | | .eq("phone", phone)); |
| | | if (user != null) { |
| | | if (user.getState() == 2) { |
| | | return AjaxResult.error("登录失败,您的账号已被冻结!"); |
| | | } |
| | | } else { |
| | | // 手机验证码校验 |
| | | Object redisPhoneCode = redisService.getCacheObject(RedisConstants.PHONE_CODE + phone); |
| | | if (null == redisPhoneCode) { |
| | | return AjaxResult.error("登录失败,手机验证码已过期!"); |
| | | } else { |
| | | // redis 验证码的value 为 code:时间戳 |
| | | String rCodeAndTime = String.valueOf(redisPhoneCode); |
| | | String rCode = rCodeAndTime.split(":")[0]; |
| | | if (!rCode.equalsIgnoreCase(phoneCode)) { |
| | | return AjaxResult.error("登录失败,手机验证码输入有误!"); |
| | | } else { |
| | | user = getUser(phone); |
| | | userService.save(user); |
| | | } |
| | | } |
| | | } |
| | | // 生成登录用户信息 |
| | | LoginUserParent loginUserParent = new LoginUserParent(); |
| | | loginUserParent.setName(user.getName()); |
| | | loginUserParent.setUserid(user.getId()); |
| | | loginUserParent.setPhone(user.getPhone()); |
| | | loginUserParent.setLoginTime(System.currentTimeMillis()); |
| | | HashMap<String, Object> map = new HashMap<>(); |
| | | map.put("token", tokenService.createTokenStudy(loginUserParent)); |
| | | // 获取登录token |
| | | return AjaxResult.success(map); |
| | | } |
| | | |
| | | private TUser getUser(String phone) { |
| | | TUser user = new TUser(); |
| | | // 注册 |
| | | user.setName(phone); |
| | | user.setAccount(phone); |
| | | user.setState(1); |
| | | user.setInsertTime(new Date()); |
| | | user.setCreateTime(new Date()); |
| | | user.setPhone(phone); |
| | | return user; |
| | | } |
| | | |
| | | /** |
| | | * 家长端 学习端都可用 |
| | | * |
| | | * @param phone 手机号 |
| | | */ |
| | | @GetMapping("/sendPhoneCode") |
| | | @ApiOperation(value = "发送手机验证码", tags = {"家长端/学习端-发送手机验证码"}) |
| | | public AjaxResult sendPhoneCode(@RequestParam String phone) { |
| | | return userService.phoneCode(phone) ? AjaxResult.success() : AjaxResult.error(); |
| | | } |
| | | |
| | | @PostMapping("/deleteUser") |
| | | @ApiOperation(value = "注销当前帐号", tags = {"家长端-个人中心"}) |
| | |
| | | userService.removeById(tUser); |
| | | return AjaxResult.success("注销成功"); |
| | | } |
| | | |
| | | @PostMapping("/logout") |
| | | @ApiOperation(value = "退出登录", tags = {"家长端-个人中心"}) |
| | | @ApiImplicitParams({ |
| | |
| | | return AjaxResult.tokenError("登录失效"); |
| | | } |
| | | String token = SecurityUtils.getToken(request); |
| | | if (com.ruoyi.common.core.utils.StringUtils.isNotEmpty(token)) |
| | | { |
| | | if (com.ruoyi.common.core.utils.StringUtils.isNotEmpty(token)) { |
| | | // 删除用户缓存记录 |
| | | AuthUtil.logoutByToken1(token); |
| | | } |
| | | // todo 清除token |
| | | return AjaxResult.success("退出登录成功"); |
| | | } |
| | | |
| | | @PostMapping("/updateUserInfo") |
| | | @ApiOperation(value = "修改个人资料", tags = {"家长端-个人中心"}) |
| | | @ApiImplicitParams({ |
| | |
| | | @ApiImplicitParam(name = "headImg", value = "头像 改什么就只传什么"), |
| | | }) |
| | | public AjaxResult updateUserInfo(String name, String phone,String headImg) { |
| | | if (tokenService.getLoginUser1() == null){ |
| | | return AjaxResult.tokenError("登录失效",new Object()); |
| | | } |
| | | // todo 获取用户id |
| | | Integer userid = tokenService.getLoginUser1().getUserid(); |
| | | TUser byId = userService.getById(userid); |
| | |
| | | userService.updateById(byId); |
| | | return AjaxResult.success("修改成功"); |
| | | } |
| | | |
| | | @PostMapping("/vipBack/{id}") |
| | | @ApiOperation(value = "会员退款", tags = {"管理后台-会员退款"}) |
| | | public R vipBack(@PathVariable("id") Integer id) throws AlipayApiException { |
| | |
| | | } |
| | | return R.ok(); |
| | | } |
| | | |
| | | @PostMapping("/userList") |
| | | @ApiOperation(value = "用户列表", tags = {"管理后台-用户管理"}) |
| | | public R<PageInfo<AppUserVO>> couponReceive(@RequestBody AppUserQuery query) { |
| | |
| | | res.setGameRecords(list); |
| | | return R.ok(res); |
| | | } |
| | | |
| | | @PostMapping("/freeze/{id}") |
| | | @ApiOperation(value = "冻结/解冻", tags = {"管理后台-用户管理"}) |
| | | public R freeze(@PathVariable("id") Integer id) { |