Pu Zhibing
2025-05-08 41600563b0ee8cfad746c359c4d3971169d1c931
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
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
package com.ruoyi.other.controller;
 
 
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.ruoyi.common.core.web.domain.AjaxResult;
import com.ruoyi.common.log.annotation.Log;
import com.ruoyi.common.log.enums.BusinessType;
import com.ruoyi.common.log.enums.OperatorType;
import com.ruoyi.common.security.annotation.Logical;
import com.ruoyi.common.security.annotation.RequiresPermissions;
import com.ruoyi.other.api.domain.TNotice;
import com.ruoyi.other.api.dto.NoticeQueryDto;
import com.ruoyi.other.mapper.SysNoticeMapper;
import com.ruoyi.other.service.TNoticeService;
import io.swagger.annotations.ApiOperation;
import org.springframework.web.bind.annotation.*;
 
import javax.annotation.Resource;
import java.time.LocalDate;
import java.time.LocalDateTime;
import java.util.List;
 
/**
 * <p>
 *  前端控制器
 * </p>
 *
 * @author 无关风月
 * @since 2024-08-06
 */
@RestController
@RequestMapping("/t-notice")
public class TNoticeController {
    @Resource
    private TNoticeService noticeService;
    
    
    @RequiresPermissions(value = {"/publicAnnouncementManagement/add", "/publicAnnouncementManagement/update"}, logical = Logical.OR)
    @ApiOperation(tags = {"后台-内容设置-公告管理"},value = "新增修改")
    @PostMapping(value = "/saveOrUpdate")
    @Log(title = "【公告管理】新增修改公告", businessType = BusinessType.INSERT)
    public AjaxResult saveOrUpdate(@RequestBody TNotice notice) {
        noticeService.saveOrUpdate(notice);
        return AjaxResult.success();
    }
    
    
    @RequiresPermissions(value = {"/publicAnnouncementManagement/del"}, logical = Logical.OR)
    @ApiOperation(tags = {"后台-内容设置-公告管理"},value = "删除")
    @DeleteMapping(value = "/deleteById")
    @Log(title = "【公告管理】删除公告", businessType = BusinessType.DELETE)
    public AjaxResult deleteById(String ids) {
        String[] split = ids.split(",");
        for (String id : split) {
            noticeService.removeById(id);
        }
 
        return AjaxResult.success();
    }
    
    
    @RequiresPermissions(value = {"/publicAnnouncementManagement"}, logical = Logical.OR)
    @ApiOperation(tags = {"后台-内容设置-公告管理"},value = "查询")
    @PostMapping(value = "/pageList")
    public AjaxResult<Page<TNotice>> authPageList(@RequestBody NoticeQueryDto query) {
        if (query.getStatus()==null){
 
                return AjaxResult.success(noticeService.lambdaQuery()
                        .like(query.getContent()!=null&&query.getContent()!="",TNotice::getContent,query.getContent())
                        .page(Page.of(query.getPageCurr(),query.getPageSize())));
 
        }
 
            if (query.getStatus()==0){
                return AjaxResult.success(noticeService.lambdaQuery()
                        .le(TNotice::getStartTime, LocalDateTime.now())
                        .like(query.getContent()!=null&&query.getContent()!="",TNotice::getContent,query.getContent())
                        .page(Page.of(query.getPageCurr(),query.getPageSize())));
            }else if (query.getStatus()==1){
                return AjaxResult.success(noticeService.lambdaQuery()
                        .ge(TNotice::getStartTime, LocalDateTime.now()).le(TNotice::getEndTime,LocalDateTime.now())
                        .like(query.getContent()!=null&&query.getContent()!="",TNotice::getContent,query.getContent())
                        .page(Page.of(query.getPageCurr(),query.getPageSize())));
            }else if (query.getStatus()==2){
                return AjaxResult.success(noticeService.lambdaQuery()
                        .ge(TNotice::getEndTime, LocalDateTime.now())
                        .like(query.getContent()!=null&&query.getContent()!="",TNotice::getContent,query.getContent())
                        .page(Page.of(query.getPageCurr(),query.getPageSize())));
            }else{
                return AjaxResult.success(noticeService.lambdaQuery()
                        .like(query.getContent()!=null&&query.getContent()!="",TNotice::getContent,query.getContent())
                        .page(Page.of(query.getPageCurr(),query.getPageSize())));
        }
 
 
    }
    
    
    @ApiOperation(tags = {"小程序-首页-公告管理"},value = "查询")
    @GetMapping(value = "/list")
    public AjaxResult<List<TNotice>> list() {
        return AjaxResult.success(noticeService.list(Wrappers.lambdaQuery(TNotice.class)
                .le(TNotice::getStartTime, LocalDate.now())
                .ge(TNotice::getEndTime,LocalDate.now())));
 
    }
 
}