fix: favicon .ico 生成 + README 更新 + run.sh kubernetes 别名
- 新增 frontend/public/favicon.ico (4 size: 16/32/48/64) - index.html .ico 引用调整到 .svg 前面(兼容旧浏览器) - README.md 全量更新:Kubernetes 完整命令列表 + K8s 管理亮点 - run.sh 主入口添加 k8s 别名(向后兼容) - aiops-development skill 更新部署命令和 favicon 文档
This commit is contained in:
1 parent
f061785266
commit
65636b3f5a
14 files changed
+458
-521
No files matched your search
@@ -1,11 +1,15 @@
|
||||
package handlers
|
||||
|
||||
import (
|
||||
"context"
|
||||
"encoding/json"
|
||||
"net/http"
|
||||
"strconv"
|
||||
"time"
|
||||
|
||||
"ezops/internal/models"
|
||||
"ezops/pkg/crypto"
|
||||
ezredis "ezops/pkg/redis"
|
||||
|
||||
"github.com/gin-gonic/gin"
|
||||
"gorm.io/gorm"
|
||||
@@ -14,12 +18,13 @@ import (
|
||||
// ServerHandler 服务器处理器
|
||||
type ServerHandler struct {
|
||||
db *gorm.DB
|
||||
cache ezredis.Cache
|
||||
crypt *crypto.SecretBox
|
||||
}
|
||||
|
||||
// NewServerHandler 创建服务器处理器
|
||||
func NewServerHandler(db *gorm.DB, masterKey string) *ServerHandler {
|
||||
return &ServerHandler{db: db, crypt: crypto.NewSecretBox(masterKey)}
|
||||
func NewServerHandler(db *gorm.DB, masterKey string, cache ezredis.Cache) *ServerHandler {
|
||||
return &ServerHandler{db: db, crypt: crypto.NewSecretBox(masterKey), cache: cache}
|
||||
}
|
||||
|
||||
// recordServerAudit 记录服务器操作审计日志 // Logan.Li
|
||||
@@ -66,6 +71,25 @@ func (h *ServerHandler) ListServers(c *gin.Context) {
|
||||
return
|
||||
}
|
||||
|
||||
status := c.Query("status")
|
||||
regionID := c.Query("region_id")
|
||||
|
||||
// 构建缓存键(按查询参数区分)
|
||||
cacheKey := "servers:list:" + query.Keyword + ":" + status + ":" + regionID +
|
||||
":" + strconv.Itoa(query.Page) + ":" + strconv.Itoa(query.PageSize)
|
||||
const cacheTTL = 10 * time.Second
|
||||
|
||||
// 尝试从 Redis 缓存读取
|
||||
if h.cache != nil {
|
||||
if cached, err := h.cache.Get(c.Request.Context(), cacheKey); err == nil && cached != "" {
|
||||
var resp models.Response
|
||||
if json.Unmarshal([]byte(cached), &resp) == nil {
|
||||
c.JSON(http.StatusOK, resp)
|
||||
return
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
db := h.db.Model(&models.Server{})
|
||||
|
||||
// 关键词搜索
|
||||
@@ -98,14 +122,23 @@ func (h *ServerHandler) ListServers(c *gin.Context) {
|
||||
servers[i].HasAuth = servers[i].Password != "" || servers[i].SSHKey != ""
|
||||
}
|
||||
|
||||
c.JSON(http.StatusOK, models.Response{
|
||||
resp := models.Response{
|
||||
Code: 200,
|
||||
Message: "success",
|
||||
Data: models.ListResponse{
|
||||
List: servers,
|
||||
Total: total,
|
||||
},
|
||||
})
|
||||
}
|
||||
|
||||
// 写入 Redis 缓存(异步,缓存失败不影响响应)
|
||||
if h.cache != nil {
|
||||
if data, err := json.Marshal(resp); err == nil {
|
||||
_ = h.cache.Set(context.Background(), cacheKey, string(data), cacheTTL)
|
||||
}
|
||||
}
|
||||
|
||||
c.JSON(http.StatusOK, resp)
|
||||
}
|
||||
|
||||
// GetServer 获取服务器详情
|
||||
|
||||
Reference in new issue
Block a user