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 com.ycl.vo.cockpit.CockpitVO;
|
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 params
|
*/
|
public void cockpit(CockpitVO params) {
|
apiKeyService.checkIsExist(params.getAppId(), params.getAppKey(), "驾驶仓");
|
StringBuffer sb = new StringBuffer();
|
sb.append("appId=");
|
sb.append(params.getAppId());
|
sb.append("&appKey=");
|
sb.append(params.getAppKey());
|
String result;
|
if (!StringUtils.isBlank(params.getBeginTime()) && !StringUtils.isBlank(params.getEndTime())) {
|
sb.append("&beginTime=");
|
sb.append(params.getBeginTime());
|
sb.append("&endTime=");
|
sb.append(params.getEndTime());
|
}
|
if (params.getStreetId() != null) {
|
sb.append("&streetId=");
|
sb.append(params.getStreetId());
|
}
|
result = MD5Util.md5Encrypt32Lower(sb.toString());
|
if (!params.getSign().equals(result)) {
|
throw new ApiException(ResultCode.SIGN_ERROR);
|
}
|
}
|
}
|