From 6c5016912ecba36a2c40b4a31f5c7f0f601c8038 Mon Sep 17 00:00:00 2001 From: liangzai <2440983361@qq.com> Date: Sun, 3 Aug 2025 18:46:53 +0800 Subject: [PATCH] fix --- configs/env.development.yaml | 2 +- internal/domains/api/dto/api_request_dto.go | 14 +++-- .../api/services/api_request_service.go | 2 + .../processors/flxg/flxg3d56_processor.go | 23 ++++---- .../processors/flxg/flxgca3d_processor.go | 10 ++-- .../processors/ivyz/ivyzgz08_processor.go | 52 +++++++++++++++++++ .../gorm_certification_query_repository.go | 4 +- .../finance/gorm_wallet_repository.go | 5 +- .../gorm_product_category_repository.go | 11 ++-- .../product/gorm_product_repository.go | 15 +++--- .../product/gorm_subscription_repository.go | 9 ++-- .../user/gorm_enterprise_info_repository.go | 5 +- .../user/gorm_sms_code_repository.go | 2 +- .../repositories/user/gorm_user_repository.go | 7 ++- 14 files changed, 124 insertions(+), 37 deletions(-) create mode 100644 internal/domains/api/services/processors/ivyz/ivyzgz08_processor.go diff --git a/configs/env.development.yaml b/configs/env.development.yaml index 840b3e5..b3d2754 100644 --- a/configs/env.development.yaml +++ b/configs/env.development.yaml @@ -20,7 +20,7 @@ database: logger: level: info format: json - output: "file" + output: "console" log_dir: "logs" max_size: 100 max_backups: 5 diff --git a/internal/domains/api/dto/api_request_dto.go b/internal/domains/api/dto/api_request_dto.go index b1b983b..b18bcc5 100644 --- a/internal/domains/api/dto/api_request_dto.go +++ b/internal/domains/api/dto/api_request_dto.go @@ -186,6 +186,11 @@ type IVYZ1C9DReq struct { Years int64 `json:"years" validate:"omitempty,min=0,max=100"` } +type IVYZGZ08Req struct { + IDCard string `json:"id_card" validate:"required,validIDCard"` + Name string `json:"name" validate:"required,min=1,validName"` +} + type FLXG8A3FReq struct { IDCard string `json:"id_card" validate:"required,validIDCard"` Name string `json:"name" validate:"required,min=1,validName"` @@ -197,10 +202,11 @@ type FLXG5B2EReq struct { } type COMB298YReq struct { - IDCard string `json:"id_card" validate:"required,validIDCard"` - Name string `json:"name" validate:"required,min=1,validName"` - MobileNo string `json:"mobile_no" validate:"required,min=11,max=11,validMobileNo"` - AuthDate string `json:"auth_date" validate:"required,validAuthDate" encrypt:"false"` + IDCard string `json:"id_card" validate:"required,validIDCard"` + Name string `json:"name" validate:"required,min=1,validName"` + MobileNo string `json:"mobile_no" validate:"required,min=11,max=11,validMobileNo"` + AuthDate string `json:"auth_date" validate:"required,validAuthDate" encrypt:"false"` + TimeRange string `json:"time_range" validate:"omitempty,validTimeRange"` // 非必填字段 } type COMB86PMReq struct { diff --git a/internal/domains/api/services/api_request_service.go b/internal/domains/api/services/api_request_service.go index 4483926..370b6cb 100644 --- a/internal/domains/api/services/api_request_service.go +++ b/internal/domains/api/services/api_request_service.go @@ -81,6 +81,7 @@ func registerAllProcessors(combService *comb.CombService) { "FLXGDEC7": flxg.ProcessFLXGDEC7Request, "FLXG8A3F": flxg.ProcessFLXG8A3FRequest, "FLXG5B2E": flxg.ProcessFLXG5B2ERequest, + "FLXG0687": flxg.ProcessFLXG0687Request, // JRZQ系列处理器 "JRZQ8203": jrzq.ProcessJRZQ8203Request, @@ -117,6 +118,7 @@ func registerAllProcessors(combService *comb.CombService) { "IVYZ7F2A": ivyz.ProcessIVYZ7F2ARequest, "IVYZ4E8B": ivyz.ProcessIVYZ4E8BRequest, "IVYZ1C9D": ivyz.ProcessIVYZ1C9DRequest, + "IVYZGZ08": ivyz.ProcessIVYZGZ08Request, // COMB系列处理器 "COMB298Y": comb.ProcessCOMB298YRequest, diff --git a/internal/domains/api/services/processors/flxg/flxg3d56_processor.go b/internal/domains/api/services/processors/flxg/flxg3d56_processor.go index 3f5f99f..4ded777 100644 --- a/internal/domains/api/services/processors/flxg/flxg3d56_processor.go +++ b/internal/domains/api/services/processors/flxg/flxg3d56_processor.go @@ -36,19 +36,24 @@ func ProcessFLXG3D56Request(ctx context.Context, params []byte, deps *processors if err != nil { return nil, fmt.Errorf("%s: %w", processors.ErrSystem, err) } - encryptedTimeRange, err := deps.WestDexService.Encrypt(paramsDto.TimeRange) - if err != nil { - return nil, fmt.Errorf("%s: %w", processors.ErrSystem, err) - } + reqData := map[string]interface{}{ "data": map[string]interface{}{ - "name": encryptedName, - "id": encryptedIDCard, - "cell": encryptedMobileNo, - "time_range": encryptedTimeRange, + "name": encryptedName, + "id": encryptedIDCard, + "cell": encryptedMobileNo, }, } + // 只有当 TimeRange 不为空时才加密和传参 + if paramsDto.TimeRange != "" { + encryptedTimeRange, err := deps.WestDexService.Encrypt(paramsDto.TimeRange) + if err != nil { + return nil, fmt.Errorf("%s: %w", processors.ErrSystem, err) + } + reqData["data"].(map[string]interface{})["time_range"] = encryptedTimeRange + } + respBytes, err := deps.WestDexService.CallAPI("G26BJ05", reqData) if err != nil { if errors.Is(err, westdex.ErrDatasource) { @@ -59,4 +64,4 @@ func ProcessFLXG3D56Request(ctx context.Context, params []byte, deps *processors } return respBytes, nil -} \ No newline at end of file +} diff --git a/internal/domains/api/services/processors/flxg/flxgca3d_processor.go b/internal/domains/api/services/processors/flxg/flxgca3d_processor.go index 5250089..f39cd47 100644 --- a/internal/domains/api/services/processors/flxg/flxgca3d_processor.go +++ b/internal/domains/api/services/processors/flxg/flxgca3d_processor.go @@ -35,18 +35,22 @@ func ProcessFLXGCA3DRequest(ctx context.Context, params []byte, deps *processors reqData := map[string]interface{}{ "data": map[string]interface{}{ "name": encryptedName, - "idcard": encryptedIDCard, + "id_card": encryptedIDCard, }, } respBytes, err := deps.WestDexService.CallAPI("G22BJ03", reqData) if err != nil { if errors.Is(err, westdex.ErrDatasource) { - return nil, fmt.Errorf("%s: %w", processors.ErrDatasource, err) + if respBytes != nil { + return respBytes, nil + } else { + return nil, fmt.Errorf("%s: %w", processors.ErrDatasource, err) + } } else { return nil, fmt.Errorf("%s: %w", processors.ErrSystem, err) } } return respBytes, nil -} \ No newline at end of file +} diff --git a/internal/domains/api/services/processors/ivyz/ivyzgz08_processor.go b/internal/domains/api/services/processors/ivyz/ivyzgz08_processor.go new file mode 100644 index 0000000..976baf8 --- /dev/null +++ b/internal/domains/api/services/processors/ivyz/ivyzgz08_processor.go @@ -0,0 +1,52 @@ +package ivyz + +import ( + "context" + "encoding/json" + "errors" + "fmt" + + "tyapi-server/internal/domains/api/dto" + "tyapi-server/internal/domains/api/services/processors" + "tyapi-server/internal/infrastructure/external/westdex" +) + +// ProcessIVYZGZ08Request IVYZGZ08 API处理方法 +func ProcessIVYZGZ08Request(ctx context.Context, params []byte, deps *processors.ProcessorDependencies) ([]byte, error) { + var paramsDto dto.IVYZGZ08Req + if err := json.Unmarshal(params, ¶msDto); err != nil { + return nil, fmt.Errorf("%s: %w", processors.ErrSystem, err) + } + + if err := deps.Validator.ValidateStruct(paramsDto); err != nil { + return nil, fmt.Errorf("%s: %w", processors.ErrInvalidParam, err) + } + + encryptedName, err := deps.WestDexService.Encrypt(paramsDto.Name) + if err != nil { + return nil, fmt.Errorf("%s: %w", processors.ErrSystem, err) + } + + encryptedIDCard, err := deps.WestDexService.Encrypt(paramsDto.IDCard) + if err != nil { + return nil, fmt.Errorf("%s: %w", processors.ErrSystem, err) + } + + reqData := map[string]interface{}{ + "data": map[string]interface{}{ + "xm": encryptedName, + "gmsfzhm": encryptedIDCard, + }, + } + + respBytes, err := deps.WestDexService.CallAPI("G08SC02", reqData) + if err != nil { + if errors.Is(err, westdex.ErrDatasource) { + return nil, fmt.Errorf("%s: %w", processors.ErrDatasource, err) + } else { + return nil, fmt.Errorf("%s: %w", processors.ErrSystem, err) + } + } + + return respBytes, nil +} diff --git a/internal/infrastructure/database/repositories/certification/gorm_certification_query_repository.go b/internal/infrastructure/database/repositories/certification/gorm_certification_query_repository.go index 8add233..0b2b7a5 100644 --- a/internal/infrastructure/database/repositories/certification/gorm_certification_query_repository.go +++ b/internal/infrastructure/database/repositories/certification/gorm_certification_query_repository.go @@ -198,7 +198,7 @@ func (r *GormCertificationQueryRepository) ListByUserIDs(ctx context.Context, us } var certifications []*entities.Certification - if err := r.GetDB(ctx).Where("user_id IN ?", userIDs).Find(&certifications).Error; err != nil { + if err := r.GetDB(ctx).Where("user_id IN ?", userIDs).Order("created_at DESC").Find(&certifications).Error; err != nil { return nil, fmt.Errorf("根据用户ID列表查询认证失败: %w", err) } @@ -207,7 +207,7 @@ func (r *GormCertificationQueryRepository) ListByUserIDs(ctx context.Context, us // ListByStatus 根据状态查询 func (r *GormCertificationQueryRepository) ListByStatus(ctx context.Context, status enums.CertificationStatus, limit int) ([]*entities.Certification, error) { - db := r.GetDB(ctx).Where("status = ?", status) + db := r.GetDB(ctx).Where("status = ?", status).Order("created_at DESC") if limit > 0 { db = db.Limit(limit) } diff --git a/internal/infrastructure/database/repositories/finance/gorm_wallet_repository.go b/internal/infrastructure/database/repositories/finance/gorm_wallet_repository.go index 909bbac..af572f9 100644 --- a/internal/infrastructure/database/repositories/finance/gorm_wallet_repository.go +++ b/internal/infrastructure/database/repositories/finance/gorm_wallet_repository.go @@ -89,7 +89,7 @@ func (r *GormWalletRepository) CreateBatch(ctx context.Context, wallets []entiti func (r *GormWalletRepository) GetByIDs(ctx context.Context, ids []string) ([]entities.Wallet, error) { var wallets []entities.Wallet - err := r.GetDB(ctx).Where("id IN ?", ids).Find(&wallets).Error + err := r.GetDB(ctx).Where("id IN ?", ids).Order("created_at DESC").Find(&wallets).Error return wallets, err } @@ -120,6 +120,9 @@ func (r *GormWalletRepository) List(ctx context.Context, options interfaces.List order += " ASC" } query = query.Order(order) + } else { + // 默认按创建时间倒序 + query = query.Order("created_at DESC") } if options.Page > 0 && options.PageSize > 0 { offset := (options.Page - 1) * options.PageSize diff --git a/internal/infrastructure/database/repositories/product/gorm_product_category_repository.go b/internal/infrastructure/database/repositories/product/gorm_product_category_repository.go index 71a1f2a..b2207f5 100644 --- a/internal/infrastructure/database/repositories/product/gorm_product_category_repository.go +++ b/internal/infrastructure/database/repositories/product/gorm_product_category_repository.go @@ -70,7 +70,7 @@ func (r *GormProductCategoryRepository) FindByCode(ctx context.Context, code str // FindVisible 查找可见分类 func (r *GormProductCategoryRepository) FindVisible(ctx context.Context) ([]*entities.ProductCategory, error) { var categories []entities.ProductCategory - err := r.GetDB(ctx).Where("is_visible = ? AND is_enabled = ?", true, true).Find(&categories).Error + err := r.GetDB(ctx).Where("is_visible = ? AND is_enabled = ?", true, true).Order("sort ASC, created_at DESC").Find(&categories).Error if err != nil { return nil, err } @@ -86,7 +86,7 @@ func (r *GormProductCategoryRepository) FindVisible(ctx context.Context) ([]*ent // FindEnabled 查找启用分类 func (r *GormProductCategoryRepository) FindEnabled(ctx context.Context) ([]*entities.ProductCategory, error) { var categories []entities.ProductCategory - err := r.GetDB(ctx).Where("is_enabled = ?", true).Find(&categories).Error + err := r.GetDB(ctx).Where("is_enabled = ?", true).Order("sort ASC, created_at DESC").Find(&categories).Error if err != nil { return nil, err } @@ -130,7 +130,7 @@ func (r *GormProductCategoryRepository) ListCategories(ctx context.Context, quer dbQuery = dbQuery.Order(order) } else { // 默认按排序字段和创建时间排序 - dbQuery = dbQuery.Order("sort ASC, created_at ASC") + dbQuery = dbQuery.Order("sort ASC, created_at DESC") } // 应用分页 @@ -193,7 +193,7 @@ func (r *GormProductCategoryRepository) Count(ctx context.Context, options inter // GetByIDs 根据ID列表获取分类 func (r *GormProductCategoryRepository) GetByIDs(ctx context.Context, ids []string) ([]entities.ProductCategory, error) { var categories []entities.ProductCategory - err := r.GetDB(ctx).Where("id IN ?", ids).Find(&categories).Error + err := r.GetDB(ctx).Where("id IN ?", ids).Order("sort ASC, created_at DESC").Find(&categories).Error return categories, err } @@ -238,6 +238,9 @@ func (r *GormProductCategoryRepository) List(ctx context.Context, options interf order += " ASC" } query = query.Order(order) + } else { + // 默认按排序字段和创建时间倒序 + query = query.Order("sort ASC, created_at DESC") } // 应用分页 diff --git a/internal/infrastructure/database/repositories/product/gorm_product_repository.go b/internal/infrastructure/database/repositories/product/gorm_product_repository.go index 13bed3f..685299d 100644 --- a/internal/infrastructure/database/repositories/product/gorm_product_repository.go +++ b/internal/infrastructure/database/repositories/product/gorm_product_repository.go @@ -82,7 +82,7 @@ func (r *GormProductRepository) FindByOldID(ctx context.Context, oldID string) ( // FindByCategoryID 根据分类ID查找产品 func (r *GormProductRepository) FindByCategoryID(ctx context.Context, categoryID string) ([]*entities.Product, error) { var productEntities []entities.Product - err := r.GetDB(ctx).Preload("Category").Where("category_id = ?", categoryID).Find(&productEntities).Error + err := r.GetDB(ctx).Preload("Category").Where("category_id = ?", categoryID).Order("created_at DESC").Find(&productEntities).Error if err != nil { return nil, err } @@ -98,7 +98,7 @@ func (r *GormProductRepository) FindByCategoryID(ctx context.Context, categoryID // FindVisible 查找可见产品 func (r *GormProductRepository) FindVisible(ctx context.Context) ([]*entities.Product, error) { var productEntities []entities.Product - err := r.GetDB(ctx).Preload("Category").Where("is_visible = ? AND is_enabled = ?", true, true).Find(&productEntities).Error + err := r.GetDB(ctx).Preload("Category").Where("is_visible = ? AND is_enabled = ?", true, true).Order("created_at DESC").Find(&productEntities).Error if err != nil { return nil, err } @@ -114,7 +114,7 @@ func (r *GormProductRepository) FindVisible(ctx context.Context) ([]*entities.Pr // FindEnabled 查找启用产品 func (r *GormProductRepository) FindEnabled(ctx context.Context) ([]*entities.Product, error) { var productEntities []entities.Product - err := r.GetDB(ctx).Preload("Category").Where("is_enabled = ?", true).Find(&productEntities).Error + err := r.GetDB(ctx).Preload("Category").Where("is_enabled = ?", true).Order("created_at DESC").Find(&productEntities).Error if err != nil { return nil, err } @@ -303,7 +303,7 @@ func (r *GormProductRepository) ListProductsWithSubscriptionStatus(ctx context.C // FindSubscribableProducts 查找可订阅产品 func (r *GormProductRepository) FindSubscribableProducts(ctx context.Context, userID string) ([]*entities.Product, error) { var productEntities []entities.Product - err := r.GetDB(ctx).Where("is_enabled = ? AND is_visible = ?", true, true).Find(&productEntities).Error + err := r.GetDB(ctx).Where("is_enabled = ? AND is_visible = ?", true, true).Order("created_at DESC").Find(&productEntities).Error if err != nil { return nil, err } @@ -318,7 +318,7 @@ func (r *GormProductRepository) FindSubscribableProducts(ctx context.Context, us // FindProductsByIDs 根据ID列表查找产品 func (r *GormProductRepository) FindProductsByIDs(ctx context.Context, ids []string) ([]*entities.Product, error) { var productEntities []entities.Product - err := r.GetDB(ctx).Where("id IN ?", ids).Find(&productEntities).Error + err := r.GetDB(ctx).Where("id IN ?", ids).Order("created_at DESC").Find(&productEntities).Error if err != nil { return nil, err } @@ -379,7 +379,7 @@ func (r *GormProductRepository) Count(ctx context.Context, options interfaces.Co // GetByIDs 根据ID列表获取产品 func (r *GormProductRepository) GetByIDs(ctx context.Context, ids []string) ([]entities.Product, error) { var products []entities.Product - err := r.GetDB(ctx).Where("id IN ?", ids).Find(&products).Error + err := r.GetDB(ctx).Where("id IN ?", ids).Order("created_at DESC").Find(&products).Error return products, err } @@ -424,6 +424,9 @@ func (r *GormProductRepository) List(ctx context.Context, options interfaces.Lis order += " ASC" } query = query.Order(order) + } else { + // 默认按创建时间倒序 + query = query.Order("created_at DESC") } // 应用分页 diff --git a/internal/infrastructure/database/repositories/product/gorm_subscription_repository.go b/internal/infrastructure/database/repositories/product/gorm_subscription_repository.go index 9530d3f..6bb18d6 100644 --- a/internal/infrastructure/database/repositories/product/gorm_subscription_repository.go +++ b/internal/infrastructure/database/repositories/product/gorm_subscription_repository.go @@ -60,7 +60,7 @@ func (r *GormSubscriptionRepository) Update(ctx context.Context, entity entities // FindByUserID 根据用户ID查找订阅 func (r *GormSubscriptionRepository) FindByUserID(ctx context.Context, userID string) ([]*entities.Subscription, error) { var subscriptions []entities.Subscription - err := r.GetDB(ctx).WithContext(ctx).Where("user_id = ?", userID).Find(&subscriptions).Error + err := r.GetDB(ctx).WithContext(ctx).Where("user_id = ?", userID).Order("created_at DESC").Find(&subscriptions).Error if err != nil { return nil, err } @@ -76,7 +76,7 @@ func (r *GormSubscriptionRepository) FindByUserID(ctx context.Context, userID st // FindByProductID 根据产品ID查找订阅 func (r *GormSubscriptionRepository) FindByProductID(ctx context.Context, productID string) ([]*entities.Subscription, error) { var subscriptions []entities.Subscription - err := r.GetDB(ctx).WithContext(ctx).Where("product_id = ?", productID).Find(&subscriptions).Error + err := r.GetDB(ctx).WithContext(ctx).Where("product_id = ?", productID).Order("created_at DESC").Find(&subscriptions).Error if err != nil { return nil, err } @@ -243,7 +243,7 @@ func (r *GormSubscriptionRepository) Count(ctx context.Context, options interfac // GetByIDs 根据ID列表获取订阅 func (r *GormSubscriptionRepository) GetByIDs(ctx context.Context, ids []string) ([]entities.Subscription, error) { var subscriptions []entities.Subscription - err := r.GetDB(ctx).WithContext(ctx).Where("id IN ?", ids).Find(&subscriptions).Error + err := r.GetDB(ctx).WithContext(ctx).Where("id IN ?", ids).Order("created_at DESC").Find(&subscriptions).Error return subscriptions, err } @@ -288,6 +288,9 @@ func (r *GormSubscriptionRepository) List(ctx context.Context, options interface order += " ASC" } query = query.Order(order) + } else { + // 默认按创建时间倒序 + query = query.Order("created_at DESC") } // 应用分页 diff --git a/internal/infrastructure/database/repositories/user/gorm_enterprise_info_repository.go b/internal/infrastructure/database/repositories/user/gorm_enterprise_info_repository.go index 74ef048..f7ae7bd 100644 --- a/internal/infrastructure/database/repositories/user/gorm_enterprise_info_repository.go +++ b/internal/infrastructure/database/repositories/user/gorm_enterprise_info_repository.go @@ -211,7 +211,7 @@ func (r *GormEnterpriseInfoRepository) CreateBatch(ctx context.Context, enterpri // GetByIDs 根据ID列表获取企业信息 func (r *GormEnterpriseInfoRepository) GetByIDs(ctx context.Context, ids []string) ([]entities.EnterpriseInfo, error) { var enterpriseInfos []entities.EnterpriseInfo - err := r.db.WithContext(ctx).Where("id IN ?", ids).Find(&enterpriseInfos).Error + err := r.db.WithContext(ctx).Where("id IN ?", ids).Order("created_at DESC").Find(&enterpriseInfos).Error return enterpriseInfos, err } @@ -246,6 +246,9 @@ func (r *GormEnterpriseInfoRepository) List(ctx context.Context, options interfa order = options.Order } query = query.Order(options.Sort + " " + order) + } else { + // 默认按创建时间倒序 + query = query.Order("created_at DESC") } if options.Page > 0 && options.PageSize > 0 { diff --git a/internal/infrastructure/database/repositories/user/gorm_sms_code_repository.go b/internal/infrastructure/database/repositories/user/gorm_sms_code_repository.go index 883ac96..7577167 100644 --- a/internal/infrastructure/database/repositories/user/gorm_sms_code_repository.go +++ b/internal/infrastructure/database/repositories/user/gorm_sms_code_repository.go @@ -72,7 +72,7 @@ func (r *GormSMSCodeRepository) CreateBatch(ctx context.Context, smsCodes []enti // GetByIDs 根据ID列表获取短信验证码 func (r *GormSMSCodeRepository) GetByIDs(ctx context.Context, ids []string) ([]entities.SMSCode, error) { var smsCodes []entities.SMSCode - err := r.GetDB(ctx).Where("id IN ?", ids).Find(&smsCodes).Error + err := r.GetDB(ctx).Where("id IN ?", ids).Order("created_at DESC").Find(&smsCodes).Error return smsCodes, err } diff --git a/internal/infrastructure/database/repositories/user/gorm_user_repository.go b/internal/infrastructure/database/repositories/user/gorm_user_repository.go index 8ccd049..ec99a03 100644 --- a/internal/infrastructure/database/repositories/user/gorm_user_repository.go +++ b/internal/infrastructure/database/repositories/user/gorm_user_repository.go @@ -102,7 +102,7 @@ func (r *GormUserRepository) CreateBatch(ctx context.Context, users []entities.U func (r *GormUserRepository) GetByIDs(ctx context.Context, ids []string) ([]entities.User, error) { var users []entities.User - err := r.GetDB(ctx).Where("id IN ?", ids).Find(&users).Error + err := r.GetDB(ctx).Where("id IN ?", ids).Order("created_at DESC").Find(&users).Error return users, err } @@ -174,7 +174,7 @@ func (r *GormUserRepository) GetByUsername(ctx context.Context, username string) func (r *GormUserRepository) GetByUserType(ctx context.Context, userType string) ([]*entities.User, error) { var users []*entities.User - err := r.GetDB(ctx).Where("user_type = ?", userType).Find(&users).Error + err := r.GetDB(ctx).Where("user_type = ?", userType).Order("created_at DESC").Find(&users).Error return users, err } @@ -214,6 +214,9 @@ func (r *GormUserRepository) ListUsers(ctx context.Context, query *queries.ListU return nil, 0, err } + // 应用排序(默认按创建时间倒序) + db = db.Order("users.created_at DESC") + // 应用分页 offset := (query.Page - 1) * query.PageSize if err := db.Offset(offset).Limit(query.PageSize).Find(&users).Error; err != nil {