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();
|
}
|
|
}
|