API功能性修复
This commit is contained in:
@@ -250,10 +250,11 @@ func AdminPlanSort(c *gin.Context) {
|
||||
|
||||
|
||||
func AdminOrdersFetch(c *gin.Context) {
|
||||
page := parsePositiveInt(c.DefaultQuery("page", "1"), 1)
|
||||
perPage := parsePositiveInt(c.DefaultQuery("per_page", "50"), 50)
|
||||
keyword := strings.TrimSpace(c.Query("keyword"))
|
||||
statusFilter := strings.TrimSpace(c.Query("status"))
|
||||
params := getFetchParams(c)
|
||||
page := parsePositiveInt(params["page"], 1)
|
||||
perPage := parsePositiveInt(params["per_page"], 50)
|
||||
keyword := strings.TrimSpace(params["keyword"])
|
||||
statusFilter := strings.TrimSpace(params["status"])
|
||||
|
||||
query := database.DB.Model(&model.Order{}).Preload("Plan").Preload("Payment").Order("id DESC")
|
||||
if keyword != "" {
|
||||
@@ -552,13 +553,20 @@ func AdminUserUpdate(c *gin.Context) {
|
||||
Fail(c, http.StatusInternalServerError, "failed to update user")
|
||||
return
|
||||
}
|
||||
|
||||
// Sync password to children (IPv6 sub-users) if changed
|
||||
if pwd, ok := values["password"].(string); ok && pwd != "" {
|
||||
database.DB.Model(&model.User{}).Where("parent_id = ?", id).Update("password", pwd)
|
||||
}
|
||||
|
||||
Success(c, true)
|
||||
}
|
||||
|
||||
func AdminUsersFetch(c *gin.Context) {
|
||||
page := parsePositiveInt(c.DefaultQuery("page", "1"), 1)
|
||||
perPage := parsePositiveInt(c.DefaultQuery("per_page", "50"), 50)
|
||||
keyword := strings.TrimSpace(c.Query("keyword"))
|
||||
params := getFetchParams(c)
|
||||
page := parsePositiveInt(params["page"], 1)
|
||||
perPage := parsePositiveInt(params["per_page"], 50)
|
||||
keyword := strings.TrimSpace(params["keyword"])
|
||||
|
||||
query := database.DB.Model(&model.User{}).Preload("Plan").Order("id DESC")
|
||||
if keyword != "" {
|
||||
@@ -577,9 +585,20 @@ func AdminUsersFetch(c *gin.Context) {
|
||||
return
|
||||
}
|
||||
|
||||
userIDs := make([]int, 0, len(users))
|
||||
for _, user := range users {
|
||||
userIDs = append(userIDs, user.ID)
|
||||
}
|
||||
deviceMap := service.GetUsersDevices(userIDs)
|
||||
|
||||
groupNames := loadServerGroupNameMap()
|
||||
items := make([]gin.H, 0, len(users))
|
||||
for _, user := range users {
|
||||
onlineIP := ""
|
||||
if ips, ok := deviceMap[user.ID]; ok && len(ips) > 0 {
|
||||
onlineIP = strings.Join(ips, ", ")
|
||||
}
|
||||
|
||||
items = append(items, gin.H{
|
||||
"id": user.ID,
|
||||
"email": user.Email,
|
||||
@@ -598,7 +617,8 @@ func AdminUsersFetch(c *gin.Context) {
|
||||
"online_count": intValue(user.OnlineCount),
|
||||
"expired_at": int64Value(user.ExpiredAt),
|
||||
"last_login_at": int64Value(user.LastLoginAt),
|
||||
"last_online_at": unixTimeValue(user.LastOnlineAt),
|
||||
"last_login_ip": user.LastLoginIP,
|
||||
"online_ip": onlineIP,
|
||||
"created_at": user.CreatedAt,
|
||||
"updated_at": user.UpdatedAt,
|
||||
"remarks": stringValue(user.Remarks),
|
||||
@@ -623,14 +643,15 @@ func AdminUsersFetch(c *gin.Context) {
|
||||
}
|
||||
|
||||
func AdminTicketsFetch(c *gin.Context) {
|
||||
if ticketID := strings.TrimSpace(c.Query("id")); ticketID != "" {
|
||||
params := getFetchParams(c)
|
||||
if ticketID := strings.TrimSpace(params["id"]); ticketID != "" {
|
||||
adminTicketDetail(c, ticketID)
|
||||
return
|
||||
}
|
||||
|
||||
page := parsePositiveInt(c.DefaultQuery("page", "1"), 1)
|
||||
perPage := parsePositiveInt(c.DefaultQuery("per_page", "50"), 50)
|
||||
keyword := strings.TrimSpace(c.Query("keyword"))
|
||||
page := parsePositiveInt(params["page"], 1)
|
||||
perPage := parsePositiveInt(params["per_page"], 50)
|
||||
keyword := strings.TrimSpace(params["keyword"])
|
||||
|
||||
query := database.DB.Model(&model.Ticket{}).Order("updated_at DESC, id DESC")
|
||||
if keyword != "" {
|
||||
|
||||
Reference in New Issue
Block a user