style(be):拆分模块目录

This commit is contained in:
teaser
2021-03-20 21:42:32 +08:00
committed by dushixiang
parent 86e8e25aac
commit c31b3c8359
36 changed files with 68 additions and 48 deletions

View File

@ -4,9 +4,9 @@ import (
"strings"
"time"
"next-terminal/server/global"
"next-terminal/pkg/global"
"next-terminal/pkg/totp"
"next-terminal/server/model"
"next-terminal/server/totp"
"next-terminal/server/utils"
"github.com/labstack/echo/v4"
@ -40,6 +40,11 @@ type Authorization struct {
User model.User
}
//
//type UserServer struct {
// repository.UserRepository
//}
func LoginEndpoint(c echo.Context) error {
var loginAccount LoginAccount
if err := c.Bind(&loginAccount); err != nil {

View File

@ -1,8 +1,8 @@
package api
import (
"next-terminal/server/constant"
"next-terminal/server/global"
"next-terminal/pkg/constant"
"next-terminal/pkg/global"
"next-terminal/server/model"
"github.com/labstack/echo/v4"

View File

@ -8,7 +8,7 @@ import (
"strconv"
"strings"
"next-terminal/server/constant"
"next-terminal/pkg/constant"
"next-terminal/server/model"
"next-terminal/server/utils"

View File

@ -5,7 +5,7 @@ import (
"strconv"
"strings"
"next-terminal/server/constant"
"next-terminal/pkg/constant"
"next-terminal/server/model"
"next-terminal/server/utils"

View File

@ -4,8 +4,8 @@ import (
"strconv"
"strings"
"next-terminal/pkg/global"
"next-terminal/pkg/log"
"next-terminal/server/global"
"github.com/labstack/echo/v4"
)

View File

@ -7,8 +7,8 @@ import (
"strings"
"time"
"next-terminal/server/constant"
"next-terminal/server/global"
"next-terminal/pkg/constant"
"next-terminal/pkg/global"
"next-terminal/server/utils"
"github.com/labstack/echo/v4"

View File

@ -4,13 +4,14 @@ import (
"github.com/labstack/echo/v4"
)
//
// todo 监控
func MonitorEndpoint(c echo.Context) (err error) {
//ws, err := UpGrader.Upgrade(c.Response().Writer, c.Request(), nil)
//if err != nil {
// log.Errorf("升级为WebSocket协议失败%v", err.Error())
// return err
//}
return
}

View File

@ -1,7 +1,7 @@
package api
import (
"next-terminal/server/constant"
"next-terminal/pkg/constant"
"next-terminal/server/repository"
"github.com/labstack/echo/v4"

View File

@ -7,11 +7,11 @@ import (
"strings"
"time"
"next-terminal/pkg/global"
"next-terminal/pkg/log"
"next-terminal/server/global"
"next-terminal/pkg/service"
"next-terminal/server/model"
"next-terminal/server/repository"
"next-terminal/server/service"
"next-terminal/server/utils"
"github.com/labstack/echo/v4"

View File

@ -4,7 +4,7 @@ import (
"strconv"
"strings"
"next-terminal/server/global"
"next-terminal/pkg/global"
"next-terminal/server/model"
"next-terminal/server/utils"

View File

@ -13,9 +13,9 @@ import (
"strings"
"sync"
"next-terminal/pkg/constant"
"next-terminal/pkg/global"
"next-terminal/pkg/log"
"next-terminal/server/constant"
"next-terminal/server/global"
"next-terminal/server/model"
"next-terminal/server/utils"

View File

@ -7,12 +7,12 @@ import (
"strconv"
"time"
"next-terminal/pkg/constant"
"next-terminal/pkg/global"
"next-terminal/pkg/guacd"
"next-terminal/pkg/log"
"next-terminal/server/constant"
"next-terminal/server/global"
"next-terminal/pkg/term"
"next-terminal/server/model"
"next-terminal/server/term"
"next-terminal/server/utils"
"github.com/gorilla/websocket"

View File

@ -1,63 +0,0 @@
package api
import (
"strconv"
"time"
"next-terminal/pkg/log"
"next-terminal/server/constant"
)
func SetupTicker() {
// 每隔一小时删除一次未使用的会话信息
unUsedSessionTicker := time.NewTicker(time.Minute * 60)
go func() {
for range unUsedSessionTicker.C {
sessions, _ := sessionRepository.FindByStatusIn([]string{constant.NoConnect, constant.Connecting})
if len(sessions) > 0 {
now := time.Now()
for i := range sessions {
if now.Sub(sessions[i].ConnectedTime.Time) > time.Hour*1 {
_ = sessionRepository.DeleteById(sessions[i].ID)
s := sessions[i].Username + "@" + sessions[i].IP + ":" + strconv.Itoa(sessions[i].Port)
log.Infof("会话「%v」ID「%v」超过1小时未打开已删除。", s, sessions[i].ID)
}
}
}
}
}()
// 每日凌晨删除超过时长限制的会话
timeoutSessionTicker := time.NewTicker(time.Hour * 24)
go func() {
for range timeoutSessionTicker.C {
property, err := propertyRepository.FindByName("session-saved-limit")
if err != nil {
return
}
if property.Value == "" || property.Value == "-" {
return
}
limit, err := strconv.Atoi(property.Value)
if err != nil {
return
}
sessions, err := sessionRepository.FindOutTimeSessions(limit)
if err != nil {
return
}
if len(sessions) > 0 {
var sessionIds []string
for i := range sessions {
sessionIds = append(sessionIds, sessions[i].ID)
}
err := sessionRepository.DeleteByIds(sessionIds)
if err != nil {
log.Errorf("删除离线会话失败 %v", err)
}
}
}
}()
}

View File

@ -5,10 +5,10 @@ import (
"path"
"strconv"
"next-terminal/pkg/constant"
"next-terminal/pkg/global"
"next-terminal/pkg/guacd"
"next-terminal/pkg/log"
"next-terminal/server/constant"
"next-terminal/server/global"
"next-terminal/server/model"
"github.com/gorilla/websocket"

View File

@ -4,8 +4,8 @@ import (
"strconv"
"strings"
"next-terminal/pkg/global"
"next-terminal/pkg/log"
"next-terminal/server/global"
"next-terminal/server/model"
"next-terminal/server/utils"