2026-03-16 14:37:35 +08:00
|
|
|
|
package admin_query
|
|
|
|
|
|
|
|
|
|
|
|
import (
|
|
|
|
|
|
"context"
|
|
|
|
|
|
|
|
|
|
|
|
"ycc-server/app/main/api/internal/svc"
|
|
|
|
|
|
"ycc-server/app/main/api/internal/types"
|
2026-03-16 14:51:14 +08:00
|
|
|
|
"ycc-server/common/xerr"
|
2026-03-16 14:37:35 +08:00
|
|
|
|
|
2026-03-16 14:51:14 +08:00
|
|
|
|
"github.com/pkg/errors"
|
2026-03-16 14:37:35 +08:00
|
|
|
|
"github.com/zeromicro/go-zero/core/logx"
|
2026-03-16 14:51:14 +08:00
|
|
|
|
"github.com/zeromicro/go-zero/core/stores/sqlx"
|
2026-03-16 14:37:35 +08:00
|
|
|
|
)
|
|
|
|
|
|
|
|
|
|
|
|
type AdminDeleteQueryFeatureDataLogic struct {
|
|
|
|
|
|
logx.Logger
|
|
|
|
|
|
ctx context.Context
|
|
|
|
|
|
svcCtx *svc.ServiceContext
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
func NewAdminDeleteQueryFeatureDataLogic(ctx context.Context, svcCtx *svc.ServiceContext) *AdminDeleteQueryFeatureDataLogic {
|
|
|
|
|
|
return &AdminDeleteQueryFeatureDataLogic{
|
|
|
|
|
|
Logger: logx.WithContext(ctx),
|
|
|
|
|
|
ctx: ctx,
|
|
|
|
|
|
svcCtx: svcCtx,
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
func (l *AdminDeleteQueryFeatureDataLogic) AdminDeleteQueryFeatureData(req *types.AdminDeleteQueryFeatureDataReq) (resp *types.AdminDeleteQueryFeatureDataResp, err error) {
|
2026-03-16 14:51:14 +08:00
|
|
|
|
// 基本参数校验
|
|
|
|
|
|
if req.QueryId == "" {
|
|
|
|
|
|
return nil, errors.Wrapf(xerr.NewErrMsg("QueryId 不能为空"), "")
|
|
|
|
|
|
}
|
|
|
|
|
|
if req.FeatureApiId == "" {
|
|
|
|
|
|
return nil, errors.Wrapf(xerr.NewErrMsg("feature_api_id 不能为空"), "")
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
// 使用事务调用 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("删除失败,请稍后重试"), "")
|
|
|
|
|
|
}
|
2026-03-16 14:37:35 +08:00
|
|
|
|
|
2026-03-16 14:51:14 +08:00
|
|
|
|
return &types.AdminDeleteQueryFeatureDataResp{
|
|
|
|
|
|
Success: true,
|
|
|
|
|
|
Message: "删除成功(如果原本不存在该模块数据,则视为已删除)",
|
|
|
|
|
|
}, nil
|
2026-03-16 14:37:35 +08:00
|
|
|
|
}
|