package com.cxyxiaomo.epp.miniprogram.index.controller;

import com.cxyxiaomo.epp.common.response.Res;
import com.cxyxiaomo.epp.common.pojo.Notice;
import com.cxyxiaomo.epp.miniprogram.index.service.NoticeService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

@Controller
@RequestMapping("notice")
public class NoticeController {

    @Autowired
    private NoticeService noticeService;

    @RequestMapping("/noticeList")
    @ResponseBody
    public Res noticeList(Integer limit){
        return Res.success(noticeService.noticeList(limit));
    }

    @RequestMapping("/addNotice")
    @ResponseBody
    public String addNotice(Notice notice){
        noticeService.addNotice(notice);
        return "发布成功";
    }

    @RequestMapping("/delNotice")
    @ResponseBody
    public String delNotice(Integer id){
        noticeService.delNotice(id);
        return "删除成功";
    }
}
