From f5f0e0d8b236a199bd8120eeac506bc6dc0b86ee Mon Sep 17 00:00:00 2001 From: liangzai <2440983361@qq.com> Date: Mon, 16 Mar 2026 14:51:14 +0800 Subject: [PATCH] =?UTF-8?q?=E7=99=BD=E5=90=8D=E5=8D=95fix?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../admindeletequeryfeaturedatalogic.go | 25 +++++++++++++++++-- 1 file changed, 23 insertions(+), 2 deletions(-) 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 }