zhanghua
2023-03-21 cea14a6019ce363742527a92896eb0c49e9e8599
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
52
53
54
55
56
57
58
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());
        }
        if (params.getPageIndex() != null && params.getPageSize() != null) {
            sb.append("&pageIndex=");
            sb.append(params.getPageIndex());
            sb.append("&pageSize=");
            sb.append(params.getPageSize());
        }
        result = MD5Util.md5Encrypt32Lower(sb.toString());
        if (!params.getSign().equals(result)) {
            throw new ApiException(ResultCode.SIGN_ERROR);
        }
    }
}