This commit is contained in:
laodaming
2023-09-05 18:29:44 +08:00
parent 262c8dc1b5
commit d2bb801fb4
4 changed files with 106 additions and 21 deletions

View File

@@ -12,7 +12,7 @@ func (s *FsProductSizeModel) GetAllByIds(ctx context.Context, ids []int64, sort
if len(ids) == 0 {
return
}
db := s.db.Model(&FsProductSize{}).Where("`id` in (?) and `status` = ?", ids, 1)
db := s.db.WithContext(ctx).Model(&FsProductSize{}).Where("`id` in (?) and `status` = ?", ids, 1)
switch sort {
case "sort-asc":
db = db.Order("`sort` ASC")
@@ -112,3 +112,12 @@ func (s *FsProductSizeModel) FindOneByIdProductId(ctx context.Context, id int64,
err = s.db.WithContext(ctx).Model(&FsProductSize{}).Where("`id` = ? and product_id = ?", id, productId).Take(&resp).Error
return resp, err
}
func (s *FsProductSizeModel) GetAllByModelIdsJoinModeld(ctx context.Context, modelIds []int64) (resp []FsProductSize, err error) {
if len(modelIds) == 0 {
return
}
err = s.db.WithContext(ctx).Table(s.name + " as s").
Joins("left join fs_product_model3d as m on s.id = m.size_id").
Select("s.*").Find(&resp).Error
return resp, err
}