Commit 6e0c1a2c authored by zhangzc's avatar zhangzc

修改token校验

parent 09c37a12
......@@ -32,6 +32,7 @@ public class ProtocolComponent {
* map.put("mobileId", mobileId); // 手机唯一标识
* map.put("cVer", cVer); // 客户端版本
* map.put("accountType", "1"); // 帐号身份类型:1-司机、2-货主
* map.put("tenantId", "1"); // 租户ID:1-司机、2-货主
* param [request]
* return void
* author Administrator
......@@ -54,6 +55,9 @@ public class ProtocolComponent {
if (StringUtils.isBlank(request.getHeader("cVer"))) {
throw new EException(ECode.PROTOCOL_ILLEGAL.code(), "请求头[cVer]不符合协议");
}
if (StringUtils.isBlank(request.getHeader("tenantId"))) {
throw new EException(ECode.PROTOCOL_ILLEGAL.code(), "请求头[tenantId]不符合协议");
}
if (!String.valueOf(AccountConstants.ACCOUNT_TYPE_DRIVER).equals(request.getHeader("accountType"))
&& !String.valueOf(AccountConstants.ACCOUNT_TYPE_GOODS_OWNER).equals(request.getHeader("accountType"))) {
throw new EException(ECode.PROTOCOL_ILLEGAL.code(), "请求头[accountType]不符合协议");
......
......@@ -85,7 +85,13 @@ public class RedisComponent {
public void del(String... key) {
if (key != null && key.length > 0) {
if (key.length == 1) {
redisTemplate.delete(key[0]);
Boolean b = redisTemplate.delete(key[0]);
if(b == true) {
log.info("123... del is true");
}
else {
log.info("123... del is false");
}
} else {
redisTemplate.delete(CollectionUtils.arrayToList(key));
}
......
......@@ -6,6 +6,7 @@ import com.esv.freight.app.common.constants.AccountConstants;
import com.esv.freight.app.common.exception.EException;
import com.esv.freight.app.common.response.ECode;
import com.esv.freight.app.common.util.AESSecretUtils;
import com.esv.freight.app.common.util.AesUtils;
import com.esv.freight.app.common.util.DateUtils;
import com.esv.freight.app.common.util.ReqUtils;
import com.esv.freight.app.module.account.entity.AppLoginEntity;
......@@ -36,7 +37,8 @@ public class TokenComponent {
@Value("${spring.application.name}")
private String applicationName;
@Value("${aes.sha1prng.key:freight-app-service-001}")
// 为了和终端加密/解密统一,密码长度控制为16位
@Value("${aes.sha1prng.key:ADGJLPIYRE24680A}")
private String AES_KEY;
/**
......@@ -75,9 +77,9 @@ public class TokenComponent {
tokenInfoPojo.setOsVersion(ReqUtils.getRequestHeader("osVer"));
tokenInfoPojo.setAppVersion(ReqUtils.getRequestHeader("cVer"));
tokenInfoPojo.setAccountType(Integer.parseInt(ReqUtils.getRequestHeader("accountType")));
String accessToken = AESSecretUtils.encryptToStr(this.getAccessTokenOriginalContent(tokenInfoPojo), AES_KEY);
String accessToken = AesUtils.aesEncrypt(this.getAccessTokenOriginalContent(tokenInfoPojo), AES_KEY);
tokenInfoPojo.setAccessToken(accessToken);
String refreshToken = AESSecretUtils.encryptToStr(this.getRefreshTokenOriginalContent(tokenInfoPojo), AES_KEY);
String refreshToken = AesUtils.aesEncrypt(this.getRefreshTokenOriginalContent(tokenInfoPojo), AES_KEY);
tokenInfoPojo.setRefreshToken(refreshToken);
Date loginTime = new Date();
tokenInfoPojo.setLoginTime(loginTime.getTime());
......@@ -112,6 +114,16 @@ public class TokenComponent {
}
}
public TokenInfoPojo getTokenInfo() {
String token = ReqUtils.getRequestHeader("Union-Authorization");
if(StringUtils.isEmpty(token)) {
return null;
}
else {
return this.getTokenInfo(token);
}
}
/**
* description 获取Token信息
* param [accessToken]
......@@ -124,7 +136,7 @@ public class TokenComponent {
return null;
}
// 解密Token并基础校验
String decryptToken = AESSecretUtils.decryptToStr(accessToken, AES_KEY);
String decryptToken = AesUtils.aesDecrypt(accessToken, AES_KEY);
if (StringUtils.isBlank(decryptToken)) {
return null;
}
......@@ -159,12 +171,20 @@ public class TokenComponent {
if (null != appLoginEntity) {
tokenInfoPojo = new TokenInfoPojo();
BeanUtils.copyProperties(appLoginEntity, tokenInfoPojo);
try {
tokenInfoPojo.setAccountId(appLoginEntity.getId());
tokenInfoPojo.setAccount(appLoginEntity.getPhone());
tokenInfoPojo.setLoginTime(appLoginEntity.getLoginTime().getTime());
tokenInfoPojo.setRefreshTime(appLoginEntity.getRefreshTime().getTime());
tokenInfoPojo.setAccessTokenValidTime(appLoginEntity.getAccessTokenValidTime().getTime());
tokenInfoPojo.setRefreshTokenValidTime(appLoginEntity.getRefreshTokenValidTime().getTime());
// 缓存Token信息
redisComponent.set(cacheKey, tokenInfoPojo.toString(), this.accessTokenValidTime * TOKEN_TIME);
}
catch (Exception e) {
return null;
}
}
} else {
tokenInfoPojo = JSONObject.toJavaObject(JSONObject.parseObject(cacheInfo), TokenInfoPojo.class);
......@@ -204,5 +224,4 @@ public class TokenComponent {
public String getTokenInfoCacheKey(String account, Integer accountType) {
return applicationName + "::token::" + accountType + "::" + account;
}
}
......@@ -33,7 +33,8 @@ public class AuthFilter implements Filter {
* 不需要TOKEN校验的URL
**/
private static final String[] NOT_TOKEN_URL = new String[]{"/app/ownerBackend/account/login/loginBySms", "/app/ownerBackend/account/login/loginByPwd",
"/app/driverBackend/account/login/loginBySms", "/app/driverBackend/account/login/loginByPwd"};
"/app/driverBackend/account/login/loginBySms", "/app/driverBackend/account/login/loginByPwd", "/app/driverBackend/account/login/check/phone",
"/app/driverBackend/account/carrier/list","/app/driverBackend/grab/find/list","/app/ownerBackend/password/reset","/app/driverBackend/password/reset"};
@Autowired
private ProtocolComponent protocolComponent;
......@@ -69,6 +70,7 @@ public class AuthFilter implements Filter {
break;
}
}
if (isCheckToken) {
String token = request.getHeader("Union-Authorization");
try {
......
package com.esv.freight.app.common.util;
import javax.crypto.BadPaddingException;
import javax.crypto.Cipher;
import javax.crypto.IllegalBlockSizeException;
import javax.crypto.NoSuchPaddingException;
import javax.crypto.spec.IvParameterSpec;
import javax.crypto.spec.SecretKeySpec;
import java.io.UnsupportedEncodingException;
import java.security.InvalidAlgorithmParameterException;
import java.security.InvalidKeyException;
import java.security.NoSuchAlgorithmException;
public class AesUtils {
public static final String VIPARA = "1269571569321021";
public static final String bm = "utf-8";
/**
* 字节数组转化为大写16进制字符串
*
* @param b
* @return
*/
private static String byte2HexStr(byte[] b) {
StringBuilder sb = new StringBuilder();
for (int i = 0; i < b.length; i++) {
String s = Integer.toHexString(b[i] & 0xFF);
if (s.length() == 1) {
sb.append("0");
}
sb.append(s.toUpperCase());
}
return sb.toString();
}
/**
* 16进制字符串转字节数组
*
* @param s
* @return
*/
private static byte[] str2ByteArray(String s) {
int byteArrayLength = s.length() / 2;
byte[] b = new byte[byteArrayLength];
for (int i = 0; i < byteArrayLength; i++) {
byte b0 = (byte) Integer.valueOf(s.substring(i * 2, i * 2 + 2), 16)
.intValue();
b[i] = b0;
}
return b;
}
/**
* AES 加密
*
* @param content
* 明文
* @param password
* 生成秘钥的关键字
* @return
*/
public static String aesEncrypt(String content, String password) {
try {
IvParameterSpec zeroIv = new IvParameterSpec(VIPARA.getBytes());
SecretKeySpec key = new SecretKeySpec(password.getBytes(), "AES");
Cipher cipher = Cipher.getInstance("AES/CBC/PKCS5Padding");
cipher.init(Cipher.ENCRYPT_MODE, key, zeroIv);
byte[] encryptedData = cipher.doFinal(content.getBytes(bm));
return Base64.encode(encryptedData);
// return byte2HexStr(encryptedData);
} catch (NoSuchAlgorithmException e) {
e.printStackTrace();
} catch (NoSuchPaddingException e) {
e.printStackTrace();
} catch (UnsupportedEncodingException e) {
e.printStackTrace();
} catch (InvalidKeyException e) {
e.printStackTrace();
} catch (IllegalBlockSizeException e) {
e.printStackTrace();
} catch (BadPaddingException e) {
e.printStackTrace();
} catch (InvalidAlgorithmParameterException e) {
e.printStackTrace();
}
return null;
}
/**
* AES 解密
*
* @param content
* 密文
* @param password
* 生成秘钥的关键字
* @return
*/
public static String aesDecrypt(String content, String password) {
try {
byte[] byteMi = Base64.decode(content);
// byte[] byteMi= str2ByteArray(content);
IvParameterSpec zeroIv = new IvParameterSpec(VIPARA.getBytes());
SecretKeySpec key = new SecretKeySpec(password.getBytes(), "AES");
Cipher cipher = Cipher.getInstance("AES/CBC/PKCS5Padding");
cipher.init(Cipher.DECRYPT_MODE, key, zeroIv);
byte[] decryptedData = cipher.doFinal(byteMi);
return new String(decryptedData, "utf-8");
} catch (NoSuchAlgorithmException e) {
e.printStackTrace();
} catch (NoSuchPaddingException e) {
e.printStackTrace();
} catch (InvalidKeyException e) {
e.printStackTrace();
} catch (IllegalBlockSizeException e) {
e.printStackTrace();
} catch (BadPaddingException e) {
e.printStackTrace();
} catch (UnsupportedEncodingException e) {
e.printStackTrace();
} catch (InvalidAlgorithmParameterException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
return null;
}
}
package com.esv.freight.app.common.util;
import java.io.ByteArrayOutputStream;
import java.io.IOException;
import java.io.OutputStream;
/**
* Created by zzc on 2018/8/16.
*/
public class Base64 {
private static final char[] base64EncodeChars = new char[] { 'A', 'B', 'C',
'D', 'E', 'F', 'G', 'H', 'I', 'J', 'K', 'L', 'M', 'N', 'O', 'P',
'Q', 'R', 'S', 'T', 'U', 'V', 'W', 'X', 'Y', 'Z', 'a', 'b', 'c',
'd', 'e', 'f', 'g', 'h', 'i', 'j', 'k', 'l', 'm', 'n', 'o', 'p',
'q', 'r', 's', 't', 'u', 'v', 'w', 'x', 'y', 'z', '0', '1', '2',
'3', '4', '5', '6', '7', '8', '9', '+', '/' };
private static byte[] base64DecodeChars = new byte[] { -1, -1, -1, -1, -1,
-1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
-1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
-1, -1, -1, -1, 62, -1, -1, -1, 63, 52, 53, 54, 55, 56, 57, 58, 59,
60, 61, -1, -1, -1, -1, -1, -1, -1, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9,
10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, -1,
-1, -1, -1, -1, -1, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37,
38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, 49, 50, 51, -1, -1, -1,
-1, -1 };
private Base64() {
}
private static final char[] legalChars = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/"
.toCharArray();
public static String encode(byte[] data) {
StringBuffer sb = new StringBuffer();
int start = 0;
int len = data.length;
int i = 0;
int b1, b2, b3;
while (i < len) {
b1 = data[i++] & 0xff;
if (i == len) {
sb.append(base64EncodeChars[b1 >>> 2]);
sb.append(base64EncodeChars[(b1 & 0x3) << 4]);
sb.append("==");
break;
}
b2 = data[i++] & 0xff;
if (i == len) {
sb.append(base64EncodeChars[b1 >>> 2]);
sb.append(base64EncodeChars[((b1 & 0x03) << 4)
| ((b2 & 0xf0) >>> 4)]);
sb.append(base64EncodeChars[(b2 & 0x0f) << 2]);
sb.append("=");
break;
}
b3 = data[i++] & 0xff;
sb.append(base64EncodeChars[b1 >>> 2]);
sb.append(base64EncodeChars[((b1 & 0x03) << 4)
| ((b2 & 0xf0) >>> 4)]);
sb.append(base64EncodeChars[((b2 & 0x0f) << 2)
| ((b3 & 0xc0) >>> 6)]);
sb.append(base64EncodeChars[b3 & 0x3f]);
StringBuffer buf = new StringBuffer(data.length * 3 / 2);
int end = len - 3;
int i = start;
int n = 0;
while (i <= end) {
int d = ((((int) data[i]) & 0x0ff) << 16) | ((((int) data[i + 1]) & 0x0ff) << 8)
| (((int) data[i + 2]) & 0x0ff);
buf.append(legalChars[(d >> 18) & 63]);
buf.append(legalChars[(d >> 12) & 63]);
buf.append(legalChars[(d >> 6) & 63]);
buf.append(legalChars[d & 63]);
i += 3;
if (n++ >= 14) {
n = 0;
buf.append(" ");
}
return sb.toString();
}
public static byte[] decode(String str) {
byte[] data = str.getBytes();
int len = data.length;
ByteArrayOutputStream buf = new ByteArrayOutputStream(len);
int i = 0;
int b1, b2, b3, b4;
if (i == start + len - 2) {
int d = ((((int) data[i]) & 0x0ff) << 16) | ((((int) data[i + 1]) & 255) << 8);
while (i < len) {
buf.append(legalChars[(d >> 18) & 63]);
buf.append(legalChars[(d >> 12) & 63]);
buf.append(legalChars[(d >> 6) & 63]);
buf.append("=");
} else if (i == start + len - 1) {
int d = (((int) data[i]) & 0x0ff) << 16;
/* b1 */
do {
b1 = base64DecodeChars[data[i++]];
} while (i < len && b1 == -1);
if (b1 == -1) {
break;
buf.append(legalChars[(d >> 18) & 63]);
buf.append(legalChars[(d >> 12) & 63]);
buf.append("==");
}
/* b2 */
do {
b2 = base64DecodeChars[data[i++]];
} while (i < len && b2 == -1);
if (b2 == -1) {
break;
return buf.toString();
}
buf.write((int) ((b1 << 2) | ((b2 & 0x30) >>> 4)));
/* b3 */
do {
b3 = data[i++];
if (b3 == 61) {
return buf.toByteArray();
private static int decode(char c) {
if (c >= 'A' && c <= 'Z')
return ((int) c) - 65;
else if (c >= 'a' && c <= 'z')
return ((int) c) - 97 + 26;
else if (c >= '0' && c <= '9')
return ((int) c) - 48 + 26 + 26;
else
switch (c) {
case '+':
return 62;
case '/':
return 63;
case '=':
return 0;
default:
throw new RuntimeException("unexpected code: " + c);
}
b3 = base64DecodeChars[b3];
} while (i < len && b3 == -1);
if (b3 == -1) {
break;
}
buf.write((int) (((b2 & 0x0f) << 4) | ((b3 & 0x3c) >>> 2)));
/* b4 */
do {
b4 = data[i++];
if (b4 == 61) {
return buf.toByteArray();
/**
* Decodes the given Base64 encoded String to a new byte array. The byte
* array holding the decoded data is returned.
*/
public static byte[] decode(String s) {
ByteArrayOutputStream bos = new ByteArrayOutputStream();
try {
decode(s, bos);
} catch (IOException e) {
throw new RuntimeException();
}
b4 = base64DecodeChars[b4];
} while (i < len && b4 == -1);
if (b4 == -1) {
break;
byte[] decodedBytes = bos.toByteArray();
try {
bos.close();
bos = null;
} catch (IOException ex) {
System.err.println("Error while decoding BASE64: " + ex.toString());
}
buf.write((int) (((b3 & 0x03) << 6) | b4));
return decodedBytes;
}
private static void decode(String s, OutputStream os) throws IOException {
int i = 0;
int len = s.length();
while (true) {
while (i < len && s.charAt(i) <= ' ')
i++;
if (i == len)
break;
int tri = (decode(s.charAt(i)) << 18) + (decode(s.charAt(i + 1)) << 12) + (decode(s.charAt(i + 2)) << 6)
+ (decode(s.charAt(i + 3)));
os.write((tri >> 16) & 255);
if (s.charAt(i + 2) == '=')
break;
os.write((tri >> 8) & 255);
if (s.charAt(i + 3) == '=')
break;
os.write(tri & 255);
i += 4;
}
return buf.toByteArray();
}
}
......@@ -21,12 +21,6 @@ public class ReqUtils {
return request.getHeader(headerKey);
}
public static CustomToken getTokenInfo() {
ServletRequestAttributes servletRequestAttributes = (ServletRequestAttributes) RequestContextHolder.getRequestAttributes();
HttpServletRequest request = servletRequestAttributes.getRequest();
return (CustomToken) request.getAttribute("tokenInfo");
}
/**
* description 获得Http客户端的ip
* param []
......
package com.esv.freight.app.config;
import com.esv.freight.app.common.component.TokenComponent;
import com.esv.freight.app.common.util.ReqUtils;
import com.esv.freight.app.common.util.SecurityUtils;
import com.esv.freight.app.module.account.CustomToken;
import com.esv.freight.app.module.account.pojo.TokenInfoPojo;
import com.esv.gateway.common.GatewayHeaders;
import feign.RequestInterceptor;
import lombok.extern.slf4j.Slf4j;
import org.slf4j.MDC;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.cloud.openfeign.EnableFeignClients;
import org.springframework.context.annotation.Bean;
......@@ -32,6 +35,9 @@ public class FeignConfigure {
@Value("${spring.application.name}")
private String applicationName;
@Autowired
private TokenComponent tokenComponent;
@Bean
public RestTemplate restTemplate() {
return new RestTemplate();
......@@ -47,11 +53,12 @@ public class FeignConfigure {
requestTemplate.header("esv_system", "app");
requestTemplate.header("esv_department", "5");
requestTemplate.header("esv_department_children", "5,6,7");
CustomToken customToken = ReqUtils.getTokenInfo();
if (null != customToken) {
requestTemplate.header("esv_user", customToken.getUserId());
requestTemplate.header("esv_account", customToken.getAccount());
requestTemplate.header("esv_tenant", String.valueOf(customToken.getTenantId()));
requestTemplate.header("esv_tenant", ReqUtils.getRequestHeader("tenantId"));
TokenInfoPojo tokenInfoPojo = tokenComponent.getTokenInfo();
if (tokenInfoPojo != null) {
requestTemplate.header("esv_user", String.valueOf(tokenInfoPojo.getAccountId()));
requestTemplate.header("esv_account", tokenInfoPojo.getAccount());
}
}));
return requestInterceptor;
......
......@@ -2,6 +2,7 @@ package com.esv.freight.app.module.account.controller;
import com.alibaba.fastjson.JSONArray;
import com.alibaba.fastjson.JSONObject;
import com.esv.freight.app.common.component.TokenComponent;
import com.esv.freight.app.common.constants.AccountConstants;
import com.esv.freight.app.common.response.EResponse;
import com.esv.freight.app.common.util.FeignUtils;
......@@ -16,6 +17,7 @@ import com.esv.freight.app.module.account.form.DriverAuthForm;
import com.esv.freight.app.module.account.form.LoginForm;
import com.esv.freight.app.module.account.form.RefreshTokenForm;
import com.esv.freight.app.module.account.pojo.DriverAccountInfoPojo;
import com.esv.freight.app.module.account.pojo.OwnerAccountInfoPojo;
import com.esv.freight.app.module.account.pojo.TokenInfoPojo;
import com.esv.freight.app.module.account.service.AppLoginService;
import com.esv.freight.app.module.account.validator.groups.ValidatorAccountExist;
......@@ -53,13 +55,15 @@ public class DriverAccountController {
private NoticeInterface noticeInterface;
private AppLoginService appLoginService;
private CarrierInterface carrierInterface;
private TokenComponent tokenComponent;
@Autowired
public DriverAccountController(CarrierInterface carrierInterface, DriverInterface driverInterface, NoticeInterface noticeInterface, AppLoginService appLoginService) {
public DriverAccountController(TokenComponent tokenComponent, CarrierInterface carrierInterface, DriverInterface driverInterface, NoticeInterface noticeInterface, AppLoginService appLoginService) {
this.noticeInterface = noticeInterface;
this.appLoginService = appLoginService;
this.driverInterface = driverInterface;
this.carrierInterface = carrierInterface;
this.tokenComponent = tokenComponent;
}
/**
......@@ -72,32 +76,74 @@ public class DriverAccountController {
@PostMapping("/login/loginBySms")
public EResponse loginBySms(@RequestHeader @RequestBody(required=false) @Validated(ValidatorDriverLoginBySms.class) LoginForm loginForm) {
// 调用通知服务验证短信接口
// 1:调用通知服务验证短信接口
JSONObject reqJson = new JSONObject();
reqJson.put("phone", loginForm.getPhone());
reqJson.put("type", "login");
reqJson.put("captcha", loginForm.getSmsCode());
log.info(reqJson.toJSONString());
JSONObject resultCheck = noticeInterface.checkSmsCaptcha(reqJson);
log.info(resultCheck.toJSONString());
JSONObject result;
try {
result = noticeInterface.checkSmsCaptcha(reqJson);
} catch (Exception e) {
log.error("Feign请求时发生错误:" + e.getMessage(), e);
return EResponse.error();
}
if(resultCheck.getInteger("code") != 200) {
return EResponse.error(resultCheck.getInteger("code"), resultCheck.getString("message"));
if(!FeignUtils.isFeignSuccess(result)) {
return FeignUtils.getFeignEResponse(result);
}
// 2:查询司机详情(通过帐号)
reqJson.clear();
reqJson.put("account", loginForm.getPhone());
try {
result = driverInterface.getDetailByAccount(reqJson);
} catch (Exception e) {
log.error("Feign请求时发生错误:" + e.getMessage(), e);
return EResponse.error();
}
// 3:表示账号未注册
if(result.getInteger("code") == 1001) {
// 调用注册帐号接口
reqJson.clear();
reqJson.put("account", loginForm.getPhone());
reqJson.put("carrierId", loginForm.getCarrierId());
JSONObject resultRegister = driverInterface.register(reqJson);
try {
result = driverInterface.register(reqJson);
} catch (Exception e) {
log.error("Feign请求时发生错误:" + e.getMessage(), e);
return EResponse.error();
}
// 1001表示 帐号已存在
if(resultRegister.getInteger("code") != 200 && resultRegister.getInteger("code") != 1001) {
return EResponse.error(resultRegister.getInteger("code"), resultRegister.getString("message"));
if(!FeignUtils.isFeignSuccess(result)) {
return FeignUtils.getFeignEResponse(result);
}
LoginVO loginByPwdVO = appLoginService.login(loginForm.getPhone());
return EResponse.ok(loginByPwdVO);
DriverAccountInfoPojo pojo = new DriverAccountInfoPojo();
pojo.setId(result.getJSONObject("data").getLong("id"));
pojo.setCarrierId(loginForm.getCarrierId());
pojo.setAccount(loginForm.getPhone());
pojo.setLoginMode(AccountConstants.ACCOUNT_LOGIN_MODE_SMS);
LoginVO vo = appLoginService.driverLogin(pojo);
return EResponse.ok(vo);
}
if(!FeignUtils.isFeignSuccess(result)) {
return FeignUtils.getFeignEResponse(result);
}
// 校验帐号状态:1-正常、2-停用
DriverAccountInfoPojo driverAccountInfoPojo = JSONObject.toJavaObject(FeignUtils.getFeignDataJson(result), DriverAccountInfoPojo.class);
if (AccountConstants.ACCOUNT_STATUS_BLOCK.equals(driverAccountInfoPojo.getAccountStatus())) {
return EResponse.error(1003, "帐号已停用");
}
// 登录
driverAccountInfoPojo.setLoginMode(AccountConstants.ACCOUNT_LOGIN_MODE_SMS);
LoginVO vo = appLoginService.driverLogin(driverAccountInfoPojo);
return EResponse.ok(vo);
}
/**
......@@ -132,8 +178,6 @@ public class DriverAccountController {
return EResponse.error(1003, "帐号已停用");
}
// LoginVO loginByPwdVO = appLoginService.login(loginForm.getPhone());
// 登录
driverAccountInfoPojo.setLoginMode(AccountConstants.ACCOUNT_LOGIN_MODE_PWD);
LoginVO vo = appLoginService.driverLogin(driverAccountInfoPojo);
......@@ -183,8 +227,7 @@ public class DriverAccountController {
**/
@PostMapping("/logout")
public EResponse logout() {
CustomToken customToken = ReqUtils.getTokenInfo();
appLoginService.logout(customToken.getAccessToken());
appLoginService.logout();
return EResponse.ok();
}
......@@ -198,8 +241,7 @@ public class DriverAccountController {
@PostMapping("/token/refresh")
public EResponse refresh(@RequestBody(required=false) @Validated(ValidatorInsert.class) RefreshTokenForm refreshTokenForm) {
CustomToken customToken = ReqUtils.getTokenInfo();
LoginVO loginByPwdVO = appLoginService.refreshToken(customToken.getAccessToken(), refreshTokenForm);
LoginVO loginByPwdVO = appLoginService.refreshToken(refreshTokenForm);
return EResponse.ok(loginByPwdVO);
}
......@@ -212,8 +254,9 @@ public class DriverAccountController {
**/
@PostMapping("/detail")
public EResponse detail() {
appLoginService.checkAccessToken();
String phone = ReqUtils.getTokenInfo().getAccount();
TokenInfoPojo tokenInfoPojo = tokenComponent.getTokenInfo();
String phone = tokenInfoPojo.getAccount();
// 调用获取账号详情接口
JSONObject reqJsonDetail = new JSONObject();
......@@ -271,7 +314,6 @@ public class DriverAccountController {
**/
@PostMapping("/realNameAuth")
public EResponse realNameAuth(@RequestBody(required=false) @Validated(ValidatorUpdate.class) DriverAuthForm driverAuthForm) {
appLoginService.checkAccessToken();
// 调用编辑帐号信息接口
JSONObject reqJson = new JSONObject();
......@@ -284,6 +326,8 @@ public class DriverAccountController {
reqJson.put("districtCode", driverAuthForm.getDistrictCode());
reqJson.put("detailAddress", driverAuthForm.getDetailAddress());
reqJson.put("settlementType", driverAuthForm.getSettlementType());
reqJson.put("sex", driverAuthForm.getSex());
reqJson.put("birthDate", driverAuthForm.getBirthDate());
reqJson.put("drivingLicense", driverAuthForm.getDrivingLicense());
reqJson.put("drivingLicenseType", driverAuthForm.getDrivingLicenseType());
reqJson.put("drivingLicenseStartDate", driverAuthForm.getDrivingLicenseStartDate());
......@@ -350,7 +394,7 @@ public class DriverAccountController {
@PostMapping("/stop")
public EResponse stopUsingAccount(@RequestBody(required=false) @Validated(ValidatorAccountExist.class) LoginForm loginForm) {
appLoginService.stopUsing(loginForm.getPhone());
appLoginService.stopUsing(loginForm.getPhone(), AccountConstants.ACCOUNT_TYPE_DRIVER);
return EResponse.ok();
}
}
package com.esv.freight.app.module.account.controller;
import com.alibaba.fastjson.JSONObject;
import com.esv.freight.app.common.component.TokenComponent;
import com.esv.freight.app.common.response.ECode;
import com.esv.freight.app.common.response.EResponse;
import com.esv.freight.app.common.util.ReqUtils;
......@@ -10,6 +11,7 @@ import com.esv.freight.app.feign.DriverInterface;
import com.esv.freight.app.feign.NoticeInterface;
import com.esv.freight.app.module.account.form.LoginForm;
import com.esv.freight.app.module.account.form.ModifyPasswordForm;
import com.esv.freight.app.module.account.pojo.TokenInfoPojo;
import com.esv.freight.app.module.account.service.AppLoginService;
import com.esv.freight.app.module.account.validator.groups.ValidatorResetPwd;
import lombok.extern.slf4j.Slf4j;
......@@ -33,14 +35,14 @@ import org.springframework.web.bind.annotation.*;
public class DriverPasswordController {
private NoticeInterface noticeInterface;
private AppLoginService appLoginService;
private DriverInterface driverInterface;
private TokenComponent tokenComponent;
@Autowired
public DriverPasswordController(DriverInterface driverInterface, NoticeInterface noticeInterface, AppLoginService appLoginService) {
public DriverPasswordController(DriverInterface driverInterface, NoticeInterface noticeInterface, TokenComponent tokenComponent) {
this.noticeInterface = noticeInterface;
this.appLoginService = appLoginService;
this.driverInterface = driverInterface;
this.tokenComponent = tokenComponent;
}
/**
......@@ -108,9 +110,8 @@ public class DriverPasswordController {
@PostMapping("/edit")
public EResponse edit(@RequestBody(required=false) @Validated(ValidatorInsert.class) ModifyPasswordForm modifyPasswordFrom) {
appLoginService.checkAccessToken();
String phone = ReqUtils.getTokenInfo().getAccount();
TokenInfoPojo tokenInfoPojo = tokenComponent.getTokenInfo();
String phone = tokenInfoPojo.getAccount();
// 调用帐号密码校验接口
JSONObject reqJson = new JSONObject();
......
package com.esv.freight.app.module.account.controller;
import com.alibaba.fastjson.JSONObject;
import com.esv.freight.app.common.component.TokenComponent;
import com.esv.freight.app.common.constants.AccountConstants;
import com.esv.freight.app.common.util.FeignUtils;
import com.esv.freight.app.common.util.ReqUtils;
import com.esv.freight.app.common.validator.groups.ValidatorUpdate;
import com.esv.freight.app.feign.GoodsOwnerInterface;
import com.esv.freight.app.feign.NoticeInterface;
import com.esv.freight.app.module.account.CustomToken;
import com.esv.freight.app.module.account.form.*;
import com.esv.freight.app.module.account.pojo.OwnerAccountInfoPojo;
import com.esv.freight.app.module.account.pojo.TokenInfoPojo;
import com.esv.freight.app.module.account.service.AppLoginService;
import com.esv.freight.app.module.account.validator.groups.ValidatorAccountExist;
import com.esv.freight.app.module.account.validator.groups.ValidatorLoginByPwd;
......@@ -39,12 +44,14 @@ public class OwnerAccountController {
private GoodsOwnerInterface goodsOwnerInterface;
private NoticeInterface noticeInterface;
private AppLoginService appLoginService;
private TokenComponent tokenComponent;
@Autowired
public OwnerAccountController(GoodsOwnerInterface goodsOwnerInterface, NoticeInterface noticeInterface, AppLoginService appLoginService) {
public OwnerAccountController(TokenComponent tokenComponent, GoodsOwnerInterface goodsOwnerInterface, NoticeInterface noticeInterface, AppLoginService appLoginService) {
this.goodsOwnerInterface = goodsOwnerInterface;
this.noticeInterface = noticeInterface;
this.appLoginService = appLoginService;
this.tokenComponent = tokenComponent;
}
/**
......@@ -62,24 +69,67 @@ public class OwnerAccountController {
reqJson.put("phone", loginForm.getPhone());
reqJson.put("type", "login");
reqJson.put("captcha", loginForm.getSmsCode());
JSONObject resultCheck = noticeInterface.checkSmsCaptcha(reqJson);
JSONObject result;
try {
result = noticeInterface.checkSmsCaptcha(reqJson);
} catch (Exception e) {
log.error("Feign请求时发生错误:" + e.getMessage(), e);
return EResponse.error();
}
if(!FeignUtils.isFeignSuccess(result)) {
return FeignUtils.getFeignEResponse(result);
}
if(resultCheck.getInteger("code") != 200) {
return EResponse.error(resultCheck.getInteger("code"), resultCheck.getString("message"));
// 2:查询货主详情(通过帐号)
reqJson.clear();
reqJson.put("account", loginForm.getPhone());
try {
result = goodsOwnerInterface.getAccountDetail(reqJson);
} catch (Exception e) {
log.error("Feign请求时发生错误:" + e.getMessage(), e);
return EResponse.error();
}
// 3:表示账号未注册
if(result.getInteger("code") == 1002) {
// 调用注册帐号接口
reqJson.clear();
reqJson.put("account", loginForm.getPhone());
JSONObject resultRegister = goodsOwnerInterface.accountRegister(reqJson);
try {
result = goodsOwnerInterface.accountRegister(reqJson);
} catch (Exception e) {
log.error("Feign请求时发生错误:" + e.getMessage(), e);
return EResponse.error();
}
// 1001表示 帐号已存在
if(resultRegister.getInteger("code") != 200 && resultRegister.getInteger("code") != 1001) {
return EResponse.error(resultRegister.getInteger("code"), resultRegister.getString("message"));
if(!FeignUtils.isFeignSuccess(result)) {
return FeignUtils.getFeignEResponse(result);
}
LoginVO loginByPwdVO = appLoginService.login(loginForm.getPhone());
return EResponse.ok(loginByPwdVO);
OwnerAccountInfoPojo pojo = new OwnerAccountInfoPojo();
pojo.setId(result.getJSONObject("data").getLong("id"));
pojo.setAccount(loginForm.getPhone());
pojo.setLoginMode(AccountConstants.ACCOUNT_LOGIN_MODE_SMS);
LoginVO vo = appLoginService.ownerLogin(pojo);
return EResponse.ok(vo);
}
if(!FeignUtils.isFeignSuccess(result)) {
return FeignUtils.getFeignEResponse(result);
}
// 校验帐号状态:1-正常、2-停用
OwnerAccountInfoPojo ownerAccountInfoPojo = JSONObject.toJavaObject(FeignUtils.getFeignDataJson(result), OwnerAccountInfoPojo.class);
if (AccountConstants.ACCOUNT_STATUS_BLOCK.equals(ownerAccountInfoPojo.getAccountStatus())) {
return EResponse.error(1003, "帐号已停用");
}
// 登录
ownerAccountInfoPojo.setLoginMode(AccountConstants.ACCOUNT_LOGIN_MODE_SMS);
LoginVO vo = appLoginService.ownerLogin(ownerAccountInfoPojo);
return EResponse.ok(vo);
}
/**
......@@ -92,18 +142,33 @@ public class OwnerAccountController {
@PostMapping("/login/loginByPwd")
public EResponse loginByPwd(@RequestBody(required=false) @Validated(ValidatorLoginByPwd.class) LoginForm loginForm) {
// 调用帐号密码校验接口
// 1:调用帐号密码校验接口
JSONObject reqJson = new JSONObject();
reqJson.put("account", loginForm.getPhone());
reqJson.put("password", loginForm.getPwd());
JSONObject result = goodsOwnerInterface.checkAccountPwd(reqJson);
JSONObject result;
try {
result = goodsOwnerInterface.checkAccountPwd(reqJson);
} catch (Exception e) {
log.error("Feign请求时发生错误:" + e.getMessage(), e);
return EResponse.error();
}
if(result.getInteger("code") != 200) {
return EResponse.error(result.getInteger("code"), result.getString("message"));
if(!FeignUtils.isFeignSuccess(result)) {
return FeignUtils.getFeignEResponse(result);
}
LoginVO loginByPwdVO = appLoginService.login(loginForm.getPhone());
return EResponse.ok(loginByPwdVO);
// 2:校验帐号状态:1-正常、2-停用
OwnerAccountInfoPojo ownerAccountInfoPojo= JSONObject.toJavaObject(FeignUtils.getFeignDataJson(result), OwnerAccountInfoPojo.class);
if (AccountConstants.ACCOUNT_STATUS_BLOCK.equals(ownerAccountInfoPojo.getAccountStatus())) {
return EResponse.error(1003, "帐号已停用");
}
// 登录
ownerAccountInfoPojo.setLoginMode(AccountConstants.ACCOUNT_LOGIN_MODE_PWD);
LoginVO vo = appLoginService.ownerLogin(ownerAccountInfoPojo);
return EResponse.ok(vo);
}
/**
......@@ -115,8 +180,7 @@ public class OwnerAccountController {
**/
@PostMapping("/logout")
public EResponse logout() {
CustomToken customToken = ReqUtils.getTokenInfo();
appLoginService.logout(customToken.getAccessToken());
appLoginService.logout();
return EResponse.ok();
}
......@@ -130,8 +194,7 @@ public class OwnerAccountController {
@PostMapping("/token/refresh")
public EResponse refresh(@RequestBody(required=false) @Validated(ValidatorInsert.class) RefreshTokenForm refreshTokenForm) {
CustomToken customToken = ReqUtils.getTokenInfo();
LoginVO loginByPwdVO = appLoginService.refreshToken(customToken.getAccessToken(), refreshTokenForm);
LoginVO loginByPwdVO = appLoginService.refreshToken(refreshTokenForm);
return EResponse.ok(loginByPwdVO);
}
......@@ -144,9 +207,9 @@ public class OwnerAccountController {
**/
@PostMapping("/detail")
public EResponse detail() {
appLoginService.checkAccessToken();
String phone = ReqUtils.getTokenInfo().getAccount();
TokenInfoPojo tokenInfoPojo = tokenComponent.getTokenInfo();
String phone = tokenInfoPojo.getAccount();
// 调用获取账号详情接口
JSONObject reqJsonDetail = new JSONObject();
......@@ -195,8 +258,6 @@ public class OwnerAccountController {
@PostMapping("/realNameAuth")
public EResponse realNameAuth(@RequestBody(required=false) @Validated(ValidatorUpdate.class) OwnerAuthForm ownerAuthForm) {
appLoginService.checkAccessToken();
// 调用编辑帐号信息接口
JSONObject reqJson = new JSONObject();
reqJson.put("id", ownerAuthForm.getId());
......@@ -242,7 +303,7 @@ public class OwnerAccountController {
@PostMapping("/stop")
public EResponse stopUsingAccount(@RequestBody(required=false) @Validated(ValidatorAccountExist.class) LoginForm loginForm) {
appLoginService.stopUsing(loginForm.getPhone());
appLoginService.stopUsing(loginForm.getPhone(), AccountConstants.ACCOUNT_TYPE_GOODS_OWNER);
return EResponse.ok();
}
}
\ No newline at end of file
package com.esv.freight.app.module.account.controller;
import com.alibaba.fastjson.JSONObject;
import com.esv.freight.app.common.component.TokenComponent;
import com.esv.freight.app.common.response.ECode;
import com.esv.freight.app.common.util.ReqUtils;
import com.esv.freight.app.feign.GoodsOwnerInterface;
import com.esv.freight.app.feign.NoticeInterface;
import com.esv.freight.app.module.account.form.LoginForm;
import com.esv.freight.app.module.account.form.ModifyPasswordForm;
import com.esv.freight.app.module.account.pojo.TokenInfoPojo;
import com.esv.freight.app.module.account.service.AppLoginService;
import com.esv.freight.app.common.response.EResponse;
import com.esv.freight.app.common.validator.groups.ValidatorInsert;
......@@ -32,14 +34,14 @@ import org.springframework.web.bind.annotation.*;
public class OwnerPasswordController {
private NoticeInterface noticeInterface;
private AppLoginService appLoginService;
private GoodsOwnerInterface goodsOwnerInterface;
private TokenComponent tokenComponent;
@Autowired
public OwnerPasswordController(GoodsOwnerInterface goodsOwnerInterface, NoticeInterface noticeInterface, AppLoginService appLoginService) {
public OwnerPasswordController(GoodsOwnerInterface goodsOwnerInterface, NoticeInterface noticeInterface, AppLoginService appLoginService, TokenComponent tokenComponent) {
this.noticeInterface = noticeInterface;
this.appLoginService = appLoginService;
this.goodsOwnerInterface = goodsOwnerInterface;
this.tokenComponent = tokenComponent;
}
/**
......@@ -108,9 +110,8 @@ public class OwnerPasswordController {
@PostMapping("/edit")
public EResponse edit(@RequestBody(required=false) @Validated(ValidatorInsert.class) ModifyPasswordForm modifyPasswordFrom) {
appLoginService.checkAccessToken();
String phone = ReqUtils.getTokenInfo().getAccount();
TokenInfoPojo tokenInfoPojo = tokenComponent.getTokenInfo();
String phone = tokenInfoPojo.getAccount();
// 调用帐号密码校验接口
JSONObject reqJson = new JSONObject();
......
......@@ -83,6 +83,19 @@ public class DriverAuthForm {
@NotNull(message = "参数settlementType不能为空", groups = {ValidatorUpdate.class})
private Integer settlementType;
/**
* 性别(字典表):1-男、2-女、3-未知
*/
@Range(min = 1, max = 3, message = "参数sex不合法", groups = {ValidatorUpdate.class})
@NotNull(message = "参数sex不能为空", groups = {ValidatorUpdate.class})
private Integer sex;
/**
* 出生日期
*/
@Length(max = 20, message = "参数birthDate长度不合法", groups = {ValidatorUpdate.class})
private String birthDate;
/**
* 驾驶证号码
*/
......
package com.esv.freight.app.module.account.pojo;
import lombok.Data;
import org.apache.commons.lang3.builder.ToStringBuilder;
import org.apache.commons.lang3.builder.ToStringStyle;
/**
* @description:
* @project: app-service
* @name: com.esv.freight.app.module.account.pojo.OwnerAccountInfoPojo
* @author: 张志臣
* @email: zhangzhichen@esvtek.com
* @createTime: 2020/05/15 9:00
* @version:1.0
*/
@Data
public class OwnerAccountInfoPojo {
/**
*
*/
private Long id;
/**
* 登录帐号,货主手机号
*/
private String account;
/**
* 创建来源:1-平台创建、2-自行注册
*/
private Integer sourceType;
/**
* 帐号状态:1-正常、2-停用
*/
private Integer accountStatus;
/**
* 货主帐号审核状态:0-待审核、1-审核成功,2-审核失败,APP自行注册需要平台审核
*/
private Integer auditStatus;
/**
* 货主类型:1-个人、2-企业
*/
private Integer ownerType;
/**
* 客户编码
*/
private String ownerNumber;
/**
* 客户名称
*/
private String ownerFullName;
/**
* 客户简称
*/
private String ownerBriefName;
/**
* 统一社会信用代码
*/
private String uniCreditCode;
/**
* 营业期限
*/
private String creditExpireDate;
/**
* 营业执照正本ULR
*/
private String creditOriginalUrl;
/**
* 营业执照副本ULR
*/
private String creditCopyUrl;
/**
* 企业法人姓名
*/
private String legalPerson;
/**
* 企业法人手机号
*/
private String legalPhone;
/**
* 省份代码
*/
private String provinceCode;
/**
* 市代码
*/
private String cityCode;
/**
* 区县代码
*/
private String districtCode;
/**
* 详细地址
*/
private String detailAddress;
/**
* (个人或企业)联系人
*/
private String contactor;
/**
* (个人或企业)身份证号码
*/
private String idCard;
/**
* (个人或企业)身份证有效期
*/
private String idCardExpireDate;
/**
* 身份证正面图片URL
*/
private String idCardFrontUrl;
/**
* 身份证背面图片URL
*/
private String idCardBackUrl;
/**
* 帐号登录方式:1-帐号密码登录、2-短信验证码登录
*/
private Integer loginMode;
@Override
public String toString() {
return ToStringBuilder.reflectionToString(this, ToStringStyle.JSON_STYLE);
}
}
......@@ -4,6 +4,7 @@ import com.baomidou.mybatisplus.extension.service.IService;
import com.esv.freight.app.module.account.entity.AppLoginEntity;
import com.esv.freight.app.module.account.form.RefreshTokenForm;
import com.esv.freight.app.module.account.pojo.DriverAccountInfoPojo;
import com.esv.freight.app.module.account.pojo.OwnerAccountInfoPojo;
import com.esv.freight.app.module.account.pojo.TokenInfoPojo;
import com.esv.freight.app.module.account.vo.LoginVO;
......@@ -16,15 +17,6 @@ import com.esv.freight.app.module.account.vo.LoginVO;
*/
public interface AppLoginService extends IService<AppLoginEntity> {
/**
* description 账号登录
* param [phone]
* return LoginVO
* author 张志臣
* createTime 2020/04/13 16:48
**/
LoginVO login(String phone);
/**
* description 司机帐号登录
* param [driverDetailInfoPojo]
......@@ -34,6 +26,15 @@ public interface AppLoginService extends IService<AppLoginEntity> {
**/
LoginVO driverLogin(DriverAccountInfoPojo driverAccountInfoPojo);
/**
* description 货主帐号登录
* param [ownerAccountInfoPojo]
* return com.esv.freight.app.module.account.vo.LoginVO
* author Administrator
* createTime 2020/05/14 13:17
**/
LoginVO ownerLogin(OwnerAccountInfoPojo ownerAccountInfoPojo);
/**
* description 账号登出
* param [accessToken]
......@@ -41,7 +42,7 @@ public interface AppLoginService extends IService<AppLoginEntity> {
* author 张志臣
* createTime 2020/04/13 16:48
**/
void logout(String accessToken);
void logout();
/**
* description 账号停用
......@@ -50,7 +51,7 @@ public interface AppLoginService extends IService<AppLoginEntity> {
* author 张志臣
* createTime 2020/05/06 16:48
**/
void stopUsing(String phone);
void stopUsing(String phone, Integer type);
/**
* description 刷新token
......@@ -59,25 +60,8 @@ public interface AppLoginService extends IService<AppLoginEntity> {
* author 张志臣
* createTime 2020/04/13 16:48
**/
LoginVO refreshToken(String accessToken, RefreshTokenForm refreshTokenForm);
LoginVO refreshToken(RefreshTokenForm refreshTokenForm);
/**
* description 判断accessToken是否有效
* param [accessToken]
* return java.lang.Long
* author 张志臣
* createTime 2020/04/13 16:48
**/
void checkAccessToken();
/**
* description 判断refreshToken是否有效
* param [refreshToken]
* return java.lang.Long
* author 张志臣
* createTime 2020/04/13 16:48
**/
boolean isInvalidRefreshToken(String refreshToken);
/**
* description 获取AppLoginEntity
* param [phone]
......
......@@ -54,8 +54,6 @@ public class DeliveryAddressController {
@PostMapping("/list")
public EResponse list(@RequestBody(required=false) @Validated(ValidatorList.class) AddressQueryForm addressQueryForm) {
appLoginService.checkAccessToken();
// 调用获取货主发货地址列表接口
JSONObject reqJson = new JSONObject();
reqJson.put("ownerId", addressQueryForm.getOwnerId());
......@@ -94,8 +92,6 @@ public class DeliveryAddressController {
@PostMapping("/add")
public EResponse add(@RequestBody(required=false) @Validated(ValidatorInsert.class) DeliveryAddressForm deliveryAddressForm) {
appLoginService.checkAccessToken();
// 调用添加货主发货地址接口
JSONObject reqJson = new JSONObject();
reqJson.put("ownerId", deliveryAddressForm.getOwnerId());
......@@ -127,8 +123,6 @@ public class DeliveryAddressController {
@PostMapping("/edit")
public EResponse edit(@RequestBody(required=false) @Validated(ValidatorUpdate.class) DeliveryAddressForm deliveryAddressForm) {
appLoginService.checkAccessToken();
// 调用编辑货主发货地址接口
JSONObject reqJson = new JSONObject();
reqJson.put("id", deliveryAddressForm.getId());
......@@ -159,8 +153,6 @@ public class DeliveryAddressController {
@PostMapping("/delete")
public EResponse delete(@RequestBody(required=false) @Validated(ValidatorDelete.class) AddressQueryForm addressQueryForm) {
appLoginService.checkAccessToken();
// 调用获取删除货主发货地址接口
JSONObject reqJson = new JSONObject();
reqJson.put("id", addressQueryForm.getId());
......@@ -183,8 +175,6 @@ public class DeliveryAddressController {
@PostMapping("/detail")
public EResponse detail(@RequestBody(required=false) @Validated(ValidatorDetail.class) DeliveryAddressForm deliveryAddressForm) {
appLoginService.checkAccessToken();
// 调用获取发货地址详情接口
JSONObject reqJson = new JSONObject();
reqJson.put("id", deliveryAddressForm.getId());
......
......@@ -56,8 +56,6 @@ public class ReceiveAddressController {
@PostMapping("/list")
public EResponse list(@RequestBody(required=false) @Validated(ValidatorList.class) AddressQueryForm addressQueryForm) {
appLoginService.checkAccessToken();
// 调用获取货主发货地址列表接口
JSONObject reqJson = new JSONObject();
reqJson.put("ownerId", addressQueryForm.getOwnerId());
......@@ -96,8 +94,6 @@ public class ReceiveAddressController {
@PostMapping("/add")
public EResponse add(@RequestBody(required=false) @Validated(ValidatorInsert.class) ReceiveAddressForm receiveAddressForm) {
appLoginService.checkAccessToken();
// 调用添加货主发货地址接口
JSONObject reqJson = new JSONObject();
reqJson.put("ownerId", receiveAddressForm.getOwnerId());
......@@ -129,8 +125,6 @@ public class ReceiveAddressController {
@PostMapping("/edit")
public EResponse edit(@RequestBody(required=false) @Validated(ValidatorInsert.class) ReceiveAddressForm receiveAddressForm) {
appLoginService.checkAccessToken();
// 调用编辑货主发货地址接口
JSONObject reqJson = new JSONObject();
reqJson.put("id", receiveAddressForm.getId());
......@@ -161,8 +155,6 @@ public class ReceiveAddressController {
@PostMapping("/delete")
public EResponse delete(@RequestBody(required=false) @Validated(ValidatorInsert.class) AddressQueryForm addressQueryForm) {
appLoginService.checkAccessToken();
// 调用获取删除货主发货地址接口
JSONObject reqJson = new JSONObject();
reqJson.put("id", addressQueryForm.getId());
......@@ -185,8 +177,6 @@ public class ReceiveAddressController {
@PostMapping("/detail")
public EResponse detail(@RequestBody(required=false) @Validated(ValidatorDetail.class) ReceiveAddressForm receiveAddressForm) {
appLoginService.checkAccessToken();
// 调用获取发货地址详情接口
JSONObject reqJson = new JSONObject();
reqJson.put("id", receiveAddressForm.getId());
......
......@@ -58,8 +58,6 @@ public class GrabController {
@PostMapping("/find/list")
public EResponse getFindGoodsList(@RequestBody(required=false) @Validated(ValidatorList.class) OrderGrabbingQueryForm orderGrabbingQueryForm) {
// appLoginService.checkAccessToken();
// 调用查询抢单信息列表接口
JSONObject reqJson = new JSONObject();
if(orderGrabbingQueryForm.getDriverId() != null) {
......@@ -153,8 +151,6 @@ public class GrabController {
@PostMapping("/find/grab")
public EResponse grabOrder(@RequestBody(required=false) @Validated(ValidatorInsert.class) OrderGrabbingForm orderGrabbingForm) {
appLoginService.checkAccessToken();
// 调用抢单接口
JSONObject reqJson = new JSONObject();
reqJson.put("orderGrabbingId", orderGrabbingForm.getOrderGrabbingId());
......
......@@ -59,8 +59,6 @@ public class OrderController {
@PostMapping("/statistics/getCountByType")
public EResponse getCountByType() {
appLoginService.checkAccessToken();
// 调用货主查询不同状态的订单数接口
JSONObject result = tmsInterface.getOrderCount();
log.info(result.toJSONString());
......@@ -89,8 +87,6 @@ public class OrderController {
@PostMapping("/list")
public EResponse list(@RequestBody(required=false) @Validated(ValidatorList.class) OrderQueryForm orderQueryForm) {
appLoginService.checkAccessToken();
// 调用订单列表分页查询接口
JSONObject reqJson = new JSONObject();
reqJson.put("goodsOwnerId", orderQueryForm.getGoodsOwnerId());
......@@ -156,8 +152,6 @@ public class OrderController {
@PostMapping("/add")
public EResponse add(@RequestBody(required=false) @Validated(ValidatorInsert.class) OrderForm orderForm) {
appLoginService.checkAccessToken();
// 调用订单新增接口
JSONObject reqJson = new JSONObject();
reqJson.put("goodsOwnerId", orderForm.getGoodsOwnerId());
......@@ -199,8 +193,6 @@ public class OrderController {
@PostMapping("/cancel")
public EResponse cancel(@RequestBody(required=false) @Validated(ValidatorDetail.class) OrderQueryForm orderQueryForm) {
appLoginService.checkAccessToken();
// 调用取消订单接口
JSONObject reqJson = new JSONObject();
reqJson.put("orderId", orderQueryForm.getId());
......@@ -225,8 +217,6 @@ public class OrderController {
@PostMapping("/detail")
public EResponse detail(@RequestBody(required=false) @Validated(ValidatorDetail.class) OrderQueryForm orderQueryForm) {
appLoginService.checkAccessToken();
// 调用获取订单详情接口
JSONObject reqJson = new JSONObject();
reqJson.put("orderId", orderQueryForm.getId());
......@@ -291,8 +281,6 @@ public class OrderController {
@PostMapping("/edit")
public EResponse edit(@RequestBody(required=false) @Validated(ValidatorUpdate.class) OrderForm orderForm) {
appLoginService.checkAccessToken();
// 调用编辑订单接口
JSONObject reqJson = new JSONObject();
reqJson.put("id", orderForm.getId());
......
......@@ -60,8 +60,6 @@ public class VehicleController {
@PostMapping("/add")
public EResponse add(@RequestBody(required=false) @Validated(ValidatorInsert.class) VehicleForm vehicleForm) {
appLoginService.checkAccessToken();
// 调用新增车辆接口
JSONObject reqJson = new JSONObject();
reqJson.put("carrierId", vehicleForm.getCarrierId());
......@@ -123,7 +121,6 @@ public class VehicleController {
**/
@PostMapping("/edit")
public EResponse edit(@RequestBody(required=false) @Validated(ValidatorUpdate.class) VehicleForm vehicleForm) {
appLoginService.checkAccessToken();
// 调用编辑车辆接口
JSONObject reqJson = new JSONObject();
......@@ -186,7 +183,6 @@ public class VehicleController {
**/
@PostMapping("/detail")
public EResponse detail(@RequestBody(required=false) @Validated(ValidatorUpdate.class) VehicleQueryForm vehicleQueryForm) {
appLoginService.checkAccessToken();
// 调用获取订单详情接口
JSONObject reqJson = new JSONObject();
......@@ -258,7 +254,6 @@ public class VehicleController {
**/
@PostMapping("/list")
public EResponse list(@RequestBody(required=false) @Validated(ValidatorDetail.class) VehicleQueryForm vehicleQueryForm) {
appLoginService.checkAccessToken();
// 调用获取司机的车辆列表接口
JSONObject reqJson = new JSONObject();
......
......@@ -61,8 +61,6 @@ public class DriverWaybillController {
@PostMapping("/list")
public EResponse list(@RequestBody(required=false) @Validated(ValidatorList.class) WaybillQueryForm waybillQueryForm) {
appLoginService.checkAccessToken();
// 调用运单列表分页查询接口
JSONObject reqJson = new JSONObject();
reqJson.put("driverId", waybillQueryForm.getUserId());
......@@ -143,8 +141,6 @@ public class DriverWaybillController {
@PostMapping("/detail")
public EResponse detail(@RequestBody(required=false) @Validated(ValidatorDetail.class) WaybillQueryForm waybillQueryForm) {
appLoginService.checkAccessToken();
// 调用获取运单详情接口
JSONObject reqJson = new JSONObject();
reqJson.put("id", waybillQueryForm.getWaybillId());
......@@ -195,8 +191,6 @@ public class DriverWaybillController {
@PostMapping("/delivery/upload")
public EResponse uploadDeliveryEvidence(@RequestBody(required=false) @Validated(ValidatorInsert.class) UploadEvidenceForm uploadEvidenceForm) {
appLoginService.checkAccessToken();
// 调用上传发货单据接口
JSONObject reqJson = new JSONObject();
reqJson.put("waybillId", uploadEvidenceForm.getWaybillId());
......@@ -235,8 +229,6 @@ public class DriverWaybillController {
@PostMapping("/receive/upload")
public EResponse uploadReceiveEvidence(@RequestBody(required=false) @Validated(ValidatorInsert.class) UploadEvidenceForm uploadEvidenceForm) {
appLoginService.checkAccessToken();
// 调用上传发货单据接口
JSONObject reqJson = new JSONObject();
reqJson.put("waybillId", uploadEvidenceForm.getWaybillId());
......@@ -275,8 +267,6 @@ public class DriverWaybillController {
@PostMapping("/list/multi/condition")
public EResponse condition(@RequestBody(required=false) @Validated(ValidatorList.class) WaybillMultiQueryForm waybillMultiQueryForm) {
appLoginService.checkAccessToken();
// 调用运单列表分页查询接口
JSONObject reqJson = new JSONObject();
reqJson.put("condition", waybillMultiQueryForm.getCondition());
......
......@@ -61,8 +61,6 @@ public class OwnerWaybillController {
@PostMapping("/list")
public EResponse list(@RequestBody(required=false) @Validated(ValidatorList.class) WaybillQueryForm waybillQueryForm) {
appLoginService.checkAccessToken();
// 调用运单列表分页查询接口
JSONObject reqJson = new JSONObject();
reqJson.put("goodsOwnerId", waybillQueryForm.getUserId());
......@@ -146,8 +144,6 @@ public class OwnerWaybillController {
@PostMapping("/sign")
public EResponse sign(@RequestBody(required=false) @Validated(ValidatorDetail.class) WaybillQueryForm waybillQueryForm) {
appLoginService.checkAccessToken();
// 调用上传发货单据接口
JSONObject reqJson = new JSONObject();
reqJson.put("id", waybillQueryForm.getWaybillId());
......@@ -172,8 +168,6 @@ public class OwnerWaybillController {
@PostMapping("/list/multi/condition")
public EResponse condition(@RequestBody(required=false) @Validated(ValidatorList.class) WaybillMultiQueryForm waybillMultiQueryForm) {
appLoginService.checkAccessToken();
// 调用运单列表分页查询接口
JSONObject reqJson = new JSONObject();
reqJson.put("condition", waybillMultiQueryForm.getCondition());
......
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