admin
2022-04-29 6cc97918a5a42e37a3c3867cc5b78a0b9fd43a24
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
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
package com.yeshi.makemoney.app.service.manager;
 
import com.ks.lib.common.exception.ParamsException;
import com.ks.push.exception.BPushDeviceTokenException;
import com.ks.push.pojo.DO.BPushDeviceToken;
import com.ks.push.pojo.DO.PushPlatform;
import com.ks.push.service.BDeviceTokenService;
import com.yeshi.makemoney.app.entity.SystemEnum;
import com.yeshi.makemoney.app.entity.config.SystemConfigKey;
import com.yeshi.makemoney.app.service.inter.config.SystemConfigService;
import com.yeshi.makemoney.app.vo.AcceptData;
import org.springframework.stereotype.Component;
 
import javax.annotation.Resource;
import java.util.Date;
 
/**
 * @author hxh
 * @title: PushManager
 * @description: 推送管理器
 * @date 2022/4/29 17:33
 */
@Component
public class PushManager {
 
    //@Reference(version = "1.0")
    private BDeviceTokenService bdeviceTokenService;
 
    @Resource
    private SystemConfigService systemConfigService;
 
    /**
     * @return void
     * @author hxh
     * @description 保存token
     * @date 17:36 2022/4/29
     * @param: acceptData
     * @param: uid
     * @param: regId
     **/
    public void saveToken(AcceptData acceptData, Long uid, String regId) throws BPushDeviceTokenException, ParamsException {
        BPushDeviceToken token = new BPushDeviceToken();
        if (uid != null) {
            token.setUid(uid + "");
        }
        token.setType(PushPlatform.jpush);
        token.setAppCode(systemConfigService.getValueCache(acceptData.getSystem(), SystemConfigKey.androidPushAppCode));
        token.setVersionCode(acceptData.getVersion());
        token.setToken(regId);
        token.setDeviceId(acceptData.getUtdId());
        token.setBuildVersion(acceptData.getOsVersion());
        token.setBuildModel(acceptData.getDeviceType());
        token.setCreateTime(new Date());
        bdeviceTokenService.save(token);
    }
 
 
    /**
     * @return void
     * @author hxh
     * @description 绑定用户ID
     * @date 17:40 2022/4/29
     * @param: system
     * @param: uid
     * @param: deviceId
     **/
    public void bindUid(SystemEnum system, Long uid, String deviceId) {
        bdeviceTokenService.bindUid(systemConfigService.getValueCache(system, SystemConfigKey.androidPushAppCode), deviceId, uid + "");
    }
 
    /**
     * @return void
     * @author hxh
     * @description 解绑用户ID
     * @date 17:41 2022/4/29
     * @param: system
     * @param: deviceId
     **/
    public void unBind(SystemEnum system, String deviceId) {
        bdeviceTokenService.unBindUid(systemConfigService.getValueCache(system, SystemConfigKey.androidPushAppCode), deviceId);
    }
 
 
}