mirror of
				https://github.com/TeaOSLab/EdgeAPI.git
				synced 2025-11-04 16:00:24 +08:00 
			
		
		
		
	创建集群的时候可以填写DNS信息/集群设置页增加DNS设置功能
This commit is contained in:
		@@ -195,3 +195,19 @@ func (this *DNSDomainDAO) FindDomainRouteName(domainId int64, routeCode string)
 | 
			
		||||
	}
 | 
			
		||||
	return "", nil
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
// 判断是否有域名可选
 | 
			
		||||
func (this *DNSDomainDAO) ExistAvailableDomains() (bool, error) {
 | 
			
		||||
	subQuery, err := SharedDNSProviderDAO.Query().
 | 
			
		||||
		Where("state=1"). // 这里要使用非变量
 | 
			
		||||
		ResultPk().
 | 
			
		||||
		AsSQL()
 | 
			
		||||
	if err != nil {
 | 
			
		||||
		return false, err
 | 
			
		||||
	}
 | 
			
		||||
	return this.Query().
 | 
			
		||||
		State(DNSDomainStateEnabled).
 | 
			
		||||
		Attr("isOn", true).
 | 
			
		||||
		Where("providerId IN (" + subQuery + ")").
 | 
			
		||||
		Exist()
 | 
			
		||||
}
 | 
			
		||||
 
 | 
			
		||||
@@ -100,7 +100,7 @@ func (this *NodeClusterDAO) FindAllEnableClusters() (result []*NodeCluster, err
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
// 创建集群
 | 
			
		||||
func (this *NodeClusterDAO) CreateCluster(name string, grantId int64, installDir string) (clusterId int64, err error) {
 | 
			
		||||
func (this *NodeClusterDAO) CreateCluster(name string, grantId int64, installDir string, dnsDomainId int64, dnsName string) (clusterId int64, err error) {
 | 
			
		||||
	uniqueId, err := this.genUniqueId()
 | 
			
		||||
	if err != nil {
 | 
			
		||||
		return 0, err
 | 
			
		||||
@@ -116,6 +116,8 @@ func (this *NodeClusterDAO) CreateCluster(name string, grantId int64, installDir
 | 
			
		||||
	op.Name = name
 | 
			
		||||
	op.GrantId = grantId
 | 
			
		||||
	op.InstallDir = installDir
 | 
			
		||||
	op.DnsDomainId = dnsDomainId
 | 
			
		||||
	op.DnsName = dnsName
 | 
			
		||||
	op.UseAllAPINodes = 1
 | 
			
		||||
	op.ApiNodes = "[]"
 | 
			
		||||
	op.UniqueId = uniqueId
 | 
			
		||||
 
 | 
			
		||||
@@ -416,6 +416,21 @@ func (this *DNSDomainService) FindAllDNSDomainRoutes(ctx context.Context, req *p
 | 
			
		||||
	return &pb.FindAllDNSDomainRoutesResponse{Routes: pbRoutes}, nil
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
// 判断是否有域名可选
 | 
			
		||||
func (this *DNSDomainService) ExistAvailableDomains(ctx context.Context, req *pb.ExistAvailableDomainsRequest) (*pb.ExistAvailableDomainsResponse, error) {
 | 
			
		||||
	// 校验请求
 | 
			
		||||
	_, _, err := rpcutils.ValidateRequest(ctx, rpcutils.UserTypeAdmin)
 | 
			
		||||
	if err != nil {
 | 
			
		||||
		return nil, err
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	exist, err := models.SharedDNSDomainDAO.ExistAvailableDomains()
 | 
			
		||||
	if err != nil {
 | 
			
		||||
		return nil, err
 | 
			
		||||
	}
 | 
			
		||||
	return &pb.ExistAvailableDomainsResponse{Exist: exist}, nil
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
// 转换域名信息
 | 
			
		||||
func (this *DNSDomainService) convertDomainToPB(domain *models.DNSDomain) (*pb.DNSDomain, error) {
 | 
			
		||||
	domainId := int64(domain.Id)
 | 
			
		||||
 
 | 
			
		||||
@@ -23,7 +23,7 @@ func (this *NodeClusterService) CreateNodeCluster(ctx context.Context, req *pb.C
 | 
			
		||||
		return nil, err
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	clusterId, err := models.SharedNodeClusterDAO.CreateCluster(req.Name, req.GrantId, req.InstallDir)
 | 
			
		||||
	clusterId, err := models.SharedNodeClusterDAO.CreateCluster(req.Name, req.GrantId, req.InstallDir, req.DnsDomainId, req.DnsName)
 | 
			
		||||
	if err != nil {
 | 
			
		||||
		return nil, err
 | 
			
		||||
	}
 | 
			
		||||
 
 | 
			
		||||
		Reference in New Issue
	
	Block a user