- GetUsers接口改变

This commit is contained in:
gazebo
2019-08-06 16:35:37 +08:00
parent d5d35274dd
commit a0c74cf02a
5 changed files with 20 additions and 16 deletions

View File

@@ -23,7 +23,7 @@ func GetUserByID(db *DaoDB, fieldName, fieldValue string) (user *model.User, err
return user, err
}
func GetUsers(db *DaoDB, userType int, userID, userID2, mobile, userName string) (userList []*model.User, err error) {
func GetUsers(db *DaoDB, userType int, keyword string, userIDs []string, userID2, mobile string) (userList []*model.User, err error) {
if userType == 0 {
userType = 255
}
@@ -35,9 +35,9 @@ func GetUsers(db *DaoDB, userType int, userID, userID2, mobile, userName string)
utils.DefaultTimeValue,
userType,
}
if userID != "" {
sql += " AND t1.user_id = ?"
sqlParams = append(sqlParams, userID)
if len(userIDs) > 0 {
sql += " AND t1.user_id IN (" + GenQuestionMarks(len(userIDs)) + ")"
sqlParams = append(sqlParams, userIDs)
}
if userID2 != "" {
sql += " AND t1.user_id2 = ?"
@@ -47,9 +47,10 @@ func GetUsers(db *DaoDB, userType int, userID, userID2, mobile, userName string)
sql += " AND t1.mobile = ?"
sqlParams = append(sqlParams, mobile)
}
if userName != "" {
sql += " AND t1.name LIKE ?"
sqlParams = append(sqlParams, "%"+userName+"%")
if keyword != "" {
keywordLike := "%" + keyword + "%"
sql += " AND (t1.user_id2 LIKE % OR t1.mobile LIKE % OR t1.email LIKE ? OR t1.name LIKE ?)"
sqlParams = append(sqlParams, keywordLike, keywordLike, keywordLike, keywordLike)
}
err = GetRows(db, &userList, sql, sqlParams...)
return userList, err