数据结构优化
This commit is contained in:
@@ -9,11 +9,26 @@ import (
|
||||
"github.com/niangaodev/art-code/utils"
|
||||
)
|
||||
|
||||
// GetSettings 获取设置
|
||||
// GetSettings 获取公开的网站设置(前端使用)
|
||||
func GetSettings(c *gin.Context) {
|
||||
// 目前没有公开的设置接口,保留作为扩展
|
||||
// 如果需要公开设置,可以类似处理
|
||||
utils.Success(c, gin.H{})
|
||||
// 获取所有设置
|
||||
settingsMap, err := repositories.GetAllSettings()
|
||||
if err != nil {
|
||||
utils.ServerError(c, err)
|
||||
return
|
||||
}
|
||||
|
||||
// 只返回前端需要的公开配置项
|
||||
publicSettings := make(map[string]string)
|
||||
publicKeys := []string{"site_title", "site_description", "site_author", "site_keywords"}
|
||||
|
||||
for _, key := range publicKeys {
|
||||
if value, exists := settingsMap[key]; exists {
|
||||
publicSettings[key] = value
|
||||
}
|
||||
}
|
||||
|
||||
utils.Success(c, publicSettings)
|
||||
}
|
||||
|
||||
// AdminGetSettings 获取所有设置
|
||||
|
||||
Reference in New Issue
Block a user