137 lines
5.6 KiB
Plaintext
137 lines
5.6 KiB
Plaintext
// 通用基础响应结构(不含泛型,兼容Goctl)
|
||
type BaseResp {
|
||
Code int `json:"code"` // 状态码:0成功,非0失败
|
||
Msg string `json:"message"` // 提示信息
|
||
}
|
||
|
||
// 社会服务实体结构(与表字段对应)
|
||
type SocialService {
|
||
Id int64 `json:"id"` // 主键ID
|
||
Title string `json:"title"` // 标题
|
||
Subtitle string `json:"subtitle,omitempty"` // 副标题
|
||
CoverUrl string `json:"cover_url,omitempty"` // 封面图片URL
|
||
Intro string `json:"intro,omitempty"` // 简介(纯文字)
|
||
Content string `json:"content,omitempty"` // 内容(Markdown格式)
|
||
ImageEditors string `json:"image_editors,omitempty"` // 图片编辑者名单(逗号分隔)
|
||
TextEditors string `json:"text_editors,omitempty"` // 文字编辑者名单(逗号分隔)
|
||
ChiefEditor string `json:"chief_editor,omitempty"` // 总编辑
|
||
Proofreaders string `json:"proofreaders,omitempty"` // 校对者名单(逗号分隔)
|
||
Reviewers string `json:"reviewers,omitempty"` // 审核者名单(逗号分隔)
|
||
PublishTime string `json:"publish_time"` // 发布时间(格式:yyyy-MM-dd HH:mm:ss)
|
||
UpdateTime string `json:"update_time"` // 最后更改时间(格式:yyyy-MM-dd HH:mm:ss)
|
||
}
|
||
|
||
// 创建社会服务 - 请求参数
|
||
type CreateSocialServiceReq {
|
||
Title string `json:"title" validate:"required"` // 标题(必填)
|
||
Subtitle string `json:"subtitle,omitempty"` // 副标题
|
||
CoverUrl string `json:"cover_url,omitempty"` // 封面图片URL
|
||
Intro string `json:"intro,omitempty"` // 简介(纯文字)
|
||
Content string `json:"content,omitempty"` // 内容(Markdown格式)
|
||
ImageEditors string `json:"image_editors,omitempty"` // 图片编辑者名单(逗号分隔)
|
||
TextEditors string `json:"text_editors,omitempty"` // 文字编辑者名单(逗号分隔)
|
||
ChiefEditor string `json:"chief_editor,omitempty"` // 总编辑
|
||
Proofreaders string `json:"proofreaders,omitempty"` // 校对者名单(逗号分隔)
|
||
Reviewers string `json:"reviewers,omitempty"` // 审核者名单(逗号分隔)
|
||
}
|
||
|
||
// 创建社会服务 - 响应参数(嵌套数据,无泛型)
|
||
type CreateSocialServiceResp {
|
||
Code int `json:"code"`
|
||
Msg string `json:"message"`
|
||
Data CreateSocialServiceData `json:"data,omitempty"`
|
||
}
|
||
|
||
type CreateSocialServiceData {
|
||
Id int64 `json:"id"` // 新增记录的ID
|
||
}
|
||
|
||
// 获取社会服务列表 - 请求参数
|
||
type ListSocialServiceReq {
|
||
Page int `json:"page" form:"page" validate:"min=1"` // 页码(默认1)
|
||
PageSize int `json:"page_size" form:"page_size" validate:"min=1,max=100"` // 每页条数(默认10,最大100)
|
||
}
|
||
|
||
// 获取社会服务列表 - 响应参数(嵌套数据,无泛型)
|
||
type ListSocialServiceResp {
|
||
Code int `json:"code"`
|
||
Msg string `json:"message"`
|
||
Data ListSocialServiceData `json:"data,omitempty"`
|
||
}
|
||
|
||
type ListSocialServiceData {
|
||
Total int64 `json:"total"` // 总条数
|
||
List []SocialService `json:"list"` // 列表数据
|
||
}
|
||
|
||
// 获取社会服务详情 - 请求参数(路径参数)
|
||
type GetSocialServiceReq {
|
||
Id int64 `json:"id" path:"id" validate:"min=1"` // 社会服务ID(必填)
|
||
}
|
||
|
||
// 获取社会服务详情 - 响应参数(嵌套数据,无泛型)
|
||
type GetSocialServiceResp {
|
||
Code int `json:"code"`
|
||
Msg string `json:"message"`
|
||
Data SocialService `json:"data,omitempty"`
|
||
}
|
||
|
||
// 更新社会服务 - 请求参数
|
||
type UpdateSocialServiceReq {
|
||
Id int64 `json:"-" path:"id" validate:"min=1"` // 社会服务ID(路径参数,必填)
|
||
Title string `json:"title,omitempty"` // 标题
|
||
Subtitle string `json:"subtitle,omitempty"` // 副标题
|
||
CoverUrl string `json:"cover_url,omitempty"` // 封面图片URL
|
||
Intro string `json:"intro,omitempty"` // 简介(纯文字)
|
||
Content string `json:"content,omitempty"` // 内容(Markdown格式)
|
||
ImageEditors string `json:"image_editors,omitempty"` // 图片编辑者名单(逗号分隔)
|
||
TextEditors string `json:"text_editors,omitempty"` // 文字编辑者名单(逗号分隔)
|
||
ChiefEditor string `json:"chief_editor,omitempty"` // 总编辑
|
||
Proofreaders string `json:"proofreaders,omitempty"` // 校对者名单(逗号分隔)
|
||
Reviewers string `json:"reviewers,omitempty"` // 审核者名单(逗号分隔)
|
||
}
|
||
|
||
// 更新社会服务 - 响应参数(基础响应,无额外数据)
|
||
type UpdateSocialServiceResp {
|
||
Code int `json:"code"`
|
||
Msg string `json:"message"`
|
||
}
|
||
|
||
// 删除社会服务 - 请求参数(路径参数)
|
||
type DeleteSocialServiceReq {
|
||
Id int64 `json:"id" path:"id" validate:"min=1"` // 社会服务ID(必填)
|
||
}
|
||
|
||
// 删除社会服务 - 响应参数(基础响应,无额外数据)
|
||
type DeleteSocialServiceResp {
|
||
Code int `json:"code"`
|
||
Msg string `json:"message"`
|
||
}
|
||
|
||
@server (
|
||
group: socialService
|
||
prefix: /api/social-service // 统一前缀,接口路径无需重复
|
||
)
|
||
service social_service_api {
|
||
// 创建社会服务
|
||
@handler CreateSocialServiceHandler
|
||
post / (CreateSocialServiceReq) returns (CreateSocialServiceResp)
|
||
|
||
// 获取社会服务列表
|
||
@handler ListSocialServiceHandler
|
||
get /list (ListSocialServiceReq) returns (ListSocialServiceResp)
|
||
|
||
// 获取社会服务详情
|
||
@handler GetSocialServiceHandler
|
||
get /:id (GetSocialServiceReq) returns (GetSocialServiceResp)
|
||
|
||
// 更新社会服务
|
||
@handler UpdateSocialServiceHandler
|
||
put /:id (UpdateSocialServiceReq) returns (UpdateSocialServiceResp)
|
||
|
||
// 删除社会服务
|
||
@handler DeleteSocialServiceHandler
|
||
delete /:id (DeleteSocialServiceReq) returns (DeleteSocialServiceResp)
|
||
}
|
||
|