|
@@ -1168,3 +1168,94 @@ func (this *UserController) ChangeList() {
|
|
|
br.Success = true
|
|
|
br.Ret = 200
|
|
|
}
|
|
|
+
|
|
|
+// GlobalSearch
|
|
|
+// @Title 全局用户列表
|
|
|
+// @Description 全局用户列表
|
|
|
+// @Param PageSize query int true "每页数据条数"
|
|
|
+// @Param CurrentIndex query int true "当前页页码,从1开始"
|
|
|
+// @Param KeyWord query string true "手机号/邮箱/姓名"
|
|
|
+// @Param SortParam query string true "排序字段"
|
|
|
+// @Param SortType query string true "排序方式"
|
|
|
+// @Success 200 {object} response.UserListResp
|
|
|
+// @router /global/list [get]
|
|
|
+func (this *UserController) GlobalSearch() {
|
|
|
+ br := new(models.BaseResponse).Init()
|
|
|
+ defer func() {
|
|
|
+ this.Data["json"] = br
|
|
|
+ this.ServeJSON()
|
|
|
+ }()
|
|
|
+
|
|
|
+ pageSize, _ := this.GetInt("PageSize")
|
|
|
+ currentIndex, _ := this.GetInt("CurrentIndex")
|
|
|
+ keyWord := this.GetString("KeyWord")
|
|
|
+ sortParam := this.GetString("SortParam")
|
|
|
+ sortType := this.GetString("SortType")
|
|
|
+
|
|
|
+ if pageSize <= 0 {
|
|
|
+ pageSize = utils.PageSize20
|
|
|
+ }
|
|
|
+ if currentIndex <= 0 {
|
|
|
+ currentIndex = 1
|
|
|
+ }
|
|
|
+
|
|
|
+ var condition string
|
|
|
+ var pars []interface{}
|
|
|
+ var sortCondition string
|
|
|
+
|
|
|
+ if keyWord == "" {
|
|
|
+ br.Ret = 200
|
|
|
+ br.Msg = "查询成功"
|
|
|
+ br.Success = true
|
|
|
+ return
|
|
|
+ } else {
|
|
|
+ condition = ` AND (real_name like ? OR phone like ? OR email like ?)`
|
|
|
+ pars = utils.GetLikeKeywordPars(pars, keyWord, 3)
|
|
|
+ }
|
|
|
+
|
|
|
+ if sortParam != "" && sortType != "" {
|
|
|
+ var param, sort string
|
|
|
+ switch sortParam {
|
|
|
+ case "read_cnt":
|
|
|
+ param = "read_cnt"
|
|
|
+ case "last_update_time":
|
|
|
+ param = "last_update_time"
|
|
|
+ }
|
|
|
+ switch sortType {
|
|
|
+ case "asc":
|
|
|
+ sort = "ASC"
|
|
|
+ case "desc":
|
|
|
+ sort = "DESC"
|
|
|
+ }
|
|
|
+ if param != "" && sort != "" {
|
|
|
+ sortCondition = ` ORDER BY ` + param + ` ` + sort
|
|
|
+ }
|
|
|
+ }
|
|
|
+ if sortCondition == "" {
|
|
|
+ sortCondition = ` ORDER BY u.user_Id DESC`
|
|
|
+ }
|
|
|
+
|
|
|
+ startSize := utils.StartIndex(currentIndex, pageSize)
|
|
|
+ userIds, err := models.GetUserIdListByCondition(condition, pars)
|
|
|
+ if err != nil {
|
|
|
+ br.Msg = "查询失败"
|
|
|
+ br.ErrMsg = "查询失败,系统错误,Err:" + err.Error()
|
|
|
+ return
|
|
|
+ }
|
|
|
+
|
|
|
+ userList, err := models.GetGlobalUserByCondition(userIds, sortCondition, startSize, pageSize)
|
|
|
+ if err != nil {
|
|
|
+ br.Msg = "查询失败"
|
|
|
+ br.ErrMsg = "查询失败,系统错误,Err:" + err.Error()
|
|
|
+ return
|
|
|
+ }
|
|
|
+ page := paging.GetPaging(currentIndex, pageSize, len(userIds))
|
|
|
+ resp := new(response.UserListResp)
|
|
|
+ resp.List = userList
|
|
|
+ resp.Paging = page
|
|
|
+
|
|
|
+ br.Data = resp
|
|
|
+ br.Msg = "查询成功"
|
|
|
+ br.Success = true
|
|
|
+ br.Ret = 200
|
|
|
+}
|