Commit 58405198 by 刘红梅

刘红梅提交代码第三次

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