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.apache.dubbo.config.annotation.Reference;
|
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",check = false)
|
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);
|
}
|
|
|
}
|