1.4.5.2
This commit is contained in:
72
EdgeUser/internal/web/actions/default/ns/domains/index.go
Normal file
72
EdgeUser/internal/web/actions/default/ns/domains/index.go
Normal file
@@ -0,0 +1,72 @@
|
||||
package domains
|
||||
|
||||
import (
|
||||
"github.com/TeaOSLab/EdgeCommon/pkg/dnsconfigs"
|
||||
"github.com/TeaOSLab/EdgeCommon/pkg/rpc/pb"
|
||||
"github.com/TeaOSLab/EdgeUser/internal/web/actions/actionutils"
|
||||
"github.com/iwind/TeaGo/maps"
|
||||
)
|
||||
|
||||
type IndexAction struct {
|
||||
actionutils.ParentAction
|
||||
}
|
||||
|
||||
func (this *IndexAction) Init() {
|
||||
this.Nav("", "", "index")
|
||||
}
|
||||
|
||||
func (this *IndexAction) RunGet(params struct {
|
||||
GroupId int64
|
||||
Keyword string
|
||||
}) {
|
||||
this.Data["groupId"] = params.GroupId
|
||||
this.Data["keyword"] = params.Keyword
|
||||
|
||||
// 分页
|
||||
countResp, err := this.RPC().NSDomainRPC().CountAllNSDomains(this.UserContext(), &pb.CountAllNSDomainsRequest{
|
||||
NsDomainGroupId: params.GroupId,
|
||||
Keyword: params.Keyword,
|
||||
})
|
||||
if err != nil {
|
||||
this.ErrorPage(err)
|
||||
return
|
||||
}
|
||||
var page = this.NewPage(countResp.Count)
|
||||
this.Data["page"] = page.AsHTML()
|
||||
|
||||
// 列表
|
||||
domainsResp, err := this.RPC().NSDomainRPC().ListNSDomains(this.UserContext(), &pb.ListNSDomainsRequest{
|
||||
Keyword: params.Keyword,
|
||||
NsDomainGroupId: params.GroupId,
|
||||
Offset: page.Offset,
|
||||
Size: page.Size,
|
||||
})
|
||||
if err != nil {
|
||||
this.ErrorPage(err)
|
||||
return
|
||||
}
|
||||
var domainMaps = []maps.Map{}
|
||||
for _, domain := range domainsResp.NsDomains {
|
||||
// 分组信息
|
||||
var groupMaps = []maps.Map{}
|
||||
for _, group := range domain.NsDomainGroups {
|
||||
groupMaps = append(groupMaps, maps.Map{
|
||||
"id": group.Id,
|
||||
"name": group.Name,
|
||||
"userId": group.UserId,
|
||||
})
|
||||
}
|
||||
|
||||
domainMaps = append(domainMaps, maps.Map{
|
||||
"id": domain.Id,
|
||||
"name": domain.Name,
|
||||
"status": domain.Status,
|
||||
"statusName": dnsconfigs.NSDomainStatusName(domain.Status),
|
||||
"isOn": domain.IsOn,
|
||||
"groups": groupMaps,
|
||||
})
|
||||
}
|
||||
this.Data["domains"] = domainMaps
|
||||
|
||||
this.Show()
|
||||
}
|
||||
Reference in New Issue
Block a user