更新
This commit is contained in:
75
erp/product/category.go
Normal file
75
erp/product/category.go
Normal file
@@ -0,0 +1,75 @@
|
||||
package product
|
||||
|
||||
import (
|
||||
"context"
|
||||
"git.kumo.work/shama/service/client"
|
||||
"time"
|
||||
)
|
||||
|
||||
type category struct {
|
||||
}
|
||||
type CategoryItem struct {
|
||||
Id int64 `json:"id"`
|
||||
Name string `json:"name"`
|
||||
Sort int64 `json:"sort"`
|
||||
ParentId int64 `json:"parentId"`
|
||||
CreatedAt *time.Time `json:"createdAt"`
|
||||
UpdatedAt *time.Time `json:"updatedAt"`
|
||||
Children []*CategoryItem `json:"children"`
|
||||
}
|
||||
type ArgsCategoryAll struct {
|
||||
}
|
||||
|
||||
// All @TITLE 全部分类
|
||||
func (c *category) All(ctx context.Context, args ArgsCategoryAll) (reply []CategoryItem, err error) {
|
||||
xClient, err := client.GetClient(c)
|
||||
if err != nil {
|
||||
return
|
||||
}
|
||||
err = xClient.Call(ctx, "All", args, &reply)
|
||||
return
|
||||
}
|
||||
|
||||
type ArgsCategoryAdd struct {
|
||||
Name string // 分类名称
|
||||
Sort int64 // 排序
|
||||
ParentId int64 // 父级分类
|
||||
}
|
||||
|
||||
// Add @TITLE 添加分类
|
||||
func (c *category) Add(ctx context.Context, args ArgsCategoryAdd) (err error) {
|
||||
xClient, err := client.GetClient(c)
|
||||
if err != nil {
|
||||
return
|
||||
}
|
||||
reply := 0
|
||||
err = xClient.Call(ctx, "Add", args, &reply)
|
||||
return
|
||||
}
|
||||
|
||||
type ArgsCategoryEdit struct {
|
||||
CategoryId int64 // 分类id
|
||||
ArgsCategoryAdd
|
||||
}
|
||||
|
||||
// Edit @TITLE 编辑分类
|
||||
func (c *category) Edit(ctx context.Context, args ArgsCategoryEdit) (err error) {
|
||||
xClient, err := client.GetClient(c)
|
||||
if err != nil {
|
||||
return
|
||||
}
|
||||
reply := 0
|
||||
err = xClient.Call(ctx, "Edit", args, &reply)
|
||||
return
|
||||
}
|
||||
|
||||
// Delete @TITLE 删除分类
|
||||
func (c *category) Delete(ctx context.Context, categoryIds []int64) (err error) {
|
||||
xClient, err := client.GetClient(c)
|
||||
if err != nil {
|
||||
return
|
||||
}
|
||||
reply := 0
|
||||
err = xClient.Call(ctx, "Delete", categoryIds, &reply)
|
||||
return
|
||||
}
|
||||
Reference in New Issue
Block a user