- 注释掉老user与auth相关的代码

This commit is contained in:
gazebo
2019-09-24 16:39:50 +08:00
parent 72c9889d10
commit 412b11396a
18 changed files with 1172 additions and 1442 deletions

View File

@@ -8,6 +8,11 @@ import (
"git.rosy.net.cn/jx-callback/business/model"
)
type StoreWithCityName struct {
model.Store
CityName string `json:"cityName"`
}
func GetUserByID(db *DaoDB, fieldName, fieldValue string) (user *model.User, err error) {
sql := fmt.Sprintf(`
SELECT *
@@ -85,3 +90,61 @@ func DeleteUsers(db *DaoDB, userIDs []string) (num int64, err error) {
}
return num, err
}
func GetStoreListByMobile(db *DaoDB, mobile string) (storeList []*StoreWithCityName, err error) {
if mobile != "" {
sql := `
SELECT
DISTINCT t1.*, t2.name city_name
FROM (
SELECT *
FROM store t1
WHERE (t1.market_man_phone = ? OR t1.operator_phone = ?)
UNION DISTINCT
SELECT t1.*
FROM store t1
JOIN weixins t2 ON t2.jxstoreid = t1.id AND t2.parentid = -1
LEFT JOIN weixins t3 ON t3.parentid = t2.id
WHERE (t2.tel = ? OR t3.tel = ?)
) t1
LEFT JOIN place t2 ON t2.code = t1.city_code
WHERE t1.deleted_at = ?
ORDER BY t1.name`
sqlParams := []interface{}{
mobile,
mobile,
mobile,
mobile,
utils.DefaultTimeValue,
}
err = GetRows(db, &storeList, sql, sqlParams...)
}
return storeList, err
}
func GetStoreListByMobileOrStoreIDs(db *DaoDB, mobile string, shortRoleNameList []string, storeIDs []int) (storeList []*StoreWithCityName, err error) {
sql := `
SELECT t1.*, t2.name city_name
FROM store t1
LEFT JOIN place t2 ON t2.code = t1.city_code
WHERE t1.deleted_at = ? AND ( 1 = 0`
sqlParams := []interface{}{
utils.DefaultTimeValue,
}
if mobile != "" {
sql += " OR t1.market_man_phone = ? OR t1.operator_phone = ?"
sqlParams = append(sqlParams, mobile, mobile)
}
if len(shortRoleNameList) > 0 {
questionMarks := GenQuestionMarks(len(shortRoleNameList))
sql += " OR t1.market_man_role IN (" + questionMarks + ") OR t1.operator_role IN (" + questionMarks + ") OR t1.operator_role2 IN (" + questionMarks + ")"
sqlParams = append(sqlParams, shortRoleNameList, shortRoleNameList, shortRoleNameList)
}
if len(storeIDs) > 0 {
sql += " OR t1.id IN (" + GenQuestionMarks(len(storeIDs)) + ")"
sqlParams = append(sqlParams, storeIDs)
}
sql += ")"
err = GetRows(db, &storeList, sql, sqlParams...)
return storeList, err
}