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.entity.notice.EduNoticeSchool;
import com.yida.data.school.dto.news.ListNoticeDTO;
import com.yida.data.school.news.service.EduNoticeSchoolService;
import com.yida.data.school.vo.news.SchoolNoticePageVO;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

@Api(tags = "通知咨询-学校通知(不鉴权)")
@Slf4j
@RestController
@RequestMapping("/in/news/school")
@RequiredArgsConstructor
public class InEduNoticeSchoolController {

    private final EduNoticeSchoolService eduNoticeSchoolService;

    @GetMapping("/sendNotice")
    public ResultBean sendNotice(Long noticeId) {
        log.info("学校通知发送，id[{}]", noticeId);
        eduNoticeSchoolService.sendNotice(noticeId);
        return ResultBean.buildSuccess();
    }

    @ApiOperation("查询公告列表")
    @GetMapping("/listNoticePage")
    public ResultBean<IPage<SchoolNoticePageVO>> listNotice(ListNoticeDTO dto) {
        return ResultBean.buildSuccess(eduNoticeSchoolService.listNoticePage(dto));
    }

    @ApiOperation("查询公告")
    @GetMapping("/getNotice")
    public ResultBean<EduNoticeSchool> listNotice(Long id) {
        return ResultBean.buildSuccess(eduNoticeSchoolService.getNoticeInfo(id));
    }
}
