YouChuKoffee/app/services/VoucherService.go

35 lines
1018 B
Go
Raw Normal View History

2024-06-17 16:29:39 +08:00
package services
import (
"github.com/ahmetb/go-linq/v3"
2024-06-19 18:32:34 +08:00
"qteam/app/http/entities/front"
2024-06-17 16:29:39 +08:00
"qteam/app/models/brandmodel"
"qteam/app/models/productsmodel"
"qteam/config"
)
2024-06-19 18:32:34 +08:00
func VoucherList() (code int, VoucherListResponse front.VoucherListResponse) {
2024-06-17 16:29:39 +08:00
VoucherListResponse.MilkUrl = config.GetConf().YouChu.MilkUrl
var BrandData []brandmodel.Brand
var VoucherData []productsmodel.MilkProductsList
code, BrandData = MilkBrandList()
if BrandData != nil {
2024-06-19 18:32:34 +08:00
var MilkList []front.MilkList
linq.From(BrandData).SelectT(func(in brandmodel.Brand) (d front.MilkList) {
2024-06-17 16:29:39 +08:00
d.ResponseFromDb(in)
return
}).ToSlice(&MilkList)
VoucherListResponse.MilkList = MilkList
}
code, VoucherData = MilkProductList()
if VoucherData != nil {
2024-06-19 18:32:34 +08:00
var MilkVoucherList []front.MilkVoucherList
linq.From(VoucherData).SelectT(func(in productsmodel.MilkProductsList) (d front.MilkVoucherList) {
2024-06-17 16:29:39 +08:00
d.ResponseFromDb(in)
return
}).ToSlice(&MilkVoucherList)
VoucherListResponse.MilkVoucherList = MilkVoucherList
}
return
}