|
@@ -3,9 +3,9 @@ package v1
|
|
|
import (
|
|
|
"context"
|
|
|
"designs/app/common/request"
|
|
|
- "designs/common"
|
|
|
"designs/config"
|
|
|
"designs/global"
|
|
|
+ "designs/response"
|
|
|
"github.com/gin-gonic/gin"
|
|
|
"github.com/go-redis/redis/v8"
|
|
|
"strconv"
|
|
@@ -33,7 +33,7 @@ func AddUserToBlackList(c *gin.Context) {
|
|
|
//存在用户 读取数据
|
|
|
userdata, err := global.App.Redis.HGetAll(context.Background(), userKey).Result()
|
|
|
if err != nil {
|
|
|
- common.RetJson(1003, "用户数据不存在", err.Error(), c)
|
|
|
+ response.Fail(c, 1003, "用户数据不存在"+err.Error())
|
|
|
return
|
|
|
}
|
|
|
curHid := userdata["hid"]
|
|
@@ -69,11 +69,13 @@ func AddUserToBlackList(c *gin.Context) {
|
|
|
blackListKey := config.Get("app.black_list_table")
|
|
|
err = global.App.Redis.ZAdd(context.Background(), blackListKey, &redis.Z{Member: userKey}).Err()
|
|
|
if err != nil {
|
|
|
- common.RetJson(1003, "加入黑名单失败", "参数错误2"+err.Error(), c)
|
|
|
+ response.Fail(c, 1003, "加入黑名单失败"+err.Error())
|
|
|
return
|
|
|
}
|
|
|
|
|
|
- common.RetJson(0, "加入黑名单成功", "", c)
|
|
|
+ response.Success(c, gin.H{
|
|
|
+ "msg": "加入黑名单成功",
|
|
|
+ })
|
|
|
}
|
|
|
|
|
|
// DeleteUserFormBlackList 将玩家从从黑名单中去掉
|
|
@@ -89,7 +91,7 @@ func DeleteUserFormBlackList(c *gin.Context) {
|
|
|
//存在用户 读取数据
|
|
|
_, err := global.App.Redis.HGetAll(context.Background(), userKey).Result()
|
|
|
if err != nil {
|
|
|
- common.RetJson(1003, "用户数据不存在", err.Error(), c)
|
|
|
+ response.Fail(c, 1003, "用户数据不存在"+err.Error())
|
|
|
return
|
|
|
}
|
|
|
|
|
@@ -97,11 +99,12 @@ func DeleteUserFormBlackList(c *gin.Context) {
|
|
|
blackListKey := config.Get("app.black_list_table")
|
|
|
err = global.App.Redis.ZRem(context.Background(), blackListKey, userKey).Err()
|
|
|
if err != nil {
|
|
|
- common.RetJson(1003, "从黑名单中移除失败", "参数错误2", c)
|
|
|
+ response.Fail(c, 1003, "从黑名单中移除失败"+err.Error())
|
|
|
return
|
|
|
}
|
|
|
-
|
|
|
- common.RetJson(0, "从黑名单中移除成功", "", c)
|
|
|
+ response.Success(c, gin.H{
|
|
|
+ "msg": "从黑名单中移除成功",
|
|
|
+ })
|
|
|
}
|
|
|
|
|
|
// ReadBlackList 查看目前黑名单有哪些人
|
|
@@ -110,7 +113,7 @@ func ReadBlackList(c *gin.Context) {
|
|
|
|
|
|
data, err := global.App.Redis.ZRange(context.Background(), blackListKey, 0, -1).Result()
|
|
|
if err != nil {
|
|
|
- common.RetJson(1003, "读取黑名单列表失败", "参数错误2", c)
|
|
|
+ response.Fail(c, 1003, "读取黑名单列表失败"+err.Error())
|
|
|
return
|
|
|
}
|
|
|
|
|
@@ -118,11 +121,13 @@ func ReadBlackList(c *gin.Context) {
|
|
|
for _, value := range data {
|
|
|
user, err := global.App.Redis.HGetAll(context.Background(), value).Result()
|
|
|
if err != nil {
|
|
|
- common.RetJson(1003, "GetUserData err", "", c)
|
|
|
+ response.Fail(c, 1003, "GetUserData err"+err.Error())
|
|
|
return
|
|
|
}
|
|
|
userData = append(userData, user)
|
|
|
}
|
|
|
|
|
|
- common.RetJson(0, "读取黑名单列表成功", userData, c)
|
|
|
+ response.Success(c, gin.H{
|
|
|
+ "msg": "读取黑名单列表成功",
|
|
|
+ })
|
|
|
}
|