admin
2020-11-13 ae08b37317103344b9be1b9f91b6bdf7abbc839b
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
package com.ks.goldcorn.service;
 
import com.ks.goldcorn.exception.GoldAppException;
import com.ks.goldcorn.mapper.GoldCornAppInfoMapper;
import com.ks.goldcorn.pojo.DO.GoldCornAppInfo;
import org.springframework.stereotype.Component;
 
import javax.annotation.Resource;
 
@Component
public class GoldCornAppManager {
 
    @Resource
    private GoldCornAppInfoMapper goldCornAppInfoMapper;
 
    /**
     * 根据AppCode查询APP
     *
     * @param code
     * @return
     */
    public GoldCornAppInfo selectByAppCode(String code) {
        return goldCornAppInfoMapper.selectByAppCode(code);
    }
 
 
    /**
     * 根据code查询AppId
     *
     * @param code
     * @return
     */
    public Long selectAppIdByAppCode(String code) {
        GoldCornAppInfo app = selectByAppCode(code);
        if (app == null) {
            return null;
        }
        return app.getId();
    }
 
    /**
     * 获取appID
     *
     * @param appCode
     * @return
     * @throws GoldAppException
     */
    public Long getAppId(String appCode) throws GoldAppException {
        Long appId = selectAppIdByAppCode(appCode);
        if (appId == null) {
            throw new GoldAppException(GoldAppException.CODE_NOT_EXIST, "应用不存在");
        }
        return appId;
    }
}