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"
)
type APIConfigResp struct {
config.Config
SyncNodeIds []uint64 `json:"sync_node_ids" gorm:"serializer:json"`
SyncOverwrite bool `json:"sync_overwrite"`
}
func GetConfig(c *gin.Context) {
relativePath := c.Param("path")
@ -74,16 +68,14 @@ func GetConfig(c *gin.Context) {
return
}
c.JSON(http.StatusOK, APIConfigResp{
Config: config.Config{
Name: stat.Name(),
Content: string(content),
ChatGPTMessages: chatgpt.Content,
FilePath: absPath,
ModifiedAt: stat.ModTime(),
Dir: filepath.Dir(relativePath),
},
SyncNodeIds: cfg.SyncNodeIds,
SyncOverwrite: cfg.SyncOverwrite,
c.JSON(http.StatusOK, config.Config{
Name: stat.Name(),
Content: string(content),
ChatGPTMessages: chatgpt.Content,
FilePath: absPath,
ModifiedAt: stat.ModTime(),
Dir: filepath.Dir(relativePath),
SyncNodeIds: cfg.SyncNodeIds,
SyncOverwrite: cfg.SyncOverwrite,
})
}

View file

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

View file

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