- 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

@@ -51,7 +51,7 @@ func TransferLegacyWeixins() (err error) {
if user.Name == "" {
user.Name = user.Mobile
}
userList, err2 := dao.GetUsers(db, 0, "", "", v.Tel, "")
userList, err2 := dao.GetUsers(db, 0, "", nil, "", v.Tel)
if err = err2; err != nil {
return err
}

View File

@@ -153,6 +153,6 @@ func OnDingDingMsg(msg map[string]interface{}) (callbackResponse *dingdingapi.Ca
return api.DingDingAPI.Err2CallbackResponse(nil)
}
func GetUsers(ctx *jxcontext.Context, userType int, userID, userID2, mobile, userName string) (userList []*model.User, err error) {
return dao.GetUsers(dao.GetDB(), userType, userID, userID2, mobile, userName)
func GetUsers(ctx *jxcontext.Context, userType int, keyword string, userIDs []string, userID2, mobile string) (userList []*model.User, err error) {
return dao.GetUsers(dao.GetDB(), userType, keyword, userIDs, userID2, mobile)
}

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

View File

@@ -73,9 +73,9 @@ func (c *Auth2Controller) Login() {
})
}
// @Title 钉钉认证回调接口
// @Description 钉钉认证回调接口,自己不能直接调用
// @Param token header string true "认证token"
// @Title 得到自己登录token的信息
// @Description 得到自己登录token的信息
// @Param token header string true "认证token"
// @Success 200 {object} controllers.CallResult
// @Failure 200 {object} controllers.CallResult
// @router /GetTokenInfo [get]

View File

@@ -55,16 +55,19 @@ func (c *User2Controller) GetBindAuthInfo() {
// @Description 得到用户列表
// @Param token header string true "认证token"
// @Param userType query int true "用户类型0表示全部"
// @Param userID query string faslse "用户id必须全匹配内部唯一标识"
// @Param keyword query string faslse "关键字,可以部分匹配"
// @Param userIDs query string faslse "用户id列表"
// @Param userID2 query string faslse "用户id2必须全匹配外部唯一标识"
// @Param mobile query string faslse "用户手机,必须全匹配"
// @Param userName query string faslse "用户名,可以部分匹配"
// @Success 200 {object} controllers.CallResult
// @Failure 200 {object} controllers.CallResult
// @router /GetUsers [get]
func (c *User2Controller) GetUsers() {
c.callGetUsers(func(params *tUser2GetUsersParams) (retVal interface{}, errCode string, err error) {
retVal, err = cms.GetUsers(params.Ctx, params.UserType, params.UserID, params.UserID2, params.Mobile, params.UserName)
var userIDs []string
if err := jxutils.Strings2Objs(params.UserIDs, &userIDs); err == nil {
retVal, err = cms.GetUsers(params.Ctx, params.UserType, params.Keyword, userIDs, params.UserID2, params.Mobile)
}
return retVal, "", err
})
}