forked from all_user/stat_center
143 lines
3.5 KiB
Go
143 lines
3.5 KiB
Go
package announApi
|
|
|
|
import (
|
|
"github.com/gin-gonic/gin"
|
|
"stat/api/proto"
|
|
"stat/common/stdLog"
|
|
"stat/service/announInfoSer"
|
|
)
|
|
|
|
// @Tags 公告管理
|
|
// @Summary 公告列表
|
|
// @Description 公告列表
|
|
// @Accept json
|
|
// @Produce json
|
|
// @Security ApiKeyAuth
|
|
// @Param param body proto.ListAnnounReq true "参数"
|
|
// @Success 200 {object} proto.ListAnnounRes "成功"
|
|
// @Success 400 {string} string "失败"
|
|
// @Security ApiKeyAuth
|
|
// @Router /api/stat/announce/list [POST]
|
|
func ListAnnounce(ctx *gin.Context) {
|
|
param := proto.ListAnnounReq{}
|
|
if err := ctx.ShouldBindJSON(¶m); err != nil {
|
|
stdLog.ServerJSON(ctx, stdLog.ParamError, err)
|
|
return
|
|
}
|
|
|
|
code, data, err := announInfoSer.ListAnnoun(ctx, param)
|
|
if err != nil {
|
|
stdLog.ServerJSON(ctx, code, err)
|
|
return
|
|
}
|
|
|
|
stdLog.ServerJSON(ctx, code, data)
|
|
}
|
|
|
|
// @Tags 公告管理
|
|
// @Summary 新增公告信息
|
|
// @Description 新增公告信息
|
|
// @Accept json
|
|
// @Produce json
|
|
// @Security ApiKeyAuth
|
|
// @Param param body proto.AddAnnounReq true "参数"
|
|
// @Success 200 {string} string "成功"
|
|
// @Success 400 {string} string "失败"
|
|
// @Security ApiKeyAuth
|
|
// @Router /api/stat/announce/add [POST]
|
|
func AddAnnounce(ctx *gin.Context) {
|
|
param := proto.AddAnnounReq{}
|
|
if err := ctx.ShouldBindJSON(¶m); err != nil {
|
|
stdLog.ServerJSON(ctx, stdLog.ParamError, err)
|
|
return
|
|
}
|
|
|
|
code, data, err := announInfoSer.AddAnnounce(ctx, param)
|
|
if err != nil {
|
|
stdLog.ServerJSON(ctx, code, err)
|
|
return
|
|
}
|
|
|
|
stdLog.ServerJSON(ctx, code, data)
|
|
}
|
|
|
|
// @Tags 公告管理
|
|
// @Summary 修改公告信息
|
|
// @Description 修改公告信息
|
|
// @Accept json
|
|
// @Produce json
|
|
// @Security ApiKeyAuth
|
|
// @Param param body proto.UpdateAnnounReq true "参数列表"
|
|
// @Success 200 {string} string "成功"
|
|
// @Failure 400 {string} string "失败"
|
|
// @Security ApiKeyAuth
|
|
// @Router /api/stat/announce/update [POST]
|
|
func UpdateAnnounce(ctx *gin.Context) {
|
|
param := proto.UpdateAnnounReq{}
|
|
if err := ctx.ShouldBindJSON(¶m); err != nil {
|
|
stdLog.ServerJSON(ctx, stdLog.ParamError, err)
|
|
return
|
|
}
|
|
|
|
code, data, err := announInfoSer.UpdateAnnounce(ctx, param)
|
|
if err != nil {
|
|
stdLog.ServerJSON(ctx, code, err)
|
|
return
|
|
}
|
|
|
|
stdLog.ServerJSON(ctx, code, data)
|
|
}
|
|
|
|
// @Tags 公告管理
|
|
// @Summary 删除公告信息
|
|
// @Description 删除公告信息
|
|
// @Accept json
|
|
// @Produce json
|
|
// @Security ApiKeyAuth
|
|
// @Param param body proto.DelAnnounReq true "参数"
|
|
// @Success 200 {string} string "成功"
|
|
// @Success 400 {string} string "失败"
|
|
// @Security ApiKeyAuth
|
|
// @Router /api/stat/announce/del [POST]
|
|
func DelAnnounce(ctx *gin.Context) {
|
|
param := proto.DelAnnounReq{}
|
|
if err := ctx.ShouldBindJSON(¶m); err != nil {
|
|
stdLog.ServerJSON(ctx, stdLog.ParamError, err)
|
|
return
|
|
}
|
|
|
|
code, data, err := announInfoSer.DelAnnounce(ctx, param)
|
|
if err != nil {
|
|
stdLog.ServerJSON(ctx, code, err)
|
|
return
|
|
}
|
|
|
|
stdLog.ServerJSON(ctx, code, data)
|
|
}
|
|
|
|
// @Tags 公告管理
|
|
// @Summary 外部获取公告信息
|
|
// @Description 外部获取公告信息
|
|
// @Accept json
|
|
// @Produce json
|
|
// @Param param body proto.AnnouncementReq true "参数"
|
|
// @Success 200 {object} proto.AnnouncementRes "成功"
|
|
// @Success 400 {string} string "失败"
|
|
// @Security ApiKeyAuth
|
|
// @Router /api/stat/announce/get [POST]
|
|
func GetAnnounce(ctx *gin.Context) {
|
|
param := proto.AnnouncementReq{}
|
|
if err := ctx.ShouldBindJSON(¶m); err != nil {
|
|
stdLog.ServerJSON(ctx, stdLog.ParamError, err)
|
|
return
|
|
}
|
|
|
|
code, data, err := announInfoSer.GetAnnounce(ctx, param)
|
|
if err != nil {
|
|
stdLog.ServerJSON(ctx, code, err)
|
|
return
|
|
}
|
|
|
|
stdLog.ServerJSON(ctx, code, data)
|
|
}
|