Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: fix stack sdk inject way #641

Merged
merged 3 commits into from
Sep 12, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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>
Original file line number Diff line number Diff line change
@@ -1,11 +1,6 @@
// Copyright (c) MASA Stack All rights reserved.
// Licensed under the Apache License. See LICENSE.txt in the project root for license information.

using Masa.BuildingBlocks.Configuration;
using Masa.BuildingBlocks.Data;
using Masa.BuildingBlocks.StackSdks.Dcc.Contracts.Enum;
using Masa.Dcc.Service.Admin.Domain.App.Aggregates;

namespace Masa.Dcc.Service.Admin.Domain.App.Services
{
public class ConfigObjectDomainService : DomainService
Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@
// Copyright (c) MASA Stack All rights reserved.
// Licensed under the Apache License. See LICENSE.txt in the project root for license information.

using Microsoft.EntityFrameworkCore.Metadata.Builders;

namespace Masa.Dcc.Service.Admin.Infrastructure.EntityConfigurations.App
{
public class AppConfigEntityTypeConfiguration : IEntityTypeConfiguration<AppConfigObject>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@
// Copyright (c) MASA Stack All rights reserved.
// Licensed under the Apache License. See LICENSE.txt in the project root for license information.

using Microsoft.EntityFrameworkCore.Metadata.Builders;

namespace Masa.Dcc.Service.Admin.Infrastructure.EntityConfigurations.App
{
public class AppPinEntityTypeConfiguration : IEntityTypeConfiguration<AppPin>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@
// Copyright (c) MASA Stack All rights reserved.
// Licensed under the Apache License. See LICENSE.txt in the project root for license information.

using Microsoft.EntityFrameworkCore.Metadata.Builders;

namespace Masa.Dcc.Service.Admin.Infrastructure.EntityConfigurations.App
{
public class AppSecretEntityTypeConfiguration : IEntityTypeConfiguration<AppSecret>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@
// Copyright (c) MASA Stack All rights reserved.
// Licensed under the Apache License. See LICENSE.txt in the project root for license information.

using Microsoft.EntityFrameworkCore.Metadata.Builders;

namespace Masa.Dcc.Service.Admin.Infrastructure.EntityConfigurations.App
{
public class ConfigObjectEntityTypeConfiguration : IEntityTypeConfiguration<ConfigObject>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@
// Copyright (c) MASA Stack All rights reserved.
// Licensed under the Apache License. See LICENSE.txt in the project root for license information.

using Microsoft.EntityFrameworkCore.Metadata.Builders;

namespace Masa.Dcc.Service.Admin.Infrastructure.EntityConfigurations.App
{
public class ConfigObjectReleaseEntityTypeConfiguration : IEntityTypeConfiguration<ConfigObjectRelease>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@
// Copyright (c) MASA Stack All rights reserved.
// Licensed under the Apache License. See LICENSE.txt in the project root for license information.

using Microsoft.EntityFrameworkCore.Metadata.Builders;

namespace Masa.Dcc.Service.Admin.Infrastructure.EntityConfigurations.App
{
public class PublicConfigEntityTypeConfiguration : IEntityTypeConfiguration<PublicConfig>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@
// Copyright (c) MASA Stack All rights reserved.
// Licensed under the Apache License. See LICENSE.txt in the project root for license information.

using Microsoft.EntityFrameworkCore.Metadata.Builders;

namespace Masa.Dcc.Service.Admin.Infrastructure.EntityConfigurations.App
{
public class PublicConfigObjectEntityTypeConfiguration : IEntityTypeConfiguration<PublicConfigObject>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@
// Copyright (c) MASA Stack All rights reserved.
// Licensed under the Apache License. See LICENSE.txt in the project root for license information.

using Microsoft.EntityFrameworkCore.Metadata.Builders;

namespace Masa.Dcc.Service.Admin.Infrastructure.EntityConfigurations.Label
{
public class LabelEntityTypeConfiguration : IEntityTypeConfiguration<Domain.Label.Aggregates.Label>
Expand Down
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, 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
Loading