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
package com.yeshi.buwan.service.imp.push;
 
import com.yeshi.buwan.dao.push.PushDeviceTokenDao;
import com.yeshi.buwan.domain.push.PushDeviceToken;
import com.yeshi.buwan.service.inter.push.PushDeviceTokenService;
import com.yeshi.buwan.util.StringUtil;
import org.springframework.stereotype.Service;
 
import javax.annotation.Resource;
import java.util.Date;
 
@Service
public class PushDeviceTokenServiceImpl implements PushDeviceTokenService {
 
    @Resource
    private PushDeviceTokenDao pushDeviceTokenDao;
 
 
    @Override
    public void addDeviceToken(PushDeviceToken token) throws Exception {
        if (token == null) {
            throw new Exception("对象不能为空");
        }
 
        if (StringUtil.isNullOrEmpty(token.getDetailSystemId()) || StringUtil.isNullOrEmpty(token.getUtdId()) || StringUtil.isNullOrEmpty(token.getToken()) || StringUtil.isNullOrEmpty(token.getType())) {
            throw new Exception("参数不能为空");
        }
        token.setId(PushDeviceToken.createId(token.getDetailSystemId(),token.getUtdId()));
        token.setCreateTime(new Date());
        pushDeviceTokenDao.save(token);
    }
}