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.

102 lines
3.7 KiB
C#

using Myshipping.Core;
using Furion.DependencyInjection;
using Furion.DynamicApiController;
using Mapster;
using Microsoft.AspNetCore.Mvc;
using SqlSugar;
using System.Linq;
using System.Threading.Tasks;
using Myshipping.Application.Entity;
namespace Myshipping.Application
{
/// <summary>
/// 多品名服务
/// </summary>
[ApiDescriptionSettings("Application",Name = "BookingCtnDetail", Order = 1)]
public class BookingCtnDetailService : IBookingCtnDetailService, IDynamicApiController, ITransient
{
private readonly SqlSugarRepository<BookingCtnDetail> _rep;
public BookingCtnDetailService(SqlSugarRepository<BookingCtnDetail> rep)
{
_rep = rep;
}
/// <summary>
/// 分页查询多品名
/// </summary>
/// <param name="input"></param>
/// <returns></returns>
[HttpGet("/BookingCtnDetail/page")]
public async Task<dynamic> Page([FromQuery] QueryBookingCtnDetailInput input)
{
var entities = await _rep.AsQueryable()
.WhereIF(!string.IsNullOrWhiteSpace(input.KINDPKGS), u => u.KINDPKGS == input.KINDPKGS)
.WhereIF(!string.IsNullOrWhiteSpace(input.HSCODE), u => u.HSCODE == input.HSCODE)
.WhereIF(!string.IsNullOrWhiteSpace(input.MARKS), u => u.MARKS == input.MARKS)
.WhereIF(!string.IsNullOrWhiteSpace(input.DESCRIPTION), u => u.DESCRIPTION == input.DESCRIPTION)
.WhereIF(!string.IsNullOrWhiteSpace(input.REMARK), u => u.REMARK == input.REMARK)
.ToPagedListAsync(input.PageNo, input.PageSize);
return entities.XnPagedResult();
}
/// <summary>
/// 增加多品名
/// </summary>
/// <param name="input"></param>
/// <returns></returns>
[HttpPost("/BookingCtnDetail/add")]
public async Task Add(AddBookingCtnDetailInput input)
{
var entity = input.Adapt<BookingCtnDetail>();
await _rep.InsertAsync(entity);
}
/// <summary>
/// 更新多品名
/// </summary>
/// <param name="input"></param>
/// <returns></returns>
[HttpPost("/BookingCtnDetail/edit")]
public async Task Update(UpdateBookingCtnDetailInput input)
{
var entity = input.Adapt<BookingCtnDetail>();
await _rep.AsUpdateable(entity).IgnoreColumns(ignoreAllNullColumns:true).ExecuteCommandAsync();
}
/// <summary>
/// 删除多品名
/// </summary>
/// <param name="input"></param>
/// <returns></returns>
[HttpPost("/BookingCtnDetail/delete")]
public async Task Delete(GetBookingCtnDetailInput input)
{
var entity = await _rep.FirstOrDefaultAsync(u => u.Id == input.Id);
await _rep.DeleteAsync(entity);
}
/// <summary>
/// 获取多品名
/// </summary>
/// <param name="input"></param>
/// <returns></returns>
[HttpGet("/BookingCtnDetail/detail")]
public async Task<BookingCtnDetail> Get([FromQuery] GetBookingCtnDetailInput input)
{
return await _rep.FirstOrDefaultAsync(u => u.Id == input.Id);
}
///// <summary>
///// 获取多品名列表
///// </summary>
///// <param name="input"></param>
///// <returns></returns>
//[HttpGet("/BookingCtnDetail/list")]
//public async Task<dynamic> List([FromQuery] QueryBookingCtnDetailInput input)
//{
// return await _rep.ToListAsync();
//}
}
}