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