148 lines
3.3 KiB
Go
148 lines
3.3 KiB
Go
package controller
|
|
|
|
import (
|
|
"backend/model"
|
|
"backend/store"
|
|
"backend/util"
|
|
"fmt"
|
|
|
|
"github.com/gin-gonic/gin"
|
|
)
|
|
|
|
func UserInfo(c *gin.Context) {
|
|
Token := util.GetToken(c)
|
|
Info, _ := store.GetTokenInfo(Token)
|
|
homePath := "/dashboard"
|
|
if Info.Role == "wb_transfer" {
|
|
homePath = "/language"
|
|
}
|
|
c.JSON(200, gin.H{
|
|
"code": 0,
|
|
"data": map[string]interface{}{
|
|
"id": 0,
|
|
"realName": Info.UserName,
|
|
"roles": []string{Info.Role},
|
|
"username": Info.UserName,
|
|
"homePath": homePath,
|
|
},
|
|
"message": "Hello, world!",
|
|
})
|
|
}
|
|
|
|
// 获取玩家列表
|
|
func UserList(c *gin.Context) {
|
|
var request struct {
|
|
Id int `json:"Id"`
|
|
Uid int `json:"Uid"`
|
|
ServerId int `json:"ServerId"`
|
|
PageSize int `json:"pageSize"`
|
|
CurrentPage int `json:"currentPage"`
|
|
StartTime int `json:"StartTime"`
|
|
EndTime int `json:"EndTime"`
|
|
Nickname string `json:"Nickname"`
|
|
Username string `json:"Username"`
|
|
DeviceId string `json:"DeviceId"`
|
|
}
|
|
err := c.BindJSON(&request)
|
|
if err != nil {
|
|
fmt.Print(err)
|
|
failed(c, err.Error())
|
|
return
|
|
}
|
|
user, total, err := model.GetUserList(request.Id, request.ServerId, request.PageSize, request.CurrentPage, request.Uid, request.StartTime, request.EndTime, request.Nickname, request.Username, request.DeviceId)
|
|
if err != nil {
|
|
fmt.Print(err)
|
|
failed(c, err.Error())
|
|
return
|
|
}
|
|
|
|
success(c, map[string]interface{}{
|
|
"total": total,
|
|
"data": user,
|
|
})
|
|
}
|
|
|
|
func UserDetail(c *gin.Context) {
|
|
var request struct {
|
|
Uid int `json:"Id"`
|
|
Node int `json:"Node"`
|
|
AppId int `json:"AppId"`
|
|
}
|
|
err := c.BindJSON(&request)
|
|
if err != nil {
|
|
fmt.Print(err)
|
|
failed(c, err.Error())
|
|
return
|
|
}
|
|
user, err := model.UserDetail2(request.AppId, request.Uid, request.Node)
|
|
if err != nil {
|
|
fmt.Print(err)
|
|
failed(c, err.Error())
|
|
return
|
|
}
|
|
for _, v := range user.Order {
|
|
for _, chessInfo := range v.Chess {
|
|
chess_url := util.GetChessURL(util.String(chessInfo.GetId()))
|
|
chessInfo.Icon = chess_url
|
|
}
|
|
v.ChessId = v.Chess
|
|
}
|
|
for _, v := range user.FriendList {
|
|
face_url := util.GetFaceURL(util.Int(v.Avatar))
|
|
v.AvatarUrl = face_url
|
|
v.OnlineStatus = util.Int(v.LoginTime) > util.Int(v.LogoutTime)
|
|
}
|
|
success(c, user)
|
|
}
|
|
|
|
func UserGM(c *gin.Context) {
|
|
var request struct {
|
|
AppId int `json:"AppId"`
|
|
ServerId int `json:"ServerId"`
|
|
Uid int `json:"Uid"`
|
|
Command string `json:"Command"`
|
|
}
|
|
err := c.BindJSON(&request)
|
|
if err != nil {
|
|
fmt.Print(err)
|
|
failed(c, err.Error())
|
|
return
|
|
}
|
|
if request.Command == "" || request.AppId == 0 || request.AppId == 3 {
|
|
failed(c, "参数错误")
|
|
}
|
|
r, err := model.UserGM(request.AppId, request.ServerId, request.Uid, request.Command)
|
|
if err != nil {
|
|
fmt.Print(err)
|
|
failed(c, err.Error())
|
|
return
|
|
}
|
|
|
|
success(c, r)
|
|
}
|
|
|
|
func UserBan(c *gin.Context) {
|
|
var request struct {
|
|
AppId int `json:"AppId"`
|
|
ServerId int `json:"ServerId"`
|
|
Uid int `json:"Uid"`
|
|
Day int `json:"Day"`
|
|
Reason string `json:"Reason"`
|
|
}
|
|
err := c.BindJSON(&request)
|
|
if err != nil {
|
|
fmt.Print(err)
|
|
failed(c, err.Error())
|
|
return
|
|
}
|
|
|
|
r, err := model.UserBan(request.AppId, request.ServerId, request.Uid, request.Day, request.Reason)
|
|
if err != nil {
|
|
fmt.Print(err)
|
|
failed(c, err.Error())
|
|
return
|
|
}
|
|
|
|
success(c, r)
|
|
}
|