Skip to content

Commit

Permalink
fix: update sdk client inject way; upgrade sdk package version
Browse files Browse the repository at this point in the history
  • Loading branch information
Qinyouzeng committed Sep 12, 2024
1 parent 8865072 commit 2f9b26b
Show file tree
Hide file tree
Showing 13 changed files with 56 additions and 79 deletions.
2 changes: 1 addition & 1 deletion Directory.Build.props
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<Project>
<PropertyGroup>
<MasaFrameworkPackageVersion>1.2.0-preview.2</MasaFrameworkPackageVersion>
<MasaStackSdksPackageVersion>1.1.0-preview.2</MasaStackSdksPackageVersion>
<MasaStackSdksPackageVersion>1.2.1-preview.4</MasaStackSdksPackageVersion>
</PropertyGroup>
</Project>
4 changes: 2 additions & 2 deletions src/Services/Masa.Dcc.Service/Program.cs
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,8 @@

builder.Services.AddMasaIdentity(options =>
{
options.UserName = "name";
options.UserId = "sub";
options.UserName = IdentityClaimConsts.USER_NAME;
options.UserId = IdentityClaimConsts.USER_ID;
options.Role = IdentityClaimConsts.ROLES;
options.Environment = IdentityClaimConsts.ENVIRONMENT;
options.Mapping(nameof(MasaUser.CurrentTeamId), IdentityClaimConsts.CURRENT_TEAM);
Expand Down
8 changes: 4 additions & 4 deletions src/Services/Masa.Dcc.Service/Properties/launchSettings.json
Original file line number Diff line number Diff line change
Expand Up @@ -11,16 +11,16 @@
"VERSION": "1.0-Prev",
"IS_DEMO": "False",
"DOMAIN_NAME": "masastack.com",
"NAMESPACE": "masastack.com",
"MASA_NAMESPACE": "masastack.com",
"TLS_NAME": "",
"CLUSTER": "Default",
"MASA_CLUSTER": "Default",
"OTLP_URL": "https://otel-collector.masastack:9013",
"REDIS": "{\"RedisHost\": \"10.130.0.19\", \"RedisPort\": 2135, \"RedisDb\": 3,\"RedisPassword\": \"Hzss@123\"}",
"CONNECTIONSTRING": "{\"Server\": \"10.130.0.19\", \"Port\": 2415,\"Database\":\"pm-dev\",\"UserId\": \"ss\",\"Password\":\"Hzss@123\"}",
"MASA_STACK": "[{\"id\":\"pm\",\"service\":{\"id\":\"pm-service-dev\",\"domain\":\"http://pm-service-dev.masastack.com\"},\"web\":{\"id\":\"pm-web-dev\",\"domain\":\"https://pm-dev.masastack.com\"}},{\"id\":\"dcc\",\"service\":{\"id\":\"dcc-service-dev\",\"domain\":\"http://dcc-service-dev.masastack.com\"},\"web\":{\"id\":\"dcc-web-dev\",\"domain\":\"https://dcc-dev.masastack.com\"}},{\"id\":\"tsc\",\"service\":{\"id\":\"tsc-service-dev\",\"domain\":\"http://tsc-service-dev.masastack.com\"},\"web\":{\"id\":\"tsc-web-dev\",\"domain\":\"https://tsc-dev.masastack.com\"}},{\"id\":\"alert\",\"service\":{\"id\":\"alert-service-dev\",\"domain\":\"http://alert-service-dev.masastack.com\"},\"web\":{\"id\":\"alert-web-dev\",\"domain\":\"https://alert-dev.masastack.com\"}},{\"id\":\"scheduler\",\"service\":{\"id\":\"scheduler-service-dev\",\"domain\":\"http://scheduler-service-dev.masastack.com\"},\"worker\":{\"id\":\"scheduler-worker-dev\",\"domain\":\"http://scheduler-worker-dev.masastack.com\"},\"web\":{\"id\":\"scheduler-web-dev\",\"domain\":\"https://scheduler-dev.masastack.com\"}},{\"id\":\"mc\",\"service\":{\"id\":\"mc-service-dev\",\"domain\":\"http://mc-service-dev.masastack.com\"},\"web\":{\"id\":\"mc-web-dev\",\"domain\":\"https://mc-dev.masastack.com\"}},{\"id\":\"auth\",\"service\":{\"id\":\"auth-service-dev\",\"domain\":\"http://auth-service-dev.masastack.com\"},\"web\":{\"id\":\"auth-web-dev\",\"domain\":\"https://auth-dev.masastack.com\"},\"sso\":{\"id\":\"auth-sso-dev\",\"domain\":\"https://auth-sso-dev.masastack.com\"}}]",
"ELASTIC": "{\"Nodes\": [\"http://es-ydy-new.lonsid.cn:9200\"],\"Index\": \"auth_user_development\"}",
"ENVIRONMENT": "Development",
"ADMIN_PWD": "admin_pwd",
"MASA_ENVIRONMENT": "Development",
"ADMIN_PWD": "admin123",
"DCC_SECRET": "masastack.com",
"SUFFIX_IDENTITY": "dev"
},
Expand Down
35 changes: 11 additions & 24 deletions src/Services/Masa.Dcc.Service/Services/AppService.cs
Original file line number Diff line number Diff line change
Expand Up @@ -5,13 +5,8 @@ namespace Masa.Dcc.Service.Admin.Services;

public class AppService : ServiceBase
{
private readonly IPmClient _pmClient;
private readonly IAuthClient _authClient;

public AppService(IPmClient pmClient, IAuthClient authClient)
public AppService()
{
_pmClient = pmClient;
_authClient = authClient;
App.MapGet("api/v1/app/{id}", GetAsync);
App.MapPost("api/v1/projects/app", GetListByProjectIdsAsync);
App.MapGet("api/v1/appWithEnvCluster/{id}", GetWithEnvironmentClusterAsync);
Expand All @@ -21,38 +16,31 @@ public AppService(IPmClient pmClient, IAuthClient authClient)
App.MapPost("api/v1/app/latestReleaseConfig", GetLatestReleaseConfigByAppAsync);
}

public async Task<AppDetailModel> GetAsync(int id)
public Task<AppDetailModel> GetAsync(IPmClient pmClient, int id)
{
var result = await _pmClient.AppService.GetAsync(id);
return result;
return pmClient.AppService.GetAsync(id);
}

public async Task<List<LatestReleaseConfigModel>> GetLatestReleaseConfigByAppAsync(IEventBus eventBus, LatestReleaseConfigRequestDto<int> request)
public async Task<List<LatestReleaseConfigModel>> GetLatestReleaseConfigByAppAsync(IEventBus eventBus, IHttpContextAccessor httpContext, IAuthClient authClient, LatestReleaseConfigRequestDto<int> request)
{
var query = new AppLatestReleaseQuery(request.Items, request.EnvClusterId);
await eventBus.PublishAsync(query);
return await _authClient.FillUserNameAsync(query.Result);
return await authClient.FillUserNameAsync(query.Result);
}

public async Task<List<AppDetailModel>> GetListAsync()
public async Task<List<AppDetailModel>> GetListAsync(IPmClient pmClient)
{
var result = await _pmClient.AppService.GetListAsync();

return result;
return await pmClient.AppService.GetListAsync();
}

public async Task<List<AppDetailModel>> GetListByProjectIdsAsync([FromBody] List<int> projectIds)
public async Task<List<AppDetailModel>> GetListByProjectIdsAsync(IPmClient pmClient, [FromBody] List<int> projectIds)
{
var result = await _pmClient.AppService.GetListByProjectIdsAsync(projectIds);

return result;
return await pmClient.AppService.GetListByProjectIdsAsync(projectIds);
}

public async Task<AppDetailModel> GetWithEnvironmentClusterAsync(int id)
public async Task<AppDetailModel> GetWithEnvironmentClusterAsync(IPmClient pmClient, int id)
{
var result = await _pmClient.AppService.GetWithEnvironmentClusterAsync(id);

return result;
return await pmClient.AppService.GetWithEnvironmentClusterAsync(id);
}

public async Task AddAppPinAsync(IEventBus eventBus, int appId)
Expand All @@ -69,7 +57,6 @@ public async Task<List<AppPinDto>> GetAppPinListAsync(IEventBus eventBus, [FromB
{
var query = new AppPinQuery(appIds);
await eventBus.PublishAsync(query);

return query.Result;
}
}
7 changes: 3 additions & 4 deletions src/Services/Masa.Dcc.Service/Services/BizConfigService.cs
Original file line number Diff line number Diff line change
Expand Up @@ -5,23 +5,22 @@ namespace Masa.Dcc.Service.Admin.Services
{
public class BizConfigService : ServiceBase
{
private readonly IAuthClient _authClient;

public BizConfigService(IAuthClient authClient)
public BizConfigService()
{
_authClient = authClient;
App.MapPost("api/v1/bizConfig", AddAsync);
App.MapPut("api/v1/bizConfig", UpdateAsync);
App.MapGet("api/v1/bizConfig/{identity}", GetAsync);
App.MapPost("api/v1/bizConfig/latestReleaseConfig", GetLatestReleaseConfigByProjectAsync);
}

public async Task<List<LatestReleaseConfigModel>> GetLatestReleaseConfigByProjectAsync(IEventBus eventBus,
IAuthClient authClient,
LatestReleaseConfigRequestDto<ProjectModel> request)
{
var query = new ProjectLatestReleaseQuery(request.Items, request.EnvClusterId);
await eventBus.PublishAsync(query);
return await _authClient.FillUserNameAsync(query.Result);
return await authClient.FillUserNameAsync(query.Result);
}

public async Task<BizConfigDto> AddAsync(IEventBus eventBus, AddObjectConfigDto dto)
Expand Down
19 changes: 8 additions & 11 deletions src/Services/Masa.Dcc.Service/Services/ClusterService.cs
Original file line number Diff line number Diff line change
Expand Up @@ -5,41 +5,38 @@ namespace Masa.Dcc.Service.Admin.Services;

public class ClusterService : ServiceBase
{
private readonly IPmClient _pmClient;

public ClusterService(IPmClient pmClient)
{
_pmClient = pmClient;
App.MapGet("api/v1/cluster", GetListAsync);
App.MapGet("api/v1/cluster/{Id}", GetAsync);
App.MapGet("api/v1/envClusters", GetEnvironmentClustersAsync);
App.MapGet("api/v1/{envId}/cluster", GetListByEnvIdAsync);
}

public async Task<List<ClusterModel>> GetListAsync()
public async Task<List<ClusterModel>> GetListAsync(IPmClient pmClient)
{
var result = await _pmClient.ClusterService.GetListAsync();
var result = await pmClient.ClusterService.GetListAsync();

return result;
}

public async Task<ClusterDetailModel> GetAsync(int Id)
public async Task<ClusterDetailModel> GetAsync(IPmClient pmClient, int Id)
{
var result = await _pmClient.ClusterService.GetAsync(Id);
var result = await pmClient.ClusterService.GetAsync(Id);

return result;
}

public async Task<List<EnvironmentClusterModel>> GetEnvironmentClustersAsync()
public async Task<List<EnvironmentClusterModel>> GetEnvironmentClustersAsync(IPmClient pmClient)
{
var result = await _pmClient.ClusterService.GetEnvironmentClustersAsync();
var result = await pmClient.ClusterService.GetEnvironmentClustersAsync();

return result;
}

public async Task<List<ClusterModel>> GetListByEnvIdAsync(int envId)
public async Task<List<ClusterModel>> GetListByEnvIdAsync(IPmClient pmClient, int envId)
{
var result = await _pmClient.ClusterService.GetListByEnvIdAsync(envId);
var result = await pmClient.ClusterService.GetListByEnvIdAsync(envId);

return result;
}
Expand Down
8 changes: 3 additions & 5 deletions src/Services/Masa.Dcc.Service/Services/ConfigObjectService.cs
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,8 @@ namespace Masa.Dcc.Service.Admin.Services;

public class ConfigObjectService : ServiceBase
{
private readonly IAuthClient _authClient;
public ConfigObjectService(IAuthClient authClient)
public ConfigObjectService()
{
_authClient = authClient;
App.MapPost("api/v1/configObject", AddAsync);
App.MapDelete("api/v1/configObject", RemoveAsync);
App.MapGet("api/v1/configObjects/{envClusterId}/{objectId}/{type}/{getLatestRelease}", GetListAsync);
Expand All @@ -34,11 +32,11 @@ public async Task RemoveAsync(IEventBus eventBus, [FromBody] RemoveConfigObjectD
}

public async Task<List<ConfigObjectDto>> GetListAsync(
IEventBus eventBus, int envClusterId, int objectId, ConfigObjectType type, string configObjectName = "", bool getLatestRelease = false)
IEventBus eventBus, IAuthClient authClient, int envClusterId, int objectId, ConfigObjectType type, string configObjectName = "", bool getLatestRelease = false)
{
var query = new ConfigObjectsQuery(envClusterId, objectId, type, configObjectName, getLatestRelease);
await eventBus.PublishAsync(query);
query.Result = await _authClient.FillUserNameAsync(query.Result);
query.Result = await authClient.FillUserNameAsync(query.Result);
return query.Result;
}

Expand Down
11 changes: 4 additions & 7 deletions src/Services/Masa.Dcc.Service/Services/EnvironmentService.cs
Original file line number Diff line number Diff line change
Expand Up @@ -5,25 +5,22 @@ namespace Masa.Dcc.Service.Admin.Services;

public class EnvironmentService : ServiceBase
{
private readonly IPmClient _pmClient;

public EnvironmentService(IPmClient pmClient)
{
_pmClient = pmClient;
App.MapGet("api/v1/env", GetListAsync);
App.MapGet("api/v1/env/{Id}", GetAsync);
}

public async Task<List<EnvironmentModel>> GetListAsync()
public async Task<List<EnvironmentModel>> GetListAsync(IPmClient pmClient)
{
var result = await _pmClient.EnvironmentService.GetListAsync();
var result = await pmClient.EnvironmentService.GetListAsync();

return result;
}

public async Task<EnvironmentDetailModel> GetAsync(int Id)
public async Task<EnvironmentDetailModel> GetAsync(IPmClient pmClient,int Id)
{
var result = await _pmClient.EnvironmentService.GetAsync(Id);
var result = await pmClient.EnvironmentService.GetAsync(Id);

return result;
}
Expand Down
27 changes: 12 additions & 15 deletions src/Services/Masa.Dcc.Service/Services/ProjectService.cs
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,8 @@ namespace Masa.Dcc.Service.Admin.Services;

public class ProjectService : ServiceBase
{
private readonly IPmClient _pmClient;

public ProjectService(IPmClient pmClient)
{
_pmClient = pmClient;
App.MapGet("api/v1/projectwithapps/{envName}", GetProjectListAsync);
App.MapGet("api/v1/project/{id}", GetAsync);
App.MapGet("api/v1/{envClusterId}/project", GetListByEnvironmentClusterIdAsync);
Expand All @@ -18,44 +15,44 @@ public ProjectService(IPmClient pmClient)
App.MapPost("api/v1/project/teamsProject", GetListByTeamIdsAsync);
}

public async Task<List<ProjectAppsModel>> GetProjectListAsync(string envName)
public async Task<List<ProjectAppsModel>> GetProjectListAsync(IPmClient pmClient, string envName)
{
var result = await _pmClient.ProjectService.GetProjectAppsAsync(envName);
var result = await pmClient.ProjectService.GetProjectAppsAsync(envName);

return result;
}

public async Task<ProjectDetailModel> GetAsync(int id)
public async Task<ProjectDetailModel> GetAsync(IPmClient pmClient, int id)
{
var result = await _pmClient.ProjectService.GetAsync(id);
var result = await pmClient.ProjectService.GetAsync(id);

return result;
}

public async Task<List<ProjectModel>> GetListAsync()
public async Task<List<ProjectModel>> GetListAsync(IPmClient pmClient)
{
var result = await _pmClient.ProjectService.GetListAsync();
var result = await pmClient.ProjectService.GetListAsync();

return result;
}

public async Task<List<ProjectModel>> GetListByEnvironmentClusterIdAsync(int envClusterId)
public async Task<List<ProjectModel>> GetListByEnvironmentClusterIdAsync(IPmClient pmClient, int envClusterId)
{
var result = await _pmClient.ProjectService.GetListByEnvironmentClusterIdAsync(envClusterId);
var result = await pmClient.ProjectService.GetListByEnvironmentClusterIdAsync(envClusterId);

return result;
}

public async Task<List<ProjectTypeModel>> GetProjectTypes()
public async Task<List<ProjectTypeModel>> GetProjectTypes(IPmClient pmClient)
{
var result = await _pmClient.ProjectService.GetProjectTypesAsync();
var result = await pmClient.ProjectService.GetProjectTypesAsync();

return result;
}

public async Task<List<ProjectModel>> GetListByTeamIdsAsync([FromBody] List<Guid> teamIds, IMultiEnvironmentUserContext multiEnvironmentUserContext)
public async Task<List<ProjectModel>> GetListByTeamIdsAsync(IPmClient pmClient, [FromBody] List<Guid> teamIds, IMultiEnvironmentUserContext multiEnvironmentUserContext)
{
var result = await _pmClient.ProjectService.GetListByTeamIdsAsync(teamIds, multiEnvironmentUserContext.Environment ?? "");
var result = await pmClient.ProjectService.GetListByTeamIdsAsync(teamIds, multiEnvironmentUserContext.Environment ?? "");

return result;
}
Expand Down
4 changes: 2 additions & 2 deletions src/Services/Masa.Dcc.Service/_Imports.cs
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@
global using Mapster;
global using Masa.BuildingBlocks.Authentication.Identity;
global using Masa.BuildingBlocks.Caching;
global using Masa.BuildingBlocks.Configuration;
global using Masa.BuildingBlocks.Data.UoW;
global using Masa.BuildingBlocks.Ddd.Domain.Entities.Full;
global using Masa.BuildingBlocks.Ddd.Domain.Events;
Expand All @@ -28,8 +27,8 @@
global using Masa.BuildingBlocks.ReadWriteSplitting.Cqrs.Queries;
global using Masa.BuildingBlocks.StackSdks.Auth;
global using Masa.BuildingBlocks.StackSdks.Auth.Contracts;
global using Masa.BuildingBlocks.StackSdks.Auth.Contracts.Consts;
global using Masa.BuildingBlocks.StackSdks.Config;
global using Masa.BuildingBlocks.StackSdks.Config.Consts;
global using Masa.BuildingBlocks.StackSdks.Dcc.Contracts.Model;
global using Masa.BuildingBlocks.StackSdks.Middleware;
global using Masa.BuildingBlocks.StackSdks.Pm;
Expand Down Expand Up @@ -64,3 +63,4 @@
global using Microsoft.AspNetCore.Mvc;
global using Microsoft.EntityFrameworkCore;
global using Microsoft.EntityFrameworkCore.Design;
global using Masa.BuildingBlocks.Configuration;
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,9 @@
</ItemGroup>

<ItemGroup>
<PackageReference Include="Masa.Stack.Components" Version="0.0.471" />
<PackageReference Include="Masa.Stack.Components" Version="0.0.488" />
<PackageReference Include="Microsoft.AspNetCore.Components.Web" Version="6.0.3" />
<PackageReference Include="Masa.Contrib.StackSdks.Tsc.OpenTelemetry" Version="$(MasaStackSdksPackageVersion)" />
</ItemGroup>

<ItemGroup>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
var builder = WebApplication.CreateBuilder(args);

await builder.Services.AddMasaStackComponentsAsync(project: MasaStackProject.DCC);

var masaStackConfig = builder.Services.GetMasaStackConfig();
builder.Services.AddValidatorsFromAssembly(typeof(LabelValueModel).Assembly, includeInternalTypes: true);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,11 +20,11 @@
"VERSION": "1.0-Prev",
"IS_DEMO": "False",
"DOMAIN_NAME": "masastack.com",
"NAMESPACE": "masastack.com",
"MASA_NAMESPACE": "masastack.com",
"TLS_NAME": "",
"CLUSTER": "Default",
"MASA_CLUSTER": "Default",
"OTLP_URL": "https://otel-collector.masastack:9013",
"REDIS": "{\"RedisHost\": \"10.130.0.19\", \"RedisPort\": 2135, \"RedisDb\": 0,\"RedisPassword\": \"Hzss@123\"}",
"REDIS": "{\"RedisHost\": \"10.130.0.19\", \"RedisPort\": 2135, \"RedisDb\": 3,\"RedisPassword\": \"Hzss@123\"}",
"CONNECTIONSTRING": "{\"Server\": \"10.130.0.19\", \"Port\": 2415,\"Database\":\"pm-dev\",\"UserId\": \"ss\",\"Password\":\"Hzss@123\"}",
"MASA_STACK": "[{\"id\":\"pm\",\"service\":{\"id\":\"pm-service-dev\",\"domain\":\"http://pm-service-dev.masastack.com\"},\"web\":{\"id\":\"pm-web-dev\",\"domain\":\"https://pm-dev.masastack.com\"}},{\"id\":\"dcc\",\"service\":{\"id\":\"dcc-service-dev\",\"domain\":\"http://dcc-service-dev.masastack.com\"},\"web\":{\"id\":\"dcc-web-dev\",\"domain\":\"https://dcc-dev.masastack.com\"}},{\"id\":\"tsc\",\"service\":{\"id\":\"tsc-service-dev\",\"domain\":\"http://tsc-service-dev.masastack.com\"},\"web\":{\"id\":\"tsc-web-dev\",\"domain\":\"https://tsc-dev.masastack.com\"}},{\"id\":\"alert\",\"service\":{\"id\":\"alert-service-dev\",\"domain\":\"http://alert-service-dev.masastack.com\"},\"web\":{\"id\":\"alert-web-dev\",\"domain\":\"https://alert-dev.masastack.com\"}},{\"id\":\"scheduler\",\"service\":{\"id\":\"scheduler-service-dev\",\"domain\":\"http://scheduler-service-dev.masastack.com\"},\"worker\":{\"id\":\"scheduler-worker-dev\",\"domain\":\"http://scheduler-worker-dev.masastack.com\"},\"web\":{\"id\":\"scheduler-web-dev\",\"domain\":\"https://scheduler-dev.masastack.com\"}},{\"id\":\"mc\",\"service\":{\"id\":\"mc-service-dev\",\"domain\":\"http://mc-service-dev.masastack.com\"},\"web\":{\"id\":\"mc-web-dev\",\"domain\":\"https://mc-dev.masastack.com\"}},{\"id\":\"auth\",\"service\":{\"id\":\"auth-service-dev\",\"domain\":\"http://auth-service-dev.masastack.com\"},\"web\":{\"id\":\"auth-web-dev\",\"domain\":\"https://auth-dev.masastack.com\"},\"sso\":{\"id\":\"auth-sso-dev\",\"domain\":\"https://auth-sso-dev.masastack.com\"}}]",
"ELASTIC": "{\"Nodes\": [\"http://es-ydy-new.lonsid.cn:9200\"],\"Index\": \"auth_user_development\"}",
Expand Down

0 comments on commit 2f9b26b

Please sign in to comment.