|
@@ -434,7 +434,7 @@ func (this *UserController) Check() {
|
|
|
// @Description 用户列表
|
|
|
// @Param PageSize query int true "每页数据条数"
|
|
|
// @Param CurrentIndex query int true "当前页页码,从1开始"
|
|
|
-// @Param SellerId query int true "销售id"
|
|
|
+// @Param SellerId query string true "销售id"
|
|
|
// @Param Status query int true "用户状态"
|
|
|
// @Param KeyWord query string true "手机号/邮箱/姓名"
|
|
|
// @Param IsRegistered query string true "是否注册"
|
|
@@ -443,8 +443,8 @@ func (this *UserController) Check() {
|
|
|
// @Param RegisterEndDate query string true "注册结束时间"
|
|
|
// @Param CreateStartDate query string true "创建开始时间"
|
|
|
// @Param CreateEndDate query string true "创建结束时间"
|
|
|
-// @Param Last query string true "创建结束时间"
|
|
|
-// @Param CreateEndDate query string true "创建结束时间"
|
|
|
+// @Param SortParam query string true "排序字段"
|
|
|
+// @Param SortType query string true "排序方式"
|
|
|
// @Success 200 {object} response.UserListResp
|
|
|
// @router /list [get]
|
|
|
func (this *UserController) List() {
|
|
@@ -453,10 +453,9 @@ func (this *UserController) List() {
|
|
|
this.Data["json"] = br
|
|
|
this.ServeJSON()
|
|
|
}()
|
|
|
-
|
|
|
pageSize, _ := this.GetInt("PageSize")
|
|
|
currentIndex, _ := this.GetInt("CurrentIndex")
|
|
|
- sellerId, _ := this.GetInt("SellerId")
|
|
|
+ sellerIdStr := this.GetString("SellerId")
|
|
|
status := this.GetString("Status")
|
|
|
keyWord := this.GetString("KeyWord")
|
|
|
IsRegistered := this.GetString("IsRegisterd")
|
|
@@ -465,8 +464,11 @@ func (this *UserController) List() {
|
|
|
registerEndDate := this.GetString("RegisterEndDate")
|
|
|
createStartDate := this.GetString("CreateStartDate")
|
|
|
createEndDate := this.GetString("CreateEndDate")
|
|
|
+ sortParma := this.GetString("SortParam")
|
|
|
+ sortType := this.GetString("SortTye")
|
|
|
|
|
|
var condition string
|
|
|
+ var sortCondition string
|
|
|
var pars []interface{}
|
|
|
|
|
|
if keyWord != "" {
|
|
@@ -483,9 +485,45 @@ func (this *UserController) List() {
|
|
|
currentIndex = 1
|
|
|
}
|
|
|
|
|
|
- if sellerId > 0 {
|
|
|
- condition += " AND u.seller_id=? "
|
|
|
- pars = append(pars, sellerId)
|
|
|
+ if sortParma != "" && sortType != "" {
|
|
|
+ sortCondition = " ORDER BY "
|
|
|
+ var param, sort string
|
|
|
+ switch sortParma {
|
|
|
+ case "RegisterTime":
|
|
|
+ param = "u.register_time"
|
|
|
+ case "CreateTime":
|
|
|
+ param = "u.create_time"
|
|
|
+ case "RestDate":
|
|
|
+ param = "u.rest_date"
|
|
|
+ }
|
|
|
+ switch sortType {
|
|
|
+ case "asc":
|
|
|
+ sort = " ASC "
|
|
|
+ case "desc":
|
|
|
+ sort = " DESC "
|
|
|
+ }
|
|
|
+ if param != "" && sort != "" {
|
|
|
+ sortCondition += param + " " + sort
|
|
|
+ } else {
|
|
|
+ sortCondition = ""
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ if sellerIdStr != "" {
|
|
|
+ sellerIds := strings.Split(sellerIdStr, ",")
|
|
|
+ if len(sellerIds) != 0 {
|
|
|
+ condition += ` AND ( `
|
|
|
+ for i, id := range sellerIds {
|
|
|
+ if i == 0 {
|
|
|
+ condition += ` u.seller_id = ? `
|
|
|
+ pars = append(pars, id)
|
|
|
+ } else {
|
|
|
+ condition += ` OR u.seller_id = ? `
|
|
|
+ pars = append(pars, id)
|
|
|
+ }
|
|
|
+ }
|
|
|
+ condition += `) `
|
|
|
+ }
|
|
|
}
|
|
|
switch status {
|
|
|
case "禁用":
|
|
@@ -569,7 +607,7 @@ func (this *UserController) List() {
|
|
|
br.ErrMsg = "获取失败,Err:" + err.Error()
|
|
|
return
|
|
|
}
|
|
|
- userList, err := models.GetUserList(condition, pars, startSize, pageSize)
|
|
|
+ userList, err := models.GetUserListByConditonSort(condition, sortCondition, pars, startSize, pageSize)
|
|
|
if err != nil {
|
|
|
br.Msg = "查询用户失败"
|
|
|
br.Msg = "查询用户失败,系统错误,Err:" + err.Error()
|