Skip to content

Commit

Permalink
refactor: packages to pkg
Browse files Browse the repository at this point in the history
  • Loading branch information
devhaozi committed Jul 19, 2023
1 parent ec7138a commit 5ce6565
Show file tree
Hide file tree
Showing 33 changed files with 260 additions and 260 deletions.
4 changes: 2 additions & 2 deletions .github/workflows/issue-auto-reply.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ jobs:
steps:
- name: ✏️ Feature
if: github.event.label.name == '✏️ Feature'
uses: actions-cool/issues-helper@v3
uses: actions-cool/issues-tools@v3
with:
actions: 'create-comment'
token: ${{ secrets.GITHUB_TOKEN }}
Expand All @@ -30,7 +30,7 @@ jobs:
"Talk is cheap, Show me the Code." - Linus Torvalds
- name: ☢️ Bug
if: github.event.label.name == '☢️ Bug'
uses: actions-cool/issues-helper@v3
uses: actions-cool/issues-tools@v3
with:
actions: 'create-comment'
token: ${{ secrets.GITHUB_TOKEN }}
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/issue-close-question.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ jobs:
runs-on: ubuntu-latest
steps:
- name: needs more info
uses: actions-cool/issues-helper@v3
uses: actions-cool/issues-tools@v3
with:
actions: 'close-issues'
labels: 'question'
Expand Down
4 changes: 2 additions & 2 deletions app/console/commands/monitoring.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ import (
"github.com/goravel/framework/support/carbon"

"panel/app/models"
"panel/packages/helper"
"panel/pkg/tools"
)

type Monitoring struct {
Expand Down Expand Up @@ -43,7 +43,7 @@ func (receiver *Monitoring) Handle(ctx console.Context) error {
return nil
}

info := helper.GetMonitoringInfo()
info := tools.GetMonitoringInfo()

err := facades.Orm().Query().Create(&models.Monitor{
Info: info,
Expand Down
14 changes: 7 additions & 7 deletions app/console/commands/panel.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ import (

"panel/app/models"
"panel/app/services"
"panel/packages/helper"
"panel/pkg/tools"
)

type Panel struct {
Expand Down Expand Up @@ -57,7 +57,7 @@ func (receiver *Panel) Handle(ctx console.Context) error {
return nil
}

hash, err := facades.Hash().Make(helper.RandomString(32))
hash, err := facades.Hash().Make(tools.RandomString(32))
if err != nil {
color.Redln("初始化失败")
return nil
Expand All @@ -73,7 +73,7 @@ func (receiver *Panel) Handle(ctx console.Context) error {
color.Greenln("初始化成功")

case "update":
err := helper.UpdatePanel()
err := tools.UpdatePanel()
if err != nil {
color.Redln("更新失败: " + err.Error())
return nil
Expand All @@ -89,14 +89,14 @@ func (receiver *Panel) Handle(ctx console.Context) error {
return nil
}

password := helper.RandomString(16)
password := tools.RandomString(16)
hash, err := facades.Hash().Make(password)
if err != nil {
color.Redln("生成密码失败")
return nil
}

user.Username = helper.RandomString(8)
user.Username = tools.RandomString(8)
user.Password = hash

err = facades.Orm().Query().Save(&user)
Expand All @@ -105,15 +105,15 @@ func (receiver *Panel) Handle(ctx console.Context) error {
return nil
}

port := helper.ExecShell("cat /www/panel/panel.conf | grep APP_PORT | awk -F '=' '{print $2}'")
port := tools.ExecShell("cat /www/panel/panel.conf | grep APP_PORT | awk -F '=' '{print $2}'")

color.Greenln("用户名: " + user.Username)
color.Greenln("密码: " + password)
color.Greenln("面板端口: " + port)
color.Greenln("面板入口: " + services.NewSettingImpl().Get(models.SettingKeyPanelEntrance, "/"))

case "getPort":
port := helper.ExecShell("cat /www/panel/panel.conf | grep APP_PORT | awk -F '=' '{print $2}'")
port := tools.ExecShell("cat /www/panel/panel.conf | grep APP_PORT | awk -F '=' '{print $2}'")
color.Greenln("面板端口: " + port)

case "getEntrance":
Expand Down
20 changes: 10 additions & 10 deletions app/http/controllers/cron_controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import (

"panel/app/models"
"panel/app/services"
"panel/packages/helper"
"panel/pkg/tools"
)

type CronController struct {
Expand Down Expand Up @@ -59,23 +59,23 @@ func (r *CronController) Add(ctx http.Context) {
// 写入shell
shellDir := "/www/server/cron/"
shellLogDir := "/www/server/cron/logs/"
if !helper.Exists(shellDir) {
if !tools.Exists(shellDir) {
facades.Log().Error("[面板][CronController] 计划任务目录不存在")
Error(ctx, http.StatusInternalServerError, "计划任务目录不存在")
return
}
if !helper.Exists(shellLogDir) {
if !tools.Exists(shellLogDir) {
facades.Log().Error("[面板][CronController] 计划任务日志目录不存在")
Error(ctx, http.StatusInternalServerError, "计划任务日志目录不存在")
return
}
shellFile := strconv.Itoa(int(carbon.Now().Timestamp())) + helper.RandomString(16)
if !helper.WriteFile(shellDir+shellFile+".sh", ctx.Request().Input("script"), 0644) {
shellFile := strconv.Itoa(int(carbon.Now().Timestamp())) + tools.RandomString(16)
if !tools.WriteFile(shellDir+shellFile+".sh", ctx.Request().Input("script"), 0644) {
facades.Log().Error("[面板][CronController] 创建计划任务脚本失败 ", err)
Error(ctx, http.StatusInternalServerError, "系统内部错误")
return
}
helper.ExecShell("dos2unix " + shellDir + shellFile + ".sh")
tools.ExecShell("dos2unix " + shellDir + shellFile + ".sh")

var cron models.Cron
cron.Name = ctx.Request().Input("name")
Expand Down Expand Up @@ -122,12 +122,12 @@ func (r *CronController) Update(ctx http.Context) {
return
}

if !helper.WriteFile(cron.Shell, ctx.Request().Input("script"), 0644) {
if !tools.WriteFile(cron.Shell, ctx.Request().Input("script"), 0644) {
facades.Log().Error("[面板][CronController] 更新计划任务脚本失败 ", err)
Error(ctx, http.StatusInternalServerError, "系统内部错误")
return
}
helper.ExecShell("dos2unix " + cron.Shell)
tools.ExecShell("dos2unix " + cron.Shell)

r.cron.DeleteFromSystem(cron)
if cron.Status {
Expand Down Expand Up @@ -226,12 +226,12 @@ func (r *CronController) Log(ctx http.Context) {
return
}

if !helper.Exists(cron.Log) {
if !tools.Exists(cron.Log) {
Error(ctx, http.StatusBadRequest, "日志文件不存在")
return
}

Success(ctx, http.Json{
"log": helper.ReadFile(cron.Log),
"log": tools.ReadFile(cron.Log),
})
}
6 changes: 3 additions & 3 deletions app/http/controllers/info_controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import (

"panel/app/models"
"panel/app/services"
"panel/packages/helper"
"panel/pkg/tools"
)

type MenuItem struct {
Expand Down Expand Up @@ -81,11 +81,11 @@ func (r *InfoController) HomePlugins(ctx http.Context) {
}

func (r *InfoController) NowMonitor(ctx http.Context) {
Success(ctx, helper.GetMonitoringInfo())
Success(ctx, tools.GetMonitoringInfo())
}

func (r *InfoController) SystemInfo(ctx http.Context) {
monitorInfo := helper.GetMonitoringInfo()
monitorInfo := tools.GetMonitoringInfo()

Success(ctx, http.Json{
"os_name": monitorInfo.Host.Platform + " " + monitorInfo.Host.PlatformVersion,
Expand Down
Loading

0 comments on commit 5ce6565

Please sign in to comment.