package com.stylefeng.guns.modular.system.service.impl;
|
|
import com.baomidou.mybatisplus.service.impl.ServiceImpl;
|
import com.stylefeng.guns.modular.system.dao.SystemNoticeMapper;
|
import com.stylefeng.guns.modular.system.dao.TNoticesMapper;
|
import com.stylefeng.guns.modular.system.model.SystemNotice;
|
import com.stylefeng.guns.modular.system.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.insert(systemNotice);
|
}
|
|
/**
|
* 获取未阅读数据
|
* @param uid
|
* @return
|
* @throws Exception
|
*/
|
@Override
|
public int queryNoReadNoticeNum(Integer uid) throws Exception {
|
return systemNoticeMapper.queryNoReadNoticeNum(uid);
|
}
|
|
/**
|
* 获取消息列表
|
* @param type
|
* @param pageNum
|
* @param size
|
* @param uid
|
* @return
|
*/
|
@Override
|
public List<Map<String, Object>> queryList(Integer type, Integer pageNum, Integer size, Integer uid) {
|
pageNum = (pageNum - 1) * size;
|
List<Map<String, Object>> list = null;
|
if(type == 1){//系统公告
|
list = tNoticesMapper.queryList(pageNum, size, uid);
|
}
|
if(type == 2){//系统消息
|
list = systemNoticeMapper.queryList(type, pageNum, size, uid);
|
for(Map<String, Object> map : list){
|
systemNoticeMapper.readSystemNotice(Integer.valueOf(String.valueOf(map.get("id"))), uid);
|
}
|
}
|
return list;
|
}
|
|
|
/**
|
* 阅读操作
|
* @param id
|
* @param uid
|
* @throws Exception
|
*/
|
@Override
|
public void readSystemNotice(Integer id, Integer uid) throws Exception {
|
systemNoticeMapper.readSystemNotice(id, uid);
|
}
|
|
|
/**
|
* 删除公告或消息
|
* @param id
|
* @param uid
|
* @throws Exception
|
*/
|
@Override
|
public void delSystemNotice(Integer id, Integer uid) throws Exception {
|
systemNoticeMapper.delSystemNotice(id, uid);
|
}
|
|
|
/**
|
* 清空消息或公告
|
* @param uid
|
* @throws Exception
|
*/
|
@Override
|
public void clearSystemNotice(Integer uid) throws Exception {
|
systemNoticeMapper.delSystemNotice(null, uid);
|
}
|
}
|