diff --git a/backend/service/client.go b/backend/service/client.go index cccf260..b782836 100644 --- a/backend/service/client.go +++ b/backend/service/client.go @@ -251,7 +251,7 @@ func (s *ClientService) UpdateClientsOnInboundDelete(tx *gorm.DB, id uint, tag s func (s *ClientService) UpdateLinksByInboundChange(tx *gorm.DB, inbounIds []uint, hostname string) error { var inbounds []model.Inbound err := tx.Model(model.Inbound{}).Preload("Tls").Where("id in ? and type in ?", inbounIds, util.InboundTypeWithLink).Find(&inbounds).Error - if err != nil && err != gorm.ErrRecordNotFound { + if err != nil && database.IsNotFound(err) { return err } for _, inbound := range inbounds { diff --git a/backend/service/inbounds.go b/backend/service/inbounds.go index 7b4aeea..1ff63a0 100644 --- a/backend/service/inbounds.go +++ b/backend/service/inbounds.go @@ -96,7 +96,7 @@ func (s *InboundService) FromIds(ids []uint) ([]*model.Inbound, error) { return inbounds, nil } -func (s *InboundService) Save(tx *gorm.DB, act string, data json.RawMessage, initUsers string, hostname string) (uint, error) { +func (s *InboundService) Save(tx *gorm.DB, act string, data json.RawMessage, initUserIds string, hostname string) (uint, error) { var err error var id uint @@ -146,7 +146,7 @@ func (s *InboundService) Save(tx *gorm.DB, act string, data json.RawMessage, ini if act == "edit" { inboundConfig, err = s.addUsers(tx, inboundConfig, inbound.Id, inbound.Type) } else { - inboundConfig, err = s.initUsers(tx, inboundConfig, initUsers, inbound.Id, inbound.Type) + inboundConfig, err = s.initUsers(tx, inboundConfig, initUserIds, inbound.Type) } if err != nil { return 0, err @@ -270,7 +270,7 @@ func (s *InboundService) addUsers(db *gorm.DB, inboundJson []byte, inboundId uin return json.Marshal(inbound) } -func (s *InboundService) initUsers(db *gorm.DB, inboundJson []byte, clientIds string, inboundId uint, inboundType string) ([]byte, error) { +func (s *InboundService) initUsers(db *gorm.DB, inboundJson []byte, clientIds string, inboundType string) ([]byte, error) { ClientIds := strings.Split(clientIds, ",") if len(ClientIds) == 0 { return inboundJson, nil diff --git a/backend/service/user.go b/backend/service/user.go index 6e2920d..3a476f2 100644 --- a/backend/service/user.go +++ b/backend/service/user.go @@ -6,8 +6,6 @@ import ( "s-ui/logger" "s-ui/util/common" "time" - - "gorm.io/gorm" ) type UserService struct { @@ -63,7 +61,7 @@ func (s *UserService) CheckUser(username string, password string, remoteIP strin Where("username = ? and password = ?", username, password). First(user). Error - if err == gorm.ErrRecordNotFound { + if database.IsNotFound(err) { return nil } else if err != nil { logger.Warning("check user err:", err, " IP: ", remoteIP)