YouChuKoffee/app/services/VoucherService.go

35 lines
1.0 KiB
Go

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