feat 增加厂区接口

This commit is contained in:
2025-07-02 18:51:46 +08:00
parent 9e8f51b93a
commit 069a639cbb
4 changed files with 73 additions and 0 deletions

View 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();
}
}
}

View 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; }
}
}

View File

@@ -0,0 +1,9 @@
using Dlhis.External.OpenApi.Response;
namespace Dlhis.External.OpenApi.Services
{
public interface IFactoryService : IScopeDependency
{
Task<List<FactoryResponse>> GetAllFactoriesAsync();
}
}

View File

@@ -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();
}
}
}