เพิ่ม Code ในการแยก api ออกมาเป็น ClassLibrary และดึงไปใช้ในแต่ละ project
This commit is contained in:
parent
00f795483a
commit
ea6cfb0e98
6 changed files with 71 additions and 1 deletions
19
BMA.EHR.API.Command/BMA.EHR.API.Command.csproj
Normal file
19
BMA.EHR.API.Command/BMA.EHR.API.Command.csproj
Normal file
|
|
@ -0,0 +1,19 @@
|
||||||
|
<Project Sdk="Microsoft.NET.Sdk">
|
||||||
|
|
||||||
|
<PropertyGroup>
|
||||||
|
<TargetFramework>net7.0</TargetFramework>
|
||||||
|
<ImplicitUsings>enable</ImplicitUsings>
|
||||||
|
<Nullable>enable</Nullable>
|
||||||
|
</PropertyGroup>
|
||||||
|
|
||||||
|
<ItemGroup>
|
||||||
|
<PackageReference Include="Microsoft.AspNetCore.Mvc" Version="2.2.0" />
|
||||||
|
<PackageReference Include="Microsoft.AspNetCore.Mvc.Versioning" Version="5.1.0" />
|
||||||
|
<PackageReference Include="Microsoft.AspNetCore.Mvc.Versioning.ApiExplorer" Version="5.1.0" />
|
||||||
|
</ItemGroup>
|
||||||
|
|
||||||
|
<ItemGroup>
|
||||||
|
<ProjectReference Include="..\BMA.EHR.Infrastructure\BMA.EHR.Infrastructure.csproj" />
|
||||||
|
</ItemGroup>
|
||||||
|
|
||||||
|
</Project>
|
||||||
20
BMA.EHR.API.Command/CommandAPIRegistration.cs
Normal file
20
BMA.EHR.API.Command/CommandAPIRegistration.cs
Normal file
|
|
@ -0,0 +1,20 @@
|
||||||
|
using Microsoft.Extensions.DependencyInjection;
|
||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Reflection;
|
||||||
|
using System.Text;
|
||||||
|
using System.Threading.Tasks;
|
||||||
|
|
||||||
|
namespace BMA.EHR.API.Command
|
||||||
|
{
|
||||||
|
public static class CommandAPIRegistration
|
||||||
|
{
|
||||||
|
public static IMvcBuilder RegisterCommandControllers(this IMvcBuilder builder)
|
||||||
|
{
|
||||||
|
Assembly assembly = typeof(CommandAPIRegistration).Assembly;
|
||||||
|
builder.AddApplicationPart(assembly);
|
||||||
|
return builder;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
21
BMA.EHR.API.Command/TestController.cs
Normal file
21
BMA.EHR.API.Command/TestController.cs
Normal file
|
|
@ -0,0 +1,21 @@
|
||||||
|
using BMA.EHR.Domain.Common;
|
||||||
|
using Microsoft.AspNetCore.Mvc;
|
||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Text;
|
||||||
|
using System.Threading.Tasks;
|
||||||
|
|
||||||
|
namespace BMA.EHR.API.Command
|
||||||
|
{
|
||||||
|
[Route("api/test")]
|
||||||
|
[ApiController]
|
||||||
|
public class TestController : BaseController
|
||||||
|
{
|
||||||
|
[HttpGet]
|
||||||
|
public ActionResult<ResponseObject> Get()
|
||||||
|
{
|
||||||
|
return Success("Test", new { data = "11111" });
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
@ -37,6 +37,7 @@
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
|
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
|
<ProjectReference Include="..\BMA.EHR.API.Command\BMA.EHR.API.Command.csproj" />
|
||||||
<ProjectReference Include="..\BMA.EHR.Infrastructure\BMA.EHR.Infrastructure.csproj" />
|
<ProjectReference Include="..\BMA.EHR.Infrastructure\BMA.EHR.Infrastructure.csproj" />
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -1,3 +1,4 @@
|
||||||
|
using BMA.EHR.API.Command;
|
||||||
using BMA.EHR.Application;
|
using BMA.EHR.Application;
|
||||||
using BMA.EHR.Infrastructure;
|
using BMA.EHR.Infrastructure;
|
||||||
using BMA.EHR.Infrastructure.Persistence;
|
using BMA.EHR.Infrastructure.Persistence;
|
||||||
|
|
@ -83,6 +84,7 @@ var builder = WebApplication.CreateBuilder(args);
|
||||||
{
|
{
|
||||||
options.SuppressAsyncSuffixInActionNames = false;
|
options.SuppressAsyncSuffixInActionNames = false;
|
||||||
})
|
})
|
||||||
|
.RegisterCommandControllers()
|
||||||
.AddNewtonsoftJson(x => x.SerializerSettings.ReferenceLoopHandling = Newtonsoft.Json.ReferenceLoopHandling.Ignore);
|
.AddNewtonsoftJson(x => x.SerializerSettings.ReferenceLoopHandling = Newtonsoft.Json.ReferenceLoopHandling.Ignore);
|
||||||
|
|
||||||
builder.Services.AddSwaggerGen();
|
builder.Services.AddSwaggerGen();
|
||||||
|
|
|
||||||
|
|
@ -13,7 +13,9 @@ Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "BMA.EHR.MetaData.Service",
|
||||||
EndProject
|
EndProject
|
||||||
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "src", "src", "{F3C2F68F-8DC8-45A3-825B-24F17867D380}"
|
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "src", "src", "{F3C2F68F-8DC8-45A3-825B-24F17867D380}"
|
||||||
EndProject
|
EndProject
|
||||||
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "API", "API", "{FA618F0C-1AF5-49AB-AE13-C020B403B64F}"
|
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Service", "Service", "{FA618F0C-1AF5-49AB-AE13-C020B403B64F}"
|
||||||
|
EndProject
|
||||||
|
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "BMA.EHR.API.Command", "BMA.EHR.API.Command\BMA.EHR.API.Command.csproj", "{FC7215BD-5651-4226-9210-8894E8FA8767}"
|
||||||
EndProject
|
EndProject
|
||||||
Global
|
Global
|
||||||
GlobalSection(SolutionConfigurationPlatforms) = preSolution
|
GlobalSection(SolutionConfigurationPlatforms) = preSolution
|
||||||
|
|
@ -37,6 +39,10 @@ Global
|
||||||
{939DD34A-C7AE-406E-B557-33F69AC64127}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
{939DD34A-C7AE-406E-B557-33F69AC64127}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
||||||
{939DD34A-C7AE-406E-B557-33F69AC64127}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
{939DD34A-C7AE-406E-B557-33F69AC64127}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
||||||
{939DD34A-C7AE-406E-B557-33F69AC64127}.Release|Any CPU.Build.0 = Release|Any CPU
|
{939DD34A-C7AE-406E-B557-33F69AC64127}.Release|Any CPU.Build.0 = Release|Any CPU
|
||||||
|
{FC7215BD-5651-4226-9210-8894E8FA8767}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
|
||||||
|
{FC7215BD-5651-4226-9210-8894E8FA8767}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
||||||
|
{FC7215BD-5651-4226-9210-8894E8FA8767}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
||||||
|
{FC7215BD-5651-4226-9210-8894E8FA8767}.Release|Any CPU.Build.0 = Release|Any CPU
|
||||||
EndGlobalSection
|
EndGlobalSection
|
||||||
GlobalSection(SolutionProperties) = preSolution
|
GlobalSection(SolutionProperties) = preSolution
|
||||||
HideSolutionNode = FALSE
|
HideSolutionNode = FALSE
|
||||||
|
|
@ -47,6 +53,7 @@ Global
|
||||||
{F83D3633-4A7A-432A-9E47-29378F4D175F} = {F3C2F68F-8DC8-45A3-825B-24F17867D380}
|
{F83D3633-4A7A-432A-9E47-29378F4D175F} = {F3C2F68F-8DC8-45A3-825B-24F17867D380}
|
||||||
{939DD34A-C7AE-406E-B557-33F69AC64127} = {FA618F0C-1AF5-49AB-AE13-C020B403B64F}
|
{939DD34A-C7AE-406E-B557-33F69AC64127} = {FA618F0C-1AF5-49AB-AE13-C020B403B64F}
|
||||||
{FA618F0C-1AF5-49AB-AE13-C020B403B64F} = {F3C2F68F-8DC8-45A3-825B-24F17867D380}
|
{FA618F0C-1AF5-49AB-AE13-C020B403B64F} = {F3C2F68F-8DC8-45A3-825B-24F17867D380}
|
||||||
|
{FC7215BD-5651-4226-9210-8894E8FA8767} = {F3C2F68F-8DC8-45A3-825B-24F17867D380}
|
||||||
EndGlobalSection
|
EndGlobalSection
|
||||||
GlobalSection(ExtensibilityGlobals) = postSolution
|
GlobalSection(ExtensibilityGlobals) = postSolution
|
||||||
SolutionGuid = {3111A492-1818-4438-B718-75199D8E779A}
|
SolutionGuid = {3111A492-1818-4438-B718-75199D8E779A}
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue