xuhy
4 天以前 a069a12647ab551281091efb0f066163d1c8c156
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
package com.ruoyi.web.controller.api;
 
 
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
import com.ruoyi.common.core.domain.R;
import com.ruoyi.framework.web.service.TokenService;
import com.ruoyi.system.model.TNotice;
import com.ruoyi.system.service.TNoticeService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
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.RestController;
 
import java.util.List;
 
/**
 * <p>
 * 待办事项 前端控制器
 * </p>
 *
 * @author xiaochen
 * @since 2025-04-08
 */
@Api(tags = "待办事项")
@RestController
@RequestMapping("")
public class TNoticeController {
 
    private final TNoticeService noticeService;
    private final TokenService tokenService;
    @Autowired
    public TNoticeController(TNoticeService noticeService, TokenService tokenService) {
        this.noticeService = noticeService;
        this.tokenService = tokenService;
    }
 
    /**
     * 获取待办事项
     */
    //@PreAuthorize("@ss.hasPermi('system:notice:list')")
    @ApiOperation(value = "获取待办事项")
    @GetMapping(value = "/open/t-notice/list")
    public R<List<TNotice>> list() {
        // 获取当前用户
        Long userId = tokenService.getLoginUser().getUserId();
        List<TNotice> list = noticeService.list(Wrappers.lambdaQuery(TNotice.class)
                .eq(TNotice::getUserId, userId)
                .eq(TNotice::getIsRead, 0));
        return R.ok(list);
    }
 
    /**
     * 操作已读
     */
    //@PreAuthorize("@ss.hasPermi('system:notice:read')")
    @ApiOperation(value = "操作已读")
    @GetMapping(value = "/open/t-notice/read")
    public R<String> read(@RequestParam String id) {
        TNotice notice = noticeService.getById(id);
        notice.setIsRead(1);
        noticeService.updateById(notice);
        return R.ok();
    }
 
}