换成单集群模式

This commit is contained in:
robin
2026-03-02 20:07:53 +08:00
parent 5d0b7c7e91
commit 2a76d1773d
432 changed files with 5681 additions and 5095 deletions

View File

@@ -1,6 +1,8 @@
package users
import (
"encoding/json"
"github.com/TeaOSLab/EdgeAdmin/internal/web/actions/actionutils"
"github.com/TeaOSLab/EdgeAdmin/internal/web/actions/default/users/userutils"
"github.com/TeaOSLab/EdgeCommon/pkg/langs/codes"
@@ -85,6 +87,46 @@ func (this *UpdateAction) RunGet(params struct {
this.Data["clusterId"] = user.NodeCluster.Id
}
// 检查用户是否开通了 HTTPDNS 功能
var hasHTTPDNSFeature = false
userFeaturesResp, err := this.RPC().UserRPC().FindUserFeatures(this.AdminContext(), &pb.FindUserFeaturesRequest{UserId: params.UserId})
if err != nil {
this.ErrorPage(err)
return
}
for _, f := range userFeaturesResp.Features {
if f.Code == "httpdns" {
hasHTTPDNSFeature = true
break
}
}
this.Data["hasHTTPDNSFeature"] = hasHTTPDNSFeature
// 读取用户已关联的 HTTPDNS 集群(取第一个作为下拉默认值)
var httpdnsClusterId int64
if len(user.HttpdnsClusterIdsJSON) > 0 {
var userHTTPDNSClusterIds []int64
if json.Unmarshal(user.HttpdnsClusterIdsJSON, &userHTTPDNSClusterIds) == nil && len(userHTTPDNSClusterIds) > 0 {
httpdnsClusterId = userHTTPDNSClusterIds[0]
}
}
this.Data["httpdnsClusterId"] = httpdnsClusterId
// 加载所有 HTTPDNS 集群
httpdnsClusterResp, err := this.RPC().HTTPDNSClusterRPC().FindAllHTTPDNSClusters(this.AdminContext(), &pb.FindAllHTTPDNSClustersRequest{})
if err != nil {
this.ErrorPage(err)
return
}
httpdnsClusters := make([]maps.Map, 0, len(httpdnsClusterResp.GetClusters()))
for _, c := range httpdnsClusterResp.GetClusters() {
httpdnsClusters = append(httpdnsClusters, maps.Map{
"id": c.GetId(),
"name": c.GetName(),
})
}
this.Data["httpdnsClusters"] = httpdnsClusters
this.Show()
}
@@ -99,8 +141,9 @@ func (this *UpdateAction) RunPost(params struct {
Email string
Remark string
IsOn bool
ClusterId int64
BandwidthAlgo string
ClusterId int64
HttpdnsClusterId int64
BandwidthAlgo string
// OTP
OtpOn bool
@@ -151,18 +194,25 @@ func (this *UpdateAction) RunPost(params struct {
Email("请输入正确的电子邮箱")
}
var httpdnsClusterIds []int64
if params.HttpdnsClusterId > 0 {
httpdnsClusterIds = []int64{params.HttpdnsClusterId}
}
httpdnsClusterIdsJSON, _ := json.Marshal(httpdnsClusterIds)
_, err = this.RPC().UserRPC().UpdateUser(this.AdminContext(), &pb.UpdateUserRequest{
UserId: params.UserId,
Username: params.Username,
Password: params.Pass1,
Fullname: params.Fullname,
Mobile: params.Mobile,
Tel: params.Tel,
Email: params.Email,
Remark: params.Remark,
IsOn: params.IsOn,
NodeClusterId: params.ClusterId,
BandwidthAlgo: params.BandwidthAlgo,
UserId: params.UserId,
Username: params.Username,
Password: params.Pass1,
Fullname: params.Fullname,
Mobile: params.Mobile,
Tel: params.Tel,
Email: params.Email,
Remark: params.Remark,
IsOn: params.IsOn,
NodeClusterId: params.ClusterId,
BandwidthAlgo: params.BandwidthAlgo,
HttpdnsClusterIdsJSON: httpdnsClusterIdsJSON,
})
if err != nil {
this.ErrorPage(err)