yujian
2019-12-10 c8041ec0544bf122e6819e6bf698997ccbf30aaf
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
85
86
87
package com.yeshi.fanli.service.impl.help;
 
import java.util.Date;
import java.util.List;
 
import javax.annotation.Resource;
 
import org.springframework.cache.annotation.Cacheable;
import org.springframework.stereotype.Service;
 
import com.yeshi.fanli.dao.mybatis.help.AppPageNotificationMapper;
import com.yeshi.fanli.entity.bus.help.AppPageNotification;
import com.yeshi.fanli.service.inter.help.AppPageNotificationService;
import com.yeshi.fanli.util.StringUtil;
 
@Service
public class AppPageNotificationServiceImpl implements AppPageNotificationService {
 
    @Resource
    private AppPageNotificationMapper appPageNotificationMapper;
 
    @Override
    public AppPageNotification getAppPageNotificationByType(String type) {
 
        return appPageNotificationMapper.selectByType(type);
    }
 
    @Cacheable(value = "configCache", key = "'getValidNotificationByTypeCache-'+#type")
    @Override
    public AppPageNotification getValidNotificationByTypeCache(String type) {
        return appPageNotificationMapper.selectValidByType(type);
    }
 
    @Override
    public void addAppPageNotification(AppPageNotification apn) throws Exception {
        if (apn == null)
            return;
        if (apn.getType() == null)
            throw new Exception("类型为空");
        AppPageNotification old = getAppPageNotificationByType(apn.getType().name());
 
        if (old != null)
            throw new Exception("已存在改类型");
 
        apn.setCreateTime(new Date());
        apn.setUpdateTime(new Date());
        apn.setMd5(StringUtil.Md5(apn.getType().name() + "#" + apn.getContent() + "#" + apn.getContentUrl()));
        appPageNotificationMapper.insertSelective(apn);
    }
 
    @Override
    public void insertSelective(AppPageNotification record) {
        appPageNotificationMapper.insertSelective(record);
    }
 
    @Override
    public void updateByPrimaryKey(AppPageNotification record) {
        appPageNotificationMapper.updateByPrimaryKey(record);        
    }
    
    @Override
    public void updateByPrimaryKeySelective(AppPageNotification record) {
        appPageNotificationMapper.updateByPrimaryKeySelective(record);        
    }
 
    @Override
    public AppPageNotification selectByPrimaryKey(Long id) {
        return appPageNotificationMapper.selectByPrimaryKey(id);
    }
 
    @Override
    public int deleteBatchByPrimaryKey(List<Long> list) {
        return appPageNotificationMapper.deleteBatchByPrimaryKey(list);
    }
 
    @Override
    public List<AppPageNotification> listQuery(long start, int count, String key, Integer show, Integer canClose) {
        return appPageNotificationMapper.listQuery(start, count, key, show, canClose);
    }
 
    @Override
    public long countQuery(String key, Integer show, Integer canClose) {
        return appPageNotificationMapper.countQuery(key, show, canClose);
    }
 
    
}