package com.dsh.course.controller;
|
|
import com.dsh.course.model.vo.SystemNoticeAddReq;
|
import com.dsh.course.model.vo.SystemNoticeListReq;
|
import com.dsh.course.model.vo.SystemNoticeListWarpper;
|
import com.dsh.course.model.vo.SystemNoticeWarpper;
|
import com.dsh.course.service.ISystemNoticeService;
|
import org.springframework.beans.factory.annotation.Autowired;
|
import org.springframework.web.bind.annotation.PostMapping;
|
import org.springframework.web.bind.annotation.RequestBody;
|
import org.springframework.web.bind.annotation.RequestMapping;
|
import org.springframework.web.bind.annotation.RestController;
|
|
import java.util.ArrayList;
|
import java.util.List;
|
import java.util.Map;
|
|
|
@RestController
|
@RequestMapping("/systemNotice")
|
public class SystemNoticeController {
|
|
@Autowired
|
private ISystemNoticeService systemNoticeService;
|
|
|
/**
|
* 远程调用
|
* @throws Exception
|
*/
|
@PostMapping("/addSystemNotice")
|
public void addSystemNotice(SystemNoticeAddReq req) {
|
try {
|
systemNoticeService.addSystemNotice(req.getUserType(), req.getContent(), req.getUserId(), req.getNoticeType());
|
}catch (Exception e){
|
e.printStackTrace();
|
}
|
}
|
|
|
/**
|
* 获取未读消息数量
|
* @return
|
*/
|
@PostMapping("/queryNoReadNoticeNum")
|
public int queryNoReadNoticeNum(SystemNoticeListReq req){
|
try {
|
return systemNoticeService.queryNoReadNoticeNum(req.getUid(), req.getUserType());
|
}catch (Exception e){
|
e.printStackTrace();
|
return 0;
|
}
|
}
|
|
/**
|
* 获取消息列表
|
* @param req
|
* @return
|
*/
|
@PostMapping("/querySystemNoticeListV2")
|
public List<SystemNoticeWarpper> querySystemNoticeListV2(@RequestBody SystemNoticeListReq req){
|
try {
|
List<Map<String, Object>> list = systemNoticeService.queryList(req.getType(), req.getPageNum(), req.getSize(), req.getUid(), req.getUserType(),req.getLanguage());
|
List<SystemNoticeWarpper> systemNoticeWarpper = SystemNoticeWarpper.getSystemNoticeWarpper(list);
|
return systemNoticeWarpper;
|
}catch (Exception e){
|
e.printStackTrace();
|
return new ArrayList<>();
|
}
|
}
|
|
|
/**
|
* 获取消息列表
|
* @param req
|
* @return
|
*/
|
@PostMapping("/querySystemNoticeList")
|
public SystemNoticeListWarpper querySystemNoticeList(SystemNoticeListReq req){
|
try {
|
List<Map<String, Object>> list = systemNoticeService.queryList(req.getType(), req.getPageNum(), req.getSize(), req.getUid(), req.getUserType(),req.getLanguage());
|
List<SystemNoticeWarpper> systemNoticeWarpper = SystemNoticeWarpper.getSystemNoticeWarpper(list);
|
SystemNoticeListWarpper listWarpper = new SystemNoticeListWarpper();
|
listWarpper.setList(systemNoticeWarpper);
|
return listWarpper;
|
}catch (Exception e){
|
e.printStackTrace();
|
return null;
|
}
|
}
|
|
/**
|
* 阅读系统消息
|
* @param req
|
*/
|
@PostMapping("/readSystemNotice")
|
public void readSystemNotice(SystemNoticeListReq req){
|
try {
|
systemNoticeService.readSystemNotice(req.getId(), req.getUid(), req.getUserType());
|
}catch (Exception e){
|
e.printStackTrace();
|
}
|
}
|
|
|
/**
|
* 删除系统消息
|
* @param req
|
*/
|
@PostMapping("/delSystemNotice")
|
public void delSystemNotice(SystemNoticeListReq req){
|
try {
|
systemNoticeService.delSystemNotice(req.getId(), req.getUid(), req.getUserType());
|
}catch (Exception e){
|
e.printStackTrace();
|
}
|
}
|
|
|
/**
|
* 清空系统消息
|
*/
|
@PostMapping("/clearSystemNotice")
|
public void clearSystemNotice(SystemNoticeListReq req){
|
try {
|
systemNoticeService.clearSystemNotice(req.getUid(), req.getUserType());
|
}catch (Exception e){
|
e.printStackTrace();
|
}
|
}
|
}
|