Commit 58405198 by 刘红梅

刘红梅提交代码第三次

parent 9f09b5c2
......@@ -8,10 +8,10 @@ import com.cnooc.expert.common.utils.JwtUtils;
import com.cnooc.expert.common.utils.Sm2Util;
import com.cnooc.expert.common.utils.ValidUtils;
import com.cnooc.expert.external.expert.auth.service.LoginServicesClient;
import com.cnooc.expert.external.expert.model.response.ExpertInfoAppResp;
import com.cnooc.expert.external.expert.model.response.ExpertInfoResp;
import com.cnooc.expert.system.entity.vo.LoginVO;
import com.cnooc.expert.system.entity.vo.VerifyCodeVO;
import com.cnooc.expert.system.entity.vo.ZhuanJiaInfoAppVo;
import com.cnooc.expert.system.entity.vo.ZhuanJiaInfoVo;
import com.cnooc.expert.auth.service.LoginService;
import com.cnooc.expert.auth.service.SmsService;
import com.cnooc.expert.auth.service.SysCaptchaService;
......@@ -108,26 +108,19 @@ public class LoginServiceImpl implements LoginService {
ValidUtils.isTrue(Validator.isMobile(loginVO.getPhoneNumber()), "请输入正确格式的手机号");
ValidUtils.isText(loginVO.getPassword(), "请输入密码");
//1.根据手机号去库中查询是否存在
ZhuanJiaInfoVo zhuanJiaInfoVo = new ZhuanJiaInfoVo();
zhuanJiaInfoVo.setMobile(loginVO.getPhoneNumber());
zhuanJiaInfoVo = loginServicesClient.querySingleByShengFenZhengOrMobile(zhuanJiaInfoVo);
if(zhuanJiaInfoVo == null){
ExpertInfoResp expertInfoResp = loginServicesClient.querySingleByShengFenZhengOrMobile(loginVO.getPhoneNumber(),null);
if(expertInfoResp == null){
return "用户信息不存在";
}
//2.判断密码是否存在
ZhuanJiaInfoAppVo zhuanJiaInfoAppVo = new ZhuanJiaInfoAppVo();
zhuanJiaInfoAppVo.setBaseGuid(zhuanJiaInfoVo.getBaseGuid());
zhuanJiaInfoAppVo = loginServicesClient.getZhuanJiaInfoAppById(zhuanJiaInfoAppVo);
ExpertInfoAppResp expertInfoAppResp = loginServicesClient.getZhuanJiaInfoAppById(expertInfoResp.getBaseGuid());
String pwd = Sm2Util.decrypt(loginVO.getPassword());
if(zhuanJiaInfoAppVo == null){
if(expertInfoAppResp == null){
//没有记录的话就是新建记录
zhuanJiaInfoAppVo = new ZhuanJiaInfoAppVo();
zhuanJiaInfoAppVo.setPassword(passwordEncoder.encode(pwd));
loginServicesClient.saveZhuanJiaInfoApp(zhuanJiaInfoAppVo);
loginServicesClient.saveZhuanJiaInfoApp(null,passwordEncoder.encode(pwd));
}else{
//否则更新密码
zhuanJiaInfoAppVo.setPassword(passwordEncoder.encode(pwd));
loginServicesClient.updateZhuanJiaInfoApp(zhuanJiaInfoAppVo);
loginServicesClient.updateZhuanJiaInfoApp(expertInfoAppResp.getBaseGuid(),passwordEncoder.encode(pwd));
}
//手机号,验证码,图形验证码都需要判断
//判断密码是否符合规则
......@@ -158,16 +151,12 @@ public class LoginServiceImpl implements LoginService {
ValidUtils.isText(loginVO.getIdNumber(), "请输入身份证号");
ValidUtils.isText(loginVO.getPassword(), "请输入密码");
ValidUtils.isTrue(IdcardUtil.isValidCard(loginVO.getIdNumber()), "请输入正确的身份证号");
ZhuanJiaInfoVo zhuanJiaInfoVo = new ZhuanJiaInfoVo();
zhuanJiaInfoVo.setShengfenzheng(loginVO.getIdNumber());
zhuanJiaInfoVo = loginServicesClient.querySingleByShengFenZhengOrMobile(zhuanJiaInfoVo);
if(zhuanJiaInfoVo == null){
ExpertInfoResp expertInfoResp = loginServicesClient.querySingleByShengFenZhengOrMobile(null,loginVO.getIdNumber());
if(expertInfoResp == null){
return "用户信息不存在";
}
ZhuanJiaInfoAppVo zhuanJiaInfoAppVo = new ZhuanJiaInfoAppVo();
zhuanJiaInfoAppVo.setBaseGuid(zhuanJiaInfoVo.getBaseGuid());
zhuanJiaInfoAppVo = loginServicesClient.getZhuanJiaInfoAppById(zhuanJiaInfoAppVo);
if(zhuanJiaInfoAppVo == null){
ExpertInfoAppResp expertInfoAppResp = loginServicesClient.getZhuanJiaInfoAppById(expertInfoResp.getBaseGuid());
if(expertInfoAppResp == null){
return "该用户还没有设置密码";
}
// 验证码效验
......@@ -181,7 +170,7 @@ public class LoginServiceImpl implements LoginService {
//2.存在校验密码
//解密
String pwd = Sm2Util.decrypt(loginVO.getPassword());
flag = passwordEncoder.matches(pwd, zhuanJiaInfoAppVo.getPassword());
flag = passwordEncoder.matches(pwd, expertInfoAppResp.getPassword());
if (!flag) {
// 登录日志
//sysLogLoginService.savePortal(login.getAccountName(), Constant.FAIL, LoginOperationEnum.ACCOUNT_FAIL.getValue(), 1);
......@@ -208,10 +197,8 @@ public class LoginServiceImpl implements LoginService {
ValidUtils.isText(loginVO.getPhoneCode(), "请输入验证码");
ValidUtils.isTrue(Validator.isMobile(loginVO.getPhoneNumber()), "请输入正确格式的手机号");
//1.根据手机号去库中查询是否存在
ZhuanJiaInfoVo zhuanJiaInfoVo = new ZhuanJiaInfoVo();
zhuanJiaInfoVo.setMobile(loginVO.getPhoneNumber());
zhuanJiaInfoVo = loginServicesClient.querySingleByShengFenZhengOrMobile(zhuanJiaInfoVo);
if(zhuanJiaInfoVo == null){
ExpertInfoResp expertInfoResp = loginServicesClient.querySingleByShengFenZhengOrMobile(loginVO.getPhoneNumber(),null);
if(expertInfoResp == null){
return "用户信息不存在";
}
//2.存在校验验证码
......
package com.cnooc.expert.external.expert.api;
import com.cnooc.expert.external.expert.model.request.ExpertInfoGetReq;
import com.cnooc.expert.external.expert.model.request.ExpertInfoAppReq;
import com.cnooc.expert.external.expert.model.request.ExpertInfoReq;
import com.cnooc.expert.external.expert.model.response.ExpertInfoAppResp;
import com.cnooc.expert.external.expert.model.response.ExpertInfoGetResp;
import com.cnooc.expert.external.expert.model.response.ExpertInfoResp;
import retrofit2.Call;
import retrofit2.http.Body;
import retrofit2.http.HeaderMap;
......@@ -11,5 +14,14 @@ import java.util.Map;
public interface LoginServiceApi {
@POST("/")
Call<ExpertInfoGetResp> expertDetailUpDate(@HeaderMap Map<String, Object> headers, @Body ExpertInfoGetReq user);
Call<ExpertInfoResp> querySingleByShengFenZhengOrMobile(@HeaderMap Map<String, Object> headers, @Body ExpertInfoReq expertInfoReq);
@POST("/")
Call<ExpertInfoAppResp> getZhuanJiaInfoAppById(@HeaderMap Map<String, Object> headers, @Body ExpertInfoAppReq expertInfoAppReq);
@POST("/")
Call<ExpertInfoAppResp> saveZhuanJiaInfoApp(@HeaderMap Map<String, Object> headers, @Body ExpertInfoAppReq expertInfoAppReq);
@POST("/")
Call<ExpertInfoAppResp> updateZhuanJiaInfoApp(@HeaderMap Map<String, Object> headers, @Body ExpertInfoAppReq expertInfoAppReq);
}
package com.cnooc.expert.external.expert.auth.service;
import com.cnooc.expert.external.common.AbstractRetrofitManager;
import com.cnooc.expert.system.entity.vo.ZhuanJiaInfoVo;
import com.cnooc.expert.system.entity.vo.ZhuanJiaInfoAppVo;
import com.cnooc.expert.external.expert.api.LoginServiceApi;
import com.cnooc.expert.external.expert.model.request.ExpertInfoAppReq;
import com.cnooc.expert.external.expert.model.request.ExpertInfoReq;
import com.cnooc.expert.external.expert.model.response.ExpertInfoAppResp;
import com.cnooc.expert.external.expert.model.response.ExpertInfoResp;
import com.google.common.collect.Maps;
import org.springframework.beans.factory.annotation.Qualifier;
import org.springframework.stereotype.Service;
import retrofit2.Call;
import retrofit2.Retrofit;
import java.util.Map;
@Service
public class LoginServicesClient extends AbstractRetrofitManager {
public ZhuanJiaInfoVo querySingleByShengFenZhengOrMobile(ZhuanJiaInfoVo zhuanJiaInfoVo){
ZhuanJiaInfoVo res = new ZhuanJiaInfoVo();
private final LoginServiceApi loginServiceApi;
public LoginServicesClient(@Qualifier("retrofitExpert") Retrofit retrofit) {
this.loginServiceApi = retrofit.create(LoginServiceApi.class);
}
public ExpertInfoResp querySingleByShengFenZhengOrMobile(String mobile,String shenfenzheng){
Map<String, Object> headers = Maps.newHashMap();
ExpertInfoReq expertInfoReq = new ExpertInfoReq();
expertInfoReq.setMobile(mobile);
expertInfoReq.setShengfenzheng(shenfenzheng);
Call<ExpertInfoResp> call = loginServiceApi.querySingleByShengFenZhengOrMobile(headers,expertInfoReq);
return this.getResponseBody(call, "querySingleByShengFenZhengOrMobile");
/* String jsonString = JsonUtils.toJsonString(zhuanJiaInfoVo);
res = RestUtils.sendPostRequest2Expert("/zjfw/zggrxxgl/querySingleByShengFenZhengOrMobile",jsonString,null);
*/ return res;
*/
}
public ZhuanJiaInfoAppVo getZhuanJiaInfoAppById(ZhuanJiaInfoAppVo zhuanJiaInfoAppVo){
ZhuanJiaInfoAppVo res = new ZhuanJiaInfoAppVo();
public ExpertInfoAppResp getZhuanJiaInfoAppById(String baseGuid){
ExpertInfoAppReq expertInfoAppReq = new ExpertInfoAppReq();
Map<String, Object> headers = Maps.newHashMap();
expertInfoAppReq.setBaseGuid(baseGuid);
Call<ExpertInfoAppResp> call = loginServiceApi.getZhuanJiaInfoAppById(headers,expertInfoAppReq);
return this.getResponseBody(call, "getZhuanJiaInfoAppById");
/* String jsonString = JsonUtils.toJsonString(zhuanJiaInfoAppVo);
res = RestUtils.sendPostRequest2Expert("/zjfw/zggrxxgl/getZhuanJiaInfoAppById",jsonString,null);*/
return res;
}
public ZhuanJiaInfoAppVo saveZhuanJiaInfoApp(ZhuanJiaInfoAppVo zhuanJiaInfoAppVo){
ZhuanJiaInfoAppVo res = new ZhuanJiaInfoAppVo();
public ExpertInfoAppResp saveZhuanJiaInfoApp(String baseGuid,String password){
ExpertInfoAppReq expertInfoAppReq = new ExpertInfoAppReq();
Map<String, Object> headers = Maps.newHashMap();
expertInfoAppReq.setBaseGuid(baseGuid);
expertInfoAppReq.setPassword(password);
Call<ExpertInfoAppResp> call = loginServiceApi.saveZhuanJiaInfoApp(headers,expertInfoAppReq);
return this.getResponseBody(call, "saveZhuanJiaInfoApp");
/* String jsonString = JsonUtils.toJsonString(zhuanJiaInfoAppVo);
res = RestUtils.sendPostRequest2Expert("/zjfw/zggrxxgl/saveZhuanJiaInfoApp",jsonString,null);*/
return res;
}
public ZhuanJiaInfoAppVo updateZhuanJiaInfoApp(ZhuanJiaInfoAppVo zhuanJiaInfoAppVo){
ZhuanJiaInfoAppVo res = new ZhuanJiaInfoAppVo();
public ExpertInfoAppResp updateZhuanJiaInfoApp(String baseGuid,String password){
ExpertInfoAppReq expertInfoAppReq = new ExpertInfoAppReq();
Map<String, Object> headers = Maps.newHashMap();
expertInfoAppReq.setBaseGuid(baseGuid);
expertInfoAppReq.setPassword(password);
Call<ExpertInfoAppResp> call = loginServiceApi.updateZhuanJiaInfoApp(headers,expertInfoAppReq);
return this.getResponseBody(call, "updateZhuanJiaInfoApp");
/* String jsonString = JsonUtils.toJsonString(zhuanJiaInfoAppVo);
res = RestUtils.sendPostRequest2Expert("/zjfw/zggrxxgl/updateZhuanJiaInfoApp",jsonString,null);*/
return res;
}
}
package com.cnooc.expert.external.expert.model.request;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;
@Data
@NoArgsConstructor
@AllArgsConstructor
public class ExpertInfoAppReq {
private String baseGuid;
private String password;
}
package com.cnooc.expert.external.expert.model.request;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;
@Data
@NoArgsConstructor
@AllArgsConstructor
public class ExpertInfoReq {
private String baseGuid;
private String mobile;
private String shengfenzheng;
private String password;
}
package com.cnooc.expert.system.entity.vo;
package com.cnooc.expert.external.expert.model.response;
import lombok.Data;
import java.io.Serializable;
@Data
public class ZhuanJiaInfoAppVo implements Serializable {
private static final long serialVersionUID = 1L;
public class ExpertInfoAppResp {
private String baseGuid;
private String password;
}
package com.cnooc.expert.system.entity.vo;
package com.cnooc.expert.external.expert.model.response;
import lombok.Data;
import java.io.Serializable;
@Data
public class ZhuanJiaInfoVo implements Serializable {
private String baseGuid;
public class ExpertInfoResp {
private String baseGuid;
private String mobile;
private String shengfenzheng;
private String password;
......
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