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);
|
}
|
|
}
|