This commit is contained in:
suyl
2021-09-10 09:11:23 +08:00
parent 4ae75be0d6
commit 92fd4c8107
5 changed files with 24 additions and 18 deletions

View File

@@ -990,25 +990,30 @@ func GetStoreAuditPage(db *DaoDB, statuss []int, keyword string, applyTimeStart,
return pagedInfo, err
}
func GetBrands(db *DaoDB, name string, brandID int, poolKey string) (brands []*model.Brand, err error) {
func GetBrands(db *DaoDB, name string, brandID int, poolKey string, isManage bool, userID string) (brands []*model.Brand, err error) {
sqlParams := []interface{}{}
sql := `
SELECT *
FROM brand
WHERE deleted_at = ?
SELECT a.*
FROM brand a
`
sqlParams := []interface{}{
utils.DefaultTimeValue,
if isManage {
sql += ` JOIN brand_user b ON a.id = b.brand_id AND b.user_id = ?`
sqlParams = append(sqlParams, userID)
}
sql += `
WHERE a.deleted_at = ?
`
sqlParams = append(sqlParams, utils.DefaultTimeValue)
if name != "" {
sql += " AND name LIKE ?"
sql += " AND a.name LIKE ?"
sqlParams = append(sqlParams, "%"+name+"%")
}
if brandID != 0 {
sql += " AND id = ?"
sql += " AND a.id = ?"
sqlParams = append(sqlParams, brandID)
}
if poolKey != "" {
sql += " AND secret_number_pool_key = ?"
sql += " AND a.secret_number_pool_key = ?"
sqlParams = append(sqlParams, poolKey)
}
err = GetRows(db, &brands, sql, sqlParams)