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.
BookingHeChuan/Myshipping.Application/Service/DjyBooking/DjyBookingService.cs

104 lines
3.4 KiB
C#

using Magic.Core;
using Furion.DependencyInjection;
using Furion.DynamicApiController;
using Mapster;
using Microsoft.AspNetCore.Mvc;
using SqlSugar;
using System.Linq;
using System.Threading.Tasks;
using Magic.Application.Entity;
using Furion;
using System;
namespace Magic.Application
{
/// <summary>
/// 订舱服务
/// </summary>
[ApiDescriptionSettings("Application", Name = "DjyBooking", Order = 1)]
public class DjyBookingService : IDjyBookingService, IDynamicApiController, ITransient
{
private readonly SqlSugarRepository<DjyBooking> _rep;
public DjyBookingService(SqlSugarRepository<DjyBooking> rep)
{
_rep = rep;
}
/// <summary>
/// 分页查询订舱
/// </summary>
/// <param name="input"></param>
/// <returns></returns>
[HttpGet("/DjyBooking/page")]
public async Task<dynamic> Page([FromQuery] DjyBookingInput input)
{
var entities = await _rep.AsQueryable()
.WhereIF(!string.IsNullOrWhiteSpace(input.MBLNO), u => u.MBLNO == input.MBLNO)
.WhereIF(!string.IsNullOrWhiteSpace(input.Carrier), u => u.Carrier == input.Carrier)
.WhereIF(!string.IsNullOrWhiteSpace(input.CarrierId), u => u.CarrierId == input.CarrierId)
.ToPagedListAsync(input.PageNo, input.PageSize);
return entities.XnPagedResult();
}
/// <summary>
/// 增加订舱
/// </summary>
/// <param name="input"></param>
/// <returns></returns>
[HttpPost("/DjyBooking/add")]
public async Task Add(AddDjyBookingInput input)
{
var entity = input.Adapt<DjyBooking>();
entity.TenantId = Convert.ToInt64(App.User.FindFirst(ClaimConst.TENANT_ID)?.Value);
await _rep.InsertAsync(entity);
}
/// <summary>
/// 删除订舱
/// </summary>
/// <param name="input"></param>
/// <returns></returns>
[HttpPost("/DjyBooking/delete")]
public async Task Delete(DeleteDjyBookingInput input)
{
var entity = await _rep.FirstOrDefaultAsync(u => u.Id == input.Id);
await _rep.DeleteAsync(entity);
}
/// <summary>
/// 更新订舱
/// </summary>
/// <param name="input"></param>
/// <returns></returns>
[HttpPost("/DjyBooking/edit")]
public async Task Update(UpdateDjyBookingInput input)
{
var entity = input.Adapt<DjyBooking>();
await _rep.AsUpdateable(entity).IgnoreColumns(ignoreAllNullColumns: true).ExecuteCommandAsync();
}
/// <summary>
/// 获取订舱
/// </summary>
/// <param name="input"></param>
/// <returns></returns>
[HttpGet("/DjyBooking/detail")]
public async Task<DjyBooking> Get([FromQuery] QueryeDjyBookingInput input)
{
return await _rep.FirstOrDefaultAsync(u => u.Id == input.Id);
}
/// <summary>
/// 获取订舱列表
/// </summary>
/// <param name="input"></param>
/// <returns></returns>
[HttpGet("/DjyBooking/list")]
public async Task<dynamic> List([FromQuery] DjyBookingInput input)
{
return await _rep.ToListAsync();
}
}
}