package api

import (
	"gadmin/internal/admin/forms"
	"gadmin/internal/admin/service"
	"github.com/gin-gonic/gin"
)

func AnnouncementList(c *gin.Context) {
	c.JSON(200, service.Announcement.List())
}

func AnnouncementAdd(c *gin.Context) {
	var req forms.AnnouncementAddReq
	if err := c.ShouldBind(&req); err != nil {
		c.JSON(200, ErrorResponse(err))
		return
	}

	if err := forms.ParseParams(&req); err != nil {
		c.JSON(200, ErrorResponse(err))
		return
	}

	c.JSON(200, service.Announcement.Add(req))
}

func AnnouncementDel(c *gin.Context) {
	c.JSON(200, service.Announcement.Del())
}

func AnnouncementInfo(c *gin.Context) {
	service.Get(c)
}
