first commit
This commit is contained in:
@@ -0,0 +1,58 @@
|
||||
using F9WebAiTest.Application.Common;
|
||||
using F9WebAiTest.Application.Dtos;
|
||||
using F9WebAiTest.Application.Dtos.Base;
|
||||
using F9WebAiTest.Application.Dtos.Prod;
|
||||
using F9WebAiTest.Application.Services;
|
||||
using F9WebAiTest.Application.Services.Base;
|
||||
using F9WebAiTest.Application.Services.Prod;
|
||||
using Microsoft.AspNetCore.Authorization;
|
||||
using Microsoft.AspNetCore.Mvc;
|
||||
|
||||
namespace F9WebAiTest.Api.Controllers.Prod;
|
||||
|
||||
[ApiController]
|
||||
[Route("api/lsjl")]
|
||||
[Authorize]
|
||||
public class LsjlController : ControllerBase
|
||||
{
|
||||
private readonly ILsjlService _svc;
|
||||
private readonly IJizuChetaiService _jzSvc;
|
||||
|
||||
public LsjlController(ILsjlService svc, IJizuChetaiService jzSvc)
|
||||
{
|
||||
_svc = svc;
|
||||
_jzSvc = jzSvc;
|
||||
}
|
||||
|
||||
[HttpGet]
|
||||
public async Task<IActionResult> GetPaged(
|
||||
[FromQuery] int pageIndex = 1, [FromQuery] int pageSize = 20,
|
||||
[FromQuery] DateTime? date = null, [FromQuery] long? deptId = null, [FromQuery] string keyword = "")
|
||||
=> Ok(ApiResult<PageResult<LsjlDto>>.Ok(await _svc.GetPagedAsync(pageIndex, pageSize, date, deptId, keyword)));
|
||||
|
||||
// 根据车间+机组查询车台号范围
|
||||
[HttpGet("chetai")]
|
||||
public async Task<IActionResult> GetChetai([FromQuery] long deptId, [FromQuery] int jizu)
|
||||
=> Ok(ApiResult<JizuChetaiDto>.Ok(await _jzSvc.GetByDepIdAndJizuAsync(deptId, jizu)));
|
||||
|
||||
[HttpPost]
|
||||
public async Task<IActionResult> Create([FromBody] LsjlCreateDto dto)
|
||||
{
|
||||
try { return Ok(ApiResult<LsjlDto>.Ok(await _svc.CreateAsync(dto), "创建成功")); }
|
||||
catch (ServiceException ex) { return StatusCode(ex.Code, ApiResult<object>.Fail(ex.Message, ex.Code)); }
|
||||
}
|
||||
|
||||
[HttpPut("{id}")]
|
||||
public async Task<IActionResult> Update(long id, [FromBody] LsjlCreateDto dto)
|
||||
{
|
||||
try { return Ok(ApiResult<LsjlDto>.Ok(await _svc.UpdateAsync(id, dto), "更新成功")); }
|
||||
catch (ServiceException ex) { return StatusCode(ex.Code, ApiResult<object>.Fail(ex.Message, ex.Code)); }
|
||||
}
|
||||
|
||||
[HttpDelete("{id}")]
|
||||
public async Task<IActionResult> Delete(long id)
|
||||
{
|
||||
try { await _svc.DeleteAsync(id); return Ok(ApiResult<object>.Ok(null, "删除成功")); }
|
||||
catch (ServiceException ex) { return StatusCode(ex.Code, ApiResult<object>.Fail(ex.Message, ex.Code)); }
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user