|
|
@@ -118,10 +118,10 @@ public class WxUserGrantController extends BaseController { |
|
|
|
*/ |
|
|
|
@AuthIgnore |
|
|
|
@PostMapping("/login") |
|
|
|
@ApiOperation(value = "用户登录", notes = "{\"appId\":\"string\",\"code\":\"string\",\"scene\":\"string\",\"sceneAddress\":\"string\",\"latitude\":\"string\",\"longitude\":\"string\",\"systemInfo\":\"string\"}") |
|
|
|
public ResultData userLogin(@RequestBody Map<String, String> map) { |
|
|
|
@ApiOperation(value = "用户登录", notes = "{\"phone\":\"string\",\"password\":\"string\",\"code\":\"string\"}") |
|
|
|
public ResultData loginByPhone(@RequestBody Map<String, String> map) { |
|
|
|
String ipAddr = getIpAddr(); |
|
|
|
logger.debug("[" + ipAddr + "] WxUserGrantController::doLogin"); |
|
|
|
logger.debug("[" + ipAddr + "] WxUserGrantController::loginByPhone"); |
|
|
|
String code = map.get("code"); |
|
|
|
if(StringUtils.isBlank(code)){ |
|
|
|
return new ResultData(ErrorCode.SYS_PARAMETER_NOT_NULL.getCode(), "请输入验证码"); |
|
|
@@ -147,14 +147,60 @@ public class WxUserGrantController extends BaseController { |
|
|
|
return new ResultData(ErrorCode.USER_IS_EMPTY); |
|
|
|
} |
|
|
|
|
|
|
|
String encryptPassword = new PasswordHelper().encryptPassword(phone, password); |
|
|
|
String encryptPassword = new PasswordHelper().encryptPassword(password); |
|
|
|
|
|
|
|
if(!encryptPassword.equals(basicInfo.getPassword())){ |
|
|
|
return new ResultData(ErrorCode.SYS_PARAMETER_ERROR.getCode(), "手机号或密码错误"); |
|
|
|
} |
|
|
|
wxCUserBasicInfoService.handleLoginUser(basicInfo); |
|
|
|
Map resultMap = new HashMap(); |
|
|
|
resultMap.put("phone", basicInfo.getPhone()); |
|
|
|
// resultMap.put("phone", basicInfo.getPhone()); |
|
|
|
resultMap.put("token", basicInfo.getToken()); |
|
|
|
return new ResultData(resultMap); |
|
|
|
} |
|
|
|
|
|
|
|
@AuthIgnore |
|
|
|
@PostMapping("/loginByEmail") |
|
|
|
@ApiOperation(value = "用户登录", notes = "{\"email\":\"string\",\"password\":\"string\",\"code\":\"string\"}") |
|
|
|
public ResultData loginByEmail(@RequestBody Map<String, String> map) { |
|
|
|
String ipAddr = getIpAddr(); |
|
|
|
logger.debug("[" + ipAddr + "] WxUserGrantController::loginByEmail"); |
|
|
|
String code = map.get("code"); |
|
|
|
if(StringUtils.isBlank(code)){ |
|
|
|
return new ResultData(ErrorCode.SYS_PARAMETER_NOT_NULL.getCode(), "请输入验证码"); |
|
|
|
} |
|
|
|
|
|
|
|
String key = Constant.captchaPrev + ":" + ipAddr; |
|
|
|
String code1 = RedisCacheUtils.getCacheString(redisTemplate, key); |
|
|
|
if(StringUtils.isBlank(code1)){ |
|
|
|
return new ResultData(ErrorCode.SYS_PARAMETER_ERROR.getCode(), "验证码已过期"); |
|
|
|
} |
|
|
|
if(!code1.equals(code)){ |
|
|
|
return new ResultData(ErrorCode.SYS_PARAMETER_ERROR.getCode(), "验证码不正确"); |
|
|
|
} |
|
|
|
|
|
|
|
String email = map.get("email"); |
|
|
|
String password = map.get("password"); |
|
|
|
if(StringUtils.isBlank(email) || StringUtils.isBlank(password)){ |
|
|
|
return new ResultData(ErrorCode.SYS_PARAMETER_ERROR.getCode(), "邮箱或密码为空"); |
|
|
|
} |
|
|
|
|
|
|
|
WxCUserBasicInfo basicInfo = wxCUserBasicInfoService.findInfoByEmail(getTenantInfo(), email); |
|
|
|
if(basicInfo == null){ |
|
|
|
return new ResultData(ErrorCode.USER_IS_EMPTY); |
|
|
|
} |
|
|
|
if(EnumCUserBasicInfoStatus.NOT_ACTIVE.getCode().equals(basicInfo.getStatus())){ |
|
|
|
return new ResultData(ErrorCode.MEMBER_IS_LOCKED.getCode(),"该用户未激活"); |
|
|
|
} |
|
|
|
|
|
|
|
String encryptPassword = new PasswordHelper().encryptPassword(password); |
|
|
|
|
|
|
|
if(!encryptPassword.equals(basicInfo.getPassword())){ |
|
|
|
return new ResultData(ErrorCode.SYS_PARAMETER_ERROR.getCode(), "邮箱或密码错误"); |
|
|
|
} |
|
|
|
wxCUserBasicInfoService.handleLoginUser(basicInfo); |
|
|
|
Map resultMap = new HashMap(); |
|
|
|
// resultMap.put("phone", basicInfo.getPhone()); |
|
|
|
resultMap.put("token", basicInfo.getToken()); |
|
|
|
return new ResultData(resultMap); |
|
|
|
} |
|
|
@@ -328,7 +374,7 @@ public class WxUserGrantController extends BaseController { |
|
|
|
return new ResultData(Result.ERROR, e.getMessage()); |
|
|
|
} |
|
|
|
if(isValidCode) { |
|
|
|
String encryptPassword = new PasswordHelper().encryptPassword(phone, pwd); |
|
|
|
String encryptPassword = new PasswordHelper().encryptPassword(pwd); |
|
|
|
WxCUserBasicInfo basicInfoUpd = new WxCUserBasicInfo(); |
|
|
|
basicInfoUpd.setId(basicInfo.getId()); |
|
|
|
basicInfoUpd.setPassword(encryptPassword); |
|
|
|