using System.Net;
using DS.Module.Core;
using DS.Module.Core.Data;
using DS.WMS.Core.Fee.Dtos;
using DS.WMS.Core.Fee.Entity;
using DS.WMS.Core.Fee.Interface;
using Microsoft.AspNetCore.Mvc;
namespace DS.WMS.FeeApi.Controllers
{
///
/// 往来单位费用模板API
///
public class FeeCustTemplateController : ApiController
{
readonly IFeeCustTemplateService _invokeService;
///
/// 构造函数
///
///
public FeeCustTemplateController(IFeeCustTemplateService invokeService)
{
_invokeService = invokeService;
}
///
/// 生成订单费用
///
///
///
[HttpPost, Route("GenerateFees")]
public async Task GenerateFeesAsync([FromBody] BizItem biz)
{
HttpStatusCode httpStatusCode;
try
{
await _invokeService.GenerateFeesAsync(biz.Id, biz.BusinessType);
httpStatusCode = HttpStatusCode.NoContent;
}
catch
{
httpStatusCode = HttpStatusCode.InternalServerError;
throw;
}
return new StatusCodeResult((int)httpStatusCode);
}
///
/// 列表
///
///
///
[HttpPost, Route("GetList")]
public async Task>> GetListAsync([FromBody] PageRequest request)
{
return await _invokeService.GetListAsync(request);
}
///
/// 编辑
///
///
///
[HttpPost, Route("Edit")]
public async Task EditAsync([FromBody] FeeCustTemplate model)
{
if (model == null)
return DataResult.FailedWithDesc(MultiLanguageConst.IllegalRequest);
return await _invokeService.EditAsync(model);
}
///
/// 详情
///
///
///
[HttpGet, Route("Edit")]
public async Task> GetAsync([FromQuery] long id)
{
return await _invokeService.GetAsync(id);
}
///
/// 根据ID删除
///
///
///
[HttpPost, Route("Delete")]
public async Task DeleteAsync([FromBody] IdModel model)
{
if (!ModelState.IsValid)
return DataResult.Failed(ModelState.GetErrorMessage(), MultiLanguageConst.IllegalRequest);
return await _invokeService.DeleteAsync(model);
}
}
}