diff --git a/app/main/api/internal/logic/admin_query/admindeletequeryfeaturedatalogic.go b/app/main/api/internal/logic/admin_query/admindeletequeryfeaturedatalogic.go index 2e619b0..32d0001 100644 --- a/app/main/api/internal/logic/admin_query/admindeletequeryfeaturedatalogic.go +++ b/app/main/api/internal/logic/admin_query/admindeletequeryfeaturedatalogic.go @@ -5,8 +5,11 @@ import ( "ycc-server/app/main/api/internal/svc" "ycc-server/app/main/api/internal/types" + "ycc-server/common/xerr" + "github.com/pkg/errors" "github.com/zeromicro/go-zero/core/logx" + "github.com/zeromicro/go-zero/core/stores/sqlx" ) type AdminDeleteQueryFeatureDataLogic struct { @@ -24,7 +27,25 @@ func NewAdminDeleteQueryFeatureDataLogic(ctx context.Context, svcCtx *svc.Servic } func (l *AdminDeleteQueryFeatureDataLogic) AdminDeleteQueryFeatureData(req *types.AdminDeleteQueryFeatureDataReq) (resp *types.AdminDeleteQueryFeatureDataResp, err error) { - // todo: add your logic here and delete this line + // 基本参数校验 + if req.QueryId == "" { + return nil, errors.Wrapf(xerr.NewErrMsg("QueryId 不能为空"), "") + } + if req.FeatureApiId == "" { + return nil, errors.Wrapf(xerr.NewErrMsg("feature_api_id 不能为空"), "") + } - return + // 使用事务调用 WhitelistService.DeleteFeatureFromQueryData,保持与其它删除逻辑一致 + err = l.svcCtx.QueryModel.Trans(l.ctx, func(ctx context.Context, session sqlx.Session) error { + return l.svcCtx.WhitelistService.DeleteFeatureFromQueryData(ctx, session, req.QueryId, req.FeatureApiId) + }) + if err != nil { + l.Errorf("Admin 删除查询模块数据失败, queryId=%s, featureApiId=%s, err=%+v", req.QueryId, req.FeatureApiId, err) + return nil, errors.Wrapf(xerr.NewErrMsg("删除失败,请稍后重试"), "") + } + + return &types.AdminDeleteQueryFeatureDataResp{ + Success: true, + Message: "删除成功(如果原本不存在该模块数据,则视为已删除)", + }, nil }