feat: show current owner names and persist user and limit order (#576)

Resolve current forwarding-rule owner names by user ID. Add administrator-managed persistent user and speed-limit ordering, backup compatibility, and conflict recovery. Repair PostgreSQL explicit-ID import sequences transactionally.

Closes #574
Closes #575
This commit is contained in:
sagit
2026-11-10 09:13:05 +08:00
committed by GitHub
parent 3209ff8a59
commit 577c189737
20 changed files with 2901 additions and 720 deletions
@@ -37,8 +37,14 @@ func (r *Repository) ListForwardsByTunnelTx(tx *gorm.DB, tunnelID int64) ([]mode
if tx == nil {
return nil, errors.New("database unavailable")
}
var forwards []model.Forward
err := tx.Where("tunnel_id = ?", tunnelID).Order("id ASC").Find(&forwards).Error
var forwards []struct {
model.Forward
CurrentUserName string
}
err := tx.Model(&model.Forward{}).
Select(`forward.*, COALESCE(owner."user", forward.user_name) AS current_user_name`).
Joins(`LEFT JOIN "user" AS owner ON owner.id = forward.user_id`).
Where("forward.tunnel_id = ?", tunnelID).Order("forward.id ASC").Find(&forwards).Error
if err != nil {
return nil, err
}
@@ -48,7 +54,7 @@ func (r *Repository) ListForwardsByTunnelTx(tx *gorm.DB, tunnelID int64) ([]mode
rows = append(rows, model.ForwardRecord{
ID: f.ID,
UserID: f.UserID,
UserName: f.UserName,
UserName: f.CurrentUserName,
Name: f.Name,
TunnelID: f.TunnelID,
RemoteAddr: f.RemoteAddr,