This commit is contained in:
laodaming
2023-07-20 11:08:35 +08:00
parent 3e1d4d2e4f
commit b8333ecaf8
5 changed files with 128 additions and 84 deletions

View File

@@ -75,3 +75,18 @@ func (d *FsProductModel3dModel) GetAll(ctx context.Context) (resp []FsProductMod
err = d.db.WithContext(ctx).Model(&FsProductModel3d{}).Find(&resp).Error
return resp, err
}
type GetGroupPartListByProductIdsRsp struct {
PartList string `json:"part_list"`
ProductId int64 `json:"product_id"`
}
func (d *FsProductModel3dModel) GetGroupPartListByProductIds(ctx context.Context, productIds []int64) (resp []GetGroupPartListByProductIdsRsp, err error) {
if len(productIds) == 0 {
return
}
err = d.db.WithContext(ctx).Model(&FsProductModel3d{}).
Select("product_id,group_concat(part_list) as part_list").
Group("product_id").Find(&resp).Error
return resp, err
}