package com.iailab.module.system.service.notify; import com.iailab.framework.common.pojo.PageResult; import com.iailab.module.system.controller.admin.notify.vo.message.NotifyMessageMyPageReqVO; import com.iailab.module.system.controller.admin.notify.vo.message.NotifyMessagePageReqVO; import com.iailab.module.system.dal.dataobject.notify.NotifyMessageDO; import com.iailab.module.system.dal.dataobject.notify.NotifyTemplateDO; import com.iailab.module.system.dal.mysql.notify.NotifyMessageMapper; import org.springframework.stereotype.Service; import org.springframework.validation.annotation.Validated; import javax.annotation.Resource; import java.util.Collection; import java.util.List; import java.util.Map; /** * 站内信 Service 实现类 * * @author xrcoder */ @Service @Validated public class NotifyMessageServiceImpl implements NotifyMessageService { @Resource private NotifyMessageMapper notifyMessageMapper; @Override public Long createNotifyMessage(Long userId, Integer userType, NotifyTemplateDO template, String templateContent, Map templateParams) { NotifyMessageDO message = new NotifyMessageDO().setUserId(userId).setUserType(userType) .setTemplateId(template.getId()).setTemplateCode(template.getCode()) .setTemplateType(template.getType()).setTemplateNickname(template.getNickname()) .setTemplateContent(templateContent).setTemplateParams(templateParams).setReadStatus(false); notifyMessageMapper.insert(message); return message.getId(); } @Override public PageResult getNotifyMessagePage(NotifyMessagePageReqVO pageReqVO) { return notifyMessageMapper.selectPage(pageReqVO); } @Override public PageResult getMyMyNotifyMessagePage(NotifyMessageMyPageReqVO pageReqVO, Long userId, Integer userType) { return notifyMessageMapper.selectPage(pageReqVO, userId, userType); } @Override public NotifyMessageDO getNotifyMessage(Long id) { return notifyMessageMapper.selectById(id); } @Override public List getUnreadNotifyMessageList(Long userId, Integer userType, Integer size) { return notifyMessageMapper.selectUnreadListByUserIdAndUserType(userId, userType, size); } @Override public Long getUnreadNotifyMessageCount(Long userId, Integer userType) { return notifyMessageMapper.selectUnreadCountByUserIdAndUserType(userId, userType); } @Override public int updateNotifyMessageRead(Collection ids, Long userId, Integer userType) { return notifyMessageMapper.updateListRead(ids, userId, userType); } @Override public int updateAllNotifyMessageRead(Long userId, Integer userType) { return notifyMessageMapper.updateListRead(userId, userType); } }