mg
2022-11-02 2cb34c56308db1490aa56e6b03d7b23605c2f7aa
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
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
     * @param appKey
     * @param sign
     * @param name
     * @param beginTime
     * @param endTime
     */
    public void cockpit(String appId, String appKey, String sign, String beginTime, String endTime) {
        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);
        }
        result = MD5Util.md5Encrypt32Lower(sb.toString());
        if (!sign.equals(result)) {
            throw new ApiException(ResultCode.SIGN_ERROR);
        }
    }
}