SysNoticeController.java
3.08 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
package com.huaheng.pc.system.notice.controller;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.huaheng.common.utils.StringUtils;
import com.huaheng.common.utils.security.ShiroUtils;
import com.huaheng.framework.web.controller.BaseController;
import com.huaheng.framework.web.domain.AjaxResult;
import com.huaheng.framework.web.page.PageDomain;
import com.huaheng.framework.web.page.TableDataInfo;
import com.huaheng.framework.web.page.TableSupport;
import com.huaheng.pc.receipt.receiptHeader.domain.ReceiptHeader;
import com.huaheng.pc.system.notice.domain.SysNotice;
import com.huaheng.pc.system.notice.service.SysNoticeService;
import org.springframework.stereotype.Controller;
import org.springframework.ui.ModelMap;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.ResponseBody;
import javax.annotation.Resource;
import java.util.ArrayList;
@Controller
@RequestMapping("/system/notice")
public class SysNoticeController extends BaseController {
@Resource
private SysNoticeService sysNoticeService;
private String prefix = "system/notice";
@GetMapping("/mailbox")
public String mailbox(ModelMap mmap){
mmap.put("user",ShiroUtils.getUser());
return prefix+"/mailbox";
}
@GetMapping("/list")
@ResponseBody
public TableDataInfo list(String status) {
LambdaQueryWrapper<SysNotice> lambdaQueryWrapper = Wrappers.lambdaQuery();
PageDomain pageDomain = TableSupport.buildPageRequest();
Integer pageNum = pageDomain.getPageNum();
Integer pageSize = pageDomain.getPageSize();
lambdaQueryWrapper.eq(StringUtils.isNotEmpty(status), SysNotice::getStatus, status)
.orderByAsc(SysNotice::getStatus);
if (StringUtils.isNotNull(pageNum) && StringUtils.isNotNull(pageSize)) {
Page<SysNotice> page = new Page(pageNum, pageSize);
IPage<SysNotice> iPage = sysNoticeService.page(page, lambdaQueryWrapper);
return getMpDataTable(iPage.getRecords(), iPage.getTotal());
} else {
return getDataTable(sysNoticeService.list(lambdaQueryWrapper));
}
}
/**
* 将所有消息已读
* @return
*/
@GetMapping("/readAll")
@ResponseBody
public AjaxResult readAll(){
if (sysNoticeService.readAll()){
return AjaxResult.success();
}else {
return AjaxResult.error("消息记录状态修改失败");
}
}
@GetMapping("/readOne")
@ResponseBody
public AjaxResult readOne(@RequestParam String id){
if (sysNoticeService.readOne(id)){
return AjaxResult.success();
}else {
return AjaxResult.error("id为"+id+"消息记录状态修改失败");
}
}
}