package com.kym.admin.controller;

import com.kym.common.R;
import com.kym.entity.queryParams.NoticeQueryParams;
import com.kym.entity.vo.NoticeStationVo;
import com.kym.service.SystemNoticeService;
import org.springframework.web.bind.annotation.*;

/**
 * <p>
 * 系统公告通知表 前端控制器
 * </p>
 *
 * @author skyline
 * @since 2024-08-20
 */
@RestController
@RequestMapping("/notice")
public class SystemNoticeController {

    private final SystemNoticeService systemNoticeService;

    public SystemNoticeController(SystemNoticeService systemNoticeService) {
        this.systemNoticeService = systemNoticeService;
    }

    /**
     * 新增系统公告
     *
     * @param vo
     * @return
     */
    @PostMapping("/create")
    public R<?> createSystemNotice(@RequestBody NoticeStationVo vo) {
        systemNoticeService.createNotice(vo);
        return R.success();
    }

    /**
     * 系统公告列表
     *
     * @param params
     * @return
     */
    @GetMapping("/list")
    public R<?> listSystemNotice(@ModelAttribute NoticeQueryParams params) {
        return R.success(systemNoticeService.listSystemNotice(params));
    }

    /**
     * 系统公告详情
     *
     * @param noticeId
     * @return
     */
    @GetMapping("/detail/{noticeId}")
    public R<?> listSystemNotice(@PathVariable("noticeId") Long noticeId) {
        return R.success(systemNoticeService.getNoticeById(noticeId));
    }
}
