实现category service基础接口

This commit is contained in:
2025-05-31 16:27:01 +08:00
parent faa6a35475
commit e5446bf836
33 changed files with 1420 additions and 67 deletions

View File

@ -3,6 +3,65 @@
package types
type BaseCategory struct {
ID string `json:"id"` // 分类ID (UUID)
SystemID string `json:"systemId"` // 所属系统ID
Name string `json:"name"` // 分类名称
Alias string `json:"alias"` // URL别名
ParentID string `json:"parentId"` // 父分类ID (可为空)
Description string `json:"description"` // 分类描述
CreatedAt string `json:"createdAt"` // 创建时间 (ISO8601)
UpdatedAt string `json:"updatedAt"` // 更新时间 (ISO8601)
}
type BaseResp struct {
Code int `json:"code"` // 状态码 (0=成功)
Message string `json:"message"` // 消息
}
type CategoryDetail struct {
BaseCategory
Parent *BaseCategory `json:"parent"` // 父分类信息
}
type CategoryDetailResp struct {
CategoryDetail
}
type CategoryTreeResp struct {
Root TreeNode `json:"root"` // 分类树根节点
}
type CreateCategoryReq struct {
SystemID string `json:"systemId" validate:"required"` // 所属系统ID
Name string `json:"name" validate:"required"` // 分类名称
Alias string `json:"alias,optional"` // URL别名
ParentID string `json:"parentId,optional"` // 父分类ID
Description string `json:"description,optional"` // 分类描述
}
type CreateCategoryResp struct {
ID string `json:"id"` // 新创建的分类ID
}
type DeleteCategoryReq struct {
ID string `path:"id"` // 分类ID
}
type GetCategoryReq struct {
ID string `path:"id"` // 分类ID
}
type GetCategoryTreeReq struct {
ID string `path:"id"` // 起始分类ID
}
type GetSystemCategoriesReq struct {
SystemID string `path:"system_id"` // 系统ID
ParentID string `form:"parentId,optional"` // 父分类ID (可选)
IncludeDescendants bool `form:"includeDescendants,default=true"` // 是否包含子分类
}
type GetUserInfoReq struct {
UserId string `path:"user_id"`
}
@ -15,6 +74,19 @@ type GetUserInfoResp struct {
Roles []string `json:"roles"`
}
type ListCategoriesReq struct {
SystemID string `form:"systemId,optional"` // 按系统ID过滤
ParentID string `form:"parentId,optional"` // 按父分类ID过滤
Name string `form:"name,optional"` // 按名称模糊搜索
Page int `form:"page,default=1"` // 页码
PageSize int `form:"pageSize,default=20"` // 每页数量
}
type ListCategoriesResp struct {
Total int64 `json:"total"` // 总数
List []BaseCategory `json:"list"` // 分类列表
}
type LoginReq struct {
Username string `json:"username"`
Password string `json:"password"`
@ -42,3 +114,16 @@ type RegisterReq struct {
type RegisterResp struct {
UserId string `json:"user_id"`
}
type TreeNode struct {
BaseCategory
Children []*TreeNode `json:"children"` // 子分类列表
}
type UpdateCategoryReq struct {
ID string `path:"id"` // 分类ID
Name string `json:"name,optional"` // 新名称
Alias string `json:"alias,optional"` // 新别名
ParentID string `json:"parentId,optional"` // 新父分类ID
Description string `json:"description,optional"` // 新描述
}