feat: 添加支持文件路径处理函数,增强证书目录路径验证和日志记录功能

This commit is contained in:
ryan
2026-03-13 16:01:52 +08:00
parent 17f88917f4
commit 8c3dd75802
6 changed files with 290 additions and 12 deletions
+20
View File
@@ -29,3 +29,23 @@ func GetLatestApplyLog(nodeID string) (*ApplyLog, error) {
err := DB.Where("node_id = ?", nodeID).Order("id desc").First(log).Error
return log, err
}
func GetLatestApplyLogsByNodeIDs(nodeIDs []string) (map[string]*ApplyLog, error) {
result := make(map[string]*ApplyLog)
if len(nodeIDs) == 0 {
return result, nil
}
var logs []*ApplyLog
subQuery := DB.Model(&ApplyLog{}).
Select("MAX(id) AS id").
Where("node_id IN ?", nodeIDs).
Group("node_id")
if err := DB.Where("id IN (?)", subQuery).Find(&logs).Error; err != nil {
return nil, err
}
for _, log := range logs {
result[log.NodeID] = log
}
return result, nil
}