|
|
@@ -25,9 +25,7 @@ import com.zd.system.api.model.SimpleUserVO;
|
|
|
import com.zd.system.domain.SysLogoConfig;
|
|
|
import com.zd.system.domain.SysPost;
|
|
|
import com.zd.system.service.*;
|
|
|
-import io.swagger.annotations.Api;
|
|
|
-import io.swagger.annotations.ApiOperation;
|
|
|
-import io.swagger.annotations.ApiParam;
|
|
|
+import io.swagger.annotations.*;
|
|
|
import org.apache.commons.lang3.ArrayUtils;
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
|
import org.springframework.data.redis.core.RedisTemplate;
|
|
|
@@ -717,13 +715,15 @@ public class SysUserController extends BaseController {
|
|
|
|
|
|
/**
|
|
|
* 发送验证码
|
|
|
+ * @param phone 手机号码
|
|
|
+ * @return 验证码
|
|
|
*/
|
|
|
+ @ApiOperation("发送验证码")
|
|
|
+ @ApiImplicitParams({
|
|
|
+ @ApiImplicitParam(name = "phone",required = true,value = "手机号")
|
|
|
+ })
|
|
|
@PostMapping("/send/code")
|
|
|
public R<?> send(@RequestParam String phone) {
|
|
|
- SysUser sysUser = userService.selectUserIdByPhone(phone);
|
|
|
- if (sysUser == null) {
|
|
|
- throw new ServiceException("手机号:" + phone + " 关联用户不存在", 530);
|
|
|
- }
|
|
|
String key = Constants.DEFAULT_CODE_KEY + Constants.UPDATE_TYPE_MOBILE + "@" + phone;
|
|
|
String code = RandomUtil.randomNumbers(6);
|
|
|
redisTemplate.opsForValue().set(key, code, CODE_EXPIRATION, TimeUnit.MINUTES);
|
|
|
@@ -733,19 +733,41 @@ public class SysUserController extends BaseController {
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
- * 发送验证码
|
|
|
+ * 验证码校验
|
|
|
+ * @param phone 手机号
|
|
|
+ * @param code 验证码
|
|
|
+ * @return 校对结果
|
|
|
*/
|
|
|
- @PostMapping("/check/code")
|
|
|
+ @ApiOperation("验证码校验")
|
|
|
+ @ApiImplicitParams({
|
|
|
+ @ApiImplicitParam(name = "phone",required = true,value = "手机号"),
|
|
|
+ @ApiImplicitParam(name = "code",required = true,value = "验证码")
|
|
|
+ })
|
|
|
+ @GetMapping("/check/code")
|
|
|
public R<?> checkCode(@RequestParam("phone") String phone, @RequestParam("code") String code) {
|
|
|
return R.ok(check(phone, code));
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
- * 用户自己修改手机号
|
|
|
+ * 用户修改手机号
|
|
|
+ * @param oldPhone 原手机号
|
|
|
+ * @param newPhone 新手机号
|
|
|
+ * @param code 验证码
|
|
|
+ * @return AjaxResult
|
|
|
*/
|
|
|
- @Log(title = "用户自己修改手机号", businessType = BusinessType.UPDATE)
|
|
|
+ @ApiOperation("修改手机号")
|
|
|
+ @ApiImplicitParams({
|
|
|
+ @ApiImplicitParam(name = "oldPhone",required = true,value = "原手机号"),
|
|
|
+ @ApiImplicitParam(name = "newPhone",required = true,value = "新手机号"),
|
|
|
+ @ApiImplicitParam(name = "code",required = true,value = "验证码")
|
|
|
+ })
|
|
|
+ @Log(title = "用户修改手机号", businessType = BusinessType.UPDATE)
|
|
|
@PutMapping("/update/phone")
|
|
|
public AjaxResult updatePhone(@RequestParam("oldPhone") String oldPhone,@RequestParam("newPhone") String newPhone,@RequestParam("code") String code) {
|
|
|
+ if (StringUtils.isEmpty(oldPhone) || StringUtils.isEmpty(newPhone)){
|
|
|
+ throw new ServiceException("原密码或新密码不能为空");
|
|
|
+ }
|
|
|
+
|
|
|
SysUser user = userService.selectUserIdByPhone(oldPhone);
|
|
|
if(user==null){
|
|
|
throw new ServiceException("用户查询失败");
|