New file |
| | |
| | | package com.dsh.course.service.impl; |
| | | |
| | | import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; |
| | | import com.dsh.course.entity.SystemNotice; |
| | | import com.dsh.course.mapper.SystemNoticeMapper; |
| | | import com.dsh.course.mapper.TNoticesMapper; |
| | | import com.dsh.course.service.ISystemNoticeService; |
| | | import org.springframework.stereotype.Service; |
| | | |
| | | import javax.annotation.Resource; |
| | | import java.util.Date; |
| | | import java.util.List; |
| | | import java.util.Map; |
| | | |
| | | |
| | | @Service |
| | | public class SystemNoticeServiceImpl extends ServiceImpl<SystemNoticeMapper, SystemNotice> implements ISystemNoticeService { |
| | | |
| | | @Resource |
| | | private SystemNoticeMapper systemNoticeMapper; |
| | | |
| | | @Resource |
| | | private TNoticesMapper tNoticesMapper; |
| | | |
| | | |
| | | /** |
| | | * 添加系统消息 |
| | | * @param userType |
| | | * @param content |
| | | * @param userId |
| | | * @throws Exception |
| | | */ |
| | | @Override |
| | | public void addSystemNotice(Integer userType, String content, Integer userId, Integer noticeType) throws Exception { |
| | | SystemNotice systemNotice = new SystemNotice(); |
| | | systemNotice.setContent(content); |
| | | systemNotice.setInsertTime(new Date()); |
| | | systemNotice.setRead(1); |
| | | systemNotice.setType(2); |
| | | systemNotice.setNoticeType(noticeType); |
| | | systemNotice.setUserId(userId); |
| | | systemNotice.setUserType(userType); |
| | | this.baseMapper.insert(systemNotice); |
| | | } |
| | | |
| | | /** |
| | | * 获取未阅读数据 |
| | | * @param uid |
| | | * @return |
| | | * @throws Exception |
| | | */ |
| | | @Override |
| | | public int queryNoReadNoticeNum(Integer uid, Integer userType) throws Exception { |
| | | return systemNoticeMapper.queryNoReadNoticeNum(uid, userType); |
| | | } |
| | | |
| | | /** |
| | | * 获取消息列表 |
| | | * @param type |
| | | * @param pageNum |
| | | * @param size |
| | | * @param uid |
| | | * @return |
| | | */ |
| | | @Override |
| | | public List<Map<String, Object>> queryList(Integer type, Integer pageNum, Integer size, Integer uid, Integer userType,Integer language) { |
| | | pageNum = (pageNum - 1) * size; |
| | | List<Map<String, Object>> list = null; |
| | | if(type == 1){//系统公告 |
| | | list = tNoticesMapper.queryList(pageNum, size, uid, userType,language); |
| | | } |
| | | if(type == 2){//系统消息 |
| | | list = systemNoticeMapper.queryList(type, pageNum, size, uid, userType,language); |
| | | for(Map<String, Object> map : list){ |
| | | systemNoticeMapper.readSystemNotice(Integer.valueOf(String.valueOf(map.get("id"))), uid, userType); |
| | | } |
| | | } |
| | | return list; |
| | | } |
| | | |
| | | |
| | | /** |
| | | * 阅读操作 |
| | | * @param id |
| | | * @param uid |
| | | * @throws Exception |
| | | */ |
| | | @Override |
| | | public void readSystemNotice(Integer id, Integer uid, Integer userType) throws Exception { |
| | | systemNoticeMapper.readSystemNotice(id, uid, userType); |
| | | } |
| | | |
| | | |
| | | /** |
| | | * 删除公告或消息 |
| | | * @param id |
| | | * @param uid |
| | | * @throws Exception |
| | | */ |
| | | @Override |
| | | public void delSystemNotice(Integer id, Integer uid, Integer userType) throws Exception { |
| | | systemNoticeMapper.delSystemNotice(id, uid, userType); |
| | | } |
| | | |
| | | |
| | | /** |
| | | * 清空消息或公告 |
| | | * @param uid |
| | | * @throws Exception |
| | | */ |
| | | @Override |
| | | public void clearSystemNotice(Integer uid, Integer userType) throws Exception { |
| | | systemNoticeMapper.delSystemNotice(null, uid, userType); |
| | | } |
| | | } |