liyanqi
2022-11-01 15ccd1b13a0f1358d654aa9b9945560067bdd679
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
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
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);
        }
    }
}