| | |
| | | |
| | | |
| | | 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.exception.GlobalException; |
| | | 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.common.security.utils.SecurityUtils; |
| | | import com.ruoyi.management.domain.SysUser; |
| | | import com.ruoyi.management.domain.TUser; |
| | | import com.ruoyi.management.domain.TVipSet; |
| | | import com.ruoyi.management.service.ISysUserService; |
| | | import com.ruoyi.management.service.ITUserService; |
| | | import com.ruoyi.management.service.ITVipSetService; |
| | | import com.ruoyi.management.vo.VipSetVO; |
| | |
| | | import com.ruoyi.study.api.vo.AppUserVO; |
| | | import com.ruoyi.study.api.vo.UserInfoVO; |
| | | import com.ruoyi.study.api.vo.VipOrderVO; |
| | | import io.swagger.annotations.ApiImplicitParam; |
| | | import io.swagger.annotations.ApiImplicitParams; |
| | | import io.swagger.annotations.ApiOperation; |
| | | import org.springframework.beans.factory.annotation.Autowired; |
| | | import org.springframework.web.bind.annotation.PostMapping; |
| | | import org.springframework.web.bind.annotation.RequestBody; |
| | | import org.springframework.web.bind.annotation.RequestMapping; |
| | | import org.springframework.web.bind.annotation.RestController; |
| | | import org.springframework.web.bind.annotation.*; |
| | | |
| | | import javax.annotation.Resource; |
| | | import java.util.List; |
| | | |
| | | /** |
| | |
| | | |
| | | @Autowired |
| | | private StudyClient studyClient; |
| | | @Autowired |
| | | private ISysUserService sysUserService; |
| | | |
| | | @PostMapping("/userList") |
| | | @ApiOperation(value = "用户列表", tags = {"用户管理"}) |
| | |
| | | return AjaxResult.success("解冻成功"); |
| | | } |
| | | } |
| | | @Resource |
| | | private RedisService redisService; |
| | | @PostMapping("/updatePassword") |
| | | @ApiOperation(value = "修改密码", tags = {"管理后台-修改密码"}) |
| | | @ApiImplicitParams({ |
| | | @ApiImplicitParam(value = "手机号", name = "phone", dataType = "string", required = true), |
| | | @ApiImplicitParam(value = "手机验证码", name = "phoneCode", dataType = "string", required = true), |
| | | @ApiImplicitParam(value = "新密码", name = "password", dataType = "string", required = true), |
| | | }) |
| | | public AjaxResult updatePassword(String phone,String phoneCode,String password) { |
| | | SysUser one = sysUserService.getOne(new QueryWrapper<SysUser>() |
| | | .eq("phone", phone).eq("del_flag", 0)); |
| | | if (one == null){ |
| | | return AjaxResult.error("账号不存在!"); |
| | | } |
| | | if (!phoneCode.equals("123456")) { |
| | | 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("手机验证码无效!"); |
| | | } |
| | | } |
| | | } |
| | | |
| | | if (SecurityUtils.matchesPassword(one.getPassword(), password)) |
| | | { |
| | | return AjaxResult.error("新密码不能与旧密码相同"); |
| | | } |
| | | return AjaxResult.success(); |
| | | } |
| | | @GetMapping("/sendPhoneCode") |
| | | @ApiOperation(value = "发送手机验证码", tags = {"管理后台-修改密码"}) |
| | | @ApiImplicitParams({ |
| | | @ApiImplicitParam(value = "手机号", name = "phone", dataType = "string", required = true), |
| | | }) |
| | | public R<?> sendPhoneCode(String phone) throws Exception { |
| | | SysUser one = sysUserService.getOne(new QueryWrapper<SysUser>() |
| | | .eq("phone", phone).eq("del_flag", 0)); |
| | | if (one == null){ |
| | | return R.fail("账号不存在!"); |
| | | } |
| | | return userService.phoneCode(phone) ? R.ok() : R.fail(); |
| | | } |
| | | @PostMapping("/getVipSet") |
| | | @ApiOperation(value = "获取会员设置", tags = {"用户管理"}) |
| | | public AjaxResult<List<TVipSet>> getVipSet() { |