Commit 6e0c1a2c authored by zhangzc's avatar zhangzc

修改token校验

parent 09c37a12
...@@ -32,6 +32,7 @@ public class ProtocolComponent { ...@@ -32,6 +32,7 @@ public class ProtocolComponent {
* map.put("mobileId", mobileId); // 手机唯一标识 * map.put("mobileId", mobileId); // 手机唯一标识
* map.put("cVer", cVer); // 客户端版本 * map.put("cVer", cVer); // 客户端版本
* map.put("accountType", "1"); // 帐号身份类型:1-司机、2-货主 * map.put("accountType", "1"); // 帐号身份类型:1-司机、2-货主
* map.put("tenantId", "1"); // 租户ID:1-司机、2-货主
* param [request] * param [request]
* return void * return void
* author Administrator * author Administrator
...@@ -54,6 +55,9 @@ public class ProtocolComponent { ...@@ -54,6 +55,9 @@ public class ProtocolComponent {
if (StringUtils.isBlank(request.getHeader("cVer"))) { if (StringUtils.isBlank(request.getHeader("cVer"))) {
throw new EException(ECode.PROTOCOL_ILLEGAL.code(), "请求头[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")) if (!String.valueOf(AccountConstants.ACCOUNT_TYPE_DRIVER).equals(request.getHeader("accountType"))
&& !String.valueOf(AccountConstants.ACCOUNT_TYPE_GOODS_OWNER).equals(request.getHeader("accountType"))) { && !String.valueOf(AccountConstants.ACCOUNT_TYPE_GOODS_OWNER).equals(request.getHeader("accountType"))) {
throw new EException(ECode.PROTOCOL_ILLEGAL.code(), "请求头[accountType]不符合协议"); throw new EException(ECode.PROTOCOL_ILLEGAL.code(), "请求头[accountType]不符合协议");
......
...@@ -85,7 +85,13 @@ public class RedisComponent { ...@@ -85,7 +85,13 @@ public class RedisComponent {
public void del(String... key) { public void del(String... key) {
if (key != null && key.length > 0) { if (key != null && key.length > 0) {
if (key.length == 1) { 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 { } else {
redisTemplate.delete(CollectionUtils.arrayToList(key)); redisTemplate.delete(CollectionUtils.arrayToList(key));
} }
......
...@@ -6,6 +6,7 @@ import com.esv.freight.app.common.constants.AccountConstants; ...@@ -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.exception.EException;
import com.esv.freight.app.common.response.ECode; import com.esv.freight.app.common.response.ECode;
import com.esv.freight.app.common.util.AESSecretUtils; 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.DateUtils;
import com.esv.freight.app.common.util.ReqUtils; import com.esv.freight.app.common.util.ReqUtils;
import com.esv.freight.app.module.account.entity.AppLoginEntity; import com.esv.freight.app.module.account.entity.AppLoginEntity;
...@@ -36,7 +37,8 @@ public class TokenComponent { ...@@ -36,7 +37,8 @@ public class TokenComponent {
@Value("${spring.application.name}") @Value("${spring.application.name}")
private String applicationName; private String applicationName;
@Value("${aes.sha1prng.key:freight-app-service-001}") // 为了和终端加密/解密统一,密码长度控制为16位
@Value("${aes.sha1prng.key:ADGJLPIYRE24680A}")
private String AES_KEY; private String AES_KEY;
/** /**
...@@ -75,9 +77,9 @@ public class TokenComponent { ...@@ -75,9 +77,9 @@ public class TokenComponent {
tokenInfoPojo.setOsVersion(ReqUtils.getRequestHeader("osVer")); tokenInfoPojo.setOsVersion(ReqUtils.getRequestHeader("osVer"));
tokenInfoPojo.setAppVersion(ReqUtils.getRequestHeader("cVer")); tokenInfoPojo.setAppVersion(ReqUtils.getRequestHeader("cVer"));
tokenInfoPojo.setAccountType(Integer.parseInt(ReqUtils.getRequestHeader("accountType"))); 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); tokenInfoPojo.setAccessToken(accessToken);
String refreshToken = AESSecretUtils.encryptToStr(this.getRefreshTokenOriginalContent(tokenInfoPojo), AES_KEY); String refreshToken = AesUtils.aesEncrypt(this.getRefreshTokenOriginalContent(tokenInfoPojo), AES_KEY);
tokenInfoPojo.setRefreshToken(refreshToken); tokenInfoPojo.setRefreshToken(refreshToken);
Date loginTime = new Date(); Date loginTime = new Date();
tokenInfoPojo.setLoginTime(loginTime.getTime()); tokenInfoPojo.setLoginTime(loginTime.getTime());
...@@ -112,6 +114,16 @@ public class TokenComponent { ...@@ -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信息 * description 获取Token信息
* param [accessToken] * param [accessToken]
...@@ -124,7 +136,7 @@ public class TokenComponent { ...@@ -124,7 +136,7 @@ public class TokenComponent {
return null; return null;
} }
// 解密Token并基础校验 // 解密Token并基础校验
String decryptToken = AESSecretUtils.decryptToStr(accessToken, AES_KEY); String decryptToken = AesUtils.aesDecrypt(accessToken, AES_KEY);
if (StringUtils.isBlank(decryptToken)) { if (StringUtils.isBlank(decryptToken)) {
return null; return null;
} }
...@@ -159,12 +171,20 @@ public class TokenComponent { ...@@ -159,12 +171,20 @@ public class TokenComponent {
if (null != appLoginEntity) { if (null != appLoginEntity) {
tokenInfoPojo = new TokenInfoPojo(); tokenInfoPojo = new TokenInfoPojo();
BeanUtils.copyProperties(appLoginEntity, tokenInfoPojo); BeanUtils.copyProperties(appLoginEntity, tokenInfoPojo);
tokenInfoPojo.setAccountId(appLoginEntity.getId()); try {
tokenInfoPojo.setAccount(appLoginEntity.getPhone()); tokenInfoPojo.setAccountId(appLoginEntity.getId());
tokenInfoPojo.setLoginTime(appLoginEntity.getLoginTime().getTime()); tokenInfoPojo.setAccount(appLoginEntity.getPhone());
tokenInfoPojo.setRefreshTime(appLoginEntity.getRefreshTime().getTime()); tokenInfoPojo.setLoginTime(appLoginEntity.getLoginTime().getTime());
tokenInfoPojo.setAccessTokenValidTime(appLoginEntity.getAccessTokenValidTime().getTime()); tokenInfoPojo.setRefreshTime(appLoginEntity.getRefreshTime().getTime());
tokenInfoPojo.setRefreshTokenValidTime(appLoginEntity.getRefreshTokenValidTime().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 { } else {
tokenInfoPojo = JSONObject.toJavaObject(JSONObject.parseObject(cacheInfo), TokenInfoPojo.class); tokenInfoPojo = JSONObject.toJavaObject(JSONObject.parseObject(cacheInfo), TokenInfoPojo.class);
...@@ -204,5 +224,4 @@ public class TokenComponent { ...@@ -204,5 +224,4 @@ public class TokenComponent {
public String getTokenInfoCacheKey(String account, Integer accountType) { public String getTokenInfoCacheKey(String account, Integer accountType) {
return applicationName + "::token::" + accountType + "::" + account; return applicationName + "::token::" + accountType + "::" + account;
} }
} }
...@@ -33,7 +33,8 @@ public class AuthFilter implements Filter { ...@@ -33,7 +33,8 @@ public class AuthFilter implements Filter {
* 不需要TOKEN校验的URL * 不需要TOKEN校验的URL
**/ **/
private static final String[] NOT_TOKEN_URL = new String[]{"/app/ownerBackend/account/login/loginBySms", "/app/ownerBackend/account/login/loginByPwd", 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 @Autowired
private ProtocolComponent protocolComponent; private ProtocolComponent protocolComponent;
...@@ -69,6 +70,7 @@ public class AuthFilter implements Filter { ...@@ -69,6 +70,7 @@ public class AuthFilter implements Filter {
break; break;
} }
} }
if (isCheckToken) { if (isCheckToken) {
String token = request.getHeader("Union-Authorization"); String token = request.getHeader("Union-Authorization");
try { 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; package com.esv.freight.app.common.util;
import java.io.ByteArrayOutputStream; import java.io.ByteArrayOutputStream;
import java.io.IOException;
import java.io.OutputStream;
/** /**
* Created by zzc on 2018/8/16. * Created by zzc on 2018/8/16.
*/ */
public class Base64 { public class Base64 {
private static final char[] base64EncodeChars = new char[] { 'A', 'B', 'C', private static final char[] legalChars = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/"
'D', 'E', 'F', 'G', 'H', 'I', 'J', 'K', 'L', 'M', 'N', 'O', 'P', .toCharArray();
'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() {
}
public static String encode(byte[] data) { public static String encode(byte[] data) {
StringBuffer sb = new StringBuffer(); int start = 0;
int len = data.length; int len = data.length;
int i = 0; StringBuffer buf = new StringBuffer(data.length * 3 / 2);
int b1, b2, b3;
int end = len - 3;
while (i < len) { int i = start;
b1 = data[i++] & 0xff; int n = 0;
if (i == len) {
sb.append(base64EncodeChars[b1 >>> 2]); while (i <= end) {
sb.append(base64EncodeChars[(b1 & 0x3) << 4]); int d = ((((int) data[i]) & 0x0ff) << 16) | ((((int) data[i + 1]) & 0x0ff) << 8)
sb.append("=="); | (((int) data[i + 2]) & 0x0ff);
break;
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(" ");
} }
b2 = data[i++] & 0xff; }
if (i == len) {
sb.append(base64EncodeChars[b1 >>> 2]); if (i == start + len - 2) {
sb.append(base64EncodeChars[((b1 & 0x03) << 4) int d = ((((int) data[i]) & 0x0ff) << 16) | ((((int) data[i + 1]) & 255) << 8);
| ((b2 & 0xf0) >>> 4)]);
sb.append(base64EncodeChars[(b2 & 0x0f) << 2]); buf.append(legalChars[(d >> 18) & 63]);
sb.append("="); buf.append(legalChars[(d >> 12) & 63]);
break; buf.append(legalChars[(d >> 6) & 63]);
buf.append("=");
} else if (i == start + len - 1) {
int d = (((int) data[i]) & 0x0ff) << 16;
buf.append(legalChars[(d >> 18) & 63]);
buf.append(legalChars[(d >> 12) & 63]);
buf.append("==");
}
return buf.toString();
}
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 = data[i++] & 0xff; }
sb.append(base64EncodeChars[b1 >>> 2]);
sb.append(base64EncodeChars[((b1 & 0x03) << 4) /**
| ((b2 & 0xf0) >>> 4)]); * Decodes the given Base64 encoded String to a new byte array. The byte
sb.append(base64EncodeChars[((b2 & 0x0f) << 2) * array holding the decoded data is returned.
| ((b3 & 0xc0) >>> 6)]); */
sb.append(base64EncodeChars[b3 & 0x3f]);
public static byte[] decode(String s) {
ByteArrayOutputStream bos = new ByteArrayOutputStream();
try {
decode(s, bos);
} catch (IOException e) {
throw new RuntimeException();
}
byte[] decodedBytes = bos.toByteArray();
try {
bos.close();
bos = null;
} catch (IOException ex) {
System.err.println("Error while decoding BASE64: " + ex.toString());
} }
return sb.toString(); return decodedBytes;
} }
public static byte[] decode(String str) { private static void decode(String s, OutputStream os) throws IOException {
byte[] data = str.getBytes();
int len = data.length;
ByteArrayOutputStream buf = new ByteArrayOutputStream(len);
int i = 0; int i = 0;
int b1, b2, b3, b4;
while (i < len) { int len = s.length();
/* b1 */ while (true) {
do { while (i < len && s.charAt(i) <= ' ')
b1 = base64DecodeChars[data[i++]]; i++;
} while (i < len && b1 == -1);
if (b1 == -1) {
break;
}
/* b2 */ if (i == len)
do {
b2 = base64DecodeChars[data[i++]];
} while (i < len && b2 == -1);
if (b2 == -1) {
break; break;
}
buf.write((int) ((b1 << 2) | ((b2 & 0x30) >>> 4))); int tri = (decode(s.charAt(i)) << 18) + (decode(s.charAt(i + 1)) << 12) + (decode(s.charAt(i + 2)) << 6)
+ (decode(s.charAt(i + 3)));
/* b3 */
do { os.write((tri >> 16) & 255);
b3 = data[i++]; if (s.charAt(i + 2) == '=')
if (b3 == 61) {
return buf.toByteArray();
}
b3 = base64DecodeChars[b3];
} while (i < len && b3 == -1);
if (b3 == -1) {
break; break;
} os.write((tri >> 8) & 255);
buf.write((int) (((b2 & 0x0f) << 4) | ((b3 & 0x3c) >>> 2))); if (s.charAt(i + 3) == '=')
/* b4 */
do {
b4 = data[i++];
if (b4 == 61) {
return buf.toByteArray();
}
b4 = base64DecodeChars[b4];
} while (i < len && b4 == -1);
if (b4 == -1) {
break; break;
} os.write(tri & 255);
buf.write((int) (((b3 & 0x03) << 6) | b4));
i += 4;
} }
return buf.toByteArray();
} }
} }
...@@ -21,12 +21,6 @@ public class ReqUtils { ...@@ -21,12 +21,6 @@ public class ReqUtils {
return request.getHeader(headerKey); 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 * description 获得Http客户端的ip
* param [] * param []
......
package com.esv.freight.app.config; 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.ReqUtils;
import com.esv.freight.app.common.util.SecurityUtils; import com.esv.freight.app.common.util.SecurityUtils;
import com.esv.freight.app.module.account.CustomToken; import com.esv.freight.app.module.account.CustomToken;
import com.esv.freight.app.module.account.pojo.TokenInfoPojo;
import com.esv.gateway.common.GatewayHeaders; import com.esv.gateway.common.GatewayHeaders;
import feign.RequestInterceptor; import feign.RequestInterceptor;
import lombok.extern.slf4j.Slf4j; import lombok.extern.slf4j.Slf4j;
import org.slf4j.MDC; import org.slf4j.MDC;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value; import org.springframework.beans.factory.annotation.Value;
import org.springframework.cloud.openfeign.EnableFeignClients; import org.springframework.cloud.openfeign.EnableFeignClients;
import org.springframework.context.annotation.Bean; import org.springframework.context.annotation.Bean;
...@@ -32,6 +35,9 @@ public class FeignConfigure { ...@@ -32,6 +35,9 @@ public class FeignConfigure {
@Value("${spring.application.name}") @Value("${spring.application.name}")
private String applicationName; private String applicationName;
@Autowired
private TokenComponent tokenComponent;
@Bean @Bean
public RestTemplate restTemplate() { public RestTemplate restTemplate() {
return new RestTemplate(); return new RestTemplate();
...@@ -47,11 +53,12 @@ public class FeignConfigure { ...@@ -47,11 +53,12 @@ public class FeignConfigure {
requestTemplate.header("esv_system", "app"); requestTemplate.header("esv_system", "app");
requestTemplate.header("esv_department", "5"); requestTemplate.header("esv_department", "5");
requestTemplate.header("esv_department_children", "5,6,7"); requestTemplate.header("esv_department_children", "5,6,7");
CustomToken customToken = ReqUtils.getTokenInfo(); requestTemplate.header("esv_tenant", ReqUtils.getRequestHeader("tenantId"));
if (null != customToken) {
requestTemplate.header("esv_user", customToken.getUserId()); TokenInfoPojo tokenInfoPojo = tokenComponent.getTokenInfo();
requestTemplate.header("esv_account", customToken.getAccount()); if (tokenInfoPojo != null) {
requestTemplate.header("esv_tenant", String.valueOf(customToken.getTenantId())); requestTemplate.header("esv_user", String.valueOf(tokenInfoPojo.getAccountId()));
requestTemplate.header("esv_account", tokenInfoPojo.getAccount());
} }
})); }));
return requestInterceptor; return requestInterceptor;
......
...@@ -2,6 +2,7 @@ package com.esv.freight.app.module.account.controller; ...@@ -2,6 +2,7 @@ package com.esv.freight.app.module.account.controller;
import com.alibaba.fastjson.JSONArray; import com.alibaba.fastjson.JSONArray;
import com.alibaba.fastjson.JSONObject; 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.constants.AccountConstants;
import com.esv.freight.app.common.response.EResponse; import com.esv.freight.app.common.response.EResponse;
import com.esv.freight.app.common.util.FeignUtils; import com.esv.freight.app.common.util.FeignUtils;
...@@ -16,6 +17,7 @@ import com.esv.freight.app.module.account.form.DriverAuthForm; ...@@ -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.LoginForm;
import com.esv.freight.app.module.account.form.RefreshTokenForm; 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.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.pojo.TokenInfoPojo;
import com.esv.freight.app.module.account.service.AppLoginService; 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.ValidatorAccountExist;
...@@ -53,13 +55,15 @@ public class DriverAccountController { ...@@ -53,13 +55,15 @@ public class DriverAccountController {
private NoticeInterface noticeInterface; private NoticeInterface noticeInterface;
private AppLoginService appLoginService; private AppLoginService appLoginService;
private CarrierInterface carrierInterface; private CarrierInterface carrierInterface;
private TokenComponent tokenComponent;
@Autowired @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.noticeInterface = noticeInterface;
this.appLoginService = appLoginService; this.appLoginService = appLoginService;
this.driverInterface = driverInterface; this.driverInterface = driverInterface;
this.carrierInterface = carrierInterface; this.carrierInterface = carrierInterface;
this.tokenComponent = tokenComponent;
} }
/** /**
...@@ -72,32 +76,74 @@ public class DriverAccountController { ...@@ -72,32 +76,74 @@ public class DriverAccountController {
@PostMapping("/login/loginBySms") @PostMapping("/login/loginBySms")
public EResponse loginBySms(@RequestHeader @RequestBody(required=false) @Validated(ValidatorDriverLoginBySms.class) LoginForm loginForm) { public EResponse loginBySms(@RequestHeader @RequestBody(required=false) @Validated(ValidatorDriverLoginBySms.class) LoginForm loginForm) {
// 调用通知服务验证短信接口 // 1:调用通知服务验证短信接口
JSONObject reqJson = new JSONObject(); JSONObject reqJson = new JSONObject();
reqJson.put("phone", loginForm.getPhone()); reqJson.put("phone", loginForm.getPhone());
reqJson.put("type", "login"); reqJson.put("type", "login");
reqJson.put("captcha", loginForm.getSmsCode()); reqJson.put("captcha", loginForm.getSmsCode());
log.info(reqJson.toJSONString()); JSONObject result;
JSONObject resultCheck = noticeInterface.checkSmsCaptcha(reqJson); try {
log.info(resultCheck.toJSONString()); result = noticeInterface.checkSmsCaptcha(reqJson);
} catch (Exception e) {
log.error("Feign请求时发生错误:" + e.getMessage(), e);
return EResponse.error();
}
if(resultCheck.getInteger("code") != 200) { if(!FeignUtils.isFeignSuccess(result)) {
return EResponse.error(resultCheck.getInteger("code"), resultCheck.getString("message")); return FeignUtils.getFeignEResponse(result);
} }
// 调用注册帐号接口 // 2:查询司机详情(通过帐号)
reqJson.clear(); reqJson.clear();
reqJson.put("account", loginForm.getPhone()); reqJson.put("account", loginForm.getPhone());
reqJson.put("carrierId", loginForm.getCarrierId()); try {
JSONObject resultRegister = driverInterface.register(reqJson); 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());
try {
result = driverInterface.register(reqJson);
} catch (Exception e) {
log.error("Feign请求时发生错误:" + e.getMessage(), e);
return EResponse.error();
}
if(!FeignUtils.isFeignSuccess(result)) {
return FeignUtils.getFeignEResponse(result);
}
// 1001表示 帐号已存在 DriverAccountInfoPojo pojo = new DriverAccountInfoPojo();
if(resultRegister.getInteger("code") != 200 && resultRegister.getInteger("code") != 1001) { pojo.setId(result.getJSONObject("data").getLong("id"));
return EResponse.error(resultRegister.getInteger("code"), resultRegister.getString("message")); pojo.setCarrierId(loginForm.getCarrierId());
pojo.setAccount(loginForm.getPhone());
pojo.setLoginMode(AccountConstants.ACCOUNT_LOGIN_MODE_SMS);
LoginVO vo = appLoginService.driverLogin(pojo);
return EResponse.ok(vo);
} }
LoginVO loginByPwdVO = appLoginService.login(loginForm.getPhone()); if(!FeignUtils.isFeignSuccess(result)) {
return EResponse.ok(loginByPwdVO); 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 { ...@@ -132,8 +178,6 @@ public class DriverAccountController {
return EResponse.error(1003, "帐号已停用"); return EResponse.error(1003, "帐号已停用");
} }
// LoginVO loginByPwdVO = appLoginService.login(loginForm.getPhone());
// 登录 // 登录
driverAccountInfoPojo.setLoginMode(AccountConstants.ACCOUNT_LOGIN_MODE_PWD); driverAccountInfoPojo.setLoginMode(AccountConstants.ACCOUNT_LOGIN_MODE_PWD);
LoginVO vo = appLoginService.driverLogin(driverAccountInfoPojo); LoginVO vo = appLoginService.driverLogin(driverAccountInfoPojo);
...@@ -183,8 +227,7 @@ public class DriverAccountController { ...@@ -183,8 +227,7 @@ public class DriverAccountController {
**/ **/
@PostMapping("/logout") @PostMapping("/logout")
public EResponse logout() { public EResponse logout() {
CustomToken customToken = ReqUtils.getTokenInfo(); appLoginService.logout();
appLoginService.logout(customToken.getAccessToken());
return EResponse.ok(); return EResponse.ok();
} }
...@@ -198,8 +241,7 @@ public class DriverAccountController { ...@@ -198,8 +241,7 @@ public class DriverAccountController {
@PostMapping("/token/refresh") @PostMapping("/token/refresh")
public EResponse refresh(@RequestBody(required=false) @Validated(ValidatorInsert.class) RefreshTokenForm refreshTokenForm) { public EResponse refresh(@RequestBody(required=false) @Validated(ValidatorInsert.class) RefreshTokenForm refreshTokenForm) {
CustomToken customToken = ReqUtils.getTokenInfo(); LoginVO loginByPwdVO = appLoginService.refreshToken(refreshTokenForm);
LoginVO loginByPwdVO = appLoginService.refreshToken(customToken.getAccessToken(), refreshTokenForm);
return EResponse.ok(loginByPwdVO); return EResponse.ok(loginByPwdVO);
} }
...@@ -212,8 +254,9 @@ public class DriverAccountController { ...@@ -212,8 +254,9 @@ public class DriverAccountController {
**/ **/
@PostMapping("/detail") @PostMapping("/detail")
public EResponse detail() { public EResponse detail() {
appLoginService.checkAccessToken();
String phone = ReqUtils.getTokenInfo().getAccount(); TokenInfoPojo tokenInfoPojo = tokenComponent.getTokenInfo();
String phone = tokenInfoPojo.getAccount();
// 调用获取账号详情接口 // 调用获取账号详情接口
JSONObject reqJsonDetail = new JSONObject(); JSONObject reqJsonDetail = new JSONObject();
...@@ -271,7 +314,6 @@ public class DriverAccountController { ...@@ -271,7 +314,6 @@ public class DriverAccountController {
**/ **/
@PostMapping("/realNameAuth") @PostMapping("/realNameAuth")
public EResponse realNameAuth(@RequestBody(required=false) @Validated(ValidatorUpdate.class) DriverAuthForm driverAuthForm) { public EResponse realNameAuth(@RequestBody(required=false) @Validated(ValidatorUpdate.class) DriverAuthForm driverAuthForm) {
appLoginService.checkAccessToken();
// 调用编辑帐号信息接口 // 调用编辑帐号信息接口
JSONObject reqJson = new JSONObject(); JSONObject reqJson = new JSONObject();
...@@ -284,6 +326,8 @@ public class DriverAccountController { ...@@ -284,6 +326,8 @@ public class DriverAccountController {
reqJson.put("districtCode", driverAuthForm.getDistrictCode()); reqJson.put("districtCode", driverAuthForm.getDistrictCode());
reqJson.put("detailAddress", driverAuthForm.getDetailAddress()); reqJson.put("detailAddress", driverAuthForm.getDetailAddress());
reqJson.put("settlementType", driverAuthForm.getSettlementType()); reqJson.put("settlementType", driverAuthForm.getSettlementType());
reqJson.put("sex", driverAuthForm.getSex());
reqJson.put("birthDate", driverAuthForm.getBirthDate());
reqJson.put("drivingLicense", driverAuthForm.getDrivingLicense()); reqJson.put("drivingLicense", driverAuthForm.getDrivingLicense());
reqJson.put("drivingLicenseType", driverAuthForm.getDrivingLicenseType()); reqJson.put("drivingLicenseType", driverAuthForm.getDrivingLicenseType());
reqJson.put("drivingLicenseStartDate", driverAuthForm.getDrivingLicenseStartDate()); reqJson.put("drivingLicenseStartDate", driverAuthForm.getDrivingLicenseStartDate());
...@@ -350,7 +394,7 @@ public class DriverAccountController { ...@@ -350,7 +394,7 @@ public class DriverAccountController {
@PostMapping("/stop") @PostMapping("/stop")
public EResponse stopUsingAccount(@RequestBody(required=false) @Validated(ValidatorAccountExist.class) LoginForm loginForm) { 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(); return EResponse.ok();
} }
} }
package com.esv.freight.app.module.account.controller; package com.esv.freight.app.module.account.controller;
import com.alibaba.fastjson.JSONObject; 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.ECode;
import com.esv.freight.app.common.response.EResponse; import com.esv.freight.app.common.response.EResponse;
import com.esv.freight.app.common.util.ReqUtils; import com.esv.freight.app.common.util.ReqUtils;
...@@ -10,6 +11,7 @@ import com.esv.freight.app.feign.DriverInterface; ...@@ -10,6 +11,7 @@ import com.esv.freight.app.feign.DriverInterface;
import com.esv.freight.app.feign.NoticeInterface; import com.esv.freight.app.feign.NoticeInterface;
import com.esv.freight.app.module.account.form.LoginForm; 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.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.service.AppLoginService;
import com.esv.freight.app.module.account.validator.groups.ValidatorResetPwd; import com.esv.freight.app.module.account.validator.groups.ValidatorResetPwd;
import lombok.extern.slf4j.Slf4j; import lombok.extern.slf4j.Slf4j;
...@@ -33,14 +35,14 @@ import org.springframework.web.bind.annotation.*; ...@@ -33,14 +35,14 @@ import org.springframework.web.bind.annotation.*;
public class DriverPasswordController { public class DriverPasswordController {
private NoticeInterface noticeInterface; private NoticeInterface noticeInterface;
private AppLoginService appLoginService;
private DriverInterface driverInterface; private DriverInterface driverInterface;
private TokenComponent tokenComponent;
@Autowired @Autowired
public DriverPasswordController(DriverInterface driverInterface, NoticeInterface noticeInterface, AppLoginService appLoginService) { public DriverPasswordController(DriverInterface driverInterface, NoticeInterface noticeInterface, TokenComponent tokenComponent) {
this.noticeInterface = noticeInterface; this.noticeInterface = noticeInterface;
this.appLoginService = appLoginService;
this.driverInterface = driverInterface; this.driverInterface = driverInterface;
this.tokenComponent = tokenComponent;
} }
/** /**
...@@ -108,9 +110,8 @@ public class DriverPasswordController { ...@@ -108,9 +110,8 @@ public class DriverPasswordController {
@PostMapping("/edit") @PostMapping("/edit")
public EResponse edit(@RequestBody(required=false) @Validated(ValidatorInsert.class) ModifyPasswordForm modifyPasswordFrom) { public EResponse edit(@RequestBody(required=false) @Validated(ValidatorInsert.class) ModifyPasswordForm modifyPasswordFrom) {
appLoginService.checkAccessToken(); TokenInfoPojo tokenInfoPojo = tokenComponent.getTokenInfo();
String phone = tokenInfoPojo.getAccount();
String phone = ReqUtils.getTokenInfo().getAccount();
// 调用帐号密码校验接口 // 调用帐号密码校验接口
JSONObject reqJson = new JSONObject(); JSONObject reqJson = new JSONObject();
......
package com.esv.freight.app.module.account.controller; package com.esv.freight.app.module.account.controller;
import com.alibaba.fastjson.JSONObject; 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.util.ReqUtils;
import com.esv.freight.app.common.validator.groups.ValidatorUpdate; import com.esv.freight.app.common.validator.groups.ValidatorUpdate;
import com.esv.freight.app.feign.GoodsOwnerInterface; import com.esv.freight.app.feign.GoodsOwnerInterface;
import com.esv.freight.app.feign.NoticeInterface; import com.esv.freight.app.feign.NoticeInterface;
import com.esv.freight.app.module.account.CustomToken; import com.esv.freight.app.module.account.CustomToken;
import com.esv.freight.app.module.account.form.*; 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.service.AppLoginService;
import com.esv.freight.app.module.account.validator.groups.ValidatorAccountExist; import com.esv.freight.app.module.account.validator.groups.ValidatorAccountExist;
import com.esv.freight.app.module.account.validator.groups.ValidatorLoginByPwd; import com.esv.freight.app.module.account.validator.groups.ValidatorLoginByPwd;
...@@ -39,12 +44,14 @@ public class OwnerAccountController { ...@@ -39,12 +44,14 @@ public class OwnerAccountController {
private GoodsOwnerInterface goodsOwnerInterface; private GoodsOwnerInterface goodsOwnerInterface;
private NoticeInterface noticeInterface; private NoticeInterface noticeInterface;
private AppLoginService appLoginService; private AppLoginService appLoginService;
private TokenComponent tokenComponent;
@Autowired @Autowired
public OwnerAccountController(GoodsOwnerInterface goodsOwnerInterface, NoticeInterface noticeInterface, AppLoginService appLoginService) { public OwnerAccountController(TokenComponent tokenComponent, GoodsOwnerInterface goodsOwnerInterface, NoticeInterface noticeInterface, AppLoginService appLoginService) {
this.goodsOwnerInterface = goodsOwnerInterface; this.goodsOwnerInterface = goodsOwnerInterface;
this.noticeInterface = noticeInterface; this.noticeInterface = noticeInterface;
this.appLoginService = appLoginService; this.appLoginService = appLoginService;
this.tokenComponent = tokenComponent;
} }
/** /**
...@@ -62,24 +69,67 @@ public class OwnerAccountController { ...@@ -62,24 +69,67 @@ public class OwnerAccountController {
reqJson.put("phone", loginForm.getPhone()); reqJson.put("phone", loginForm.getPhone());
reqJson.put("type", "login"); reqJson.put("type", "login");
reqJson.put("captcha", loginForm.getSmsCode()); 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(resultCheck.getInteger("code") != 200) { if(!FeignUtils.isFeignSuccess(result)) {
return EResponse.error(resultCheck.getInteger("code"), resultCheck.getString("message")); return FeignUtils.getFeignEResponse(result);
} }
// 调用注册帐号接口 // 2:查询货主详情(通过帐号)
reqJson.clear(); reqJson.clear();
reqJson.put("account", loginForm.getPhone()); reqJson.put("account", loginForm.getPhone());
JSONObject resultRegister = goodsOwnerInterface.accountRegister(reqJson); 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());
try {
result = goodsOwnerInterface.accountRegister(reqJson);
} catch (Exception e) {
log.error("Feign请求时发生错误:" + e.getMessage(), e);
return EResponse.error();
}
// 1001表示 帐号已存在 if(!FeignUtils.isFeignSuccess(result)) {
if(resultRegister.getInteger("code") != 200 && resultRegister.getInteger("code") != 1001) { return FeignUtils.getFeignEResponse(result);
return EResponse.error(resultRegister.getInteger("code"), resultRegister.getString("message")); }
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);
} }
LoginVO loginByPwdVO = appLoginService.login(loginForm.getPhone()); if(!FeignUtils.isFeignSuccess(result)) {
return EResponse.ok(loginByPwdVO); 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 { ...@@ -92,18 +142,33 @@ public class OwnerAccountController {
@PostMapping("/login/loginByPwd") @PostMapping("/login/loginByPwd")
public EResponse loginByPwd(@RequestBody(required=false) @Validated(ValidatorLoginByPwd.class) LoginForm loginForm) { public EResponse loginByPwd(@RequestBody(required=false) @Validated(ValidatorLoginByPwd.class) LoginForm loginForm) {
// 调用帐号密码校验接口 // 1:调用帐号密码校验接口
JSONObject reqJson = new JSONObject(); JSONObject reqJson = new JSONObject();
reqJson.put("account", loginForm.getPhone()); reqJson.put("account", loginForm.getPhone());
reqJson.put("password", loginForm.getPwd()); 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) { if(!FeignUtils.isFeignSuccess(result)) {
return EResponse.error(result.getInteger("code"), result.getString("message")); return FeignUtils.getFeignEResponse(result);
} }
LoginVO loginByPwdVO = appLoginService.login(loginForm.getPhone()); // 2:校验帐号状态:1-正常、2-停用
return EResponse.ok(loginByPwdVO); 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 { ...@@ -115,8 +180,7 @@ public class OwnerAccountController {
**/ **/
@PostMapping("/logout") @PostMapping("/logout")
public EResponse logout() { public EResponse logout() {
CustomToken customToken = ReqUtils.getTokenInfo(); appLoginService.logout();
appLoginService.logout(customToken.getAccessToken());
return EResponse.ok(); return EResponse.ok();
} }
...@@ -130,8 +194,7 @@ public class OwnerAccountController { ...@@ -130,8 +194,7 @@ public class OwnerAccountController {
@PostMapping("/token/refresh") @PostMapping("/token/refresh")
public EResponse refresh(@RequestBody(required=false) @Validated(ValidatorInsert.class) RefreshTokenForm refreshTokenForm) { public EResponse refresh(@RequestBody(required=false) @Validated(ValidatorInsert.class) RefreshTokenForm refreshTokenForm) {
CustomToken customToken = ReqUtils.getTokenInfo(); LoginVO loginByPwdVO = appLoginService.refreshToken(refreshTokenForm);
LoginVO loginByPwdVO = appLoginService.refreshToken(customToken.getAccessToken(), refreshTokenForm);
return EResponse.ok(loginByPwdVO); return EResponse.ok(loginByPwdVO);
} }
...@@ -144,9 +207,9 @@ public class OwnerAccountController { ...@@ -144,9 +207,9 @@ public class OwnerAccountController {
**/ **/
@PostMapping("/detail") @PostMapping("/detail")
public EResponse detail() { public EResponse detail() {
appLoginService.checkAccessToken();
String phone = ReqUtils.getTokenInfo().getAccount(); TokenInfoPojo tokenInfoPojo = tokenComponent.getTokenInfo();
String phone = tokenInfoPojo.getAccount();
// 调用获取账号详情接口 // 调用获取账号详情接口
JSONObject reqJsonDetail = new JSONObject(); JSONObject reqJsonDetail = new JSONObject();
...@@ -195,8 +258,6 @@ public class OwnerAccountController { ...@@ -195,8 +258,6 @@ public class OwnerAccountController {
@PostMapping("/realNameAuth") @PostMapping("/realNameAuth")
public EResponse realNameAuth(@RequestBody(required=false) @Validated(ValidatorUpdate.class) OwnerAuthForm ownerAuthForm) { public EResponse realNameAuth(@RequestBody(required=false) @Validated(ValidatorUpdate.class) OwnerAuthForm ownerAuthForm) {
appLoginService.checkAccessToken();
// 调用编辑帐号信息接口 // 调用编辑帐号信息接口
JSONObject reqJson = new JSONObject(); JSONObject reqJson = new JSONObject();
reqJson.put("id", ownerAuthForm.getId()); reqJson.put("id", ownerAuthForm.getId());
...@@ -242,7 +303,7 @@ public class OwnerAccountController { ...@@ -242,7 +303,7 @@ public class OwnerAccountController {
@PostMapping("/stop") @PostMapping("/stop")
public EResponse stopUsingAccount(@RequestBody(required=false) @Validated(ValidatorAccountExist.class) LoginForm loginForm) { 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(); return EResponse.ok();
} }
} }
\ No newline at end of file
package com.esv.freight.app.module.account.controller; package com.esv.freight.app.module.account.controller;
import com.alibaba.fastjson.JSONObject; 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.ECode;
import com.esv.freight.app.common.util.ReqUtils; import com.esv.freight.app.common.util.ReqUtils;
import com.esv.freight.app.feign.GoodsOwnerInterface; import com.esv.freight.app.feign.GoodsOwnerInterface;
import com.esv.freight.app.feign.NoticeInterface; import com.esv.freight.app.feign.NoticeInterface;
import com.esv.freight.app.module.account.form.LoginForm; 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.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.service.AppLoginService;
import com.esv.freight.app.common.response.EResponse; import com.esv.freight.app.common.response.EResponse;
import com.esv.freight.app.common.validator.groups.ValidatorInsert; import com.esv.freight.app.common.validator.groups.ValidatorInsert;
...@@ -32,14 +34,14 @@ import org.springframework.web.bind.annotation.*; ...@@ -32,14 +34,14 @@ import org.springframework.web.bind.annotation.*;
public class OwnerPasswordController { public class OwnerPasswordController {
private NoticeInterface noticeInterface; private NoticeInterface noticeInterface;
private AppLoginService appLoginService;
private GoodsOwnerInterface goodsOwnerInterface; private GoodsOwnerInterface goodsOwnerInterface;
private TokenComponent tokenComponent;
@Autowired @Autowired
public OwnerPasswordController(GoodsOwnerInterface goodsOwnerInterface, NoticeInterface noticeInterface, AppLoginService appLoginService) { public OwnerPasswordController(GoodsOwnerInterface goodsOwnerInterface, NoticeInterface noticeInterface, AppLoginService appLoginService, TokenComponent tokenComponent) {
this.noticeInterface = noticeInterface; this.noticeInterface = noticeInterface;
this.appLoginService = appLoginService;
this.goodsOwnerInterface = goodsOwnerInterface; this.goodsOwnerInterface = goodsOwnerInterface;
this.tokenComponent = tokenComponent;
} }
/** /**
...@@ -108,9 +110,8 @@ public class OwnerPasswordController { ...@@ -108,9 +110,8 @@ public class OwnerPasswordController {
@PostMapping("/edit") @PostMapping("/edit")
public EResponse edit(@RequestBody(required=false) @Validated(ValidatorInsert.class) ModifyPasswordForm modifyPasswordFrom) { public EResponse edit(@RequestBody(required=false) @Validated(ValidatorInsert.class) ModifyPasswordForm modifyPasswordFrom) {
appLoginService.checkAccessToken(); TokenInfoPojo tokenInfoPojo = tokenComponent.getTokenInfo();
String phone = tokenInfoPojo.getAccount();
String phone = ReqUtils.getTokenInfo().getAccount();
// 调用帐号密码校验接口 // 调用帐号密码校验接口
JSONObject reqJson = new JSONObject(); JSONObject reqJson = new JSONObject();
......
...@@ -83,6 +83,19 @@ public class DriverAuthForm { ...@@ -83,6 +83,19 @@ public class DriverAuthForm {
@NotNull(message = "参数settlementType不能为空", groups = {ValidatorUpdate.class}) @NotNull(message = "参数settlementType不能为空", groups = {ValidatorUpdate.class})
private Integer settlementType; 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; ...@@ -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.entity.AppLoginEntity;
import com.esv.freight.app.module.account.form.RefreshTokenForm; 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.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.pojo.TokenInfoPojo;
import com.esv.freight.app.module.account.vo.LoginVO; import com.esv.freight.app.module.account.vo.LoginVO;
...@@ -16,15 +17,6 @@ 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> { public interface AppLoginService extends IService<AppLoginEntity> {
/**
* description 账号登录
* param [phone]
* return LoginVO
* author 张志臣
* createTime 2020/04/13 16:48
**/
LoginVO login(String phone);
/** /**
* description 司机帐号登录 * description 司机帐号登录
* param [driverDetailInfoPojo] * param [driverDetailInfoPojo]
...@@ -34,6 +26,15 @@ public interface AppLoginService extends IService<AppLoginEntity> { ...@@ -34,6 +26,15 @@ public interface AppLoginService extends IService<AppLoginEntity> {
**/ **/
LoginVO driverLogin(DriverAccountInfoPojo driverAccountInfoPojo); 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 账号登出 * description 账号登出
* param [accessToken] * param [accessToken]
...@@ -41,7 +42,7 @@ public interface AppLoginService extends IService<AppLoginEntity> { ...@@ -41,7 +42,7 @@ public interface AppLoginService extends IService<AppLoginEntity> {
* author 张志臣 * author 张志臣
* createTime 2020/04/13 16:48 * createTime 2020/04/13 16:48
**/ **/
void logout(String accessToken); void logout();
/** /**
* description 账号停用 * description 账号停用
...@@ -50,7 +51,7 @@ public interface AppLoginService extends IService<AppLoginEntity> { ...@@ -50,7 +51,7 @@ public interface AppLoginService extends IService<AppLoginEntity> {
* author 张志臣 * author 张志臣
* createTime 2020/05/06 16:48 * createTime 2020/05/06 16:48
**/ **/
void stopUsing(String phone); void stopUsing(String phone, Integer type);
/** /**
* description 刷新token * description 刷新token
...@@ -59,25 +60,8 @@ public interface AppLoginService extends IService<AppLoginEntity> { ...@@ -59,25 +60,8 @@ public interface AppLoginService extends IService<AppLoginEntity> {
* author 张志臣 * author 张志臣
* createTime 2020/04/13 16:48 * 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 * description 获取AppLoginEntity
* param [phone] * param [phone]
......
...@@ -2,6 +2,7 @@ package com.esv.freight.app.module.account.service.impl; ...@@ -2,6 +2,7 @@ package com.esv.freight.app.module.account.service.impl;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.esv.freight.app.common.component.RedisComponent;
import com.esv.freight.app.common.component.TokenComponent; import com.esv.freight.app.common.component.TokenComponent;
import com.esv.freight.app.common.constants.AccountConstants; import com.esv.freight.app.common.constants.AccountConstants;
import com.esv.freight.app.common.exception.EException; import com.esv.freight.app.common.exception.EException;
...@@ -10,6 +11,7 @@ import com.esv.freight.app.module.account.dao.AppLoginDao; ...@@ -10,6 +11,7 @@ import com.esv.freight.app.module.account.dao.AppLoginDao;
import com.esv.freight.app.module.account.entity.AppLoginEntity; 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.form.RefreshTokenForm;
import com.esv.freight.app.module.account.pojo.DriverAccountInfoPojo; 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.pojo.TokenInfoPojo;
import com.esv.freight.app.module.account.service.AppLoginService; import com.esv.freight.app.module.account.service.AppLoginService;
import com.esv.freight.app.module.account.vo.LoginVO; import com.esv.freight.app.module.account.vo.LoginVO;
...@@ -28,6 +30,9 @@ public class AppLoginServiceImpl extends ServiceImpl<AppLoginDao, AppLoginEntity ...@@ -28,6 +30,9 @@ public class AppLoginServiceImpl extends ServiceImpl<AppLoginDao, AppLoginEntity
@Autowired @Autowired
private TokenComponent tokenComponent; private TokenComponent tokenComponent;
@Autowired
private RedisComponent redisComponent;
private void createToken(AppLoginEntity entity) { private void createToken(AppLoginEntity entity) {
if(entity == null) { if(entity == null) {
return; return;
...@@ -53,6 +58,10 @@ public class AppLoginServiceImpl extends ServiceImpl<AppLoginDao, AppLoginEntity ...@@ -53,6 +58,10 @@ public class AppLoginServiceImpl extends ServiceImpl<AppLoginDao, AppLoginEntity
BeanUtils.copyProperties(tokenInfoPojo, appLoginEntity); BeanUtils.copyProperties(tokenInfoPojo, appLoginEntity);
appLoginEntity.setLoginStatus(AccountConstants.ACCOUNT_STATUS_LOGIN); appLoginEntity.setLoginStatus(AccountConstants.ACCOUNT_STATUS_LOGIN);
appLoginEntity.setPhone(tokenInfoPojo.getAccount()); appLoginEntity.setPhone(tokenInfoPojo.getAccount());
appLoginEntity.setLoginTime(new Date(tokenInfoPojo.getLoginTime()));
appLoginEntity.setAccessTokenValidTime(new Date(tokenInfoPojo.getAccessTokenValidTime()));
appLoginEntity.setRefreshTokenValidTime(new Date(tokenInfoPojo.getRefreshTokenValidTime()));
if (null == record) { if (null == record) {
this.baseMapper.insert(appLoginEntity); this.baseMapper.insert(appLoginEntity);
} else { } else {
...@@ -67,142 +76,98 @@ public class AppLoginServiceImpl extends ServiceImpl<AppLoginDao, AppLoginEntity ...@@ -67,142 +76,98 @@ public class AppLoginServiceImpl extends ServiceImpl<AppLoginDao, AppLoginEntity
} }
@Override @Override
public LoginVO login(String phone) { public LoginVO ownerLogin(OwnerAccountInfoPojo ownerAccountInfoPojo) {
// 1:初始化Token
AppLoginEntity appLoginEntity = this.getAccountByPhone(phone); TokenInfoPojo tokenInfoPojo = new TokenInfoPojo();
if(null == appLoginEntity) { BeanUtils.copyProperties(ownerAccountInfoPojo, tokenInfoPojo);
return addLogin(phone); tokenInfoPojo.setAccountId(ownerAccountInfoPojo.getId());
} this.tokenComponent.generateTokenInfo(tokenInfoPojo);
createToken(appLoginEntity);
appLoginEntity.setLoginStatus(AccountConstants.ACCOUNT_STATUS_LOGIN);
appLoginEntity.setLoginTime(new Date());
appLoginEntity.setRefreshTime(new Date());
appLoginEntity.setAccessTokenValidTime(getFuture(1));
appLoginEntity.setRefreshTokenValidTime(getFuture(30));
this.baseMapper.updateById(appLoginEntity);
//数据转换
LoginVO loginByPwdVO = new LoginVO();
loginByPwdVO.setAccessToken(appLoginEntity.getAccessToken());
loginByPwdVO.setRefreshToken(appLoginEntity.getRefreshToken());
return loginByPwdVO;
}
private LoginVO addLogin(String phone) { // 2:保存或更新登录信息
AppLoginEntity record = this.baseMapper.selectOne(new QueryWrapper<AppLoginEntity>().lambda()
.eq(AppLoginEntity::getAccountType, tokenInfoPojo.getAccountType())
.eq(AppLoginEntity::getPhone, tokenInfoPojo.getAccount()));
AppLoginEntity appLoginEntity = new AppLoginEntity(); AppLoginEntity appLoginEntity = new AppLoginEntity();
appLoginEntity.setPhone(phone); BeanUtils.copyProperties(tokenInfoPojo, appLoginEntity);
createToken(appLoginEntity);
appLoginEntity.setLoginStatus(AccountConstants.ACCOUNT_STATUS_LOGIN); appLoginEntity.setLoginStatus(AccountConstants.ACCOUNT_STATUS_LOGIN);
appLoginEntity.setLoginTime(new Date()); appLoginEntity.setPhone(tokenInfoPojo.getAccount());
appLoginEntity.setRefreshTime(new Date()); appLoginEntity.setLoginTime(new Date(tokenInfoPojo.getLoginTime()));
appLoginEntity.setLogoutTime(new Date()); appLoginEntity.setAccessTokenValidTime(new Date(tokenInfoPojo.getAccessTokenValidTime()));
appLoginEntity.setAccessTokenValidTime(getFuture(1)); appLoginEntity.setRefreshTokenValidTime(new Date(tokenInfoPojo.getRefreshTokenValidTime()));
appLoginEntity.setRefreshTokenValidTime(getFuture(30));
this.baseMapper.insert(appLoginEntity);
//数据转换
LoginVO loginByPwdVO = new LoginVO();
loginByPwdVO.setAccessToken(appLoginEntity.getAccessToken());
loginByPwdVO.setRefreshToken(appLoginEntity.getRefreshToken());
return loginByPwdVO;
}
@Override if (null == record) {
public void logout(String accessToken) { this.baseMapper.insert(appLoginEntity);
AppLoginEntity entity = this.getAccountByAccessToken(accessToken); } else {
if(entity == null) { appLoginEntity.setId(record.getId());
throw new EException(602, "Token已过期,请重新登录"); this.baseMapper.updateById(appLoginEntity);
} }
entity.setAccessToken(""); // 3:返回Token
entity.setRefreshToken(""); LoginVO loginVO = new LoginVO();
entity.setLoginStatus(AccountConstants.ACCOUNT_STATUS_LOGOUT); BeanUtils.copyProperties(tokenInfoPojo, loginVO);
entity.setLogoutTime(new Date()); return loginVO;
this.baseMapper.updateById(entity);
} }
@Override @Override
public void stopUsing(String phone) { public void logout() {
AppLoginEntity entity = this.getAccountByPhone(phone); TokenInfoPojo tokenInfoPojo = this.tokenComponent.getTokenInfo();
if(null == entity) { clearLoginInfo(tokenInfoPojo);
return;
}
entity.setAccessToken("");
entity.setRefreshToken("");
entity.setLoginStatus(AccountConstants.ACCOUNT_STATUS_LOGOUT);
entity.setLogoutTime(new Date());
this.baseMapper.updateById(entity);
} }
@Override @Override
public LoginVO refreshToken(String accessToken, RefreshTokenForm refreshTokenForm) { public void stopUsing(String phone, Integer type) {
AppLoginEntity entity = this.getAccountByAccessToken(accessToken); TokenInfoPojo tokenInfoPojo = this.tokenComponent.getTokenInfo(phone, type);
if(entity == null) { clearLoginInfo(tokenInfoPojo);
throw new EException(602, "Token已过期,请重新登录"); }
}
if(isInvalidRefreshToken(refreshTokenForm.getRefreshToken())) { private void clearLoginInfo(TokenInfoPojo tokenInfoPojo) {
throw new EException(602, "Token已过期,请重新登录"); AppLoginEntity record = this.baseMapper.selectOne(new QueryWrapper<AppLoginEntity>().lambda()
} .eq(AppLoginEntity::getAccountType, tokenInfoPojo.getAccountType())
.eq(AppLoginEntity::getPhone, tokenInfoPojo.getAccount()));
createToken(entity); AppLoginEntity appLoginEntity = new AppLoginEntity();
entity.setRefreshTime(new Date()); BeanUtils.copyProperties(tokenInfoPojo, appLoginEntity);
entity.setLoginStatus(AccountConstants.ACCOUNT_STATUS_LOGIN); appLoginEntity.setLoginStatus(AccountConstants.ACCOUNT_STATUS_LOGOUT);
entity.setAccessTokenValidTime(getFuture(1)); appLoginEntity.setAccessToken("");
entity.setRefreshTokenValidTime(getFuture(30)); appLoginEntity.setRefreshToken("");
this.baseMapper.updateById(entity); appLoginEntity.setLogoutTime(new Date());
appLoginEntity.setAccessTokenValidTime(new Date());
appLoginEntity.setRefreshTokenValidTime(new Date());
appLoginEntity.setId(record.getId());
this.baseMapper.updateById(appLoginEntity);
//数据转换 //清缓存
LoginVO loginByPwdVO = new LoginVO(); String key =tokenComponent.getTokenInfoCacheKey(tokenInfoPojo.getAccount(), tokenInfoPojo.getAccountType());
loginByPwdVO.setAccessToken(entity.getAccessToken()); redisComponent.del(key);
loginByPwdVO.setRefreshToken(entity.getRefreshToken());
return loginByPwdVO;
} }
@Override @Override
public void checkAccessToken() { public LoginVO refreshToken(RefreshTokenForm refreshTokenForm) {
String accessToken = ReqUtils.getTokenInfo().getAccessToken();
String phone = ReqUtils.getTokenInfo().getAccount();
AppLoginEntity entity = this.getAccountByPhone(phone);
// 手机号尚未登录
if(entity == null) {
throw new EException(601, "无效的Token");
}
if(StringUtils.isEmpty(entity.getAccessToken())) {
throw new EException(601, "您的账号信息发生变化,需要您重新登录");
}
if(!entity.getAccessToken().equals(accessToken)) { TokenInfoPojo pojo = this.tokenComponent.getTokenInfo();
throw new EException(601, "您的帐号正在其他设备登录,若非本人操作,您的密码已泄漏,请修改登录密码,以保证帐号安全。");
}
Date current = new Date();
Date accessDate = entity.getAccessTokenValidTime();
if(current.after(accessDate)) {
throw new EException(602, "Token已过期");
}
}
@Override TokenInfoPojo tokenInfoPojo = new TokenInfoPojo();
public boolean isInvalidRefreshToken(String refreshToken) { BeanUtils.copyProperties(pojo, tokenInfoPojo);
AppLoginEntity entity = this.getAccountByRefreshToken(refreshToken); this.tokenComponent.generateTokenInfo(tokenInfoPojo);
if(entity == null) {
throw new EException(602, "Token已过期,请重新登录");
}
Date current = new Date(); AppLoginEntity record = this.baseMapper.selectOne(new QueryWrapper<AppLoginEntity>().lambda()
Date refreshDate = entity.getRefreshTokenValidTime(); .eq(AppLoginEntity::getAccountType, tokenInfoPojo.getAccountType())
.eq(AppLoginEntity::getPhone, tokenInfoPojo.getAccount()));
if(current.after(refreshDate)) { AppLoginEntity appLoginEntity = new AppLoginEntity();
return true; BeanUtils.copyProperties(tokenInfoPojo, appLoginEntity);
} appLoginEntity.setLoginStatus(AccountConstants.ACCOUNT_STATUS_LOGIN);
appLoginEntity.setPhone(tokenInfoPojo.getAccount());
appLoginEntity.setLoginTime(new Date(tokenInfoPojo.getLoginTime()));
appLoginEntity.setAccessTokenValidTime(new Date(tokenInfoPojo.getAccessTokenValidTime()));
appLoginEntity.setRefreshTokenValidTime(new Date(tokenInfoPojo.getRefreshTokenValidTime()));
appLoginEntity.setId(record.getId());
this.baseMapper.updateById(appLoginEntity);
return false; //数据转换
LoginVO loginVO = new LoginVO();
BeanUtils.copyProperties(tokenInfoPojo, loginVO);
return loginVO;
} }
@Override @Override
...@@ -211,28 +176,4 @@ public class AppLoginServiceImpl extends ServiceImpl<AppLoginDao, AppLoginEntity ...@@ -211,28 +176,4 @@ public class AppLoginServiceImpl extends ServiceImpl<AppLoginDao, AppLoginEntity
queryWrapper.eq("phone", phone); queryWrapper.eq("phone", phone);
return this.baseMapper.selectOne(queryWrapper); return this.baseMapper.selectOne(queryWrapper);
} }
private AppLoginEntity getAccountByAccessToken(String accessToken) {
QueryWrapper<AppLoginEntity> queryWrapper = new QueryWrapper<>();
queryWrapper.eq("access_token", accessToken);
return this.baseMapper.selectOne(queryWrapper);
}
private AppLoginEntity getAccountByRefreshToken(String refreshToken) {
QueryWrapper<AppLoginEntity> queryWrapper = new QueryWrapper<>();
queryWrapper.select().eq("refresh_token", refreshToken);
return this.baseMapper.selectOne(queryWrapper);
}
/**
* 返回未来天数
* @param days
* @return
*/
public Date getFuture(int days) {
Calendar calendar = Calendar.getInstance();
calendar.setTime(new Date());
calendar.set(Calendar.DATE, calendar.get(Calendar.DATE) + days);
return calendar.getTime();
}
} }
...@@ -54,8 +54,6 @@ public class DeliveryAddressController { ...@@ -54,8 +54,6 @@ public class DeliveryAddressController {
@PostMapping("/list") @PostMapping("/list")
public EResponse list(@RequestBody(required=false) @Validated(ValidatorList.class) AddressQueryForm addressQueryForm) { public EResponse list(@RequestBody(required=false) @Validated(ValidatorList.class) AddressQueryForm addressQueryForm) {
appLoginService.checkAccessToken();
// 调用获取货主发货地址列表接口 // 调用获取货主发货地址列表接口
JSONObject reqJson = new JSONObject(); JSONObject reqJson = new JSONObject();
reqJson.put("ownerId", addressQueryForm.getOwnerId()); reqJson.put("ownerId", addressQueryForm.getOwnerId());
...@@ -94,8 +92,6 @@ public class DeliveryAddressController { ...@@ -94,8 +92,6 @@ public class DeliveryAddressController {
@PostMapping("/add") @PostMapping("/add")
public EResponse add(@RequestBody(required=false) @Validated(ValidatorInsert.class) DeliveryAddressForm deliveryAddressForm) { public EResponse add(@RequestBody(required=false) @Validated(ValidatorInsert.class) DeliveryAddressForm deliveryAddressForm) {
appLoginService.checkAccessToken();
// 调用添加货主发货地址接口 // 调用添加货主发货地址接口
JSONObject reqJson = new JSONObject(); JSONObject reqJson = new JSONObject();
reqJson.put("ownerId", deliveryAddressForm.getOwnerId()); reqJson.put("ownerId", deliveryAddressForm.getOwnerId());
...@@ -127,8 +123,6 @@ public class DeliveryAddressController { ...@@ -127,8 +123,6 @@ public class DeliveryAddressController {
@PostMapping("/edit") @PostMapping("/edit")
public EResponse edit(@RequestBody(required=false) @Validated(ValidatorUpdate.class) DeliveryAddressForm deliveryAddressForm) { public EResponse edit(@RequestBody(required=false) @Validated(ValidatorUpdate.class) DeliveryAddressForm deliveryAddressForm) {
appLoginService.checkAccessToken();
// 调用编辑货主发货地址接口 // 调用编辑货主发货地址接口
JSONObject reqJson = new JSONObject(); JSONObject reqJson = new JSONObject();
reqJson.put("id", deliveryAddressForm.getId()); reqJson.put("id", deliveryAddressForm.getId());
...@@ -159,8 +153,6 @@ public class DeliveryAddressController { ...@@ -159,8 +153,6 @@ public class DeliveryAddressController {
@PostMapping("/delete") @PostMapping("/delete")
public EResponse delete(@RequestBody(required=false) @Validated(ValidatorDelete.class) AddressQueryForm addressQueryForm) { public EResponse delete(@RequestBody(required=false) @Validated(ValidatorDelete.class) AddressQueryForm addressQueryForm) {
appLoginService.checkAccessToken();
// 调用获取删除货主发货地址接口 // 调用获取删除货主发货地址接口
JSONObject reqJson = new JSONObject(); JSONObject reqJson = new JSONObject();
reqJson.put("id", addressQueryForm.getId()); reqJson.put("id", addressQueryForm.getId());
...@@ -183,8 +175,6 @@ public class DeliveryAddressController { ...@@ -183,8 +175,6 @@ public class DeliveryAddressController {
@PostMapping("/detail") @PostMapping("/detail")
public EResponse detail(@RequestBody(required=false) @Validated(ValidatorDetail.class) DeliveryAddressForm deliveryAddressForm) { public EResponse detail(@RequestBody(required=false) @Validated(ValidatorDetail.class) DeliveryAddressForm deliveryAddressForm) {
appLoginService.checkAccessToken();
// 调用获取发货地址详情接口 // 调用获取发货地址详情接口
JSONObject reqJson = new JSONObject(); JSONObject reqJson = new JSONObject();
reqJson.put("id", deliveryAddressForm.getId()); reqJson.put("id", deliveryAddressForm.getId());
......
...@@ -56,8 +56,6 @@ public class ReceiveAddressController { ...@@ -56,8 +56,6 @@ public class ReceiveAddressController {
@PostMapping("/list") @PostMapping("/list")
public EResponse list(@RequestBody(required=false) @Validated(ValidatorList.class) AddressQueryForm addressQueryForm) { public EResponse list(@RequestBody(required=false) @Validated(ValidatorList.class) AddressQueryForm addressQueryForm) {
appLoginService.checkAccessToken();
// 调用获取货主发货地址列表接口 // 调用获取货主发货地址列表接口
JSONObject reqJson = new JSONObject(); JSONObject reqJson = new JSONObject();
reqJson.put("ownerId", addressQueryForm.getOwnerId()); reqJson.put("ownerId", addressQueryForm.getOwnerId());
...@@ -96,8 +94,6 @@ public class ReceiveAddressController { ...@@ -96,8 +94,6 @@ public class ReceiveAddressController {
@PostMapping("/add") @PostMapping("/add")
public EResponse add(@RequestBody(required=false) @Validated(ValidatorInsert.class) ReceiveAddressForm receiveAddressForm) { public EResponse add(@RequestBody(required=false) @Validated(ValidatorInsert.class) ReceiveAddressForm receiveAddressForm) {
appLoginService.checkAccessToken();
// 调用添加货主发货地址接口 // 调用添加货主发货地址接口
JSONObject reqJson = new JSONObject(); JSONObject reqJson = new JSONObject();
reqJson.put("ownerId", receiveAddressForm.getOwnerId()); reqJson.put("ownerId", receiveAddressForm.getOwnerId());
...@@ -129,8 +125,6 @@ public class ReceiveAddressController { ...@@ -129,8 +125,6 @@ public class ReceiveAddressController {
@PostMapping("/edit") @PostMapping("/edit")
public EResponse edit(@RequestBody(required=false) @Validated(ValidatorInsert.class) ReceiveAddressForm receiveAddressForm) { public EResponse edit(@RequestBody(required=false) @Validated(ValidatorInsert.class) ReceiveAddressForm receiveAddressForm) {
appLoginService.checkAccessToken();
// 调用编辑货主发货地址接口 // 调用编辑货主发货地址接口
JSONObject reqJson = new JSONObject(); JSONObject reqJson = new JSONObject();
reqJson.put("id", receiveAddressForm.getId()); reqJson.put("id", receiveAddressForm.getId());
...@@ -161,8 +155,6 @@ public class ReceiveAddressController { ...@@ -161,8 +155,6 @@ public class ReceiveAddressController {
@PostMapping("/delete") @PostMapping("/delete")
public EResponse delete(@RequestBody(required=false) @Validated(ValidatorInsert.class) AddressQueryForm addressQueryForm) { public EResponse delete(@RequestBody(required=false) @Validated(ValidatorInsert.class) AddressQueryForm addressQueryForm) {
appLoginService.checkAccessToken();
// 调用获取删除货主发货地址接口 // 调用获取删除货主发货地址接口
JSONObject reqJson = new JSONObject(); JSONObject reqJson = new JSONObject();
reqJson.put("id", addressQueryForm.getId()); reqJson.put("id", addressQueryForm.getId());
...@@ -185,8 +177,6 @@ public class ReceiveAddressController { ...@@ -185,8 +177,6 @@ public class ReceiveAddressController {
@PostMapping("/detail") @PostMapping("/detail")
public EResponse detail(@RequestBody(required=false) @Validated(ValidatorDetail.class) ReceiveAddressForm receiveAddressForm) { public EResponse detail(@RequestBody(required=false) @Validated(ValidatorDetail.class) ReceiveAddressForm receiveAddressForm) {
appLoginService.checkAccessToken();
// 调用获取发货地址详情接口 // 调用获取发货地址详情接口
JSONObject reqJson = new JSONObject(); JSONObject reqJson = new JSONObject();
reqJson.put("id", receiveAddressForm.getId()); reqJson.put("id", receiveAddressForm.getId());
......
...@@ -58,8 +58,6 @@ public class GrabController { ...@@ -58,8 +58,6 @@ public class GrabController {
@PostMapping("/find/list") @PostMapping("/find/list")
public EResponse getFindGoodsList(@RequestBody(required=false) @Validated(ValidatorList.class) OrderGrabbingQueryForm orderGrabbingQueryForm) { public EResponse getFindGoodsList(@RequestBody(required=false) @Validated(ValidatorList.class) OrderGrabbingQueryForm orderGrabbingQueryForm) {
// appLoginService.checkAccessToken();
// 调用查询抢单信息列表接口 // 调用查询抢单信息列表接口
JSONObject reqJson = new JSONObject(); JSONObject reqJson = new JSONObject();
if(orderGrabbingQueryForm.getDriverId() != null) { if(orderGrabbingQueryForm.getDriverId() != null) {
...@@ -153,8 +151,6 @@ public class GrabController { ...@@ -153,8 +151,6 @@ public class GrabController {
@PostMapping("/find/grab") @PostMapping("/find/grab")
public EResponse grabOrder(@RequestBody(required=false) @Validated(ValidatorInsert.class) OrderGrabbingForm orderGrabbingForm) { public EResponse grabOrder(@RequestBody(required=false) @Validated(ValidatorInsert.class) OrderGrabbingForm orderGrabbingForm) {
appLoginService.checkAccessToken();
// 调用抢单接口 // 调用抢单接口
JSONObject reqJson = new JSONObject(); JSONObject reqJson = new JSONObject();
reqJson.put("orderGrabbingId", orderGrabbingForm.getOrderGrabbingId()); reqJson.put("orderGrabbingId", orderGrabbingForm.getOrderGrabbingId());
......
...@@ -59,8 +59,6 @@ public class OrderController { ...@@ -59,8 +59,6 @@ public class OrderController {
@PostMapping("/statistics/getCountByType") @PostMapping("/statistics/getCountByType")
public EResponse getCountByType() { public EResponse getCountByType() {
appLoginService.checkAccessToken();
// 调用货主查询不同状态的订单数接口 // 调用货主查询不同状态的订单数接口
JSONObject result = tmsInterface.getOrderCount(); JSONObject result = tmsInterface.getOrderCount();
log.info(result.toJSONString()); log.info(result.toJSONString());
...@@ -89,8 +87,6 @@ public class OrderController { ...@@ -89,8 +87,6 @@ public class OrderController {
@PostMapping("/list") @PostMapping("/list")
public EResponse list(@RequestBody(required=false) @Validated(ValidatorList.class) OrderQueryForm orderQueryForm) { public EResponse list(@RequestBody(required=false) @Validated(ValidatorList.class) OrderQueryForm orderQueryForm) {
appLoginService.checkAccessToken();
// 调用订单列表分页查询接口 // 调用订单列表分页查询接口
JSONObject reqJson = new JSONObject(); JSONObject reqJson = new JSONObject();
reqJson.put("goodsOwnerId", orderQueryForm.getGoodsOwnerId()); reqJson.put("goodsOwnerId", orderQueryForm.getGoodsOwnerId());
...@@ -156,8 +152,6 @@ public class OrderController { ...@@ -156,8 +152,6 @@ public class OrderController {
@PostMapping("/add") @PostMapping("/add")
public EResponse add(@RequestBody(required=false) @Validated(ValidatorInsert.class) OrderForm orderForm) { public EResponse add(@RequestBody(required=false) @Validated(ValidatorInsert.class) OrderForm orderForm) {
appLoginService.checkAccessToken();
// 调用订单新增接口 // 调用订单新增接口
JSONObject reqJson = new JSONObject(); JSONObject reqJson = new JSONObject();
reqJson.put("goodsOwnerId", orderForm.getGoodsOwnerId()); reqJson.put("goodsOwnerId", orderForm.getGoodsOwnerId());
...@@ -199,8 +193,6 @@ public class OrderController { ...@@ -199,8 +193,6 @@ public class OrderController {
@PostMapping("/cancel") @PostMapping("/cancel")
public EResponse cancel(@RequestBody(required=false) @Validated(ValidatorDetail.class) OrderQueryForm orderQueryForm) { public EResponse cancel(@RequestBody(required=false) @Validated(ValidatorDetail.class) OrderQueryForm orderQueryForm) {
appLoginService.checkAccessToken();
// 调用取消订单接口 // 调用取消订单接口
JSONObject reqJson = new JSONObject(); JSONObject reqJson = new JSONObject();
reqJson.put("orderId", orderQueryForm.getId()); reqJson.put("orderId", orderQueryForm.getId());
...@@ -225,8 +217,6 @@ public class OrderController { ...@@ -225,8 +217,6 @@ public class OrderController {
@PostMapping("/detail") @PostMapping("/detail")
public EResponse detail(@RequestBody(required=false) @Validated(ValidatorDetail.class) OrderQueryForm orderQueryForm) { public EResponse detail(@RequestBody(required=false) @Validated(ValidatorDetail.class) OrderQueryForm orderQueryForm) {
appLoginService.checkAccessToken();
// 调用获取订单详情接口 // 调用获取订单详情接口
JSONObject reqJson = new JSONObject(); JSONObject reqJson = new JSONObject();
reqJson.put("orderId", orderQueryForm.getId()); reqJson.put("orderId", orderQueryForm.getId());
...@@ -291,8 +281,6 @@ public class OrderController { ...@@ -291,8 +281,6 @@ public class OrderController {
@PostMapping("/edit") @PostMapping("/edit")
public EResponse edit(@RequestBody(required=false) @Validated(ValidatorUpdate.class) OrderForm orderForm) { public EResponse edit(@RequestBody(required=false) @Validated(ValidatorUpdate.class) OrderForm orderForm) {
appLoginService.checkAccessToken();
// 调用编辑订单接口 // 调用编辑订单接口
JSONObject reqJson = new JSONObject(); JSONObject reqJson = new JSONObject();
reqJson.put("id", orderForm.getId()); reqJson.put("id", orderForm.getId());
......
...@@ -60,8 +60,6 @@ public class VehicleController { ...@@ -60,8 +60,6 @@ public class VehicleController {
@PostMapping("/add") @PostMapping("/add")
public EResponse add(@RequestBody(required=false) @Validated(ValidatorInsert.class) VehicleForm vehicleForm) { public EResponse add(@RequestBody(required=false) @Validated(ValidatorInsert.class) VehicleForm vehicleForm) {
appLoginService.checkAccessToken();
// 调用新增车辆接口 // 调用新增车辆接口
JSONObject reqJson = new JSONObject(); JSONObject reqJson = new JSONObject();
reqJson.put("carrierId", vehicleForm.getCarrierId()); reqJson.put("carrierId", vehicleForm.getCarrierId());
...@@ -123,7 +121,6 @@ public class VehicleController { ...@@ -123,7 +121,6 @@ public class VehicleController {
**/ **/
@PostMapping("/edit") @PostMapping("/edit")
public EResponse edit(@RequestBody(required=false) @Validated(ValidatorUpdate.class) VehicleForm vehicleForm) { public EResponse edit(@RequestBody(required=false) @Validated(ValidatorUpdate.class) VehicleForm vehicleForm) {
appLoginService.checkAccessToken();
// 调用编辑车辆接口 // 调用编辑车辆接口
JSONObject reqJson = new JSONObject(); JSONObject reqJson = new JSONObject();
...@@ -186,7 +183,6 @@ public class VehicleController { ...@@ -186,7 +183,6 @@ public class VehicleController {
**/ **/
@PostMapping("/detail") @PostMapping("/detail")
public EResponse detail(@RequestBody(required=false) @Validated(ValidatorUpdate.class) VehicleQueryForm vehicleQueryForm) { public EResponse detail(@RequestBody(required=false) @Validated(ValidatorUpdate.class) VehicleQueryForm vehicleQueryForm) {
appLoginService.checkAccessToken();
// 调用获取订单详情接口 // 调用获取订单详情接口
JSONObject reqJson = new JSONObject(); JSONObject reqJson = new JSONObject();
...@@ -258,7 +254,6 @@ public class VehicleController { ...@@ -258,7 +254,6 @@ public class VehicleController {
**/ **/
@PostMapping("/list") @PostMapping("/list")
public EResponse list(@RequestBody(required=false) @Validated(ValidatorDetail.class) VehicleQueryForm vehicleQueryForm) { public EResponse list(@RequestBody(required=false) @Validated(ValidatorDetail.class) VehicleQueryForm vehicleQueryForm) {
appLoginService.checkAccessToken();
// 调用获取司机的车辆列表接口 // 调用获取司机的车辆列表接口
JSONObject reqJson = new JSONObject(); JSONObject reqJson = new JSONObject();
......
...@@ -61,8 +61,6 @@ public class DriverWaybillController { ...@@ -61,8 +61,6 @@ public class DriverWaybillController {
@PostMapping("/list") @PostMapping("/list")
public EResponse list(@RequestBody(required=false) @Validated(ValidatorList.class) WaybillQueryForm waybillQueryForm) { public EResponse list(@RequestBody(required=false) @Validated(ValidatorList.class) WaybillQueryForm waybillQueryForm) {
appLoginService.checkAccessToken();
// 调用运单列表分页查询接口 // 调用运单列表分页查询接口
JSONObject reqJson = new JSONObject(); JSONObject reqJson = new JSONObject();
reqJson.put("driverId", waybillQueryForm.getUserId()); reqJson.put("driverId", waybillQueryForm.getUserId());
...@@ -143,8 +141,6 @@ public class DriverWaybillController { ...@@ -143,8 +141,6 @@ public class DriverWaybillController {
@PostMapping("/detail") @PostMapping("/detail")
public EResponse detail(@RequestBody(required=false) @Validated(ValidatorDetail.class) WaybillQueryForm waybillQueryForm) { public EResponse detail(@RequestBody(required=false) @Validated(ValidatorDetail.class) WaybillQueryForm waybillQueryForm) {
appLoginService.checkAccessToken();
// 调用获取运单详情接口 // 调用获取运单详情接口
JSONObject reqJson = new JSONObject(); JSONObject reqJson = new JSONObject();
reqJson.put("id", waybillQueryForm.getWaybillId()); reqJson.put("id", waybillQueryForm.getWaybillId());
...@@ -195,8 +191,6 @@ public class DriverWaybillController { ...@@ -195,8 +191,6 @@ public class DriverWaybillController {
@PostMapping("/delivery/upload") @PostMapping("/delivery/upload")
public EResponse uploadDeliveryEvidence(@RequestBody(required=false) @Validated(ValidatorInsert.class) UploadEvidenceForm uploadEvidenceForm) { public EResponse uploadDeliveryEvidence(@RequestBody(required=false) @Validated(ValidatorInsert.class) UploadEvidenceForm uploadEvidenceForm) {
appLoginService.checkAccessToken();
// 调用上传发货单据接口 // 调用上传发货单据接口
JSONObject reqJson = new JSONObject(); JSONObject reqJson = new JSONObject();
reqJson.put("waybillId", uploadEvidenceForm.getWaybillId()); reqJson.put("waybillId", uploadEvidenceForm.getWaybillId());
...@@ -235,8 +229,6 @@ public class DriverWaybillController { ...@@ -235,8 +229,6 @@ public class DriverWaybillController {
@PostMapping("/receive/upload") @PostMapping("/receive/upload")
public EResponse uploadReceiveEvidence(@RequestBody(required=false) @Validated(ValidatorInsert.class) UploadEvidenceForm uploadEvidenceForm) { public EResponse uploadReceiveEvidence(@RequestBody(required=false) @Validated(ValidatorInsert.class) UploadEvidenceForm uploadEvidenceForm) {
appLoginService.checkAccessToken();
// 调用上传发货单据接口 // 调用上传发货单据接口
JSONObject reqJson = new JSONObject(); JSONObject reqJson = new JSONObject();
reqJson.put("waybillId", uploadEvidenceForm.getWaybillId()); reqJson.put("waybillId", uploadEvidenceForm.getWaybillId());
...@@ -275,8 +267,6 @@ public class DriverWaybillController { ...@@ -275,8 +267,6 @@ public class DriverWaybillController {
@PostMapping("/list/multi/condition") @PostMapping("/list/multi/condition")
public EResponse condition(@RequestBody(required=false) @Validated(ValidatorList.class) WaybillMultiQueryForm waybillMultiQueryForm) { public EResponse condition(@RequestBody(required=false) @Validated(ValidatorList.class) WaybillMultiQueryForm waybillMultiQueryForm) {
appLoginService.checkAccessToken();
// 调用运单列表分页查询接口 // 调用运单列表分页查询接口
JSONObject reqJson = new JSONObject(); JSONObject reqJson = new JSONObject();
reqJson.put("condition", waybillMultiQueryForm.getCondition()); reqJson.put("condition", waybillMultiQueryForm.getCondition());
......
...@@ -61,8 +61,6 @@ public class OwnerWaybillController { ...@@ -61,8 +61,6 @@ public class OwnerWaybillController {
@PostMapping("/list") @PostMapping("/list")
public EResponse list(@RequestBody(required=false) @Validated(ValidatorList.class) WaybillQueryForm waybillQueryForm) { public EResponse list(@RequestBody(required=false) @Validated(ValidatorList.class) WaybillQueryForm waybillQueryForm) {
appLoginService.checkAccessToken();
// 调用运单列表分页查询接口 // 调用运单列表分页查询接口
JSONObject reqJson = new JSONObject(); JSONObject reqJson = new JSONObject();
reqJson.put("goodsOwnerId", waybillQueryForm.getUserId()); reqJson.put("goodsOwnerId", waybillQueryForm.getUserId());
...@@ -146,8 +144,6 @@ public class OwnerWaybillController { ...@@ -146,8 +144,6 @@ public class OwnerWaybillController {
@PostMapping("/sign") @PostMapping("/sign")
public EResponse sign(@RequestBody(required=false) @Validated(ValidatorDetail.class) WaybillQueryForm waybillQueryForm) { public EResponse sign(@RequestBody(required=false) @Validated(ValidatorDetail.class) WaybillQueryForm waybillQueryForm) {
appLoginService.checkAccessToken();
// 调用上传发货单据接口 // 调用上传发货单据接口
JSONObject reqJson = new JSONObject(); JSONObject reqJson = new JSONObject();
reqJson.put("id", waybillQueryForm.getWaybillId()); reqJson.put("id", waybillQueryForm.getWaybillId());
...@@ -172,8 +168,6 @@ public class OwnerWaybillController { ...@@ -172,8 +168,6 @@ public class OwnerWaybillController {
@PostMapping("/list/multi/condition") @PostMapping("/list/multi/condition")
public EResponse condition(@RequestBody(required=false) @Validated(ValidatorList.class) WaybillMultiQueryForm waybillMultiQueryForm) { public EResponse condition(@RequestBody(required=false) @Validated(ValidatorList.class) WaybillMultiQueryForm waybillMultiQueryForm) {
appLoginService.checkAccessToken();
// 调用运单列表分页查询接口 // 调用运单列表分页查询接口
JSONObject reqJson = new JSONObject(); JSONObject reqJson = new JSONObject();
reqJson.put("condition", waybillMultiQueryForm.getCondition()); 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