package com.ycl.util;
|
|
import com.ycl.enums.common.ResultCode;
|
import com.ycl.exception.ApiException;
|
import com.ycl.service.apiKey.IApiKeyService;
|
import com.ycl.utils.MD5Util;
|
import org.apache.commons.lang3.StringUtils;
|
import org.springframework.stereotype.Component;
|
|
import javax.annotation.Resource;
|
|
/**
|
* @author Lyq
|
* @version 1.0
|
* @date 2022/10/31
|
*/
|
@Component
|
public class CheckApiUtil {
|
|
@Resource
|
private IApiKeyService apiKeyService;
|
|
/**
|
* 驾驶舱
|
*
|
* @param appId appId
|
* @param appKey appKey
|
* @param sign sign
|
* @param beginTime 开始时间
|
* @param endTime 结束时间
|
* @param regionId 区域Id
|
*/
|
public void cockpit(String appId, String appKey, String sign, String beginTime, String endTime, String regionId) {
|
apiKeyService.checkIsExist(appId, appKey, "驾驶仓");
|
StringBuffer sb = new StringBuffer();
|
sb.append(appId);
|
sb.append(appKey);
|
String result;
|
if (!StringUtils.isBlank(beginTime) && !StringUtils.isBlank(endTime)) {
|
sb.append(beginTime);
|
sb.append(endTime);
|
}
|
if (!StringUtils.isBlank(regionId)) {
|
sb.append(regionId);
|
}
|
result = MD5Util.md5Encrypt32Lower(sb.toString());
|
if (!sign.equals(result)) {
|
throw new ApiException(ResultCode.SIGN_ERROR);
|
}
|
}
|
}
|