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

refactor: 移动pureftpd类型定义

This commit is contained in:
耗子
2024-06-14 11:30:30 +08:00
parent 8557259b53
commit 2f56241da1
2 changed files with 11 additions and 9 deletions

View File

@@ -9,16 +9,12 @@ import (
"github.com/TheTNB/panel/app/http/controllers"
"github.com/TheTNB/panel/pkg/tools"
"github.com/TheTNB/panel/types"
)
type PureFtpdController struct {
}
type User struct {
Username string `json:"username"`
Path string `json:"path"`
}
func NewPureFtpdController() *PureFtpdController {
return &PureFtpdController{}
}
@@ -29,19 +25,19 @@ func (r *PureFtpdController) List(ctx http.Context) http.Response {
if err != nil {
return controllers.Success(ctx, http.Json{
"total": 0,
"items": []User{},
"items": []types.PureFtpdUser{},
})
}
listArr := strings.Split(listRaw, "\n")
var users []User
var users []types.PureFtpdUser
for _, v := range listArr {
if len(v) == 0 {
continue
}
match := regexp.MustCompile(`(\S+)\s+(\S+)`).FindStringSubmatch(v)
users = append(users, User{
users = append(users, types.PureFtpdUser{
Username: match[1],
Path: strings.Replace(match[2], "/./", "/", 1),
})
@@ -54,7 +50,7 @@ func (r *PureFtpdController) List(ctx http.Context) http.Response {
if startIndex > len(users) {
return controllers.Success(ctx, http.Json{
"total": 0,
"items": []User{},
"items": []types.PureFtpdUser{},
})
}
if endIndex > len(users) {

6
types/pureftpd.go Normal file
View File

@@ -0,0 +1,6 @@
package types
type PureFtpdUser struct {
Username string `json:"username"`
Path string `json:"path"`
}