83 lines
2.1 KiB
Go
83 lines
2.1 KiB
Go
package api
|
|
|
|
import (
|
|
"github.com/gin-gonic/gin"
|
|
"github.com/guxuan/hailin_service/internal/mods/rbac/biz"
|
|
"github.com/guxuan/hailin_service/internal/mods/rbac/schema"
|
|
"github.com/guxuan/hailin_service/pkg/util"
|
|
)
|
|
|
|
// Banner management for RBAC
|
|
type WebSite struct {
|
|
WebSiteBIZ *biz.WebSite
|
|
}
|
|
|
|
// @Tags 网页设置
|
|
// @Security ApiKeyAuth
|
|
// @Summary Query WebSite info
|
|
// @Success 200 {object} util.ResponseResult{data=[]schema.WebSite}
|
|
// @Failure 401 {object} util.ResponseResult
|
|
// @Failure 500 {object} util.ResponseResult
|
|
// @Router /api/v1/web_site [get]
|
|
func (a *WebSite) Query(c *gin.Context) {
|
|
ctx := c.Request.Context()
|
|
|
|
result, err := a.WebSiteBIZ.Query(ctx)
|
|
if err != nil {
|
|
util.ResError(c, err)
|
|
return
|
|
}
|
|
util.ResSuccess(c, result)
|
|
}
|
|
|
|
// @Tags ArticleAPI
|
|
// @Security ApiKeyAuth
|
|
// @Summary Create WebSite record
|
|
// @Param body body schema.WebSiteForm true "Request body"
|
|
// @Success 200 {object} util.ResponseResult{data=schema.WebSite}
|
|
// @Failure 400 {object} util.ResponseResult
|
|
// @Failure 401 {object} util.ResponseResult
|
|
// @Failure 500 {object} util.ResponseResult
|
|
// @Router /api/v1/web_site [post]
|
|
func (a *WebSite) Create(c *gin.Context) {
|
|
ctx := c.Request.Context()
|
|
item := new(schema.WebSiteForm)
|
|
if err := util.ParseJSON(c, item); err != nil {
|
|
util.ResError(c, err)
|
|
return
|
|
}
|
|
|
|
result, err := a.WebSiteBIZ.Create(ctx, item)
|
|
if err != nil {
|
|
util.ResError(c, err)
|
|
return
|
|
}
|
|
util.ResSuccess(c, result)
|
|
}
|
|
|
|
// @Tags 网页设置
|
|
// @Security ApiKeyAuth
|
|
// @Summary Update WebSite record by ID
|
|
// @Param id path string true "unique id"
|
|
// @Param body body schema.WebSiteForm true "Request body"
|
|
// @Success 200 {object} util.ResponseResult
|
|
// @Failure 400 {object} util.ResponseResult
|
|
// @Failure 401 {object} util.ResponseResult
|
|
// @Failure 500 {object} util.ResponseResult
|
|
// @Router /api/v1/web_site/{id} [put]
|
|
func (a *WebSite) Update(c *gin.Context) {
|
|
ctx := c.Request.Context()
|
|
item := new(schema.WebSiteForm)
|
|
if err := util.ParseJSON(c, item); err != nil {
|
|
util.ResError(c, err)
|
|
return
|
|
}
|
|
|
|
err := a.WebSiteBIZ.Update(ctx, c.Param("id"), item)
|
|
if err != nil {
|
|
util.ResError(c, err)
|
|
return
|
|
}
|
|
util.ResOK(c)
|
|
}
|