Skip to content

Commit

Permalink
记录应用消费服务得到的地址
Browse files Browse the repository at this point in the history
  • Loading branch information
nnhy committed Jul 15, 2024
1 parent f381c6c commit 0bfa5f6
Show file tree
Hide file tree
Showing 4 changed files with 35 additions and 1 deletion.
1 change: 1 addition & 0 deletions Stardust.Data/Entity/Model.xml
Original file line number Diff line number Diff line change
Expand Up @@ -259,6 +259,7 @@
<Column Name="MinVersion" DataType="String" Description="最低版本。要求返回大于等于该版本的服务提供者" />
<Column Name="Scope" DataType="String" Description="作用域。根据配置中心应用规则计算,禁止跨域访问服务" />
<Column Name="Tag" DataType="String" Description="标签。带有指定特性,逗号分隔" />
<Column Name="Address" DataType="String" Length="500" Description="地址。最终消费得到的地址" />
<Column Name="CreateTime" DataType="DateTime" Description="创建时间" Category="扩展" />
<Column Name="CreateIP" DataType="String" Description="创建地址" Category="扩展" />
<Column Name="UpdateTime" DataType="DateTime" Description="更新时间" Category="扩展" />
Expand Down
11 changes: 11 additions & 0 deletions Stardust.Data/Entity/Stardust.htm
Original file line number Diff line number Diff line change
Expand Up @@ -1895,6 +1895,17 @@ <h3>应用消费(AppConsume)</h3>
<td>带有指定特性,逗号分隔</td>
</tr>

<tr>
<td>Address</td>
<td>地址</td>
<td>String</td>
<td>500</td>
<td></td>
<td></td>
<td></td>
<td>最终消费得到的地址</td>
</tr>

<tr>
<td>CreateTime</td>
<td>创建时间</td>
Expand Down
16 changes: 16 additions & 0 deletions Stardust.Data/Entity/应用消费.cs
Original file line number Diff line number Diff line change
Expand Up @@ -112,6 +112,14 @@ public partial class AppConsume
[BindColumn("Tag", "标签。带有指定特性,逗号分隔", "")]
public String Tag { get => _Tag; set { if (OnPropertyChanging("Tag", value)) { _Tag = value; OnPropertyChanged("Tag"); } } }

private String _Address;
/// <summary>地址。最终消费得到的地址</summary>
[DisplayName("地址")]
[Description("地址。最终消费得到的地址")]
[DataObjectField(false, false, true, 500)]
[BindColumn("Address", "地址。最终消费得到的地址", "")]
public String Address { get => _Address; set { if (OnPropertyChanging("Address", value)) { _Address = value; OnPropertyChanged("Address"); } } }

private DateTime _CreateTime;
/// <summary>创建时间</summary>
[Category("扩展")]
Expand Down Expand Up @@ -159,6 +167,7 @@ public override Object this[String name]
"MinVersion" => _MinVersion,
"Scope" => _Scope,
"Tag" => _Tag,
"Address" => _Address,
"CreateTime" => _CreateTime,
"CreateIP" => _CreateIP,
"UpdateTime" => _UpdateTime,
Expand All @@ -179,6 +188,7 @@ public override Object this[String name]
case "MinVersion": _MinVersion = Convert.ToString(value); break;
case "Scope": _Scope = Convert.ToString(value); break;
case "Tag": _Tag = Convert.ToString(value); break;
case "Address": _Address = Convert.ToString(value); break;
case "CreateTime": _CreateTime = value.ToDateTime(); break;
case "CreateIP": _CreateIP = Convert.ToString(value); break;
case "UpdateTime": _UpdateTime = value.ToDateTime(); break;
Expand Down Expand Up @@ -231,6 +241,9 @@ public partial class _
/// <summary>标签。带有指定特性,逗号分隔</summary>
public static readonly Field Tag = FindByName("Tag");

/// <summary>地址。最终消费得到的地址</summary>
public static readonly Field Address = FindByName("Address");

/// <summary>创建时间</summary>
public static readonly Field CreateTime = FindByName("CreateTime");

Expand Down Expand Up @@ -279,6 +292,9 @@ public partial class __
/// <summary>标签。带有指定特性,逗号分隔</summary>
public const String Tag = "Tag";

/// <summary>地址。最终消费得到的地址</summary>
public const String Address = "Address";

/// <summary>创建时间</summary>
public const String CreateTime = "CreateTime";

Expand Down
8 changes: 7 additions & 1 deletion Stardust.Server/Controllers/AppController.cs
Original file line number Diff line number Diff line change
Expand Up @@ -367,9 +367,15 @@ public ServiceModel[] ResolveService([FromBody] ConsumeServiceInfo model)
svc.Save();

info.Consumers = consumes.Count;

var models = _registryService.ResolveService(info, model, svc.Scope);

// 记录应用消费服务得到的地址
info.Address = models?.Select(e => new { e.Address, e.Address2, e.Weight }).ToJson();

info.Save();

return _registryService.ResolveService(info, model, svc.Scope);
return models;
}

[HttpPost(nameof(SearchService))]
Expand Down

0 comments on commit 0bfa5f6

Please sign in to comment.