refactor: replace standard log with zap logger and optimize code patterns

- Migrate all log.Printf/log.Println calls to structured zap logging
- Use cmp.Or for cleaner default value handling
- Replace manual loops with slices.ContainsFunc/IndexFunc
- Add batch query methods (IsLikedBatch, IsFavoritedBatch) to solve N+1 problem
- Update JSON tags from omitempty to omitzero for numeric fields
- Use errgroup-style wg.Go for worker goroutines
- Remove duplicate casbin/v2 dependency (keeping v3)
- Add plans/ to gitignore
This commit is contained in:
lafay
2026-03-17 00:47:17 +08:00
parent b028f7e1d3
commit 5d6c982c9c
38 changed files with 2256 additions and 290 deletions

View File

@@ -5,9 +5,10 @@ import (
"encoding/json"
"fmt"
"io"
"log"
"net/http"
"time"
"go.uber.org/zap"
)
// EmbeddingConfig embedding服务配置
@@ -94,7 +95,7 @@ func GetEmbedding(text string) ([]float64, error) {
// InitEmbeddingWithConfig 从应用配置初始化embedding
func InitEmbeddingWithConfig(apiKey, url, model string) {
if apiKey == "" {
log.Println("[WARN] Gorse embedding API key not set, using default")
zap.L().Warn("Gorse embedding API key not set, using default")
}
defaultEmbeddingConfig.APIKey = apiKey
if url != "" {
@@ -103,4 +104,4 @@ func InitEmbeddingWithConfig(apiKey, url, model string) {
if model != "" {
defaultEmbeddingConfig.Model = model
}
}
}