Commit 475b7c85 by zhiwj

Merge branch 'developer' of…

Merge branch 'developer' of http://115.159.76.241/base_platform_enterprise/gic-data-cloud into developer
parents 859c4913 4a430df2
app.id=gic-data-cloud-operation-web app.id=gic-data-cloud-operation-web
app.project-code=data-cloud app.project-code=gic-data-cloud
logging.level.org.springframework.security=DEBUG logging.level.org.springframework.security=DEBUG
......
...@@ -4,10 +4,12 @@ import com.gic.api.base.commons.ServiceResponse; ...@@ -4,10 +4,12 @@ import com.gic.api.base.commons.ServiceResponse;
import com.gic.cloud.dto.UserDTO; import com.gic.cloud.dto.UserDTO;
import com.gic.cloud.service.UserApiService; import com.gic.cloud.service.UserApiService;
import com.gic.cloud.web.constant.ErrorCode; import com.gic.cloud.web.constant.ErrorCode;
import com.gic.cloud.web.vo.LoginUserVo;
import com.gic.commons.webapi.reponse.RestResponse; import com.gic.commons.webapi.reponse.RestResponse;
import com.gic.enterprise.utils.CreateRandomUtils; import com.gic.enterprise.utils.CreateRandomUtils;
import com.gic.enterprise.utils.UserDetailUtils; import com.gic.enterprise.utils.UserDetailUtils;
import com.gic.marketing.process.api.service.sms.SmsSendApiService; import com.gic.marketing.process.api.service.sms.SmsSendApiService;
import com.gic.redis.data.util.RedisUtil;
import org.apache.commons.collections.CollectionUtils; import org.apache.commons.collections.CollectionUtils;
import org.apache.logging.log4j.LogManager; import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger; import org.apache.logging.log4j.Logger;
...@@ -16,6 +18,7 @@ import org.springframework.web.bind.annotation.RequestMapping; ...@@ -16,6 +18,7 @@ import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController; import org.springframework.web.bind.annotation.RestController;
import java.util.List; import java.util.List;
import java.util.concurrent.TimeUnit;
@RestController @RestController
public class LoginController { public class LoginController {
...@@ -32,10 +35,18 @@ public class LoginController { ...@@ -32,10 +35,18 @@ public class LoginController {
List<UserDTO> userDTOList = this.userApiService.listUserByPhone("86", phoneNumber).getResult(); List<UserDTO> userDTOList = this.userApiService.listUserByPhone("86", phoneNumber).getResult();
if(CollectionUtils.isNotEmpty(userDTOList)){ if(CollectionUtils.isNotEmpty(userDTOList)){
Integer enterpriseId = userDTOList.get(0).getEnterpriseId(); Integer enterpriseId = userDTOList.get(0).getEnterpriseId();
ServiceResponse<Void> smsSendResult = smsSendApiService.sendPlatformSms(smsSenceId, String code = CreateRandomUtils.getStringRandom(4);
enterpriseId,areaCode, phoneNumber, new String[]{CreateRandomUtils.getStringRandom(4)}); ServiceResponse<Void> smsSendResult = smsSendApiService.sendPlatformSms(smsSenceId,enterpriseId,areaCode, phoneNumber, new String[]{code});
if(smsSendResult.isSuccess()){ if(smsSendResult.isSuccess()){
return RestResponse.success(); String key = "GYTCode:" + areaCode + ":" + phoneNumber;
LoginUserVo userVo = new LoginUserVo();
userVo.setEnterpriseId(enterpriseId);
userVo.setAreaCode(areaCode);
userVo.setCode(code);
userVo.setPhoneNumber(phoneNumber);
userVo.setUserId(userDTOList.get(0).getUserId());
RedisUtil.setCache(key, userVo, 5l, TimeUnit.MINUTES);
return RestResponse.success(enterpriseId);
}else { }else {
return RestResponse.failure(ErrorCode.SYSTEMERROR.getCode(), smsSendResult.getMessage()); return RestResponse.failure(ErrorCode.SYSTEMERROR.getCode(), smsSendResult.getMessage());
} }
...@@ -43,4 +54,20 @@ public class LoginController { ...@@ -43,4 +54,20 @@ public class LoginController {
return RestResponse.failure(ErrorCode.ACCOUNTNOTEXISTS.getCode(), ErrorCode.ACCOUNTNOTEXISTS.getMsg()); return RestResponse.failure(ErrorCode.ACCOUNTNOTEXISTS.getCode(), ErrorCode.ACCOUNTNOTEXISTS.getMsg());
} }
} }
@RequestMapping("login")
public RestResponse login(String areaCode, String phoneNumber, String code){
String key = "GYTCode:" + areaCode + ":" + phoneNumber;
Object cache = RedisUtil.getCache(key);
if(cache != null){
LoginUserVo userVo = (LoginUserVo) cache;
if(userVo.getCode().equals(code)){
return RestResponse.success(userVo);
}else {
return RestResponse.failure(ErrorCode.SYSTEMERROR.getCode(), "验证码错误");
}
}else {
return RestResponse.failure(ErrorCode.ACCOUNTNOTEXISTS.getCode(), "请发送验证码");
}
}
} }
package com.gic.cloud.web.vo;
import java.io.Serializable;
public class LoginUserVo implements Serializable {
private Integer userId;
private Integer enterpriseId;
private String phoneNumber;
private String areaCode;
private String code;
public Integer getUserId() {
return userId;
}
public void setUserId(Integer userId) {
this.userId = userId;
}
public Integer getEnterpriseId() {
return enterpriseId;
}
public void setEnterpriseId(Integer enterpriseId) {
this.enterpriseId = enterpriseId;
}
public String getPhoneNumber() {
return phoneNumber;
}
public void setPhoneNumber(String phoneNumber) {
this.phoneNumber = phoneNumber;
}
public String getAreaCode() {
return areaCode;
}
public void setAreaCode(String areaCode) {
this.areaCode = areaCode;
}
public String getCode() {
return code;
}
public void setCode(String code) {
this.code = code;
}
}
package com.gic.cloud.web.vo;
public class StoreWidgetIndexVo {
/****1多渠道首页 2单渠道线下首页 3单渠道线上首页****/
private Integer type;
private String id;
private String name;
private Integer attentionCount;
public Integer getType() {
return type;
}
public void setType(Integer type) {
this.type = type;
}
public String getId() {
return id;
}
public void setId(String id) {
this.id = id;
}
public String getName() {
return name;
}
public void setName(String name) {
this.name = name;
}
public Integer getAttentionCount() {
return attentionCount;
}
public void setAttentionCount(Integer attentionCount) {
this.attentionCount = attentionCount;
}
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment