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.

101 lines
3.0 KiB
C#

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
{
/// <summary>
/// 往来单位费用模板API
/// </summary>
public class FeeCustTemplateController : ApiController
{
readonly IFeeCustTemplateService _invokeService;
/// <summary>
/// 构造函数
/// </summary>
/// <param name="invokeService"></param>
public FeeCustTemplateController(IFeeCustTemplateService invokeService)
{
_invokeService = invokeService;
}
/// <summary>
/// 生成订单费用
/// </summary>
/// <param name="biz"></param>
/// <returns></returns>
[HttpPost, Route("GenerateFees")]
public async Task<IActionResult> 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);
}
/// <summary>
/// 列表
/// </summary>
/// <param name="request"></param>
/// <returns></returns>
[HttpPost, Route("GetList")]
public async Task<DataResult<List<FeeCustTemplate>>> GetListAsync([FromBody] PageRequest request)
{
return await _invokeService.GetListAsync(request);
}
/// <summary>
/// 编辑
/// </summary>
/// <param name="model"></param>
/// <returns></returns>
[HttpPost, Route("Edit")]
public async Task<DataResult> EditAsync([FromBody] FeeCustTemplate model)
{
if (model == null)
return DataResult.FailedWithDesc(MultiLanguageConst.IllegalRequest);
return await _invokeService.EditAsync(model);
}
/// <summary>
/// 详情
/// </summary>
/// <param name="id"></param>
/// <returns></returns>
[HttpGet, Route("Edit")]
public async Task<DataResult<FeeCustTemplate>> GetAsync([FromQuery] long id)
{
return await _invokeService.GetAsync(id);
}
/// <summary>
/// 根据ID删除
/// </summary>
/// <param name="model"></param>
/// <returns></returns>
[HttpPost, Route("Delete")]
public async Task<DataResult> DeleteAsync([FromBody] IdModel model)
{
if (!ModelState.IsValid)
return DataResult.Failed(ModelState.GetErrorMessage(), MultiLanguageConst.IllegalRequest);
return await _invokeService.DeleteAsync(model);
}
}
}