package service import ( "encoding/json" "time" "github.com/1Panel-dev/1Panel/app/dto" "github.com/1Panel-dev/1Panel/constant" ) type SettingService struct{} type ISettingService interface { GetSettingInfo() (*dto.SettingInfo, error) Update(key, value string) error } func NewISettingService() ISettingService { return &SettingService{} } func (u *SettingService) GetSettingInfo() (*dto.SettingInfo, error) { setting, err := settingRepo.Get() if err != nil { return nil, constant.ErrRecordNotFound } settingMap := make(map[string]string) for _, set := range setting { settingMap[set.Key] = set.Value } var info dto.SettingInfo arr, err := json.Marshal(settingMap) if err != nil { return nil, err } if err := json.Unmarshal(arr, &info); err != nil { return nil, err } info.LocalTime = time.Now().Format("2006.01.02 15:04:05") return &info, err } func (u *SettingService) Update(key, value string) error { return settingRepo.Update(key, value) }