mirror of
https://github.com/acepanel/panel.git
synced 2026-02-04 11:27:17 +08:00
fix: lint
This commit is contained in:
@@ -140,7 +140,7 @@ func (s *Service) Load(w http.ResponseWriter, r *http.Request) {
|
||||
func (s *Service) ErrorLog(w http.ResponseWriter, r *http.Request) {
|
||||
log, err := shell.Execf("tail -n 100 %s/server/mysql/mysql-error.log", app.Root)
|
||||
if err != nil {
|
||||
service.Error(w, http.StatusInternalServerError, log)
|
||||
service.Error(w, http.StatusInternalServerError, "%v", err)
|
||||
return
|
||||
}
|
||||
|
||||
@@ -161,7 +161,7 @@ func (s *Service) ClearErrorLog(w http.ResponseWriter, r *http.Request) {
|
||||
func (s *Service) SlowLog(w http.ResponseWriter, r *http.Request) {
|
||||
log, err := shell.Execf("tail -n 100 %s/server/mysql/mysql-slow.log", app.Root)
|
||||
if err != nil {
|
||||
service.Error(w, http.StatusInternalServerError, log)
|
||||
service.Error(w, http.StatusInternalServerError, "%v", err)
|
||||
return
|
||||
}
|
||||
|
||||
@@ -216,7 +216,7 @@ func (s *Service) SetRootPassword(w http.ResponseWriter, r *http.Request) {
|
||||
}
|
||||
}
|
||||
if err = s.settingRepo.Set(biz.SettingKeyMySQLRootPassword, req.Password); err != nil {
|
||||
service.Error(w, http.StatusInternalServerError, fmt.Sprintf("设置保存失败:%v", err))
|
||||
service.Error(w, http.StatusInternalServerError, "设置保存失败:%v", err)
|
||||
return
|
||||
}
|
||||
|
||||
|
||||
@@ -184,6 +184,12 @@ func Cli() []*cli.Command {
|
||||
Usage: "设置管理",
|
||||
Hidden: true,
|
||||
Commands: []*cli.Command{
|
||||
{
|
||||
Name: "get",
|
||||
Usage: "获取面板设置(仅限指导下使用)",
|
||||
Hidden: true,
|
||||
Action: cliService.GetSetting,
|
||||
},
|
||||
{
|
||||
Name: "write",
|
||||
Usage: "写入面板设置(仅限指导下使用)",
|
||||
|
||||
@@ -456,6 +456,25 @@ func (s *CliService) ClearTask(ctx context.Context, cmd *cli.Command) error {
|
||||
return nil
|
||||
}
|
||||
|
||||
func (s *CliService) GetSetting(ctx context.Context, cmd *cli.Command) error {
|
||||
key := cmd.Args().First()
|
||||
if key == "" {
|
||||
return fmt.Errorf("参数不能为空")
|
||||
}
|
||||
|
||||
setting := new(biz.Setting)
|
||||
if err := app.Orm.Where("key", key).First(setting).Error; err != nil {
|
||||
if errors.Is(err, gorm.ErrRecordNotFound) {
|
||||
return fmt.Errorf("设置不存在")
|
||||
}
|
||||
return fmt.Errorf("获取设置失败:%v", err)
|
||||
}
|
||||
|
||||
fmt.Print(setting.Value)
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
func (s *CliService) WriteSetting(ctx context.Context, cmd *cli.Command) error {
|
||||
key := cmd.Args().Get(0)
|
||||
value := cmd.Args().Get(1)
|
||||
|
||||
Reference in New Issue
Block a user