| | |
| | | import io.swagger.annotations.ApiImplicitParam; |
| | | import io.swagger.annotations.ApiImplicitParams; |
| | | import io.swagger.annotations.ApiOperation; |
| | | import org.springframework.beans.factory.annotation.Value; |
| | | import org.springframework.validation.annotation.Validated; |
| | | import org.springframework.web.bind.annotation.*; |
| | | |
| | |
| | | private RecoveryClassifyService recoveryClassifyService; |
| | | @Resource |
| | | private RecoveryServeService recoveryServeService; |
| | | |
| | | /** |
| | | * 用户端默认头像 |
| | | */ |
| | | @Value("${default.profilePicture}") |
| | | private String profilePicture; |
| | | |
| | | /** |
| | | * 解密用户敏感数据 |
| | |
| | | // 手机验证码校验获取缓存验证码 |
| | | Object phoneCodeRedis = redisService.getCacheObject(RedisConstants.USER_LOGIN_PHONE_CODE + phone); |
| | | if (null == phoneCodeRedis) { |
| | | return R.errorCode("登录失败,验证码已过期!"); |
| | | return R.errorCode("验证码错误!"); |
| | | } else { |
| | | // redis 验证码的value 为 code:时间戳 |
| | | String rCodeAndTime = String.valueOf(phoneCodeRedis); |
| | | String rCode = rCodeAndTime.split(":")[0]; |
| | | if (!rCode.equalsIgnoreCase(phoneCode)) { |
| | | return R.errorCode("登录失败,验证码无效!"); |
| | | return R.errorCode("验证码错误!"); |
| | | } |
| | | } |
| | | } |
| | |
| | | // 随机编号 |
| | | user.setUserNo(String.format(Constants.USER_NO_PRE, RandomUtil.randomNumbers(Constants.EIGHT))); |
| | | user.setState(Constants.ONE); |
| | | user.setNickname(phone); |
| | | user.setProfilePicture(profilePicture); |
| | | user.setNickname(String.format(Constants.USER_NO_PRE, StringUtils.getCharAndNum(Constants.SIX))); |
| | | user.setPhone(phone); |
| | | user.setCity(loginPhoneRequest.getCity()); |
| | | user.setOpenId(loginPhoneRequest.getOpenId()); |
| | |
| | | @ApiImplicitParams({ |
| | | @ApiImplicitParam(value = "0:用户注册协议、1:用户隐私协议", name = "type", dataType = "Integer", required = true) |
| | | }) |
| | | public R<Agreement> recoverySearch(@RequestParam Integer type) { |
| | | public R<Agreement> registerOrAgreement(@RequestParam Integer type) { |
| | | if (!Constants.ZERO.equals(type) && !Constants.ONE.equals(type)) { |
| | | throw new GlobalException("获取类型异常!"); |
| | | } |
| | | return R.ok(adminClient.dataInfo(type).getData()); |
| | | R<Agreement> r = adminClient.agreementPolicy(type); |
| | | if (500 == r.getCode()) { |
| | | return R.fail(r.getMsg()); |
| | | } |
| | | return R.ok(r.getData()); |
| | | } |
| | | |
| | | /** |
| | |
| | | @ApiOperation(value = "轮播图列表", tags = {"用户端-首页"}) |
| | | @GetMapping(value = "/banner") |
| | | public R<List<Rotate>> banner() { |
| | | List<Rotate> data = adminClient.bannerList().getData(); |
| | | R<List<Rotate>> r = adminClient.bannerList(); |
| | | List<Rotate> data = r.getData(); |
| | | if (null == data) { |
| | | return R.fail(r.getMsg()); |
| | | } |
| | | for (Rotate datum : data) { |
| | | RecoveryServe recoveryServe = recoveryServeService.lambdaQuery() |
| | | .eq(RecoveryServe::getId, datum.getId()) |
| | | .eq(RecoveryServe::getIsDelete, 0).one(); |
| | | Integer classifyId = recoveryServe.getClassifyId(); |
| | | RecoveryClassify classify = recoveryClassifyService.lambdaQuery() |
| | | .eq(RecoveryClassify::getId, classifyId) |
| | | .eq(RecoveryClassify::getIsDelete, 0).one(); |
| | | if (null != classify) { |
| | | String supClassify = classify.getSupClassify(); |
| | | if (Constants.RECOVERY.equals(supClassify)) { |
| | | datum.setType(Constants.ONE); |
| | | } else { |
| | | datum.setType(Constants.ZERO); |
| | | .eq(RecoveryServe::getId, datum.getRotateServeId()).one(); |
| | | if (null != recoveryServe) { |
| | | Integer classifyId = recoveryServe.getClassifyId(); |
| | | RecoveryClassify classify = recoveryClassifyService.lambdaQuery() |
| | | .eq(RecoveryClassify::getId, classifyId).one(); |
| | | if (null != classify) { |
| | | String supClassify = classify.getSupClassify(); |
| | | if (Constants.RECOVERY.equals(supClassify)) { |
| | | datum.setType(Constants.ONE); |
| | | } else { |
| | | datum.setType(Constants.ZERO); |
| | | } |
| | | } |
| | | } |
| | | } |
| | |
| | | @ApiOperation(value = "首页回收分类推荐", tags = {"用户端-首页"}) |
| | | public R<List<RecoveryClassify>> recommend() { |
| | | return R.ok(recoveryClassifyService.lambdaQuery().eq(RecoveryClassify::getIsRecommend, Constants.ONE) |
| | | .eq(RecoveryClassify::getIsDelete, 0).orderByAsc(RecoveryClassify::getSort).list()); |
| | | .eq(RecoveryClassify::getIsDelete, 0).orderByDesc(RecoveryClassify::getSort) |
| | | .orderByDesc(RecoveryClassify::getCreateTime).list()); |
| | | } |
| | | |
| | | /** |
| | |
| | | public R<List<RecoveryServe>> recoverySearch(@RequestParam String keyword) { |
| | | LambdaQueryChainWrapper<RecoveryServe> wrapper = recoveryServeService.lambdaQuery() |
| | | .eq(RecoveryServe::getIsDelete, 0) |
| | | .orderByAsc(RecoveryServe::getSort); |
| | | wrapper = StringUtils.isNotBlank(keyword) ? wrapper.like(RecoveryServe::getServeName, keyword) : wrapper; |
| | | List<RecoveryServe> serveList = wrapper.list(); |
| | | .orderByDesc(RecoveryServe::getSort); |
| | | wrapper = null != keyword && !"".equals(keyword.trim()) ? |
| | | wrapper.like(RecoveryServe::getServeName, keyword) : wrapper; |
| | | List<RecoveryServe> serveList = wrapper.orderByDesc(RecoveryServe::getCreateTime).list(); |
| | | for (RecoveryServe recoveryServe : serveList) { |
| | | RecoveryClassify classify = recoveryClassifyService.lambdaQuery() |
| | | .eq(RecoveryClassify::getId, recoveryServe.getClassifyId()) |
| | | .eq(RecoveryClassify::getIsDelete, 0).one(); |
| | | if (Constants.RECOVERY.equals(classify.getSupClassify())) { |
| | | recoveryServe.setType(Constants.ONE); |
| | | } else { |
| | | recoveryServe.setType(Constants.ZERO); |
| | | .eq(RecoveryClassify::getId, recoveryServe.getClassifyId()).one(); |
| | | if (null != classify) { |
| | | if (Constants.RECOVERY.equals(classify.getSupClassify())) { |
| | | recoveryServe.setType(Constants.ONE); |
| | | } else { |
| | | recoveryServe.setType(Constants.ZERO); |
| | | } |
| | | } |
| | | } |
| | | return R.ok(wrapper.list()); |
| | | return R.ok(serveList); |
| | | } |
| | | |
| | | /** |
| | |
| | | .set(User::getNickname, nickname).update()); |
| | | } |
| | | |
| | | /** |
| | | * 用户端-修改用户定位城市 |
| | | */ |
| | | @ApiOperation(value = "修改用户定位城市", tags = {"用户端-个人中心"}) |
| | | @GetMapping(value = "/updateCity") |
| | | public R<Boolean> updateCity(@RequestParam String city, @RequestParam String cityCode) { |
| | | LoginUserInfo loginUser = tokenService.getLoginUserByUser(); |
| | | if (null == loginUser) { |
| | | return R.loginExpire("登录失效!"); |
| | | } |
| | | return R.ok(userService.lambdaUpdate().eq(User::getId, loginUser.getUserid()) |
| | | .set(User::getCity, city) |
| | | .set(User::getCityCode, cityCode).update()); |
| | | } |
| | | |
| | | } |