package com.ruoyi.web.work.api;

import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.core.page.TableDataInfo;
import com.ruoyi.web.work.domain.Notice;
import com.ruoyi.web.work.domain.vo.NoticeVoList;
import com.ruoyi.web.work.service.INoticeService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

/**
 * 通知公告
 *
 * @author lsw
 * @date 2024-08-20
 */
@RestController
@RequestMapping("/app/notice")
public class Api_NoticeController extends BaseController {
    @Autowired
    private INoticeService noticeService;

    @GetMapping("/list")
    public TableDataInfo list(Notice notice) {
        notice.setState(0);
        startPage();
        List<NoticeVoList> list = noticeService.selectList(notice);
        return getDataTable(list);
    }

    @GetMapping(value = "/detail/{id}")
    public AjaxResult detail(@PathVariable("id") Long id) {
        return AjaxResult.success(noticeService.getById(id));
    }

}
