Files
qitongxue-api/api/admin/v1/goods.go
2026-09-30 17:01:18 +08:00

90 lines
3.6 KiB
Go
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
package v1
import "github.com/gogf/gf/v2/frame/g"
// ============================================================================
// 管理端软件开发服务契约(迭代-2026-09-29):list / detail / save / delete
//
// 封面 cover_path 库内存相对路径(/static/...);响应里 cover_url 为按
// site.base_url 拼接的绝对地址。content_md 为 Markdown 原文,管理端编辑预览、
// 小程序端解析渲染(富文本节点),后端只存原文不渲染。
// ============================================================================
// AdminGoodsItem 服务列表项(响应 snake_case,不含 content_md —— 详情接口单独取)
type AdminGoodsItem struct {
Id int64 `json:"id"`
Category int `json:"category"`
CategoryName string `json:"category_name"`
Title string `json:"title"`
Summary string `json:"summary"`
CoverPath string `json:"cover_path"`
CoverUrl string `json:"cover_url"`
PriceCents int64 `json:"price_cents"`
PriceNote string `json:"price_note"`
Sort int `json:"sort"`
IsEnabled int `json:"is_enabled"`
CreatedAt string `json:"created_at"`
UpdatedAt string `json:"updated_at"`
}
// AdminGoodsListReq 服务列表
type AdminGoodsListReq struct {
g.Meta `path:"/admin/goods/list" method:"get" tags:"admin" summary:"软件开发服务列表"`
Keyword string `json:"keyword"`
Category int `json:"category"` // 0=全部
IsEnabled *int `json:"isEnabled"`
Page int `json:"page"`
PageSize int `json:"pageSize"`
SortBy string `json:"sortBy"`
SortOrder string `json:"sortOrder"` // asc / desc
}
type AdminGoodsListRes struct {
List []AdminGoodsItem `json:"list"`
Total int `json:"total"`
}
// AdminGoodsDetailReq 服务详情(编辑回填,含 content_md)
type AdminGoodsDetailReq struct {
g.Meta `path:"/admin/goods/detail" method:"get" tags:"admin" summary:"软件开发服务详情"`
Id int64 `v:"required" json:"id"`
}
type AdminGoodsDetailRes struct {
Id int64 `json:"id"`
Category int `json:"category"`
CategoryName string `json:"category_name"`
Title string `json:"title"`
Summary string `json:"summary"`
ContentMd string `json:"content_md"`
CoverPath string `json:"cover_path"`
CoverUrl string `json:"cover_url"`
PriceCents int64 `json:"price_cents"`
PriceNote string `json:"price_note"`
Sort int `json:"sort"`
IsEnabled int `json:"is_enabled"`
}
// AdminGoodsSaveReq 新增/编辑服务(id=0 新建)。coverPath 传上传接口返回的 path(相对路径)。
type AdminGoodsSaveReq struct {
g.Meta `path:"/admin/goods/save" method:"post" tags:"admin" summary:"保存软件开发服务"`
Id int64 `json:"id"`
Category int `v:"required|in:1,2,3,4#请选择分类|分类不合法" json:"category"`
Title string `v:"required#请填写服务名称" json:"title"`
Summary string `v:"length:0,500#简介最多 500 字" json:"summary"`
ContentMd string `json:"contentMd"`
PriceCents int64 `v:"min:0#价格不能为负" json:"priceCents"`
PriceNote string `v:"length:0,64#价格备注最多 64 字" json:"priceNote"`
CoverPath string `json:"coverPath"`
Sort int `json:"sort"`
IsEnabled int `json:"isEnabled"`
}
type AdminGoodsSaveRes struct {
Id int64 `json:"id"`
}
// AdminGoodsDeleteReq 删除服务(软删除)
type AdminGoodsDeleteReq struct {
g.Meta `path:"/admin/goods/delete" method:"post" tags:"admin" summary:"删除软件开发服务"`
Id int64 `v:"required" json:"id"`
}
type AdminGoodsDeleteRes struct{}