fix(config): integrate SyncNodeIds and SyncOverwrite into Config struct

This commit is contained in:
Jacky 2025-04-12 01:51:28 +00:00
parent 3502227510
commit b84c444c55
No known key found for this signature in database
GPG key ID: 215C21B10DF38B4D
3 changed files with 13 additions and 17 deletions

View file

@ -15,12 +15,6 @@ import (
"github.com/uozi-tech/cosy" "github.com/uozi-tech/cosy"
) )
type APIConfigResp struct {
config.Config
SyncNodeIds []uint64 `json:"sync_node_ids" gorm:"serializer:json"`
SyncOverwrite bool `json:"sync_overwrite"`
}
func GetConfig(c *gin.Context) { func GetConfig(c *gin.Context) {
relativePath := c.Param("path") relativePath := c.Param("path")
@ -74,15 +68,13 @@ func GetConfig(c *gin.Context) {
return return
} }
c.JSON(http.StatusOK, APIConfigResp{ c.JSON(http.StatusOK, config.Config{
Config: config.Config{
Name: stat.Name(), Name: stat.Name(),
Content: string(content), Content: string(content),
ChatGPTMessages: chatgpt.Content, ChatGPTMessages: chatgpt.Content,
FilePath: absPath, FilePath: absPath,
ModifiedAt: stat.ModTime(), ModifiedAt: stat.ModTime(),
Dir: filepath.Dir(relativePath), Dir: filepath.Dir(relativePath),
},
SyncNodeIds: cfg.SyncNodeIds, SyncNodeIds: cfg.SyncNodeIds,
SyncOverwrite: cfg.SyncOverwrite, SyncOverwrite: cfg.SyncOverwrite,
}) })

View file

@ -101,5 +101,7 @@ func EditConfig(c *gin.Context) {
FilePath: absPath, FilePath: absPath,
ModifiedAt: time.Now(), ModifiedAt: time.Now(),
Dir: filepath.Dir(relativePath), Dir: filepath.Dir(relativePath),
SyncNodeIds: cfg.SyncNodeIds,
SyncOverwrite: cfg.SyncOverwrite,
}) })
} }

View file

@ -28,4 +28,6 @@ type Config struct {
Status ConfigStatus `json:"status"` Status ConfigStatus `json:"status"`
Dir string `json:"dir"` Dir string `json:"dir"`
Urls []string `json:"urls,omitempty"` Urls []string `json:"urls,omitempty"`
SyncNodeIds []uint64 `json:"sync_node_ids,omitempty"`
SyncOverwrite bool `json:"sync_overwrite"`
} }