mirror of
https://github.com/Sagit-chu/flvx.git
synced 2026-10-08 18:56:37 +08:00
feat: 批量设置用户最大连接数
前端: - 用户列表添加 checkbox 多选(表格和网格视图) - 选中用户后显示「批量设置连接数」按钮 - 批量设置对话框,输入连接数后批量应用 后端: - 新增 BatchUpdateUserMaxConn repo 方法 - 新增 /api/v1/user/batch-set-max-conn API - 返回成功/失败计数 - 加入 admin-only 路由白名单
This commit is contained in:
@@ -1320,6 +1320,23 @@ func (r *Repository) BatchUpdateForwardStatus(ids []int64, status int) (int, int
|
||||
return s, f
|
||||
}
|
||||
|
||||
func (r *Repository) BatchUpdateUserMaxConn(ids []int64, maxConn int) (int, int) {
|
||||
if r == nil || r.db == nil {
|
||||
return 0, len(ids)
|
||||
}
|
||||
s := 0
|
||||
f := 0
|
||||
now := time.Now().UnixMilli()
|
||||
for _, id := range ids {
|
||||
if err := r.db.Model(&model.User{}).Where("id = ?", id).Updates(map[string]interface{}{"max_conn": maxConn, "updated_time": now}).Error; err != nil {
|
||||
f++
|
||||
} else {
|
||||
s++
|
||||
}
|
||||
}
|
||||
return s, f
|
||||
}
|
||||
|
||||
func (r *Repository) CreateTunnelTx(tx *gorm.DB, name string, trafficRatio float64, typeVal int, flow int64, now int64, status int, inIP interface{}, inx int, ipPreference string) (int64, error) {
|
||||
inIPVal := nullStringFromInterface(inIP)
|
||||
tunnel := model.Tunnel{
|
||||
|
||||
Reference in New Issue
Block a user