|
|
@@ -126,13 +126,25 @@ type User struct {
|
|
|
|
|
|
func UserList(c *gin.Context) {
|
|
|
form := request.Check(c, &struct {
|
|
|
- Offset int `form:"offset" json:"offset" binding:""`
|
|
|
- Limit int `form:"limit" json:"limit" binding:"required"`
|
|
|
+ Gid string `form:"gid" json:"gid" binding:"required"`
|
|
|
+ Pf string `form:"pf" json:"pf" binding:"required"`
|
|
|
+ Offset int `form:"offset" json:"offset" binding:""`
|
|
|
+ Limit int `form:"limit" json:"limit" binding:"required"`
|
|
|
}{})
|
|
|
|
|
|
//读取表
|
|
|
userTotalKey := config.Get("app.user_total")
|
|
|
- data, err := global.App.Redis.ZRevRangeWithScores(context.Background(), userTotalKey, int64(form.Offset), int64(form.Offset+form.Limit)).Result()
|
|
|
+ if form.Gid != "" && form.Pf != "" {
|
|
|
+ userTotalKey = config.Get("app.user_total") + ":" + form.Gid + ":" + form.Pf
|
|
|
+ }
|
|
|
+
|
|
|
+ data, err := global.App.Redis.ZRevRangeWithScores(context.Background(), userTotalKey, int64(form.Offset), int64(form.Offset+form.Limit)-1).Result()
|
|
|
+ if err != nil {
|
|
|
+ response.Fail(c, 1001, err.Error())
|
|
|
+ return
|
|
|
+ }
|
|
|
+
|
|
|
+ count, err := global.App.Redis.ZCard(context.Background(), userTotalKey).Result()
|
|
|
if err != nil {
|
|
|
response.Fail(c, 1001, err.Error())
|
|
|
return
|
|
|
@@ -188,6 +200,7 @@ func UserList(c *gin.Context) {
|
|
|
}
|
|
|
|
|
|
response.Success(c, gin.H{
|
|
|
- "data": res,
|
|
|
+ "data": res,
|
|
|
+ "count": count,
|
|
|
})
|
|
|
}
|