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