Files
EasyGoAdmin_GoFrame_EleVue/api/v1/notice.go
T
2026-10-20 11:37:25 +08:00

129 lines
5.9 KiB
Go

package v1
import (
"github.com/gogf/gf/v2/os/gtime"
"github.com/gogf/gf/v2/util/gmeta"
)
// ============================== 公告模块 ==============================
// NoticeItem 公告行数据
// 用于公告分页列表等场景的公告基础信息
type NoticeItem struct {
Id int64 `json:"id"` // 主键ID
Title string `json:"title"` // 公告标题
Cover string `json:"cover"` // 封面图
Type int `json:"type"` // 类型
TypeText string `json:"typeText"` // 类型文本
ClickNum int `json:"clickNum"` // 点击量
Status int `json:"status"` // 状态:0-草稿 1-发布
StatusText string `json:"statusText"` // 状态文本
CreateUser string `json:"createUser"` // 创建人
CreateTime *gtime.Time `json:"createTime"` // 创建时间
}
// NoticePageReq 公告分页请求
// 支持关键词、标题、类型、状态等条件组合查询
type NoticePageReq struct {
gmeta.Meta `method:"get" path:"/api/notice/page" summary:"公告分页" permission:"sys:notice:page" log:"公告管理-查询分页记录" logType:"query"`
PageReq // 分页基础参数
Keyword string `json:"keyword" dc:"关键词(标题模糊)"` // 关键词,标题模糊匹配
Title string `json:"title" dc:"标题模糊"` // 标题模糊匹配
Type int `json:"type" dc:"类型"` // 类型
Status int `json:"status" dc:"状态:0-草稿 1-发布"` // 状态
}
// NoticePageRes 公告分页结果
type NoticePageRes = PageData[NoticeItem]
// NoticeListReq 公告列表请求
type NoticeListReq struct {
gmeta.Meta `method:"get" path:"/api/notice/list" summary:"公告列表" permission:"sys:notice:list" log:"公告管理-查询列表" logType:"query"`
Keyword string `json:"keyword" dc:"关键词"` // 关键词
Type int `json:"type" dc:"类型"` // 类型
Status int `json:"status" dc:"状态"` // 状态
Limit int `json:"limit" dc:"条数上限"` // 条数上限
}
// NoticeListItem 公告列表行数据
// 精简结构,仅包含列表展示所需字段
type NoticeListItem struct {
Id int64 `json:"id"` // 主键ID
Title string `json:"title"` // 公告标题
Type int `json:"type"` // 类型
Status int `json:"status"` // 状态:0-草稿 1-发布
}
// NoticeListRes 公告列表结果
type NoticeListRes = []NoticeListItem
// NoticeDetailReq 公告详情请求
type NoticeDetailReq struct {
gmeta.Meta `method:"get" path:"/api/notice/detail/:id" summary:"公告详情" permission:"sys:notice:detail" log:"公告管理-查询详情" logType:"query"`
Id int64 `json:"id" v:"required#缺少ID" dc:"公告ID"` // 公告ID
}
// NoticeDetailRes 公告详情结果
type NoticeDetailRes struct {
Id int64 `json:"id"` // 主键ID
Title string `json:"title"` // 公告标题
Cover string `json:"cover"` // 封面图
Type int `json:"type"` // 类型
TypeText string `json:"typeText"` // 类型文本
Status int `json:"status"` // 状态:0-草稿 1-发布
StatusText string `json:"statusText"` // 状态文本
Content string `json:"content"` // 正文
}
// NoticeAddReq 新增公告请求
type NoticeAddReq struct {
gmeta.Meta `method:"post" path:"/api/notice/add" summary:"新增公告" permission:"sys:notice:add" log:"公告管理-新增记录" logType:"add"`
Title string `json:"title" v:"required#请输入标题" dc:"标题"` // 公告标题
Cover string `json:"cover" dc:"封面图"` // 封面图
Type int `json:"type" dc:"类型"` // 类型
Status int `json:"status" dc:"状态:0-草稿 1-发布"` // 状态
Content string `json:"content" dc:"正文"` // 正文
}
// NoticeUpdateReq 修改公告请求
type NoticeUpdateReq struct {
gmeta.Meta `method:"put" path:"/api/notice/update" summary:"修改公告" permission:"sys:notice:update" log:"公告管理-修改记录" logType:"update"`
Id int64 `json:"id" v:"required#缺少ID" dc:"公告ID"` // 公告ID
Title string `json:"title" v:"required#请输入标题" dc:"标题"` // 公告标题
Cover string `json:"cover" dc:"封面图"` // 封面图
Type int `json:"type" dc:"类型"` // 类型
Status int `json:"status" dc:"状态"` // 状态
Content string `json:"content" dc:"正文"` // 正文
}
// NoticeUpdateRes 修改公告结果
type NoticeUpdateRes struct{}
// NoticeStatusReq 公告状态请求
type NoticeStatusReq struct {
gmeta.Meta `method:"put" path:"/api/notice/status" summary:"公告状态" permission:"sys:notice:status" log:"公告管理-设置状态" logType:"update"`
Id int64 `json:"id" v:"required#缺少ID" dc:"公告ID"` // 公告ID
Status int `json:"status" v:"required#缺少状态" dc:"状态:0-草稿 1-发布"` // 状态
}
// NoticeStatusRes 公告状态结果
type NoticeStatusRes struct{}
// NoticeDeleteReq 删除公告请求
type NoticeDeleteReq struct {
gmeta.Meta `method:"delete" path:"/api/notice/delete/:id" summary:"删除公告" permission:"sys:notice:delete" log:"公告管理-删除记录" logType:"delete"`
Id int64 `json:"id" v:"required#缺少ID" dc:"公告ID"` // 公告ID
}
// NoticeDeleteRes 删除公告结果
type NoticeDeleteRes struct{}
// NoticeBatchDeleteReq 批量删除公告请求
type NoticeBatchDeleteReq struct {
gmeta.Meta `method:"delete" path:"/api/notice/batchDelete" summary:"批量删除公告" permission:"sys:notice:batchDelete" log:"公告管理-批量删除记录" logType:"delete"`
Ids []int64 `json:"ids" v:"required#请选择要删除的记录" dc:"公告ID列表"` // 公告ID列表
}
// NoticeBatchDeleteRes 批量删除结果
type NoticeBatchDeleteRes struct{}