// Code scaffolded by goctl. Safe to edit. // goctl 1.10.2 package application import ( "context" "errors" "udeServer/internal/apierr" "udeServer/internal/log" "udeServer/internal/model" "udeServer/internal/svc" "udeServer/internal/types" "github.com/zeromicro/go-zero/core/logx" ) type DeleteApplicationLogic struct { logx.Logger ctx context.Context svcCtx *svc.ServiceContext } // 删除应用凭证 func NewDeleteApplicationLogic(ctx context.Context, svcCtx *svc.ServiceContext) *DeleteApplicationLogic { return &DeleteApplicationLogic{ Logger: logx.WithContext(ctx), ctx: ctx, svcCtx: svcCtx, } } func (l *DeleteApplicationLogic) DeleteApplication(req *types.ApplicationCredentialsDeleteReq) (*types.ApplicationCredentialsDeleteResp, error) { if err := checkId(req.Id); err != nil { return nil, err } cred, err := l.svcCtx.ApplicationCredModel.FindOne(l.ctx, req.Id) if errors.Is(err, model.ErrNotFound) { return nil, apierr.NotFound("application credential", req.Id) } if err != nil { log.RecordError(l.ctx, err) return nil, apierr.New(500, "查询应用凭证失败") } if err := l.svcCtx.ApplicationCredModel.Delete(l.ctx, req.Id); err != nil { log.RecordError(l.ctx, err) return nil, apierr.New(500, "删除应用凭证失败") } return &types.ApplicationCredentialsDeleteResp{Iden: cred.CredIden}, nil }