package com.yida.data.school.news.controller;

import com.baomidou.mybatisplus.core.metadata.IPage;
import com.yida.data.common.core.common.ResultBean;
import com.yida.data.common.core.utils.FebsUtil;
import com.yida.data.school.news.service.EduNoticeSystemService;
import com.yida.data.school.vo.news.SysNoticeInfoVO;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.RequiredArgsConstructor;
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;


@Api(tags = "通知咨询-系统通知")
@RequiredArgsConstructor
@RestController
@RequestMapping("/news/sys")
public class EduNoticeSysController {

    private final EduNoticeSystemService eduNoticeSystemService;

    @ApiOperation("分页查询通知")
    @GetMapping("/listNoticePage")
    public ResultBean<IPage<SysNoticeInfoVO>> listNoticePage(@RequestParam(defaultValue = "1") Integer pageNum,
        @RequestParam(defaultValue = "10") Integer pageSize) {
        return ResultBean
            .buildSuccess(eduNoticeSystemService.listNoticePage(FebsUtil.getCurrentUser().getUserId(), pageNum, pageSize));
    }

    @ApiOperation("查询是否有新消息")
    @GetMapping("/existNewMsg")
    public ResultBean<Boolean> existNewMsg() {
        return ResultBean.buildSuccess(eduNoticeSystemService.existNewMsg(FebsUtil.getCurrentUser().getUserId()));
    }
}
