34 lines
817 B
Go
34 lines
817 B
Go
|
|
package playbooks
|
||
|
|
|
||
|
|
import (
|
||
|
|
"context"
|
||
|
|
"fmt"
|
||
|
|
|
||
|
|
"apps/backend/internal/middleware"
|
||
|
|
"apps/backend/internal/svc"
|
||
|
|
"apps/backend/internal/types"
|
||
|
|
|
||
|
|
"github.com/zeromicro/go-zero/core/logx"
|
||
|
|
)
|
||
|
|
|
||
|
|
type RemovePlaybookLogic struct {
|
||
|
|
logx.Logger
|
||
|
|
ctx context.Context
|
||
|
|
svcCtx *svc.ServiceContext
|
||
|
|
}
|
||
|
|
|
||
|
|
func NewRemovePlaybookLogic(ctx context.Context, svcCtx *svc.ServiceContext) *RemovePlaybookLogic {
|
||
|
|
return &RemovePlaybookLogic{Logger: logx.WithContext(ctx), ctx: ctx, svcCtx: svcCtx}
|
||
|
|
}
|
||
|
|
|
||
|
|
func (l *RemovePlaybookLogic) RemovePlaybook(req *types.PlaybookIdPath) (*types.OkData, error) {
|
||
|
|
uid, ok := middleware.UIDFrom(l.ctx)
|
||
|
|
if !ok || uid <= 0 {
|
||
|
|
return nil, fmt.Errorf("unauthorized")
|
||
|
|
}
|
||
|
|
if err := l.svcCtx.Growth.RemovePlaybook(l.ctx, uid, req.Id); err != nil {
|
||
|
|
return nil, err
|
||
|
|
}
|
||
|
|
return &types.OkData{Ok: true}, nil
|
||
|
|
}
|