57 lines
1.7 KiB
Go
57 lines
1.7 KiB
Go
package controller
|
|
|
|
import (
|
|
dto "assets/model/dto/asset"
|
|
service "assets/service/asset"
|
|
"context"
|
|
|
|
"gitea.redpowerfuture.com/red-future/common/beans"
|
|
)
|
|
|
|
type category struct{}
|
|
|
|
// Category 分类控制器
|
|
var Category = new(category)
|
|
|
|
// init 初始化表单配置
|
|
func init() {
|
|
}
|
|
|
|
// GetCategory 获取分类详情
|
|
func (c *category) GetCategory(ctx context.Context, req *dto.GetCategoryReq) (res *dto.GetCategoryRes, err error) {
|
|
return service.Category.GetOne(ctx, req)
|
|
}
|
|
|
|
// ListCategory 获取分类列表
|
|
func (c *category) ListCategory(ctx context.Context, req *dto.ListCategoryReq) (res *dto.ListCategoryRes, err error) {
|
|
return service.Category.List(ctx, req)
|
|
}
|
|
|
|
// GetCategoryTree 获取分类树
|
|
func (c *category) GetCategoryTree(ctx context.Context, req *dto.GetCategoryTreeReq) (res *dto.GetCategoryTreeRes, err error) {
|
|
return service.Category.GetTree(ctx, req)
|
|
}
|
|
|
|
// CreateCategory 创建分类
|
|
func (c *category) CreateCategory(ctx context.Context, req *dto.CreateCategoryReq) (res *dto.CreateCategoryRes, err error) {
|
|
return service.Category.Create(ctx, req)
|
|
}
|
|
|
|
// UpdateCategory 更新分类
|
|
func (c *category) UpdateCategory(ctx context.Context, req *dto.UpdateCategoryReq) (res *beans.ResponseEmpty, err error) {
|
|
err = service.Category.Update(ctx, req)
|
|
return
|
|
}
|
|
|
|
// UpdateCategoryStatus 更新分类状态
|
|
func (c *category) UpdateCategoryStatus(ctx context.Context, req *dto.UpdateCategoryStatusReq) (res *beans.ResponseEmpty, err error) {
|
|
err = service.Category.UpdateStatus(ctx, req)
|
|
return
|
|
}
|
|
|
|
// DeleteCategory 删除分类
|
|
func (c *category) DeleteCategory(ctx context.Context, req *dto.DeleteCategoryReq) (res *beans.ResponseEmpty, err error) {
|
|
err = service.Category.Delete(ctx, req)
|
|
return
|
|
}
|