完成xray启动

This commit is contained in:
sprov
2021-05-27 23:04:39 +08:00
parent 56ed8f355c
commit 3cd25ce5ea
42 changed files with 3627 additions and 229 deletions

40
web/service/inbound.go Normal file
View File

@@ -0,0 +1,40 @@
package service
import (
"gorm.io/gorm"
"x-ui/database"
"x-ui/database/model"
)
type InboundService struct {
}
func (s *InboundService) GetInbounds(userId int) ([]*model.Inbound, error) {
db := database.GetDB()
var inbounds []*model.Inbound
err := db.Model(model.Inbound{}).Where("user_id = ?", userId).Find(&inbounds).Error
if err != nil && err != gorm.ErrRecordNotFound {
return nil, err
}
return inbounds, nil
}
func (s *InboundService) GetAllInbounds() ([]*model.Inbound, error) {
db := database.GetDB()
var inbounds []*model.Inbound
err := db.Model(model.Inbound{}).Find(&inbounds).Error
if err != nil && err != gorm.ErrRecordNotFound {
return nil, err
}
return inbounds, nil
}
func (s *InboundService) AddInbound(inbound *model.Inbound) error {
db := database.GetDB()
return db.Save(inbound).Error
}
func (s *InboundService) DelInbound(id int) error {
db := database.GetDB()
return db.Delete(model.Inbound{}, id).Error
}