修复: 1.管理员编辑代理云端数据权限switch无效(后端缺少CanViewCloudData字段) 2.代理卡密status显示disabledbanned 3.代理用户管理只显示代理/子代理卡密充值过的用户
This commit is contained in:
@@ -42,7 +42,8 @@ type AgentTreeNode struct {
|
||||
CreatedAt string `json:"created_at"`
|
||||
LastLoginAt string `json:"last_login_at"`
|
||||
Balance float64 `json:"balance"`
|
||||
CanCreateAgent bool `json:"can_create_agent"`
|
||||
CanCreateAgent bool `json:"can_create_agent"`
|
||||
CanViewCloudData bool `json:"can_view_cloud_data"`
|
||||
CardsCount int `json:"cards_count"`
|
||||
ChildAgentsCount int `json:"child_agents_count"`
|
||||
Children []AgentTreeNode `json:"children,omitempty"`
|
||||
@@ -80,6 +81,7 @@ func handleGetAgents(c *gin.Context) {
|
||||
Balance float64 `json:"balance"`
|
||||
TotalConsumption float64 `json:"total_consumption"`
|
||||
CanCreateAgent bool `json:"can_create_agent"`
|
||||
CanViewCloudData bool `json:"can_view_cloud_data"`
|
||||
CardsCount int `json:"cards_count"`
|
||||
ChildAgentsCount int `json:"child_agents_count"`
|
||||
}
|
||||
@@ -152,8 +154,9 @@ func handleGetAgents(c *gin.Context) {
|
||||
LastLoginAt: lastLoginAt,
|
||||
Balance: user.Balance,
|
||||
TotalConsumption: user.TotalConsumption,
|
||||
CanCreateAgent: user.CanCreateAgent,
|
||||
CardsCount: cardsCountMap[user.ID],
|
||||
CanCreateAgent: user.CanCreateAgent,
|
||||
CanViewCloudData: user.CanViewCloudData,
|
||||
CardsCount: cardsCountMap[user.ID],
|
||||
ChildAgentsCount: childCountMap[user.ID],
|
||||
})
|
||||
}
|
||||
@@ -229,8 +232,9 @@ func handleGetAgentsTree(c *gin.Context) {
|
||||
CreatedAt: user.CreatedAt.Format("2006-01-02 15:04:05"),
|
||||
LastLoginAt: lastLoginAt,
|
||||
Balance: user.Balance,
|
||||
CanCreateAgent: user.CanCreateAgent,
|
||||
CardsCount: int(cardsCount),
|
||||
CanCreateAgent: user.CanCreateAgent,
|
||||
CanViewCloudData: user.CanViewCloudData,
|
||||
CardsCount: int(cardsCount),
|
||||
ChildAgentsCount: int(childAgentsCount),
|
||||
}
|
||||
|
||||
@@ -256,12 +260,13 @@ func handleGetAgentsTree(c *gin.Context) {
|
||||
|
||||
func handleCreateAgent(c *gin.Context) {
|
||||
var req struct {
|
||||
Username string `json:"username" binding:"required"`
|
||||
Email string `json:"email"`
|
||||
Password string `json:"password" binding:"required"`
|
||||
ParentAgentID *uint `json:"parent_agent_id"`
|
||||
CanCreateAgent bool `json:"can_create_agent"`
|
||||
Balance float64 `json:"balance"`
|
||||
Username string `json:"username" binding:"required"`
|
||||
Email string `json:"email"`
|
||||
Password string `json:"password" binding:"required"`
|
||||
ParentAgentID *uint `json:"parent_agent_id"`
|
||||
CanCreateAgent bool `json:"can_create_agent"`
|
||||
CanViewCloudData bool `json:"can_view_cloud_data"`
|
||||
Balance float64 `json:"balance"`
|
||||
}
|
||||
if err := c.ShouldBindJSON(&req); err != nil {
|
||||
response.Error(c, 400, "参数错误")
|
||||
@@ -296,13 +301,14 @@ func handleCreateAgent(c *gin.Context) {
|
||||
}
|
||||
|
||||
user := model.User{
|
||||
Username: req.Username,
|
||||
Password: string(hashedPassword),
|
||||
Role: "agent",
|
||||
Status: "active",
|
||||
ParentAgentID: req.ParentAgentID,
|
||||
CanCreateAgent: req.CanCreateAgent,
|
||||
Balance: req.Balance,
|
||||
Username: req.Username,
|
||||
Password: string(hashedPassword),
|
||||
Role: "agent",
|
||||
Status: "active",
|
||||
ParentAgentID: req.ParentAgentID,
|
||||
CanCreateAgent: req.CanCreateAgent,
|
||||
CanViewCloudData: req.CanViewCloudData,
|
||||
Balance: req.Balance,
|
||||
}
|
||||
|
||||
if req.Email != "" {
|
||||
@@ -406,7 +412,8 @@ func handleGetAgentDetail(c *gin.Context) {
|
||||
"role": user.Role,
|
||||
"parent_agent_id": user.ParentAgentID,
|
||||
"parent_agent_name": parentAgentName,
|
||||
"can_create_agent": user.CanCreateAgent,
|
||||
"can_create_agent": user.CanCreateAgent,
|
||||
"can_view_cloud_data": user.CanViewCloudData,
|
||||
"balance": user.Balance,
|
||||
"created_at": user.CreatedAt.Format("2006-01-02 15:04:05"),
|
||||
"last_login_at": lastLoginAt,
|
||||
@@ -426,11 +433,12 @@ func handleUpdateAgent(c *gin.Context) {
|
||||
}
|
||||
|
||||
var req struct {
|
||||
ParentAgentID *uint `json:"parent_agent_id"`
|
||||
Email *string `json:"email"`
|
||||
Password *string `json:"password"`
|
||||
CanCreateAgent *bool `json:"can_create_agent"`
|
||||
Balance *float64 `json:"balance"`
|
||||
ParentAgentID *uint `json:"parent_agent_id"`
|
||||
Email *string `json:"email"`
|
||||
Password *string `json:"password"`
|
||||
CanCreateAgent *bool `json:"can_create_agent"`
|
||||
CanViewCloudData *bool `json:"can_view_cloud_data"`
|
||||
Balance *float64 `json:"balance"`
|
||||
}
|
||||
if err := c.ShouldBindJSON(&req); err != nil {
|
||||
response.Error(c, 400, "参数错误")
|
||||
@@ -464,6 +472,9 @@ func handleUpdateAgent(c *gin.Context) {
|
||||
if req.CanCreateAgent != nil {
|
||||
user.CanCreateAgent = *req.CanCreateAgent
|
||||
}
|
||||
if req.CanViewCloudData != nil {
|
||||
user.CanViewCloudData = *req.CanViewCloudData
|
||||
}
|
||||
if req.Balance != nil {
|
||||
user.Balance = *req.Balance
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user