2
0
mirror of https://github.com/acepanel/panel.git synced 2026-02-04 09:13:49 +08:00

chore: 统一错误输出

This commit is contained in:
耗子
2023-11-02 02:56:05 +08:00
parent 1fa96e828e
commit 00ec8d693c
14 changed files with 66 additions and 66 deletions

View File

@@ -67,7 +67,7 @@ func Check(ctx http.Context, slug string) http.Response {
installedPlugins, err := services.NewPluginImpl().AllInstalled()
if err != nil {
facades.Log().Error("[面板][插件] 获取已安装插件失败")
return Error(ctx, http.StatusInternalServerError, "系统内部错误")
return ErrorSystem(ctx)
}
if installedPlugin.Version != plugin.Version || installedPlugin.Slug != plugin.Slug {

View File

@@ -35,7 +35,7 @@ func (c *CronController) List(ctx http.Context) http.Response {
err := facades.Orm().Query().Paginate(page, limit, &crons, &total)
if err != nil {
facades.Log().Error("[面板][CronController] 查询计划任务列表失败 ", err)
return Error(ctx, http.StatusInternalServerError, "系统内部错误")
return ErrorSystem(ctx)
}
return Success(ctx, http.Json{
@@ -121,7 +121,7 @@ panel cutoff ${name} ${save} 2>&1
shellFile := strconv.Itoa(int(carbon.Now().Timestamp())) + tools.RandomString(16)
if !tools.Write(shellDir+shellFile+".sh", shell, 0700) {
facades.Log().Error("[面板][CronController] 创建计划任务脚本失败 ", err)
return Error(ctx, http.StatusInternalServerError, "系统内部错误")
return ErrorSystem(ctx)
}
tools.Exec("dos2unix " + shellDir + shellFile + ".sh")
@@ -136,7 +136,7 @@ panel cutoff ${name} ${save} 2>&1
err = facades.Orm().Query().Create(&cron)
if err != nil {
facades.Log().Error("[面板][CronController] 创建计划任务失败 ", err)
return Error(ctx, http.StatusInternalServerError, "系统内部错误")
return ErrorSystem(ctx)
}
c.cron.AddToSystem(cron)
@@ -191,12 +191,12 @@ func (c *CronController) Update(ctx http.Context) http.Response {
err = facades.Orm().Query().Save(&cron)
if err != nil {
facades.Log().Error("[面板][CronController] 更新计划任务失败 ", err)
return Error(ctx, http.StatusInternalServerError, "系统内部错误")
return ErrorSystem(ctx)
}
if !tools.Write(cron.Shell, ctx.Request().Input("script"), 0644) {
facades.Log().Error("[面板][CronController] 更新计划任务脚本失败 ", err)
return Error(ctx, http.StatusInternalServerError, "系统内部错误")
return ErrorSystem(ctx)
}
tools.Exec("dos2unix " + cron.Shell)
@@ -222,7 +222,7 @@ func (c *CronController) Delete(ctx http.Context) http.Response {
_, err = facades.Orm().Query().Delete(&cron)
if err != nil {
facades.Log().Error("[面板][CronController] 删除计划任务失败 ", err)
return Error(ctx, http.StatusInternalServerError, "系统内部错误")
return ErrorSystem(ctx)
}
return Success(ctx, nil)
@@ -250,7 +250,7 @@ func (c *CronController) Status(ctx http.Context) http.Response {
err = facades.Orm().Query().Save(&cron)
if err != nil {
facades.Log().Error("[面板][CronController] 更新计划任务状态失败 ", err)
return Error(ctx, http.StatusInternalServerError, "系统内部错误")
return ErrorSystem(ctx)
}
c.cron.DeleteFromSystem(cron)

View File

@@ -39,7 +39,7 @@ func (c *InfoController) Name(ctx http.Context) http.Response {
err := facades.Orm().Query().Where("key", "name").First(&setting)
if err != nil {
facades.Log().Error("[面板][InfoController] 查询面板名称失败 ", err)
return Error(ctx, http.StatusInternalServerError, "系统内部错误")
return ErrorSystem(ctx)
}
return Success(ctx, http.Json{
@@ -53,7 +53,7 @@ func (c *InfoController) HomePlugins(ctx http.Context) http.Response {
err := facades.Orm().Query().Where("show", 1).Find(&plugins)
if err != nil {
facades.Log().Error("[面板][InfoController] 查询首页插件失败 ", err)
return Error(ctx, http.StatusInternalServerError, "系统内部错误")
return ErrorSystem(ctx)
}
type pluginsData struct {
@@ -199,7 +199,7 @@ func (c *InfoController) InstalledDbAndPhp(ctx http.Context) http.Response {
var php []models.Plugin
err := facades.Orm().Query().Where("slug like ?", "php%").Find(&php)
if err != nil {
return Error(ctx, http.StatusInternalServerError, "系统内部错误")
return ErrorSystem(ctx)
}
var mysql models.Plugin

View File

@@ -27,7 +27,7 @@ func (r *MonitorController) Switch(ctx http.Context) http.Response {
err := r.setting.Set(models.SettingKeyMonitor, cast.ToString(value))
if err != nil {
facades.Log().Error("[面板][MonitorController] 更新监控开关失败 ", err)
return Error(ctx, http.StatusInternalServerError, "系统内部错误")
return ErrorSystem(ctx)
}
return Success(ctx, nil)
@@ -39,7 +39,7 @@ func (r *MonitorController) SaveDays(ctx http.Context) http.Response {
err := r.setting.Set(models.SettingKeyMonitorDays, days)
if err != nil {
facades.Log().Error("[面板][MonitorController] 更新监控天数失败 ", err)
return Error(ctx, http.StatusInternalServerError, "系统内部错误")
return ErrorSystem(ctx)
}
return Success(ctx, nil)
@@ -61,7 +61,7 @@ func (r *MonitorController) Clear(ctx http.Context) http.Response {
_, err := facades.Orm().Query().Where("1 = 1").Delete(&models.Monitor{})
if err != nil {
facades.Log().Error("[面板][MonitorController] 清空监控数据失败 ", err)
return Error(ctx, http.StatusInternalServerError, "系统内部错误")
return ErrorSystem(ctx)
}
return Success(ctx, nil)
@@ -78,7 +78,7 @@ func (r *MonitorController) List(ctx http.Context) http.Response {
err := facades.Orm().Query().Where("created_at >= ?", startTime.ToDateTimeString()).Where("created_at <= ?", endTime.ToDateTimeString()).Get(&monitors)
if err != nil {
facades.Log().Error("[面板][MonitorController] 查询监控数据失败 ", err)
return Error(ctx, http.StatusInternalServerError, "系统内部错误")
return ErrorSystem(ctx)
}
if len(monitors) == 0 {

View File

@@ -27,7 +27,7 @@ func (r *PluginController) List(ctx http.Context) http.Response {
plugins := r.plugin.All()
installedPlugins, err := r.plugin.AllInstalled()
if err != nil {
return Error(ctx, http.StatusInternalServerError, "系统内部错误")
return ErrorSystem(ctx)
}
var lock sync.RWMutex
@@ -101,7 +101,7 @@ func (r *PluginController) Install(ctx http.Context) http.Response {
installedPlugins, err := r.plugin.AllInstalled()
if err != nil {
facades.Log().Error("[面板][PluginController] 获取已安装插件失败")
return Error(ctx, http.StatusInternalServerError, "系统内部错误")
return ErrorSystem(ctx)
}
if installedPlugin.ID != 0 {
@@ -142,7 +142,7 @@ func (r *PluginController) Install(ctx http.Context) http.Response {
task.Log = "/tmp/" + plugin.Slug + ".log"
if err := facades.Orm().Query().Create(&task); err != nil {
facades.Log().Error("[面板][PluginController] 创建任务失败: " + err.Error())
return Error(ctx, http.StatusInternalServerError, "系统内部错误")
return ErrorSystem(ctx)
}
r.task.Process(task.ID)
@@ -157,7 +157,7 @@ func (r *PluginController) Uninstall(ctx http.Context) http.Response {
installedPlugins, err := r.plugin.AllInstalled()
if err != nil {
facades.Log().Error("[面板][PluginController] 获取已安装插件失败")
return Error(ctx, http.StatusInternalServerError, "系统内部错误")
return ErrorSystem(ctx)
}
if installedPlugin.ID == 0 {
@@ -198,7 +198,7 @@ func (r *PluginController) Uninstall(ctx http.Context) http.Response {
task.Log = "/tmp/" + plugin.Slug + ".log"
if err := facades.Orm().Query().Create(&task); err != nil {
facades.Log().Error("[面板][PluginController] 创建任务失败: " + err.Error())
return Error(ctx, http.StatusInternalServerError, "系统内部错误")
return ErrorSystem(ctx)
}
r.task.Process(task.ID)
@@ -213,7 +213,7 @@ func (r *PluginController) Update(ctx http.Context) http.Response {
installedPlugins, err := r.plugin.AllInstalled()
if err != nil {
facades.Log().Error("[面板][PluginController] 获取已安装插件失败")
return Error(ctx, http.StatusInternalServerError, "系统内部错误")
return ErrorSystem(ctx)
}
if installedPlugin.ID == 0 {
@@ -254,7 +254,7 @@ func (r *PluginController) Update(ctx http.Context) http.Response {
task.Log = "/tmp/" + plugin.Slug + ".log"
if err := facades.Orm().Query().Create(&task); err != nil {
facades.Log().Error("[面板][PluginController] 创建任务失败: " + err.Error())
return Error(ctx, http.StatusInternalServerError, "系统内部错误")
return ErrorSystem(ctx)
}
r.task.Process(task.ID)
@@ -269,7 +269,7 @@ func (r *PluginController) UpdateShow(ctx http.Context) http.Response {
var plugin models.Plugin
if err := facades.Orm().Query().Where("slug", slug).First(&plugin); err != nil {
facades.Log().Error("[面板][PluginController] 查询插件失败: " + err.Error())
return Error(ctx, http.StatusInternalServerError, "系统内部错误")
return ErrorSystem(ctx)
}
if plugin.ID == 0 {
return Error(ctx, http.StatusUnprocessableEntity, "插件未安装")
@@ -278,7 +278,7 @@ func (r *PluginController) UpdateShow(ctx http.Context) http.Response {
plugin.Show = show
if err := facades.Orm().Query().Save(&plugin); err != nil {
facades.Log().Error("[面板][PluginController] 更新插件失败: " + err.Error())
return Error(ctx, http.StatusInternalServerError, "系统内部错误")
return ErrorSystem(ctx)
}
return Success(ctx, "操作成功")

View File

@@ -260,7 +260,7 @@ func (r *Php74Controller) InstallExtension(ctx http.Context) http.Response {
task.Log = "/tmp/" + item.Slug + ".log"
if err := facades.Orm().Query().Create(&task); err != nil {
facades.Log().Error("[PHP-" + r.version + "] 创建安装拓展任务失败:" + err.Error())
return controllers.Error(ctx, http.StatusInternalServerError, "系统内部错误")
return controllers.ErrorSystem(ctx)
}
r.task.Process(task.ID)
@@ -297,7 +297,7 @@ func (r *Php74Controller) UninstallExtension(ctx http.Context) http.Response {
task.Log = "/tmp/" + item.Slug + ".log"
if err := facades.Orm().Query().Create(&task); err != nil {
facades.Log().Error("[PHP-" + r.version + "] 创建卸载拓展任务失败:" + err.Error())
return controllers.Error(ctx, http.StatusInternalServerError, "系统内部错误")
return controllers.ErrorSystem(ctx)
}
r.task.Process(task.ID)

View File

@@ -260,7 +260,7 @@ func (r *Php80Controller) InstallExtension(ctx http.Context) http.Response {
task.Log = "/tmp/" + item.Slug + ".log"
if err := facades.Orm().Query().Create(&task); err != nil {
facades.Log().Error("[PHP-" + r.version + "] 创建安装拓展任务失败:" + err.Error())
return controllers.Error(ctx, http.StatusInternalServerError, "系统内部错误")
return controllers.ErrorSystem(ctx)
}
r.task.Process(task.ID)
@@ -297,7 +297,7 @@ func (r *Php80Controller) UninstallExtension(ctx http.Context) http.Response {
task.Log = "/tmp/" + item.Slug + ".log"
if err := facades.Orm().Query().Create(&task); err != nil {
facades.Log().Error("[PHP-" + r.version + "] 创建卸载拓展任务失败:" + err.Error())
return controllers.Error(ctx, http.StatusInternalServerError, "系统内部错误")
return controllers.ErrorSystem(ctx)
}
r.task.Process(task.ID)

View File

@@ -260,7 +260,7 @@ func (r *Php81Controller) InstallExtension(ctx http.Context) http.Response {
task.Log = "/tmp/" + item.Slug + ".log"
if err := facades.Orm().Query().Create(&task); err != nil {
facades.Log().Error("[PHP-" + r.version + "] 创建安装拓展任务失败:" + err.Error())
return controllers.Error(ctx, http.StatusInternalServerError, "系统内部错误")
return controllers.ErrorSystem(ctx)
}
r.task.Process(task.ID)
@@ -297,7 +297,7 @@ func (r *Php81Controller) UninstallExtension(ctx http.Context) http.Response {
task.Log = "/tmp/" + item.Slug + ".log"
if err := facades.Orm().Query().Create(&task); err != nil {
facades.Log().Error("[PHP-" + r.version + "] 创建卸载拓展任务失败:" + err.Error())
return controllers.Error(ctx, http.StatusInternalServerError, "系统内部错误")
return controllers.ErrorSystem(ctx)
}
r.task.Process(task.ID)

View File

@@ -260,7 +260,7 @@ func (r *Php82Controller) InstallExtension(ctx http.Context) http.Response {
task.Log = "/tmp/" + item.Slug + ".log"
if err := facades.Orm().Query().Create(&task); err != nil {
facades.Log().Error("[PHP-" + r.version + "] 创建安装拓展任务失败:" + err.Error())
return controllers.Error(ctx, http.StatusInternalServerError, "系统内部错误")
return controllers.ErrorSystem(ctx)
}
r.task.Process(task.ID)
@@ -297,7 +297,7 @@ func (r *Php82Controller) UninstallExtension(ctx http.Context) http.Response {
task.Log = "/tmp/" + item.Slug + ".log"
if err := facades.Orm().Query().Create(&task); err != nil {
facades.Log().Error("[PHP-" + r.version + "] 创建卸载拓展任务失败:" + err.Error())
return controllers.Error(ctx, http.StatusInternalServerError, "系统内部错误")
return controllers.ErrorSystem(ctx)
}
r.task.Process(task.ID)

View File

@@ -27,7 +27,7 @@ func (r *SettingController) List(ctx http.Context) http.Response {
err := facades.Orm().Query().Get(&settings)
if err != nil {
facades.Log().Error("[面板][SettingController] 查询设置列表失败 ", err)
return Error(ctx, http.StatusInternalServerError, "系统内部错误")
return ErrorSystem(ctx)
}
type data struct {
@@ -51,7 +51,7 @@ func (r *SettingController) List(ctx http.Context) http.Response {
err = facades.Auth().User(ctx, &user)
if err != nil {
facades.Log().Error("[面板][SettingController] 获取用户失败 ", err)
return Error(ctx, http.StatusInternalServerError, "系统内部错误")
return ErrorSystem(ctx)
}
result.Username = user.Username
result.Email = user.Email
@@ -79,7 +79,7 @@ func (r *SettingController) Save(ctx http.Context) http.Response {
err := r.setting.Set(models.SettingKeyName, name)
if err != nil {
facades.Log().Error("[面板][SettingController] 保存设置失败 ", err)
return Error(ctx, http.StatusInternalServerError, "系统内部错误")
return ErrorSystem(ctx)
}
oldPort := tools.Exec(`cat /www/panel/panel.conf | grep APP_PORT | awk -F '=' '{print $2}' | tr -d '\n'`)
if oldPort != port {
@@ -91,7 +91,7 @@ func (r *SettingController) Save(ctx http.Context) http.Response {
err = r.setting.Set(models.SettingKeyBackupPath, backupPath)
if err != nil {
facades.Log().Error("[面板][SettingController] 保存设置失败 ", err)
return Error(ctx, http.StatusInternalServerError, "系统内部错误")
return ErrorSystem(ctx)
}
if !tools.Exists(websitePath) {
tools.Mkdir(websitePath, 0755)
@@ -100,19 +100,19 @@ func (r *SettingController) Save(ctx http.Context) http.Response {
err = r.setting.Set(models.SettingKeyWebsitePath, websitePath)
if err != nil {
facades.Log().Error("[面板][SettingController] 保存设置失败 ", err)
return Error(ctx, http.StatusInternalServerError, "系统内部错误")
return ErrorSystem(ctx)
}
err = r.setting.Set(models.SettingKeyEntrance, entrance)
if err != nil {
facades.Log().Error("[面板][SettingController] 保存设置失败 ", err)
return Error(ctx, http.StatusInternalServerError, "系统内部错误")
return ErrorSystem(ctx)
}
var user models.User
err = facades.Auth().User(ctx, &user)
if err != nil {
facades.Log().Error("[面板][SettingController] 获取用户失败 ", err)
return Error(ctx, http.StatusInternalServerError, "系统内部错误")
return ErrorSystem(ctx)
}
if len(username) > 0 {
@@ -125,14 +125,14 @@ func (r *SettingController) Save(ctx http.Context) http.Response {
hash, err := facades.Hash().Make(password)
if err != nil {
facades.Log().Error("[面板][SettingController] 保存设置失败 ", err)
return Error(ctx, http.StatusInternalServerError, "系统内部错误")
return ErrorSystem(ctx)
}
user.Password = hash
}
if err = facades.Orm().Query().Save(&user); err != nil {
facades.Log().Error("[面板][SettingController] 保存设置失败 ", err)
return Error(ctx, http.StatusInternalServerError, "系统内部错误")
return ErrorSystem(ctx)
}
return Success(ctx, nil)

View File

@@ -69,22 +69,22 @@ func (r *SshController) UpdateInfo(ctx http.Context) http.Response {
err = r.setting.Set(models.SettingKeySshHost, host)
if err != nil {
facades.Log().Error("[面板][SSH] 更新配置失败 ", err)
return Error(ctx, http.StatusInternalServerError, "系统内部错误")
return ErrorSystem(ctx)
}
err = r.setting.Set(models.SettingKeySshPort, port)
if err != nil {
facades.Log().Error("[面板][SSH] 更新配置失败 ", err)
return Error(ctx, http.StatusInternalServerError, "系统内部错误")
return ErrorSystem(ctx)
}
err = r.setting.Set(models.SettingKeySshUser, user)
if err != nil {
facades.Log().Error("[面板][SSH] 更新配置失败 ", err)
return Error(ctx, http.StatusInternalServerError, "系统内部错误")
return ErrorSystem(ctx)
}
err = r.setting.Set(models.SettingKeySshPassword, password)
if err != nil {
facades.Log().Error("[面板][SSH] 更新配置失败 ", err)
return Error(ctx, http.StatusInternalServerError, "系统内部错误")
return ErrorSystem(ctx)
}
return Success(ctx, nil)
@@ -104,7 +104,7 @@ func (r *SshController) Session(ctx http.Context) http.Response {
ws, err := upGrader.Upgrade(ctx.Response().Writer(), ctx.Request().Origin(), nil)
if err != nil {
facades.Log().Error("[面板][SSH] 建立连接失败 ", err)
return Error(ctx, http.StatusInternalServerError, "系统内部错误")
return ErrorSystem(ctx)
}
defer ws.Close()
@@ -117,7 +117,7 @@ func (r *SshController) Session(ctx http.Context) http.Response {
if err != nil {
_ = ws.WriteControl(websocket.CloseMessage,
[]byte(err.Error()), time.Now().Add(time.Second))
return Error(ctx, http.StatusInternalServerError, "系统内部错误")
return ErrorSystem(ctx)
}
defer client.Close()
@@ -125,7 +125,7 @@ func (r *SshController) Session(ctx http.Context) http.Response {
if err != nil {
_ = ws.WriteControl(websocket.CloseMessage,
[]byte(err.Error()), time.Now().Add(time.Second))
return Error(ctx, http.StatusInternalServerError, "系统内部错误")
return ErrorSystem(ctx)
}
defer turn.Close()

View File

@@ -41,7 +41,7 @@ func (r *TaskController) List(ctx http.Context) http.Response {
facades.Log().With(map[string]any{
"error": err.Error(),
}).Error("[面板][TaskController] 查询任务列表失败")
return Error(ctx, http.StatusInternalServerError, "系统内部错误")
return ErrorSystem(ctx)
}
return Success(ctx, http.Json{
@@ -59,7 +59,7 @@ func (r *TaskController) Log(ctx http.Context) http.Response {
"id": ctx.Request().QueryInt("id"),
"error": err.Error(),
}).Error("[面板][TaskController] 查询任务失败")
return Error(ctx, http.StatusInternalServerError, "系统内部错误")
return ErrorSystem(ctx)
}
log := tools.Exec("tail -n 1000 " + task.Log)
@@ -76,7 +76,7 @@ func (r *TaskController) Delete(ctx http.Context) http.Response {
"id": ctx.Request().QueryInt("id"),
"error": err.Error(),
}).Error("[面板][TaskController] 删除任务失败")
return Error(ctx, http.StatusInternalServerError, "系统内部错误")
return ErrorSystem(ctx)
}
return Success(ctx, nil)

View File

@@ -80,7 +80,7 @@ func (r *UserController) Info(ctx http.Context) http.Response {
facades.Log().With(map[string]any{
"error": err.Error(),
}).Error("[面板][UserController] 查询用户信息失败")
return Error(ctx, http.StatusInternalServerError, "系统内部错误")
return ErrorSystem(ctx)
}
return Success(ctx, http.Json{

View File

@@ -36,7 +36,7 @@ func (c *WebsiteController) List(ctx http.Context) http.Response {
total, websites, err := c.website.List(page, limit)
if err != nil {
facades.Log().Error("[面板][WebsiteController] 获取网站列表失败 ", err)
return Error(ctx, http.StatusInternalServerError, "系统内部错误")
return ErrorSystem(ctx)
}
return Success(ctx, http.Json{
@@ -83,7 +83,7 @@ func (c *WebsiteController) Add(ctx http.Context) http.Response {
newSite, err := c.website.Add(website)
if err != nil {
facades.Log().Error("[面板][WebsiteController] 添加网站失败 ", err)
return Error(ctx, http.StatusInternalServerError, "系统内部错误")
return ErrorSystem(ctx)
}
return Success(ctx, newSite)
@@ -131,12 +131,12 @@ func (c *WebsiteController) SaveDefaultConfig(ctx http.Context) http.Response {
if !tools.Write("/www/server/openresty/html/index.html", index, 0644) {
facades.Log().Error("[面板][WebsiteController] 保存默认配置失败")
return Error(ctx, http.StatusInternalServerError, "系统内部错误")
return ErrorSystem(ctx)
}
if !tools.Write("/www/server/openresty/html/stop.html", stop, 0644) {
facades.Log().Error("[面板][WebsiteController] 保存默认配置失败")
return Error(ctx, http.StatusInternalServerError, "系统内部错误")
return ErrorSystem(ctx)
}
return Success(ctx, nil)
@@ -156,7 +156,7 @@ func (c *WebsiteController) GetConfig(ctx http.Context) http.Response {
config, err := c.website.GetConfig(id)
if err != nil {
facades.Log().Error("[面板][WebsiteController] 获取网站配置失败 ", err)
return Error(ctx, http.StatusInternalServerError, "系统内部错误")
return ErrorSystem(ctx)
}
return Success(ctx, config)
@@ -378,7 +378,7 @@ func (c *WebsiteController) SaveConfig(ctx http.Context) http.Response {
err = facades.Orm().Query().Save(&website)
if err != nil {
facades.Log().Error("[面板][WebsiteController] 保存网站配置失败 ", err)
return Error(ctx, http.StatusInternalServerError, "系统内部错误")
return ErrorSystem(ctx)
}
tools.Write("/www/server/vhost/"+website.Name+".conf", raw, 0644)
@@ -403,7 +403,7 @@ func (c *WebsiteController) ClearLog(ctx http.Context) http.Response {
err := facades.Orm().Query().Where("id", id).Get(&website)
if err != nil {
facades.Log().Error("[面板][WebsiteController] 获取网站信息失败 ", err)
return Error(ctx, http.StatusInternalServerError, "系统内部错误")
return ErrorSystem(ctx)
}
tools.Remove("/www/wwwlogs/" + website.Name + ".log")
@@ -422,14 +422,14 @@ func (c *WebsiteController) UpdateRemark(ctx http.Context) http.Response {
err := facades.Orm().Query().Where("id", id).Get(&website)
if err != nil {
facades.Log().Error("[面板][WebsiteController] 获取网站信息失败 ", err)
return Error(ctx, http.StatusInternalServerError, "系统内部错误")
return ErrorSystem(ctx)
}
website.Remark = ctx.Request().Input("remark")
err = facades.Orm().Query().Save(&website)
if err != nil {
facades.Log().Error("[面板][WebsiteController] 保存网站备注失败 ", err)
return Error(ctx, http.StatusInternalServerError, "系统内部错误")
return ErrorSystem(ctx)
}
return Success(ctx, nil)
@@ -440,7 +440,7 @@ func (c *WebsiteController) BackupList(ctx http.Context) http.Response {
backupList, err := c.backup.WebsiteList()
if err != nil {
facades.Log().Error("[面板][WebsiteController] 获取网站备份列表失败 ", err)
return Error(ctx, http.StatusInternalServerError, "系统内部错误")
return ErrorSystem(ctx)
}
return Success(ctx, backupList)
@@ -550,14 +550,14 @@ func (c *WebsiteController) ResetConfig(ctx http.Context) http.Response {
website := models.Website{}
if err := facades.Orm().Query().Where("id", id).Get(&website); err != nil {
facades.Log().Error("[面板][WebsiteController] 获取网站信息失败 ", err)
return Error(ctx, http.StatusInternalServerError, "系统内部错误")
return ErrorSystem(ctx)
}
website.Status = true
website.Ssl = false
if err := facades.Orm().Query().Save(&website); err != nil {
facades.Log().Error("[面板][WebsiteController] 保存网站配置失败 ", err)
return Error(ctx, http.StatusInternalServerError, "系统内部错误")
return ErrorSystem(ctx)
}
raw := fmt.Sprintf(`
@@ -640,13 +640,13 @@ func (c *WebsiteController) Status(ctx http.Context) http.Response {
website := models.Website{}
if err := facades.Orm().Query().Where("id", id).Get(&website); err != nil {
facades.Log().Error("[面板][WebsiteController] 获取网站信息失败 ", err)
return Error(ctx, http.StatusInternalServerError, "系统内部错误")
return ErrorSystem(ctx)
}
website.Status = ctx.Request().InputBool("status")
if err := facades.Orm().Query().Save(&website); err != nil {
facades.Log().Error("[面板][WebsiteController] 保存网站配置失败 ", err)
return Error(ctx, http.StatusInternalServerError, "系统内部错误")
return ErrorSystem(ctx)
}
raw := tools.Read("/www/server/vhost/" + website.Name + ".conf")