- 新增 ClientInstance 模型,记录客户端 IP 与配置项的关联 - 配置拉取接口(fetchAll/fetchChanged)自动记录客户端信息 - 配置列表页面展示每个配置的在线客户端数量 - 点击可查看具体 IP 地址、拉取方式、最后拉取时间 - 超过 5 分钟未拉取的记录自动清理 - 注释掉 /api/ping 接口
30 lines
689 B
Go
30 lines
689 B
Go
package handler
|
|
|
|
import (
|
|
"kenaito-conf/server/internal/dao"
|
|
"kenaito-conf/server/internal/model"
|
|
"net/http"
|
|
"strconv"
|
|
|
|
"github.com/gin-gonic/gin"
|
|
)
|
|
|
|
type ClientHandler struct{}
|
|
|
|
func NewClientHandler() *ClientHandler {
|
|
return &ClientHandler{}
|
|
}
|
|
|
|
func (h *ClientHandler) ListByConfigId(c *gin.Context) {
|
|
configId, _ := strconv.Atoi(c.Query("configId"))
|
|
if configId == 0 {
|
|
c.JSON(http.StatusBadRequest, model.WrapperResponse{Code: 400, Msg: "参数错误"})
|
|
return
|
|
}
|
|
|
|
var instances []model.ClientInstance
|
|
dao.Engine.Where("app_config_id = ?", configId).OrderBy("last_fetch_at DESC").Find(&instances)
|
|
|
|
c.JSON(http.StatusOK, model.WrapperResponse{Code: 0, Data: instances})
|
|
}
|