完善dockerfile构建镜像
This commit is contained in:
@ -1,7 +1,7 @@
|
||||
package model
|
||||
|
||||
import (
|
||||
"next-terminal/pkg/config"
|
||||
"next-terminal/pkg/global"
|
||||
"next-terminal/pkg/utils"
|
||||
)
|
||||
|
||||
@ -27,12 +27,12 @@ func (r *Asset) TableName() string {
|
||||
}
|
||||
|
||||
func FindAllAsset() (o []Asset, err error) {
|
||||
err = config.DB.Find(&o).Error
|
||||
err = global.DB.Find(&o).Error
|
||||
return
|
||||
}
|
||||
|
||||
func FindAssetByConditions(protocol string) (o []Asset, err error) {
|
||||
db := config.DB
|
||||
db := global.DB
|
||||
|
||||
if len(protocol) > 0 {
|
||||
db = db.Where("protocol = ?", protocol)
|
||||
@ -42,7 +42,7 @@ func FindAssetByConditions(protocol string) (o []Asset, err error) {
|
||||
}
|
||||
|
||||
func FindPageAsset(pageIndex, pageSize int, name, protocol string) (o []Asset, total int64, err error) {
|
||||
db := config.DB
|
||||
db := global.DB
|
||||
if len(name) > 0 {
|
||||
db = db.Where("name like ?", "%"+name+"%")
|
||||
}
|
||||
@ -60,27 +60,27 @@ func FindPageAsset(pageIndex, pageSize int, name, protocol string) (o []Asset, t
|
||||
}
|
||||
|
||||
func CreateNewAsset(o *Asset) (err error) {
|
||||
if err = config.DB.Create(o).Error; err != nil {
|
||||
if err = global.DB.Create(o).Error; err != nil {
|
||||
return err
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
func FindAssetById(id string) (o Asset, err error) {
|
||||
err = config.DB.Where("id = ?", id).First(&o).Error
|
||||
err = global.DB.Where("id = ?", id).First(&o).Error
|
||||
return
|
||||
}
|
||||
|
||||
func UpdateAssetById(o *Asset, id string) {
|
||||
o.ID = id
|
||||
config.DB.Updates(o)
|
||||
global.DB.Updates(o)
|
||||
}
|
||||
|
||||
func DeleteAssetById(id string) {
|
||||
config.DB.Where("id = ?", id).Delete(&Asset{})
|
||||
global.DB.Where("id = ?", id).Delete(&Asset{})
|
||||
}
|
||||
|
||||
func CountAsset() (total int64, err error) {
|
||||
err = config.DB.Find(&Asset{}).Count(&total).Error
|
||||
err = global.DB.Find(&Asset{}).Count(&total).Error
|
||||
return
|
||||
}
|
||||
|
@ -1,7 +1,7 @@
|
||||
package model
|
||||
|
||||
import (
|
||||
"next-terminal/pkg/config"
|
||||
"next-terminal/pkg/global"
|
||||
"next-terminal/pkg/utils"
|
||||
)
|
||||
|
||||
@ -18,7 +18,7 @@ func (r *Command) TableName() string {
|
||||
|
||||
func FindPageCommand(pageIndex, pageSize int, name, content string) (o []Command, total int64, err error) {
|
||||
|
||||
db := config.DB
|
||||
db := global.DB
|
||||
if len(name) > 0 {
|
||||
db = db.Where("name like ?", "%"+name+"%")
|
||||
}
|
||||
@ -35,22 +35,22 @@ func FindPageCommand(pageIndex, pageSize int, name, content string) (o []Command
|
||||
}
|
||||
|
||||
func CreateNewCommand(o *Command) (err error) {
|
||||
if err = config.DB.Create(o).Error; err != nil {
|
||||
if err = global.DB.Create(o).Error; err != nil {
|
||||
return err
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
func FindCommandById(id string) (o Command, err error) {
|
||||
err = config.DB.Where("id = ?", id).First(&o).Error
|
||||
err = global.DB.Where("id = ?", id).First(&o).Error
|
||||
return
|
||||
}
|
||||
|
||||
func UpdateCommandById(o *Command, id string) {
|
||||
o.ID = id
|
||||
config.DB.Updates(o)
|
||||
global.DB.Updates(o)
|
||||
}
|
||||
|
||||
func DeleteCommandById(id string) {
|
||||
config.DB.Where("id = ?", id).Delete(&Command{})
|
||||
global.DB.Where("id = ?", id).Delete(&Command{})
|
||||
}
|
||||
|
@ -1,7 +1,7 @@
|
||||
package model
|
||||
|
||||
import (
|
||||
"next-terminal/pkg/config"
|
||||
"next-terminal/pkg/global"
|
||||
"next-terminal/pkg/utils"
|
||||
)
|
||||
|
||||
@ -18,12 +18,12 @@ func (r *Credential) TableName() string {
|
||||
}
|
||||
|
||||
func FindAllCredential() (o []Credential, err error) {
|
||||
err = config.DB.Find(&o).Error
|
||||
err = global.DB.Find(&o).Error
|
||||
return
|
||||
}
|
||||
|
||||
func FindPageCredential(pageIndex, pageSize int, name string) (o []Credential, total int64, err error) {
|
||||
db := config.DB
|
||||
db := global.DB
|
||||
if len(name) > 0 {
|
||||
db = db.Where("name like ?", "%"+name+"%")
|
||||
}
|
||||
@ -36,7 +36,7 @@ func FindPageCredential(pageIndex, pageSize int, name string) (o []Credential, t
|
||||
}
|
||||
|
||||
func CreateNewCredential(o *Credential) (err error) {
|
||||
if err = config.DB.Create(o).Error; err != nil {
|
||||
if err = global.DB.Create(o).Error; err != nil {
|
||||
return err
|
||||
}
|
||||
return nil
|
||||
@ -44,20 +44,20 @@ func CreateNewCredential(o *Credential) (err error) {
|
||||
|
||||
func FindCredentialById(id string) (o Credential, err error) {
|
||||
|
||||
err = config.DB.Where("id = ?", id).First(&o).Error
|
||||
err = global.DB.Where("id = ?", id).First(&o).Error
|
||||
return
|
||||
}
|
||||
|
||||
func UpdateCredentialById(o *Credential, id string) {
|
||||
o.ID = id
|
||||
config.DB.Updates(o)
|
||||
global.DB.Updates(o)
|
||||
}
|
||||
|
||||
func DeleteCredentialById(id string) {
|
||||
config.DB.Where("id = ?", id).Delete(&Credential{})
|
||||
global.DB.Where("id = ?", id).Delete(&Credential{})
|
||||
}
|
||||
|
||||
func CountCredential() (total int64, err error) {
|
||||
err = config.DB.Find(&Credential{}).Count(&total).Error
|
||||
err = global.DB.Find(&Credential{}).Count(&total).Error
|
||||
return
|
||||
}
|
||||
|
@ -1,7 +1,7 @@
|
||||
package model
|
||||
|
||||
import (
|
||||
"next-terminal/pkg/config"
|
||||
"next-terminal/pkg/global"
|
||||
)
|
||||
|
||||
type Num struct {
|
||||
@ -13,13 +13,13 @@ func (r *Num) TableName() string {
|
||||
}
|
||||
|
||||
func FindAllTemp() (o []Num) {
|
||||
if config.DB.Find(&o).Error != nil {
|
||||
if global.DB.Find(&o).Error != nil {
|
||||
return nil
|
||||
}
|
||||
return
|
||||
}
|
||||
|
||||
func CreateNewTemp(o *Num) (err error) {
|
||||
err = config.DB.Create(o).Error
|
||||
err = global.DB.Create(o).Error
|
||||
return
|
||||
}
|
||||
|
@ -1,7 +1,7 @@
|
||||
package model
|
||||
|
||||
import (
|
||||
"next-terminal/pkg/config"
|
||||
"next-terminal/pkg/global"
|
||||
"next-terminal/pkg/guacd"
|
||||
)
|
||||
|
||||
@ -15,24 +15,24 @@ func (r *Property) TableName() string {
|
||||
}
|
||||
|
||||
func FindAllProperties() (o []Property) {
|
||||
if config.DB.Find(&o).Error != nil {
|
||||
if global.DB.Find(&o).Error != nil {
|
||||
return nil
|
||||
}
|
||||
return
|
||||
}
|
||||
|
||||
func CreateNewProperty(o *Property) (err error) {
|
||||
err = config.DB.Create(o).Error
|
||||
err = global.DB.Create(o).Error
|
||||
return
|
||||
}
|
||||
|
||||
func UpdatePropertyByName(o *Property, name string) {
|
||||
o.Name = name
|
||||
config.DB.Updates(o)
|
||||
global.DB.Updates(o)
|
||||
}
|
||||
|
||||
func FindPropertyByName(name string) (o Property, err error) {
|
||||
err = config.DB.Where("name = ?", name).First(&o).Error
|
||||
err = global.DB.Where("name = ?", name).First(&o).Error
|
||||
return
|
||||
}
|
||||
|
||||
|
@ -1,7 +1,7 @@
|
||||
package model
|
||||
|
||||
import (
|
||||
"next-terminal/pkg/config"
|
||||
"next-terminal/pkg/global"
|
||||
"next-terminal/pkg/utils"
|
||||
"time"
|
||||
)
|
||||
@ -57,7 +57,7 @@ type SessionVo struct {
|
||||
|
||||
func FindPageSession(pageIndex, pageSize int, status, userId, clientIp, assetId, protocol string) (results []SessionVo, total int64, err error) {
|
||||
|
||||
db := config.DB
|
||||
db := global.DB
|
||||
var params []interface{}
|
||||
|
||||
params = append(params, status)
|
||||
@ -103,40 +103,40 @@ func FindPageSession(pageIndex, pageSize int, status, userId, clientIp, assetId,
|
||||
}
|
||||
|
||||
func FindSessionByStatus(status string) (o []Session, err error) {
|
||||
err = config.DB.Where("status = ?", status).Find(&o).Error
|
||||
err = global.DB.Where("status = ?", status).Find(&o).Error
|
||||
return
|
||||
}
|
||||
|
||||
func CreateNewSession(o *Session) (err error) {
|
||||
err = config.DB.Create(o).Error
|
||||
err = global.DB.Create(o).Error
|
||||
return
|
||||
}
|
||||
|
||||
func FindSessionById(id string) (o Session, err error) {
|
||||
err = config.DB.Where("id = ?", id).First(&o).Error
|
||||
err = global.DB.Where("id = ?", id).First(&o).Error
|
||||
return
|
||||
}
|
||||
|
||||
func FindSessionByConnectionId(connectionId string) (o Session, err error) {
|
||||
err = config.DB.Where("connection_id = ?", connectionId).First(&o).Error
|
||||
err = global.DB.Where("connection_id = ?", connectionId).First(&o).Error
|
||||
return
|
||||
}
|
||||
|
||||
func UpdateSessionById(o *Session, id string) {
|
||||
o.ID = id
|
||||
config.DB.Updates(o)
|
||||
global.DB.Updates(o)
|
||||
}
|
||||
|
||||
func DeleteSessionById(id string) {
|
||||
config.DB.Where("id = ?", id).Delete(&Session{})
|
||||
global.DB.Where("id = ?", id).Delete(&Session{})
|
||||
}
|
||||
|
||||
func DeleteSessionByStatus(status string) {
|
||||
config.DB.Where("status = ?", status).Delete(&Session{})
|
||||
global.DB.Where("status = ?", status).Delete(&Session{})
|
||||
}
|
||||
|
||||
func CountOnlineSession() (total int64, err error) {
|
||||
err = config.DB.Where("status = ?", Connected).Find(&Session{}).Count(&total).Error
|
||||
err = global.DB.Where("status = ?", Connected).Find(&Session{}).Count(&total).Error
|
||||
return
|
||||
}
|
||||
|
||||
@ -155,7 +155,7 @@ func CountSessionByDay(day int) (results []D, err error) {
|
||||
|
||||
for i := range protocols {
|
||||
var result []D
|
||||
err = config.DB.Raw(sql, day, protocols[i], day).Scan(&result).Error
|
||||
err = global.DB.Raw(sql, day, protocols[i], day).Scan(&result).Error
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
@ -1,7 +1,7 @@
|
||||
package model
|
||||
|
||||
import (
|
||||
"next-terminal/pkg/config"
|
||||
"next-terminal/pkg/global"
|
||||
"next-terminal/pkg/utils"
|
||||
"reflect"
|
||||
)
|
||||
@ -25,7 +25,7 @@ func (r *User) IsEmpty() bool {
|
||||
}
|
||||
|
||||
func FindAllUser() (o []User) {
|
||||
if config.DB.Find(&o).Error != nil {
|
||||
if global.DB.Find(&o).Error != nil {
|
||||
return nil
|
||||
}
|
||||
return
|
||||
@ -33,7 +33,7 @@ func FindAllUser() (o []User) {
|
||||
|
||||
func FindPageUser(pageIndex, pageSize int, username, nickname string) (o []User, total int64, err error) {
|
||||
|
||||
db := config.DB
|
||||
db := global.DB
|
||||
if len(username) > 0 {
|
||||
db = db.Where("username like ?", "%"+username+"%")
|
||||
}
|
||||
@ -50,30 +50,30 @@ func FindPageUser(pageIndex, pageSize int, username, nickname string) (o []User,
|
||||
}
|
||||
|
||||
func CreateNewUser(o *User) (err error) {
|
||||
err = config.DB.Create(o).Error
|
||||
err = global.DB.Create(o).Error
|
||||
return
|
||||
}
|
||||
|
||||
func FindUserById(id string) (o User, err error) {
|
||||
err = config.DB.Where("id = ?", id).First(&o).Error
|
||||
err = global.DB.Where("id = ?", id).First(&o).Error
|
||||
return
|
||||
}
|
||||
|
||||
func FindUserByUsername(username string) (o User, err error) {
|
||||
err = config.DB.Where("username = ?", username).First(&o).Error
|
||||
err = global.DB.Where("username = ?", username).First(&o).Error
|
||||
return
|
||||
}
|
||||
|
||||
func UpdateUserById(o *User, id string) {
|
||||
o.ID = id
|
||||
config.DB.Updates(o)
|
||||
global.DB.Updates(o)
|
||||
}
|
||||
|
||||
func DeleteUserById(id string) {
|
||||
config.DB.Where("id = ?", id).Delete(&User{})
|
||||
global.DB.Where("id = ?", id).Delete(&User{})
|
||||
}
|
||||
|
||||
func CountUser() (total int64, err error) {
|
||||
err = config.DB.Find(&User{}).Count(&total).Error
|
||||
err = global.DB.Find(&User{}).Count(&total).Error
|
||||
return
|
||||
}
|
||||
|
Reference in New Issue
Block a user