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 = "'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); } @Override public void insertSelective(AppPageNotification record) { appPageNotificationMapper.insertSelective(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 list) { return appPageNotificationMapper.deleteBatchByPrimaryKey(list); } @Override public List 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); } }