diff options
| author | MHSanaei <mc.sanaei@gmail.com> | 2023-02-20 20:29:55 +0300 |
|---|---|---|
| committer | MHSanaei <mc.sanaei@gmail.com> | 2023-02-20 20:29:55 +0300 |
| commit | add853fadaebeed99d2eadcf6ec2fa9396bf6ccd (patch) | |
| tree | d55598f4ef7d0b812ff9a721a72aad7b2a298ded /web/service | |
| parent | d4c8b926d3a35e8b632ddd290599d3b344e13fc3 (diff) | |
update pack 3
user pass will be generated randomly
upgrade all dependencies
move add client buttom
Diffstat (limited to 'web/service')
| -rw-r--r-- | web/service/inbound.go | 20 | ||||
| -rw-r--r-- | web/service/user.go | 3 |
2 files changed, 11 insertions, 12 deletions
diff --git a/web/service/inbound.go b/web/service/inbound.go index dedf76a0..5c1cfedc 100644 --- a/web/service/inbound.go +++ b/web/service/inbound.go @@ -238,9 +238,9 @@ func (s *InboundService) AddTraffic(traffics []*xray.Traffic) (err error) { for _, traffic := range traffics { if traffic.IsInbound { err = tx.Where("tag = ?", traffic.Tag). - UpdateColumn("up", gorm.Expr("up + ?", traffic.Up)). - UpdateColumn("down", gorm.Expr("down + ?", traffic.Down)). - Error + UpdateColumns(map[string]interface{}{ + "up": gorm.Expr("up + ?", traffic.Up), + "down": gorm.Expr("down + ?", traffic.Down)}).Error if err != nil { return } @@ -298,11 +298,12 @@ func (s *InboundService) AddClientTraffic(traffics []*xray.ClientTraffic) (err e } } if tx.Where("inbound_id = ?", inbound.Id).Where("email = ?", traffic.Email). - UpdateColumn("enable", true). - UpdateColumn("expiry_time", traffic.ExpiryTime). - UpdateColumn("total", traffic.Total). - UpdateColumn("up", gorm.Expr("up + ?", traffic.Up)). - UpdateColumn("down", gorm.Expr("down + ?", traffic.Down)).RowsAffected == 0 { + UpdateColumns(map[string]interface{}{ + "enable": true, + "expiry_time": traffic.ExpiryTime, + "total": traffic.Total, + "up": gorm.Expr("up + ?", traffic.Up), + "down": gorm.Expr("down + ?", traffic.Down)}).RowsAffected == 0 { err = tx.Create(traffic).Error } @@ -374,8 +375,7 @@ func (s *InboundService) ResetClientTraffic(clientEmail string) error { result := db.Model(xray.ClientTraffic{}). Where("email = ?", clientEmail). - Update("up", 0). - Update("down", 0) + Updates(map[string]interface{}{"up": 0, "down": 0}) err := result.Error diff --git a/web/service/user.go b/web/service/user.go index e4e7572d..6da8bd1e 100644 --- a/web/service/user.go +++ b/web/service/user.go @@ -46,8 +46,7 @@ func (s *UserService) UpdateUser(id int, username string, password string) error db := database.GetDB() return db.Model(model.User{}). Where("id = ?", id). - Update("username", username). - Update("password", password). + Updates(map[string]interface{}{"username": username, "password": password}). Error } |
