package tutorial 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 UpdateTutorialLogic struct { ctx context.Context svcCtx *svc.ServiceContext logx.Logger } func NewUpdateTutorialLogic(ctx context.Context, svcCtx *svc.ServiceContext) *UpdateTutorialLogic { return &UpdateTutorialLogic{ ctx: ctx, svcCtx: svcCtx, Logger: logx.WithContext(ctx), } } func (l *UpdateTutorialLogic) UpdateTutorial(req *types.TutorialInfo) (*types.BaseMsgResp, error) { err := l.svcCtx.DB.Tutorial.UpdateOneID(*req.Id). SetNotNilEmployeeID(req.EmployeeId). SetNotNilIndex(req.Index). SetNotNilTitle(req.Title). SetNotNilContent(req.Content). Exec(l.ctx) if err != nil { return nil, dberrorhandler.DefaultEntError(l.Logger, err, req) } return &types.BaseMsgResp{Msg: errormsg.UpdateSuccess}, nil }