1、新增后台面板
2、查询页改三要素 3、佣金冻结
This commit is contained in:
		
							
								
								
									
										71
									
								
								app/main/api/internal/logic/query/updatequerydatalogic.go
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										71
									
								
								app/main/api/internal/logic/query/updatequerydatalogic.go
									
									
									
									
									
										Normal file
									
								
							| @@ -0,0 +1,71 @@ | ||||
| package query | ||||
|  | ||||
| import ( | ||||
| 	"context" | ||||
| 	"database/sql" | ||||
| 	"encoding/hex" | ||||
|  | ||||
| 	"qnc-server/app/user/cmd/api/internal/svc" | ||||
| 	"qnc-server/app/user/cmd/api/internal/types" | ||||
| 	"qnc-server/app/user/model" | ||||
| 	"qnc-server/common/xerr" | ||||
| 	"qnc-server/pkg/lzkit/crypto" | ||||
|  | ||||
| 	"github.com/pkg/errors" | ||||
| 	"github.com/zeromicro/go-zero/core/logx" | ||||
| ) | ||||
|  | ||||
| type UpdateQueryDataLogic struct { | ||||
| 	logx.Logger | ||||
| 	ctx    context.Context | ||||
| 	svcCtx *svc.ServiceContext | ||||
| } | ||||
|  | ||||
| // 更新查询数据 | ||||
| func NewUpdateQueryDataLogic(ctx context.Context, svcCtx *svc.ServiceContext) *UpdateQueryDataLogic { | ||||
| 	return &UpdateQueryDataLogic{ | ||||
| 		Logger: logx.WithContext(ctx), | ||||
| 		ctx:    ctx, | ||||
| 		svcCtx: svcCtx, | ||||
| 	} | ||||
| } | ||||
|  | ||||
| func (l *UpdateQueryDataLogic) UpdateQueryData(req *types.UpdateQueryDataReq) (resp *types.UpdateQueryDataResp, err error) { | ||||
| 	// 1. 从数据库中获取查询记录 | ||||
| 	query, err := l.svcCtx.QueryModel.FindOne(l.ctx, req.Id) | ||||
| 	if err != nil { | ||||
| 		if err == model.ErrNotFound { | ||||
| 			return nil, errors.Wrapf(xerr.NewErrCode(xerr.DB_ERROR), "查询记录不存在, 查询ID: %d", req.Id) | ||||
| 		} | ||||
| 		return nil, errors.Wrapf(xerr.NewErrCode(xerr.DB_ERROR), "查询数据库失败, 查询ID: %d, err: %v", req.Id, err) | ||||
| 	} | ||||
|  | ||||
| 	// 2. 获取加密密钥 | ||||
| 	secretKey := l.svcCtx.Config.Encrypt.SecretKey | ||||
| 	key, decodeErr := hex.DecodeString(secretKey) | ||||
| 	if decodeErr != nil { | ||||
| 		return nil, errors.Wrapf(xerr.NewErrCode(xerr.SERVER_COMMON_ERROR), "获取AES密钥失败: %v", decodeErr) | ||||
| 	} | ||||
|  | ||||
| 	// 3. 加密数据 - 传入的是JSON,需要加密处理 | ||||
| 	encryptData, aesEncryptErr := crypto.AesEncrypt([]byte(req.QueryData), key) | ||||
| 	if aesEncryptErr != nil { | ||||
| 		return nil, errors.Wrapf(xerr.NewErrCode(xerr.SERVER_COMMON_ERROR), "加密查询数据失败: %v", aesEncryptErr) | ||||
| 	} | ||||
|  | ||||
| 	// 4. 更新数据库记录 | ||||
| 	query.QueryData = sql.NullString{ | ||||
| 		String: encryptData, | ||||
| 		Valid:  true, | ||||
| 	} | ||||
| 	updateErr := l.svcCtx.QueryModel.UpdateWithVersion(l.ctx, nil, query) | ||||
| 	if updateErr != nil { | ||||
| 		return nil, errors.Wrapf(xerr.NewErrCode(xerr.DB_ERROR), "更新查询数据失败: %v", updateErr) | ||||
| 	} | ||||
|  | ||||
| 	// 5. 返回结果 | ||||
| 	return &types.UpdateQueryDataResp{ | ||||
| 		Id:        query.Id, | ||||
| 		UpdatedAt: query.UpdateTime.Format("2006-01-02 15:04:05"), | ||||
| 	}, nil | ||||
| } | ||||
		Reference in New Issue
	
	Block a user