YouChuKoffee/app/services/VoucherService.go

35 lines
1018 B
Go

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