|
@@ -31,6 +31,8 @@ import org.springframework.transaction.annotation.Transactional;
|
|
|
import org.springframework.web.bind.annotation.*;
|
|
|
import org.springframework.web.multipart.MultipartFile;
|
|
|
|
|
|
+import java.util.ArrayList;
|
|
|
+import java.util.List;
|
|
|
import java.util.Objects;
|
|
|
import java.util.concurrent.TimeUnit;
|
|
|
|
|
@@ -157,24 +159,92 @@ public class SysProfileController extends BaseController {
|
|
|
}
|
|
|
|
|
|
|
|
|
- @ApiOperation("获取用户信息")
|
|
|
+ @ApiOperation("手机号获取用户信息")
|
|
|
@GetMapping("/userPhoneNumber")
|
|
|
@Anonymous
|
|
|
- @Log(title = "登录", businessType = BusinessType.UPDATE)
|
|
|
public AjaxResult userPhoneNumber(Long userId,Long phoneNumber,Long smsCode) {
|
|
|
- SysUser sysUser = null;
|
|
|
+ if (phoneNumber == null || smsCode == null ){
|
|
|
+ return error("参数异常!");
|
|
|
+ }
|
|
|
+ smsVerifyCodeKey(phoneNumber.toString(), smsCode.toString());
|
|
|
+ System.out.println("打印成功");
|
|
|
+ List<SysUser> sysUsers = userMapper.selectUserByphoneNumber(userId, phoneNumber);
|
|
|
+ return AjaxResult.success(sysUsers);
|
|
|
+ }
|
|
|
|
|
|
- try {
|
|
|
- validateSmsCaptcha(phoneNumber.toString(), smsCode.toString());
|
|
|
- sysUser = userMapper.selectUserByphoneNumber(userId,phoneNumber);
|
|
|
- } catch (Exception e) {
|
|
|
- e.printStackTrace();
|
|
|
+ @ApiOperation("换绑VX/apple账户手机号")
|
|
|
+ @GetMapping("/updateToolId")
|
|
|
+ @Anonymous
|
|
|
+ @Transactional
|
|
|
+ public AjaxResult updateChangeVxAplle(String type,Long phoneNumber,Long oldUserId,Long newUserId) {
|
|
|
+ if (type == null){
|
|
|
+ return error("参数异常!");
|
|
|
+ }
|
|
|
|
|
|
- throw new ProjectException();
|
|
|
+ //如果当前oldUserId没有传值
|
|
|
+ if (oldUserId == null) {
|
|
|
+ oldUserId = SecurityUtils.getUserId();
|
|
|
}
|
|
|
- return AjaxResult.success(sysUser);
|
|
|
+
|
|
|
+ SysUser user = userMapper.selectUserById(oldUserId);
|
|
|
+ SysUser oldUser = new SysUser();
|
|
|
+ SysUser newUser = new SysUser();
|
|
|
+ System.out.println(user);
|
|
|
+ String openId = user.getOpenId();
|
|
|
+ String appId = user.getAppId();
|
|
|
+
|
|
|
+ switch (type) {
|
|
|
+ case "1":
|
|
|
+ //换绑微信登录
|
|
|
+ if (openId == null){
|
|
|
+ return AjaxResult.error("微信账户异常");
|
|
|
+ }
|
|
|
+ //更新老用户
|
|
|
+ oldUser = user;
|
|
|
+ oldUser.setOpenId("");
|
|
|
+ oldUser.setPhonenumber("");
|
|
|
+ userMapper.updateUser(oldUser);
|
|
|
+
|
|
|
+ //更新要绑定的新用户
|
|
|
+ newUser = userMapper.selectUserById(newUserId);
|
|
|
+ newUser.setOpenId(openId);
|
|
|
+ newUser.setPhonenumber(String.valueOf(phoneNumber));
|
|
|
+ userMapper.updateUser(newUser);
|
|
|
+ break;
|
|
|
+ case "2":
|
|
|
+ //换绑苹果登录
|
|
|
+ if (appId == null){
|
|
|
+ return AjaxResult.error("苹果账户异常");
|
|
|
+ }
|
|
|
+ //更新老用户
|
|
|
+ oldUser = user;
|
|
|
+ oldUser.setAppId("");
|
|
|
+ oldUser.setPhonenumber("");
|
|
|
+ userMapper.updateUser(oldUser);
|
|
|
+
|
|
|
+ //更新要绑定的新用户
|
|
|
+ newUser = userMapper.selectUserById(newUserId);
|
|
|
+ newUser.setAppId(openId);
|
|
|
+ newUser.setPhonenumber(String.valueOf(phoneNumber));
|
|
|
+ userMapper.updateUser(newUser);
|
|
|
+ break;
|
|
|
+ case "3":
|
|
|
+ //当前手机号绑定
|
|
|
+ oldUser = user;
|
|
|
+ oldUser.setPhonenumber(String.valueOf(phoneNumber));
|
|
|
+ userMapper.updateUser(oldUser);
|
|
|
+ break;
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+ return AjaxResult.success("更新成功");
|
|
|
}
|
|
|
|
|
|
+
|
|
|
+
|
|
|
/**
|
|
|
* 重置密码(验证码)
|
|
|
*/
|
|
@@ -243,6 +313,32 @@ public class SysProfileController extends BaseController {
|
|
|
}
|
|
|
}
|
|
|
|
|
|
+ /**
|
|
|
+ * 校验短信验证码
|
|
|
+ * 校验操作不更新不登录 单纯校验手机号
|
|
|
+ * @param username 用户名
|
|
|
+ * @param code 验证码
|
|
|
+ * @return 结果
|
|
|
+ */
|
|
|
+ public void smsVerifyCodeKey(String username, String code) {
|
|
|
+ if (StringUtils.isEmpty(code)) {
|
|
|
+ throw new CaptchaNullException();
|
|
|
+ }
|
|
|
+ String verifyKey = CacheConstants.SMS_VERIFY_CODE_KEY + StringUtils.nvl(username, "");
|
|
|
+ try {
|
|
|
+ String captcha = redisCache.getCacheObject(verifyKey).toString();
|
|
|
+ if (captcha == null) {
|
|
|
+ throw new CaptchaExpireException();
|
|
|
+ }
|
|
|
+ if (!code.equalsIgnoreCase(captcha)) {
|
|
|
+ throw new CaptchaException();
|
|
|
+ }
|
|
|
+ redisCache.deleteObject(verifyKey);
|
|
|
+ } catch (NullPointerException e) {
|
|
|
+ throw new CaptchaExpireException();
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
|
|
|
/**
|
|
|
* 拉黑用户
|