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 UpdateCategoryLogic struct { ctx context.Context svcCtx *svc.ServiceContext logx.Logger } func NewUpdateCategoryLogic(ctx context.Context, svcCtx *svc.ServiceContext) *UpdateCategoryLogic { return &UpdateCategoryLogic{ ctx: ctx, svcCtx: svcCtx, Logger: logx.WithContext(ctx), } } func (l *UpdateCategoryLogic) UpdateCategory(req *types.CategoryInfo) (*types.BaseMsgResp, error) { err := l.svcCtx.DB.Category.UpdateOneID(*req.Id). SetNotNilName(req.Name). SetNotNilOrganizationID(req.OrganizationId). Exec(l.ctx) if err != nil { return nil, dberrorhandler.DefaultEntError(l.Logger, err, req) } return &types.BaseMsgResp{Msg: errormsg.UpdateSuccess}, nil }