package com.ningdatech.pmapi.sys.controller;

import com.ningdatech.basic.model.PageVo;
import com.ningdatech.log.annotation.WebLog;
import com.ningdatech.pmapi.sys.manage.NotifyManage;
import com.ningdatech.pmapi.sys.model.req.NotifyListReq;
import com.ningdatech.pmapi.sys.model.vo.NotifyVO;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.RequiredArgsConstructor;
import org.springframework.web.bind.annotation.*;

/**
 * <p>
 * 通知消息 前端控制器
 * </p>
 *
 * @author ZPF
 * @since 2023-03-22
 */
@RestController
@Api(tags = "通知管理")
@RequiredArgsConstructor
@RequestMapping("/api/v1/notify")
public class NotifyController {

    private final NotifyManage notifyManage;

    @GetMapping("/list")
    @ApiOperation("通知列表")
    public PageVo<NotifyVO> page(@ModelAttribute NotifyListReq notifyListReq){
        return notifyManage.page(notifyListReq);
    }

    @GetMapping("/detail/{id}")
    @ApiOperation("通知详情")
    public NotifyVO save(@PathVariable Long id) {
        return notifyManage.detail(id);
    }

    @PostMapping("/read/{id}")
    @ApiOperation("已读")
    @WebLog("消息-已读")
    public Boolean read(@PathVariable Long id) {
        return notifyManage.read(id);
    }

}
