You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

91 lines
2.8 KiB
C#

using Microsoft.AspNetCore.Http;
using Microsoft.AspNetCore.Mvc;
using SlnMesnac.Model.domain;
using SlnMesnac.Repository.service;
namespace SlnMesnac.Controllers
{
/// <summary>
/// 物料信息
/// </summary>
[Route("api/[controller]")]
[ApiController]
public class BaseMaterialInfoController
{
private ILogger<BaseMaterialInfoController> _logger;
private IBaseMaterialService _service;
/// <summary>
///
/// </summary>
/// <param name="logger"></param>
/// <param name="service"></param>
public BaseMaterialInfoController(ILogger<BaseMaterialInfoController> logger, IBaseMaterialService service)
{
_logger = logger;
_service = service;
}
/// <summary>
/// 获取物料信息
/// </summary>
/// <returns></returns>
[HttpGet]
public IEnumerable<BaseMaterialInfo> Get()
{
IEnumerable<BaseMaterialInfo> materialInfos = null;
try
{
materialInfos = _service.GetMaterialInfos();
}
catch (Exception ex)
{
_logger.LogError($"获取物料信息接口调用异常:{ex.Message}");
}
return materialInfos;
}
/// <summary>
/// 根据物料编号获取物料信息
/// </summary>
/// <param name="materialCode">物料编号</param>
/// <returns></returns>
[HttpGet("Get/{materialCode}")]
public BaseMaterialInfo GetMaterialInfoByMaterialCode(string materialCode)
{
BaseMaterialInfo materialInfo = null;
try
{
materialInfo = _service.GetMaterialInfoByMaterialCode(materialCode);
}
catch (Exception ex)
{
_logger.LogError($"根据物料编号获取物料信息接口调用异常:{ex.Message}");
}
return materialInfo;
}
/// <summary>
/// 通过物料类别获取物料信息
/// </summary>
/// <param name="majorTypeId">物料大类</param>
/// <param name="minorTypeId">物料细类</param>
/// <returns></returns>
[HttpGet("Get/{majorTypeId}/{minorTypeId}")]
public IEnumerable<BaseMaterialInfo> GetMaterialInfosByMaterialType(int majorTypeId, string minorTypeId)
{
IEnumerable<BaseMaterialInfo> materialInfos = null;
try
{
materialInfos = _service.GetMaterialInfosByMaterialType(majorTypeId, minorTypeId);
}
catch (Exception ex)
{
_logger.LogError($"通过物料类别获取物料信息接口调用异常:{ex.Message}");
}
return materialInfos;
}
}
}