package category import ( "context" "wechat-api/internal/svc" "wechat-api/internal/types" "wechat-api/internal/utils/dberrorhandler" "github.com/suyuan32/simple-admin-common/msg/errormsg" "github.com/zeromicro/go-zero/core/logx" ) type CreateCategoryLogic struct { ctx context.Context svcCtx *svc.ServiceContext logx.Logger } func NewCreateCategoryLogic(ctx context.Context, svcCtx *svc.ServiceContext) *CreateCategoryLogic { return &CreateCategoryLogic{ ctx: ctx, svcCtx: svcCtx, Logger: logx.WithContext(ctx), } } func (l *CreateCategoryLogic) CreateCategory(req *types.CategoryInfo) (*types.BaseMsgResp, error) { _, err := l.svcCtx.DB.Category.Create(). SetNotNilName(req.Name). SetNotNilOrganizationID(req.OrganizationId). Save(l.ctx) if err != nil { return nil, dberrorhandler.DefaultEntError(l.Logger, err, req) } return &types.BaseMsgResp{Msg: errormsg.CreateSuccess}, nil }