add subscription gorm preload
This commit is contained in:
@@ -172,10 +172,10 @@ func (r *GormSubscriptionRepository) ListSubscriptions(ctx context.Context, quer
|
||||
dbQuery = dbQuery.Offset(offset).Limit(query.PageSize)
|
||||
}
|
||||
|
||||
// 预加载Product的id、name、code字段,并同时预加载ProductCategory的id、name、code字段
|
||||
// 预加载Product的id、name、code、price、is_package字段,并同时预加载ProductCategory的id、name、code字段
|
||||
if err := dbQuery.
|
||||
Preload("Product", func(db *gorm.DB) *gorm.DB {
|
||||
return db.Select("id", "name", "code", "category_id").
|
||||
return db.Select("id", "name", "code", "price", "is_package", "category_id").
|
||||
Preload("Category", func(db2 *gorm.DB) *gorm.DB {
|
||||
return db2.Select("id", "name", "code")
|
||||
})
|
||||
|
||||
Reference in New Issue
Block a user