aa
This commit is contained in:
@@ -441,3 +441,39 @@ func GetSkuVendorCategoryMaps(db *DaoDB, nameIDs, vendorIDs []int, vendorCategor
|
||||
}
|
||||
return nil, err
|
||||
}
|
||||
|
||||
func GetVendorCategoryMap(db *DaoDB, parentID, level, vendorID int, vendorOrgCode string, categoryID int) (vendorMaps []*model.VendorCategoryMap, err error) {
|
||||
sql := `
|
||||
SELECT a.*
|
||||
FROM vendor_category_map a
|
||||
WHERE a.deleted_at = ?
|
||||
`
|
||||
sqlParams := []interface{}{
|
||||
utils.DefaultTimeValue,
|
||||
}
|
||||
if parentID >= 0 {
|
||||
sql += " AND a.parent_id = ?"
|
||||
sqlParams = append(sqlParams, parentID)
|
||||
}
|
||||
if level > 0 {
|
||||
sql += " AND a.level = ?"
|
||||
sqlParams = append(sqlParams, level)
|
||||
}
|
||||
if vendorID != -1 {
|
||||
sql += " AND a.vendor_id = ?"
|
||||
sqlParams = append(sqlParams, vendorID)
|
||||
}
|
||||
if vendorOrgCode != "" {
|
||||
sql += " AND a.vendor_org_code = ?"
|
||||
sqlParams = append(sqlParams, vendorOrgCode)
|
||||
}
|
||||
if categoryID > 0 {
|
||||
sql += " AND a.categoryID = ?"
|
||||
sqlParams = append(sqlParams, categoryID)
|
||||
}
|
||||
err = GetRows(db, &vendorMaps, sql, sqlParams)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return vendorMaps, err
|
||||
}
|
||||
|
||||
@@ -330,6 +330,8 @@ func (*SkuVendorCategoryMap) TableIndex() [][]string {
|
||||
|
||||
type VendorCategoryMap struct {
|
||||
ModelIDCULD
|
||||
|
||||
VendorID int `orm:"column(vendor_id)" json:"vendorID"`
|
||||
VendorOrgCode string `json:"vendorOrgCode"`
|
||||
CategoryID int `orm:"column(category_id)" json:"categoryID"` // 这个是指对应的sku_category
|
||||
VendorCategoryName string `orm:"size(255)" json:"vendorCategoryName"` // 平台类别单独的名字
|
||||
@@ -340,6 +342,6 @@ type VendorCategoryMap struct {
|
||||
|
||||
func (*VendorCategoryMap) TableUnique() [][]string {
|
||||
return [][]string{
|
||||
[]string{"VendorOrgCode", "CategoryID", "DeletedAt"},
|
||||
[]string{"VendorID", "VendorOrgCode", "CategoryID", "DeletedAt"},
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user