|
|
@@ -4,6 +4,9 @@ import cn.binarywang.wx.miniapp.api.WxMaService;
|
|
|
import cn.binarywang.wx.miniapp.bean.WxMaJscode2SessionResult;
|
|
|
import cn.binarywang.wx.miniapp.bean.WxMaUserInfo;
|
|
|
import cn.hutool.core.date.DateUtil;
|
|
|
+import cn.hutool.core.util.StrUtil;
|
|
|
+import cn.hutool.json.JSONUtil;
|
|
|
+import com.YuyeTech.HeartRate.VO.ClientStateVO;
|
|
|
import com.YuyeTech.HeartRate.dataobject.*;
|
|
|
import com.YuyeTech.HeartRate.enums.*;
|
|
|
import com.YuyeTech.HeartRate.exception.AuthorizeException;
|
|
|
@@ -101,8 +104,6 @@ public class LoginController {
|
|
|
private FreeMarkerConfigurer freeMarkerConfigurer;
|
|
|
|
|
|
|
|
|
-
|
|
|
-
|
|
|
// @GetMapping("/getSessionToken")
|
|
|
// public ResultVO getSessionToken(@RequestParam("code") String code) {
|
|
|
//
|
|
|
@@ -125,6 +126,7 @@ public class LoginController {
|
|
|
|
|
|
/**
|
|
|
* android 微信登录
|
|
|
+ *
|
|
|
* @param openid
|
|
|
* @param unionid
|
|
|
* @param response
|
|
|
@@ -140,7 +142,7 @@ public class LoginController {
|
|
|
String headToken = request.getHeader("token");
|
|
|
if (StringUtils.isNotBlank(headToken)) {
|
|
|
// Boolean bSuccess = redisTemplate.delete(String.format(RedisConstant.TOKEN_PREFIX, headToken));
|
|
|
- Boolean bSuccess = redisSettingMap.deleteValue(RedisType.TOKEN,headToken);
|
|
|
+ Boolean bSuccess = redisSettingMap.deleteValue(RedisType.TOKEN, headToken);
|
|
|
if (!bSuccess) {
|
|
|
//删除不成功,redis不存在,是非法token
|
|
|
log.info("redis 没有对应的token");
|
|
|
@@ -171,7 +173,7 @@ public class LoginController {
|
|
|
} else {
|
|
|
mainInfo = mainInfoService.findMainInfoById(wxInfo.getUserId());
|
|
|
//删除用户对应的token
|
|
|
- Boolean bSuccess = redisSettingMap.deleteValue(RedisType.TOKEN,mainInfo.getToken());
|
|
|
+ Boolean bSuccess = redisSettingMap.deleteValue(RedisType.TOKEN, mainInfo.getToken());
|
|
|
if (!bSuccess) {
|
|
|
//不存在的话不用处理
|
|
|
log.info("client_wx_login,redis 不存在此用户 token。");
|
|
|
@@ -189,7 +191,7 @@ public class LoginController {
|
|
|
//2.设置token 到redis
|
|
|
// redisTemplate.opsForHash().putAll(redisSettingMap.getTokenKey(token), tokenMap);
|
|
|
// redisTemplate.expire(redisSettingMap.getTokenKey(token), expire, TimeUnit.SECONDS);
|
|
|
- redisSettingMap.putToken(token,tokenMap);
|
|
|
+ redisSettingMap.putToken(token, tokenMap);
|
|
|
//3.设置token到cookie
|
|
|
CookieUtil.set(response, CookieConstant.TOKEN, token, expire);
|
|
|
//TODO 可以增加自己的逻辑,关联业务相关数据
|
|
|
@@ -207,6 +209,7 @@ public class LoginController {
|
|
|
|
|
|
/**
|
|
|
* 统一创建mainInfo
|
|
|
+ *
|
|
|
* @return
|
|
|
*/
|
|
|
//调用创建一个mainInfo
|
|
|
@@ -224,6 +227,7 @@ public class LoginController {
|
|
|
|
|
|
/**
|
|
|
* 查询是否存在userInfo对应用户数据,如果存在。则判断为新用户
|
|
|
+ *
|
|
|
* @param userId
|
|
|
* @return
|
|
|
*/
|
|
|
@@ -395,7 +399,7 @@ public class LoginController {
|
|
|
* 在手机号或者邮件中获取验证码。通用
|
|
|
*
|
|
|
* @param account
|
|
|
- * @param type 0 默认手机,1默认邮件
|
|
|
+ * @param type 0 默认手机,1默认邮件
|
|
|
* @return
|
|
|
*/
|
|
|
@GetMapping("/getCodeAccordingType")
|
|
|
@@ -405,10 +409,10 @@ public class LoginController {
|
|
|
String code = String.valueOf((int) ((Math.random() * 9 + 1) * 1000));
|
|
|
if (account != null) {
|
|
|
|
|
|
- if(type.equals(0)){
|
|
|
+ if (type.equals(0)) {
|
|
|
//发送验证码给 手机
|
|
|
aliyunSMSUtil.sendSms(account, code);
|
|
|
- }else if(type.equals(1)){
|
|
|
+ } else if (type.equals(1)) {
|
|
|
//发送验证码给 邮件
|
|
|
//创建简单邮件消息
|
|
|
// SimpleMailMessage message = new SimpleMailMessage();
|
|
|
@@ -428,14 +432,14 @@ public class LoginController {
|
|
|
//freemarker
|
|
|
Template template = freeMarkerConfigurer.getConfiguration().getTemplate("/mail/sendSMS.ftl");
|
|
|
Map<String, String> emailMap = new HashMap<>();
|
|
|
- emailMap.put("emailCode",code);
|
|
|
+ emailMap.put("emailCode", code);
|
|
|
String s = FreeMarkerTemplateUtils.processTemplateIntoString(template, emailMap);
|
|
|
- helper.setText(s,true);
|
|
|
+ helper.setText(s, true);
|
|
|
mailSender.send(message);
|
|
|
|
|
|
} catch (MailException e) {
|
|
|
return ResultVOUtil.error(200, "发送普通邮件方失败!");
|
|
|
- }catch (MessagingException e) {
|
|
|
+ } catch (MessagingException e) {
|
|
|
return ResultVOUtil.error(200, "发送普通邮件方失败!");
|
|
|
} catch (IOException e) {
|
|
|
return ResultVOUtil.error(200, "发送普通邮件方失败!");
|
|
|
@@ -446,12 +450,12 @@ public class LoginController {
|
|
|
|
|
|
}
|
|
|
//成功后保存code到redis
|
|
|
- redisSettingMap.setSMS(account,code);
|
|
|
+ redisSettingMap.setSMS(account, code);
|
|
|
log.info("getCode:" + code);
|
|
|
Map map = new HashMap();
|
|
|
- map.put("receiver",account);
|
|
|
- map.put("tip","发送验证码成功");
|
|
|
- map.put("type",type);
|
|
|
+ map.put("receiver", account);
|
|
|
+ map.put("tip", "发送验证码成功");
|
|
|
+ map.put("type", type);
|
|
|
return ResultVOUtil.success(map);
|
|
|
} else {
|
|
|
return ResultVOUtil.error(200, "获取code失败");
|
|
|
@@ -509,17 +513,18 @@ public class LoginController {
|
|
|
|
|
|
/**
|
|
|
* 通过验证码,绑定用户手机号码或者邮箱。
|
|
|
+ *
|
|
|
* @param account
|
|
|
* @param code
|
|
|
* @return
|
|
|
*/
|
|
|
@GetMapping("/SMS_bind_account")
|
|
|
public ResultVO userBindAccount(@RequestParam("account") String account,
|
|
|
- @RequestParam("code") String code,
|
|
|
- @RequestParam("type") Integer type,
|
|
|
- @RequestParam("userId") String userId) {
|
|
|
+ @RequestParam("code") String code,
|
|
|
+ @RequestParam("type") Integer type,
|
|
|
+ @RequestParam("userId") String userId) {
|
|
|
|
|
|
- String codeValue = redisSettingMap.getValue(RedisType.SMS,account);
|
|
|
+ String codeValue = redisSettingMap.getValue(RedisType.SMS, account);
|
|
|
if (!StringUtils.equals(codeValue, code)) {
|
|
|
return ResultVOUtil.error(UserEnum.USER_CODE_ERROR.getCode(), UserEnum.USER_CODE_ERROR.getMessage());
|
|
|
}
|
|
|
@@ -527,13 +532,13 @@ public class LoginController {
|
|
|
|
|
|
try {
|
|
|
MainInfo mainInfo = null;
|
|
|
- if(type.equals(0)){
|
|
|
+ if (type.equals(0)) {
|
|
|
mainInfo = mainInfoService.findMainInfoByPhoneNumber(account);
|
|
|
if (mainInfo != null) {
|
|
|
//如果存在,此手机号提示已注册
|
|
|
return ResultVOUtil.error(UserEnum.USER_HAS_REGISTER_PHONE.getCode(), UserEnum.USER_HAS_REGISTER_PHONE.getMessage());
|
|
|
}
|
|
|
- }else if(type.equals(1)){
|
|
|
+ } else if (type.equals(1)) {
|
|
|
mainInfo = mainInfoService.findMainInfoByEmail(account);
|
|
|
if (mainInfo != null) {
|
|
|
//如果存在,此手机号提示已注册
|
|
|
@@ -547,14 +552,14 @@ public class LoginController {
|
|
|
if (mainInfo == null) {
|
|
|
return ResultVOUtil.error(UserEnum.USER_REGISTER_ERROR.getCode(), UserEnum.USER_REGISTER_ERROR.getMessage());
|
|
|
}
|
|
|
- if(type.equals(0)){
|
|
|
+ if (type.equals(0)) {
|
|
|
mainInfo.setTelephoneNumber(account);
|
|
|
- }else if(type.equals(1)){
|
|
|
+ } else if (type.equals(1)) {
|
|
|
mainInfo.setEmail(account);
|
|
|
}
|
|
|
mainInfoService.addMainInfo(mainInfo);
|
|
|
//TODO 写入成功后,删除redis里面保存的code
|
|
|
- Boolean bSuccess = redisSettingMap.deleteValue(RedisType.SMS,account);
|
|
|
+ Boolean bSuccess = redisSettingMap.deleteValue(RedisType.SMS, account);
|
|
|
if (!bSuccess) {
|
|
|
//删除不成功,redis不存在
|
|
|
log.info("redis 没有对应的token");
|
|
|
@@ -569,6 +574,7 @@ public class LoginController {
|
|
|
|
|
|
/**
|
|
|
* 解绑用户手机号
|
|
|
+ *
|
|
|
* @param userId
|
|
|
* @return
|
|
|
*/
|
|
|
@@ -592,6 +598,7 @@ public class LoginController {
|
|
|
|
|
|
/**
|
|
|
* 绑定微信信息
|
|
|
+ *
|
|
|
* @param openid
|
|
|
* @param unionid
|
|
|
* @param userId
|
|
|
@@ -691,6 +698,7 @@ public class LoginController {
|
|
|
/**
|
|
|
* 根据不同类型账号注册(ps:未注册的进行注册)->登录
|
|
|
* 手机或者邮箱 code登录
|
|
|
+ *
|
|
|
* @param account
|
|
|
* @param code
|
|
|
* @param type
|
|
|
@@ -698,7 +706,7 @@ public class LoginController {
|
|
|
*/
|
|
|
@GetMapping("/SMS_login_from_type")
|
|
|
public ResultVO userRegistrationAndSMSLogin(String account, String code, Integer type) {
|
|
|
- String codeValue = redisSettingMap.getValue(RedisType.SMS,account);
|
|
|
+ String codeValue = redisSettingMap.getValue(RedisType.SMS, account);
|
|
|
if (!StringUtils.equals(codeValue, code)) {
|
|
|
log.warn("【code校验】Redis 中查找不到验证码 {},==,{}", codeValue, code);
|
|
|
return ResultVOUtil.error(UserEnum.USER_CODE_ERROR.getCode(), UserEnum.USER_CODE_ERROR.getMessage());
|
|
|
@@ -710,9 +718,9 @@ public class LoginController {
|
|
|
Map<String, String> tokenMap = new HashMap<>();
|
|
|
try {
|
|
|
MainInfo mainInfo = null;
|
|
|
- if(type.equals(0)){
|
|
|
+ if (type.equals(0)) {
|
|
|
mainInfo = mainInfoService.findMainInfoByPhoneNumber(account);
|
|
|
- }else if(type.equals(1)){
|
|
|
+ } else if (type.equals(1)) {
|
|
|
mainInfo = mainInfoService.findMainInfoByEmail(account);
|
|
|
}
|
|
|
//验证码登录流程
|
|
|
@@ -720,16 +728,16 @@ public class LoginController {
|
|
|
if (mainInfo == null) {
|
|
|
//先main_info主表添加信息
|
|
|
mainInfo = createMainInfo();
|
|
|
- if(type.equals(0)){
|
|
|
+ if (type.equals(0)) {
|
|
|
mainInfo.setTelephoneNumber(account);
|
|
|
- }else if(type.equals(1)){
|
|
|
+ } else if (type.equals(1)) {
|
|
|
mainInfo.setEmail(account);
|
|
|
}
|
|
|
mainInfo.setToken(token);
|
|
|
mainInfoService.addMainInfo(mainInfo);
|
|
|
} else {
|
|
|
//删除用户对应的token
|
|
|
- Boolean bSuccess = redisSettingMap.deleteValue(RedisType.TOKEN,mainInfo.getToken());
|
|
|
+ Boolean bSuccess = redisSettingMap.deleteValue(RedisType.TOKEN, mainInfo.getToken());
|
|
|
if (!bSuccess) {
|
|
|
//不存在的话不用处理
|
|
|
log.info("SMS_login_from_type,redis 不存在此用户 token。");
|
|
|
@@ -739,7 +747,7 @@ public class LoginController {
|
|
|
mainInfoService.addMainInfo(mainInfo);
|
|
|
}
|
|
|
//写入成功后,删除redis里面保存的code
|
|
|
- Boolean bSuccess =redisSettingMap.deleteValue(RedisType.SMS, account);
|
|
|
+ Boolean bSuccess = redisSettingMap.deleteValue(RedisType.SMS, account);
|
|
|
if (!bSuccess) {
|
|
|
//删除不成功,redis不存在
|
|
|
log.info("code删除不成功!");
|
|
|
@@ -749,7 +757,7 @@ public class LoginController {
|
|
|
|
|
|
// redisTemplate.opsForHash().putAll(redisSettingMap.getTokenKey(token), tokenMap);
|
|
|
// redisTemplate.expire(redisSettingMap.getTokenKey(token), expire, TimeUnit.SECONDS);
|
|
|
- redisSettingMap.putToken(token,tokenMap);
|
|
|
+ redisSettingMap.putToken(token, tokenMap);
|
|
|
//返回一个token
|
|
|
LoginVO loginVO = new LoginVO();
|
|
|
loginVO.setToken(token);
|
|
|
@@ -819,12 +827,12 @@ public class LoginController {
|
|
|
* @return
|
|
|
*/
|
|
|
@GetMapping("/password_login_type")
|
|
|
- public ResultVO userPasswordLoginOnTheType(String account, String password,Integer type) {
|
|
|
+ public ResultVO userPasswordLoginOnTheType(String account, String password, Integer type) {
|
|
|
try {
|
|
|
MainInfo mainInfo = null;
|
|
|
- if(type.equals(0)){
|
|
|
+ if (type.equals(0)) {
|
|
|
mainInfo = mainInfoService.findMainInfoByPhoneNumberAndPassword(account, password);
|
|
|
- }else if(type.equals(1)){
|
|
|
+ } else if (type.equals(1)) {
|
|
|
mainInfo = mainInfoService.findMainInfoByEmailAndPassword(account, password);
|
|
|
}
|
|
|
|
|
|
@@ -832,7 +840,7 @@ public class LoginController {
|
|
|
return ResultVOUtil.error(UserEnum.USER_PASSWORD_ERROR.getCode(), UserEnum.USER_PASSWORD_ERROR.getMessage());
|
|
|
}
|
|
|
//刪除舊的token
|
|
|
- Boolean bSuccess = redisSettingMap.deleteValue(RedisType.TOKEN,mainInfo.getToken());
|
|
|
+ Boolean bSuccess = redisSettingMap.deleteValue(RedisType.TOKEN, mainInfo.getToken());
|
|
|
if (!bSuccess) {
|
|
|
//不存在的话不用处理
|
|
|
log.info("password_login_type,redis 不存在此用户 token。");
|
|
|
@@ -846,7 +854,7 @@ public class LoginController {
|
|
|
tokenMap.put("userId", mainInfo.getUserId());
|
|
|
// redisTemplate.opsForHash().putAll(redisSettingMap.getTokenKey(token), tokenMap);
|
|
|
// redisTemplate.expire(redisSettingMap.getTokenKey(token), expire, TimeUnit.SECONDS);
|
|
|
- redisSettingMap.putToken(token,tokenMap);
|
|
|
+ redisSettingMap.putToken(token, tokenMap);
|
|
|
|
|
|
//更新token
|
|
|
mainInfo.setToken(token);
|
|
|
@@ -868,6 +876,7 @@ public class LoginController {
|
|
|
|
|
|
/**
|
|
|
* 登录时候,用来验证一下信息。
|
|
|
+ *
|
|
|
* @return 返回一个bool判断是否是新用户
|
|
|
*/
|
|
|
@GetMapping("/Verification_Info")
|
|
|
@@ -887,6 +896,7 @@ public class LoginController {
|
|
|
|
|
|
/**
|
|
|
* Client 退出操作时候,删除token
|
|
|
+ *
|
|
|
* @param request
|
|
|
* @return
|
|
|
*/
|
|
|
@@ -896,7 +906,7 @@ public class LoginController {
|
|
|
String headToken = request.getHeader("token");
|
|
|
if (StringUtils.isNotBlank(headToken)) {
|
|
|
// Boolean bSuccess = redisTemplate.delete(String.format(RedisConstant.TOKEN_PREFIX, headToken));
|
|
|
- Boolean bSuccess = redisSettingMap.deleteValue(RedisType.TOKEN,headToken);
|
|
|
+ Boolean bSuccess = redisSettingMap.deleteValue(RedisType.TOKEN, headToken);
|
|
|
if (!bSuccess) {
|
|
|
//删除不成功,redis不存在,是非法token
|
|
|
log.info("redis 没有对应的token");
|
|
|
@@ -909,6 +919,7 @@ public class LoginController {
|
|
|
|
|
|
/**
|
|
|
* 苹果登录
|
|
|
+ *
|
|
|
* @param identityToken
|
|
|
* @param response
|
|
|
* @param request
|
|
|
@@ -916,13 +927,13 @@ public class LoginController {
|
|
|
*/
|
|
|
@GetMapping("/client_apple_login")
|
|
|
public ResultVO appleLogin(@RequestParam("identityToken") String identityToken,
|
|
|
- HttpServletResponse response,
|
|
|
- HttpServletRequest request) {
|
|
|
+ HttpServletResponse response,
|
|
|
+ HttpServletRequest request) {
|
|
|
//检查redis 的token 是否存在,存在则删除
|
|
|
String headToken = request.getHeader("token");
|
|
|
if (StringUtils.isNotBlank(headToken)) {
|
|
|
// Boolean bSuccess = redisTemplate.delete(String.format(RedisConstant.TOKEN_PREFIX, headToken));
|
|
|
- Boolean bSuccess = redisSettingMap.deleteValue(RedisType.TOKEN,headToken);
|
|
|
+ Boolean bSuccess = redisSettingMap.deleteValue(RedisType.TOKEN, headToken);
|
|
|
if (!bSuccess) {
|
|
|
//删除不成功,redis不存在,是非法token
|
|
|
log.info("redis 没有对应的token");
|
|
|
@@ -931,20 +942,20 @@ public class LoginController {
|
|
|
//todo 处理identityToken,判断是否是非法,暂时默认全部合法
|
|
|
try {
|
|
|
//验证identityToken
|
|
|
- if(!AppleUtil.verify(identityToken)){
|
|
|
- log.info("identityToken:{}",ResultEnum.APPLE_LOGIN_VALIDATION_FAIL.getMessage());
|
|
|
+ if (!AppleUtil.verify(identityToken)) {
|
|
|
+ log.info("identityToken:{}", ResultEnum.APPLE_LOGIN_VALIDATION_FAIL.getMessage());
|
|
|
return ResultVOUtil.error(ResultEnum.APPLE_LOGIN_VALIDATION_FAIL.getCode(),
|
|
|
- ResultEnum.APPLE_LOGIN_VALIDATION_FAIL.getMessage());
|
|
|
+ ResultEnum.APPLE_LOGIN_VALIDATION_FAIL.getMessage());
|
|
|
}
|
|
|
//对identityToken解码
|
|
|
JSONObject json = AppleUtil.parserIdentityToken(identityToken);
|
|
|
- if(json == null){
|
|
|
- log.info("identityToken:{}",ResultEnum.APPLE_LOGIN_TOKEN_FAIL.getMessage());
|
|
|
+ if (json == null) {
|
|
|
+ log.info("identityToken:{}", ResultEnum.APPLE_LOGIN_TOKEN_FAIL.getMessage());
|
|
|
return ResultVOUtil.error(ResultEnum.APPLE_LOGIN_TOKEN_FAIL.getCode(),
|
|
|
ResultEnum.APPLE_LOGIN_TOKEN_FAIL.getMessage());
|
|
|
}
|
|
|
|
|
|
- log.info("验证通过的json信息:{}",json);
|
|
|
+ log.info("验证通过的json信息:{}", json);
|
|
|
|
|
|
String token = UUID.randomUUID().toString();
|
|
|
Integer expire = RedisConstant.EXPIRE;//过期时间
|
|
|
@@ -969,7 +980,7 @@ public class LoginController {
|
|
|
} else {
|
|
|
mainInfo = mainInfoService.findMainInfoById(appleInfo.getUserId());
|
|
|
//刪除舊的token
|
|
|
- Boolean bSuccess = redisSettingMap.deleteValue(RedisType.TOKEN,mainInfo.getToken());
|
|
|
+ Boolean bSuccess = redisSettingMap.deleteValue(RedisType.TOKEN, mainInfo.getToken());
|
|
|
if (!bSuccess) {
|
|
|
//不存在的话不用处理
|
|
|
log.info("client_apple_login,redis 不存在此用户 token。");
|
|
|
@@ -987,7 +998,7 @@ public class LoginController {
|
|
|
//String.format(RedisConstant.TOKEN_PREFIX, token)
|
|
|
// redisTemplate.opsForHash().putAll(redisSettingMap.getTokenKey(token), tokenMap);
|
|
|
// redisTemplate.expire(redisSettingMap.getTokenKey(token), expire, TimeUnit.SECONDS);
|
|
|
- redisSettingMap.putToken(token,tokenMap);
|
|
|
+ redisSettingMap.putToken(token, tokenMap);
|
|
|
//3.设置token到cookie
|
|
|
CookieUtil.set(response, CookieConstant.TOKEN, token, expire);
|
|
|
//TODO 可以增加自己的逻辑,关联业务相关数据
|
|
|
@@ -999,8 +1010,8 @@ public class LoginController {
|
|
|
} catch (UserException e) {
|
|
|
log.error(e.getMessage(), e);
|
|
|
return ResultVOUtil.error(e.getCode(), e.toString());
|
|
|
- } catch (Exception e){
|
|
|
- log.error("app wxLogin error:" + e.getMessage(),e);
|
|
|
+ } catch (Exception e) {
|
|
|
+ log.error("app wxLogin error:" + e.getMessage(), e);
|
|
|
return ResultVOUtil.error(500, "apple login 系统错误");
|
|
|
}
|
|
|
|
|
|
@@ -1008,6 +1019,7 @@ public class LoginController {
|
|
|
|
|
|
/**
|
|
|
* 更新用户使用的客户端信息
|
|
|
+ *
|
|
|
* @param clientForm
|
|
|
* @return
|
|
|
*/
|
|
|
@@ -1017,7 +1029,7 @@ public class LoginController {
|
|
|
|
|
|
|
|
|
ClientInfo clientInfo = clientInfoService.findClientInfoByUserId(clientForm.getUserId());
|
|
|
- if(clientInfo == null){
|
|
|
+ if (clientInfo == null) {
|
|
|
clientInfo = new ClientInfo();
|
|
|
}
|
|
|
BeanUtils.copyProperties(clientForm, clientInfo, PropertyUtil.getNullPropertyNames(clientForm));
|
|
|
@@ -1027,14 +1039,20 @@ public class LoginController {
|
|
|
}
|
|
|
|
|
|
|
|
|
-
|
|
|
+ /**
|
|
|
+ * 根据versionCode 和 platform 获取渠道控制信息
|
|
|
+ *
|
|
|
+ * @param code
|
|
|
+ * @param platform
|
|
|
+ * @return
|
|
|
+ */
|
|
|
@GetMapping("/get_version_code_state")
|
|
|
public ResultVO getVersionCodeState(@RequestParam("code") String code,
|
|
|
- @RequestParam(value = "platform", required = false) Integer platform ) {
|
|
|
+ @RequestParam(value = "platform", required = false) Integer platform) {
|
|
|
try {
|
|
|
VersionCode versionCode = versionCodeService.findByCode(code);
|
|
|
|
|
|
- if(versionCode == null){
|
|
|
+ if (versionCode == null) {
|
|
|
return ResultVOUtil.error(ResultEnum.VERSION_CODE_NULL.getCode(), ResultEnum.VERSION_CODE_NULL.getMessage());
|
|
|
}
|
|
|
|
|
|
@@ -1042,20 +1060,78 @@ public class LoginController {
|
|
|
|
|
|
//platform 0:android 1:ios 2:all
|
|
|
//getLimitPlatform 0:全都限制,1:限制android,2:限制ios,3:都不限制
|
|
|
- if(versionCode.getLimitPlatform().equals(0)
|
|
|
- ||(platform.equals(0) && versionCode.getLimitPlatform().equals(1)) // android
|
|
|
- ||(platform.equals(1) && versionCode.getLimitPlatform().equals(2))) // ios
|
|
|
+ if (versionCode.getLimitPlatform().equals(0)
|
|
|
+ || (platform.equals(0) && versionCode.getLimitPlatform().equals(1)) // android
|
|
|
+ || (platform.equals(1) && versionCode.getLimitPlatform().equals(2))) // ios
|
|
|
{
|
|
|
- map.put("showGame",false);
|
|
|
- map.put("showVideo",false);
|
|
|
- map.put("showTool",false);
|
|
|
- }else{
|
|
|
- map.put("showGame",versionCode.getIsShowGame().equals(1));
|
|
|
- map.put("showVideo",versionCode.getIsShowVideo().equals(1));
|
|
|
- map.put("showTool",versionCode.getIsShowTool().equals(1));
|
|
|
+ map.put("showGame", false);
|
|
|
+ map.put("showVideo", false);
|
|
|
+ map.put("showTool", false);
|
|
|
+ } else {
|
|
|
+ map.put("showGame", versionCode.getIsShowGame().equals(1));
|
|
|
+ map.put("showVideo", versionCode.getIsShowVideo().equals(1));
|
|
|
+ map.put("showTool", versionCode.getIsShowTool().equals(1));
|
|
|
}
|
|
|
- map.put("versionCode",versionCode.getCode());
|
|
|
- map.put("title",versionCode.getTitle());
|
|
|
+ map.put("versionCode", versionCode.getCode());
|
|
|
+ map.put("title", versionCode.getTitle());
|
|
|
+
|
|
|
+ return ResultVOUtil.success(map);
|
|
|
+ } catch (UserException e) {
|
|
|
+ return ResultVOUtil.error(ResultEnum.VERSION_CODE_ERROR.getCode(), ResultEnum.VERSION_CODE_ERROR.getMessage());
|
|
|
+ }
|
|
|
+
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * @param code
|
|
|
+ * @param channel
|
|
|
+ * @param platform
|
|
|
+ * @return
|
|
|
+ */
|
|
|
+ @GetMapping("/get_client_state")
|
|
|
+ public ResultVO getClientState(@RequestParam("code") String code,
|
|
|
+ @RequestParam("channel") String channel,
|
|
|
+ @RequestParam(value = "platform", required = false) Integer platform) {
|
|
|
+ try {
|
|
|
+ VersionCode versionCode = versionCodeService.findByCode(code);
|
|
|
+
|
|
|
+ if (versionCode == null) {
|
|
|
+ return ResultVOUtil.error(ResultEnum.VERSION_CODE_NULL.getCode(), ResultEnum.VERSION_CODE_NULL.getMessage());
|
|
|
+ }
|
|
|
+
|
|
|
+ //解析客戶端code 对应支持的渠道信息 show config key
|
|
|
+ String showConfigKey = versionCode.getShowConfigKey();
|
|
|
+ //判断是否存在对应key,默认设置false 不存在渠道;
|
|
|
+ Boolean isContains = StrUtil.isBlank(showConfigKey) ? false : showConfigKey.contains(channel);
|
|
|
+
|
|
|
+ List<ClientStateVO> clientStateVOS = new ArrayList<>();
|
|
|
+ //解析对应的控制页面栏目信息
|
|
|
+ if (!StrUtil.isBlank(versionCode.getShowConfig())) {
|
|
|
+ clientStateVOS = JSONUtil.toList(versionCode.getShowConfig(), ClientStateVO.class);
|
|
|
+ }
|
|
|
+
|
|
|
+ HashMap map = new HashMap();
|
|
|
+
|
|
|
+ //platform 0:android 1:ios 2:all
|
|
|
+ //getLimitPlatform 0:全都限制,1:限制android,2:限制ios,3:都不限制
|
|
|
+ if (versionCode.getLimitPlatform().equals(0)
|
|
|
+ || (platform.equals(0) && versionCode.getLimitPlatform().equals(1)) // android
|
|
|
+ || (platform.equals(1) && versionCode.getLimitPlatform().equals(2))) // ios
|
|
|
+ {
|
|
|
+ map.put("showGame", false);
|
|
|
+ map.put("showVideo", false);
|
|
|
+ map.put("showTool", false);
|
|
|
+ map.put("isContains",false);
|
|
|
+ map.put("clientStates",new ArrayList<>());
|
|
|
+ } else {
|
|
|
+ map.put("showGame", versionCode.getIsShowGame().equals(1));
|
|
|
+ map.put("showVideo", versionCode.getIsShowVideo().equals(1));
|
|
|
+ map.put("showTool", versionCode.getIsShowTool().equals(1));
|
|
|
+ map.put("isContains",isContains);
|
|
|
+ map.put("clientStates",clientStateVOS);
|
|
|
+ }
|
|
|
+ map.put("versionCode", versionCode.getCode());
|
|
|
+ map.put("title", versionCode.getTitle());
|
|
|
|
|
|
return ResultVOUtil.success(map);
|
|
|
} catch (UserException e) {
|
|
|
@@ -1067,13 +1143,14 @@ public class LoginController {
|
|
|
/**
|
|
|
* 验证一下当前是否存在修改密码的code
|
|
|
* 需要限制访问次数等
|
|
|
+ *
|
|
|
* @param account
|
|
|
* @param code
|
|
|
* @return
|
|
|
*/
|
|
|
@GetMapping("/SMS_verify_code")
|
|
|
public ResultVO onlyVerifyCode(@RequestParam("account") String account,
|
|
|
- @RequestParam("code") String code) {
|
|
|
+ @RequestParam("code") String code) {
|
|
|
|
|
|
String codeValue = redisSettingMap.getValue(RedisType.SMS, account);
|
|
|
if (!StringUtils.equals(codeValue, code)) {
|
|
|
@@ -1093,9 +1170,9 @@ public class LoginController {
|
|
|
*/
|
|
|
@GetMapping("/SMS_modify_password")
|
|
|
public ResultVO userModifyPassword(@RequestParam("account") String account,
|
|
|
- @RequestParam("code") String code,
|
|
|
- @RequestParam("type") Integer type,
|
|
|
- @RequestParam("password") String password) {
|
|
|
+ @RequestParam("code") String code,
|
|
|
+ @RequestParam("type") Integer type,
|
|
|
+ @RequestParam("password") String password) {
|
|
|
|
|
|
String codeValue = redisSettingMap.getValue(RedisType.SMS, account);
|
|
|
if (!StringUtils.equals(codeValue, code)) {
|
|
|
@@ -1104,9 +1181,9 @@ public class LoginController {
|
|
|
log.info("userModifyPassword codeValue:" + codeValue);
|
|
|
try {
|
|
|
MainInfo mainInfo = null;
|
|
|
- if(type.equals(0)){
|
|
|
+ if (type.equals(0)) {
|
|
|
mainInfo = mainInfoService.findMainInfoByPhoneNumber(account);
|
|
|
- }else if(type.equals(1)){
|
|
|
+ } else if (type.equals(1)) {
|
|
|
mainInfo = mainInfoService.findMainInfoByEmail(account);
|
|
|
}
|
|
|
//如果不存在用户
|
|
|
@@ -1133,28 +1210,26 @@ public class LoginController {
|
|
|
|
|
|
/**
|
|
|
* 根据手机号或者邮箱,加旧密码,修改成新密码
|
|
|
- *
|
|
|
*/
|
|
|
@GetMapping("/modify_password_from_account")
|
|
|
public ResultVO userModifyPasswordFromAccount(@RequestParam("account") String account,
|
|
|
- @RequestParam("type") Integer type,
|
|
|
- @RequestParam("oldPassword") String oldPassword,
|
|
|
- @RequestParam("newPassword") String newPassword,
|
|
|
- @RequestParam("userId") String userId) {
|
|
|
+ @RequestParam("type") Integer type,
|
|
|
+ @RequestParam("oldPassword") String oldPassword,
|
|
|
+ @RequestParam("newPassword") String newPassword,
|
|
|
+ @RequestParam("userId") String userId) {
|
|
|
|
|
|
try {
|
|
|
MainInfo mainInfo = null;
|
|
|
- if(type.equals(0)){
|
|
|
+ if (type.equals(0)) {
|
|
|
mainInfo = mainInfoService.findMainInfoByPhoneNumber(account);
|
|
|
- }else if(type.equals(1)){
|
|
|
+ } else if (type.equals(1)) {
|
|
|
mainInfo = mainInfoService.findMainInfoByEmail(account);
|
|
|
}
|
|
|
//如果不存在用户
|
|
|
if (mainInfo == null) {
|
|
|
return ResultVOUtil.error(UserEnum.USER_MODIFY_ACCOUNT_ERROR.getCode(), UserEnum.USER_MODIFY_ACCOUNT_ERROR.getMessage());
|
|
|
}
|
|
|
- if(!mainInfo.getPassword().equals(oldPassword))
|
|
|
- {
|
|
|
+ if (!mainInfo.getPassword().equals(oldPassword)) {
|
|
|
//如果旧密码不对,提示
|
|
|
return ResultVOUtil.error(UserEnum.USER_OLD_PASSWORD_ERROR.getCode(), UserEnum.USER_OLD_PASSWORD_ERROR.getMessage());
|
|
|
}
|