feat 增加厂区接口
This commit is contained in:
26
Src/Dlhis.External/OpenApi/Controllers/FactoryController.cs
Normal file
26
Src/Dlhis.External/OpenApi/Controllers/FactoryController.cs
Normal file
@@ -0,0 +1,26 @@
|
|||||||
|
using Dlhis.External.OpenApi.Response;
|
||||||
|
using Dlhis.External.OpenApi.Services;
|
||||||
|
using Microsoft.AspNetCore.Authorization;
|
||||||
|
using Microsoft.AspNetCore.Mvc;
|
||||||
|
|
||||||
|
namespace Dlhis.External.OpenApi.Controllers
|
||||||
|
{
|
||||||
|
[Authorize]
|
||||||
|
[Route("api/[controller]")]
|
||||||
|
[ApiController]
|
||||||
|
public class FactoryController : ControllerBase
|
||||||
|
{
|
||||||
|
private readonly IFactoryService _factoryService;
|
||||||
|
|
||||||
|
public FactoryController(IFactoryService factoryService)
|
||||||
|
{
|
||||||
|
_factoryService = factoryService;
|
||||||
|
}
|
||||||
|
|
||||||
|
[HttpGet("all")]
|
||||||
|
public async Task<List<FactoryResponse>> GetAllFactoriesAsync()
|
||||||
|
{
|
||||||
|
return await _factoryService.GetAllFactoriesAsync();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
9
Src/Dlhis.External/OpenApi/Response/FactoryResponse.cs
Normal file
9
Src/Dlhis.External/OpenApi/Response/FactoryResponse.cs
Normal file
@@ -0,0 +1,9 @@
|
|||||||
|
namespace Dlhis.External.OpenApi.Response
|
||||||
|
{
|
||||||
|
public class FactoryResponse
|
||||||
|
{
|
||||||
|
public string PCode { get; set; }
|
||||||
|
public string Code { get; set; }
|
||||||
|
public string Name { get; set; }
|
||||||
|
}
|
||||||
|
}
|
||||||
9
Src/Dlhis.External/OpenApi/Services/IFactoryService.cs
Normal file
9
Src/Dlhis.External/OpenApi/Services/IFactoryService.cs
Normal file
@@ -0,0 +1,9 @@
|
|||||||
|
using Dlhis.External.OpenApi.Response;
|
||||||
|
|
||||||
|
namespace Dlhis.External.OpenApi.Services
|
||||||
|
{
|
||||||
|
public interface IFactoryService : IScopeDependency
|
||||||
|
{
|
||||||
|
Task<List<FactoryResponse>> GetAllFactoriesAsync();
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,29 @@
|
|||||||
|
using Dlhis.Entity.Sys.Entities;
|
||||||
|
using Dlhis.External.OpenApi.Response;
|
||||||
|
using Kurisu.AspNetCore.DataAccess.SqlSugar.Services;
|
||||||
|
|
||||||
|
namespace Dlhis.External.OpenApi.Services.Implements
|
||||||
|
{
|
||||||
|
public class FactoryService : IFactoryService
|
||||||
|
{
|
||||||
|
private readonly IDbContext _dbContext;
|
||||||
|
|
||||||
|
public FactoryService(IDbContext dbContext)
|
||||||
|
{
|
||||||
|
_dbContext = dbContext.ChangeDb("identity");
|
||||||
|
}
|
||||||
|
|
||||||
|
public async Task<List<FactoryResponse>> GetAllFactoriesAsync()
|
||||||
|
{
|
||||||
|
return await _dbContext.Queryable<TenantEntity>()
|
||||||
|
.Where(x => x.Code != "1234")
|
||||||
|
.Select(x => new FactoryResponse
|
||||||
|
{
|
||||||
|
PCode = x.PCode,
|
||||||
|
Code = x.Code,
|
||||||
|
Name = x.Name
|
||||||
|
})
|
||||||
|
.ToListAsync();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
Reference in New Issue
Block a user