Administrator
2018-10-30 7bf6a0582c7c62c90ee2ed8a88654f11d0479092
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
package com.yeshi.fanli.service.impl.help;
 
import java.util.Date;
 
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 = "'getAppPageNotificationByType-'+#type")
    @Override
    public AppPageNotification getAppPageNotificationByTypeCache(String type) {
 
        return appPageNotificationMapper.selectByType(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);
    }
 
}