117 lines
4.6 KiB
Go
117 lines
4.6 KiB
Go
|
|
package controller
|
||
|
|
|
||
|
|
import (
|
||
|
|
dto "assets/model/dto/asset"
|
||
|
|
service "assets/service/asset"
|
||
|
|
"context"
|
||
|
|
|
||
|
|
"gitea.com/red-future/common/beans"
|
||
|
|
)
|
||
|
|
|
||
|
|
type privateCategory struct{}
|
||
|
|
|
||
|
|
// PrivateCategory 私域分类控制器
|
||
|
|
var PrivateCategory = new(privateCategory)
|
||
|
|
|
||
|
|
// CreatePrivateCategory 创建私域分类
|
||
|
|
// @Summary 创建私域分类
|
||
|
|
// @Tags 私域分类管理
|
||
|
|
// @Accept json
|
||
|
|
// @Produce json
|
||
|
|
// @Param body body asset.CreatePrivateCategoryReq true "创建私域分类请求"
|
||
|
|
// @Success 200 {object} asset.CreatePrivateCategoryRes
|
||
|
|
// @Router /privateCategory/createPrivateCategory [post]
|
||
|
|
func (c *privateCategory) CreatePrivateCategory(ctx context.Context, req *dto.CreatePrivateCategoryReq) (res *dto.CreatePrivateCategoryRes, err error) {
|
||
|
|
return service.PrivateCategory.CreatePrivateCategory(ctx, req)
|
||
|
|
}
|
||
|
|
|
||
|
|
// BatchCreatePrivateCategory 批量创建私域分类
|
||
|
|
// @Summary 批量创建私域分类
|
||
|
|
// @Tags 私域分类管理
|
||
|
|
// @Accept json
|
||
|
|
// @Produce json
|
||
|
|
// @Param body body asset.BatchCreatePrivateCategoryReq true "批量创建私域分类请求"
|
||
|
|
// @Success 200 {object} asset.BatchCreatePrivateCategoryRes
|
||
|
|
// @Router /privateCategory/batchCreatePrivateCategory [post]
|
||
|
|
func (c *privateCategory) BatchCreatePrivateCategory(ctx context.Context, req *dto.BatchCreatePrivateCategoryReq) (res *dto.BatchCreatePrivateCategoryRes, err error) {
|
||
|
|
return service.PrivateCategory.BatchCreatePrivateCategory(ctx, req)
|
||
|
|
}
|
||
|
|
|
||
|
|
// UpdatePrivateCategory 更新私域分类
|
||
|
|
// @Summary 更新私域分类
|
||
|
|
// @Tags 私域分类管理
|
||
|
|
// @Accept json
|
||
|
|
// @Produce json
|
||
|
|
// @Param body body asset.UpdatePrivateCategoryReq true "更新私域分类请求"
|
||
|
|
// @Success 200 {object} beans.ResponseEmpty
|
||
|
|
// @Router /privateCategory/updatePrivateCategory [put]
|
||
|
|
func (c *privateCategory) UpdatePrivateCategory(ctx context.Context, req *dto.UpdatePrivateCategoryReq) (res *beans.ResponseEmpty, err error) {
|
||
|
|
err = service.PrivateCategory.UpdatePrivateCategory(ctx, req)
|
||
|
|
return
|
||
|
|
}
|
||
|
|
|
||
|
|
// DeletePrivateCategory 删除私域分类
|
||
|
|
// @Summary 删除私域分类
|
||
|
|
// @Tags 私域分类管理
|
||
|
|
// @Accept json
|
||
|
|
// @Produce json
|
||
|
|
// @Param id query string true "私域分类ID"
|
||
|
|
// @Success 200 {object} beans.ResponseEmpty
|
||
|
|
// @Router /privateCategory/deletePrivateCategory [delete]
|
||
|
|
func (c *privateCategory) DeletePrivateCategory(ctx context.Context, req *dto.DeletePrivateCategoryReq) (res *beans.ResponseEmpty, err error) {
|
||
|
|
err = service.PrivateCategory.DeletePrivateCategory(ctx, req.ID)
|
||
|
|
return
|
||
|
|
}
|
||
|
|
|
||
|
|
// GetPrivateCategory 获取私域分类详情
|
||
|
|
// @Summary 获取私域分类详情
|
||
|
|
// @Tags 私域分类管理
|
||
|
|
// @Accept json
|
||
|
|
// @Produce json
|
||
|
|
// @Param id query string true "私域分类ID"
|
||
|
|
// @Success 200 {object} asset.GetPrivateCategoryRes
|
||
|
|
// @Router /privateCategory/getPrivateCategory [get]
|
||
|
|
func (c *privateCategory) GetPrivateCategory(ctx context.Context, req *dto.GetPrivateCategoryReq) (res *dto.GetPrivateCategoryRes, err error) {
|
||
|
|
return service.PrivateCategory.GetPrivateCategory(ctx, req.ID)
|
||
|
|
}
|
||
|
|
|
||
|
|
// ListPrivateCategory 获取私域分类列表
|
||
|
|
// @Summary 获取私域分类列表
|
||
|
|
// @Tags 私域分类管理
|
||
|
|
// @Accept json
|
||
|
|
// @Produce json
|
||
|
|
// @Param name query string false "分类名称"
|
||
|
|
// @Param parentId query string false "父分类ID"
|
||
|
|
// @Param level query int false "分类层级"
|
||
|
|
// @Param isLeafNode query bool false "是否叶子节点"
|
||
|
|
// @Param pageNum query int false "页码" default(1)
|
||
|
|
// @Param pageSize query int false "每页大小" default(10)
|
||
|
|
// @Success 200 {object} asset.ListPrivateCategoryRes
|
||
|
|
// @Router /privateCategory/listPrivateCategory [get]
|
||
|
|
func (c *privateCategory) ListPrivateCategory(ctx context.Context, req *dto.ListPrivateCategoryReq) (res *dto.ListPrivateCategoryRes, err error) {
|
||
|
|
return service.PrivateCategory.ListPrivateCategory(ctx, req)
|
||
|
|
}
|
||
|
|
|
||
|
|
// GetPrivateCategoryTree 获取私域分类树
|
||
|
|
// @Summary 获取私域分类树
|
||
|
|
// @Tags 私域分类管理
|
||
|
|
// @Accept json
|
||
|
|
// @Produce json
|
||
|
|
// @Success 200 {object} asset.GetPrivateCategoryTreeRes
|
||
|
|
// @Router /privateCategory/getPrivateCategoryTree [get]
|
||
|
|
func (c *privateCategory) GetPrivateCategoryTree(ctx context.Context, req *dto.GetPrivateCategoryTreeReq) (res *dto.GetPrivateCategoryTreeRes, err error) {
|
||
|
|
return service.PrivateCategory.GetPrivateCategoryTree(ctx)
|
||
|
|
}
|
||
|
|
|
||
|
|
// GenerateTestData 生成测试数据
|
||
|
|
// @Summary 生成测试数据
|
||
|
|
// @Tags 私域分类管理
|
||
|
|
// @Accept json
|
||
|
|
// @Produce json
|
||
|
|
// @Success 200 {object} beans.ResponseEmpty
|
||
|
|
// @Router /privateCategory/generateTestData [post]
|
||
|
|
func (c *privateCategory) GenerateTestData(ctx context.Context, req *dto.GeneratePrivateCategoryTestDataReq) (res *beans.ResponseEmpty, err error) {
|
||
|
|
err = service.PrivateCategory.GenerateTestData(ctx)
|
||
|
|
return
|
||
|
|
}
|