aa
This commit is contained in:
@@ -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)
|
||||
|
||||
Reference in New Issue
Block a user