|
|
|
|
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;
|
|
|
|
|
using Microsoft.Extensions.Logging;
|
|
|
|
|
using System.Collections.Generic;
|
|
|
|
|
using Furion.FriendlyException;
|
|
|
|
|
|
|
|
|
|
namespace Myshipping.Application
|
|
|
|
|
{
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// 订舱关系人服务
|
|
|
|
|
/// </summary>
|
|
|
|
|
[ApiDescriptionSettings("Application", Name = "BookingOrderContact", Order = 1)]
|
|
|
|
|
public class BookingOrderContactService : IBookingOrderContactService, IDynamicApiController, ITransient
|
|
|
|
|
{
|
|
|
|
|
private readonly SqlSugarRepository<BookingOrderContact> _rep;
|
|
|
|
|
private readonly ILogger<BookingOrderContact> _logger;
|
|
|
|
|
|
|
|
|
|
public BookingOrderContactService(SqlSugarRepository<BookingOrderContact> rep, ILogger<BookingOrderContact> logger)
|
|
|
|
|
{
|
|
|
|
|
_rep = rep;
|
|
|
|
|
_logger = logger;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// 分页查询订舱关系人
|
|
|
|
|
/// </summary>
|
|
|
|
|
/// <param name="input"></param>
|
|
|
|
|
/// <returns></returns>
|
|
|
|
|
[HttpGet("/BookingOrderContact/page")]
|
|
|
|
|
public async Task<dynamic> Page([FromQuery] QueryBookingOrderContactInput input)
|
|
|
|
|
{
|
|
|
|
|
var entities = await _rep.AsQueryable()
|
|
|
|
|
.WhereIF(!string.IsNullOrWhiteSpace(input.RoleCode), u => u.RoleCode.Contains(input.RoleCode.Trim()))
|
|
|
|
|
.WhereIF(!string.IsNullOrWhiteSpace(input.Name), u => u.Name.Contains(input.Name.Trim()))
|
|
|
|
|
.WhereIF(!string.IsNullOrWhiteSpace(input.Tel), u => u.Tel.Contains(input.Tel.Trim()))
|
|
|
|
|
.WhereIF(!string.IsNullOrWhiteSpace(input.Email), u => u.Email.Contains(input.Email.Trim()))
|
|
|
|
|
.ToPagedListAsync(input.PageNo, input.PageSize);
|
|
|
|
|
return entities.XnPagedResult();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// 增加订舱关系人
|
|
|
|
|
/// </summary>
|
|
|
|
|
/// <param name="input"></param>
|
|
|
|
|
/// <returns></returns>
|
|
|
|
|
[HttpPost("/BookingOrderContact/add")]
|
|
|
|
|
public async Task Add(AddBookingOrderContactInput input)
|
|
|
|
|
{
|
|
|
|
|
var entity = input.Adapt<BookingOrderContact>();
|
|
|
|
|
await _rep.InsertAsync(entity);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// 更新订舱关系人
|
|
|
|
|
/// </summary>
|
|
|
|
|
/// <param name="input"></param>
|
|
|
|
|
/// <returns></returns>
|
|
|
|
|
[HttpPost("/BookingOrderContact/edit")]
|
|
|
|
|
public async Task Update(UpdateBookingOrderContactInput input)
|
|
|
|
|
{
|
|
|
|
|
var entity = input.Adapt<BookingOrderContact>();
|
|
|
|
|
await _rep.AsUpdateable(entity).IgnoreColumns(ignoreAllNullColumns: true).ExecuteCommandAsync();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// 删除订舱关系人
|
|
|
|
|
/// </summary>
|
|
|
|
|
/// <param name="input"></param>
|
|
|
|
|
/// <returns></returns>
|
|
|
|
|
[HttpPost("/BookingOrderContact/delete")]
|
|
|
|
|
public async Task Delete(GetBookingOrderContactInput input)
|
|
|
|
|
{
|
|
|
|
|
var entity = await _rep.FirstOrDefaultAsync(u => u.Id == input.Id);
|
|
|
|
|
await _rep.DeleteAsync(entity);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// 获取订舱关系人
|
|
|
|
|
/// </summary>
|
|
|
|
|
/// <param name="input"></param>
|
|
|
|
|
/// <returns></returns>
|
|
|
|
|
[HttpGet("/BookingOrderContact/detail")]
|
|
|
|
|
public async Task<BookingOrderContact> Get([FromQuery] GetBookingOrderContactInput input)
|
|
|
|
|
{
|
|
|
|
|
return await _rep.FirstOrDefaultAsync(u => u.Id == input.Id);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// 根据订舱ID获取关系人
|
|
|
|
|
/// </summary>
|
|
|
|
|
/// <param name="bookingId"></param>
|
|
|
|
|
/// <returns></returns>
|
|
|
|
|
[HttpGet("/BookingOrderContact/listbyorder")]
|
|
|
|
|
public async Task<List<BookingOrderContactOutput>> ListByOrder(long bookingId)
|
|
|
|
|
{
|
|
|
|
|
var list = await _rep.Where(x => x.BookingId == bookingId).ToListAsync();
|
|
|
|
|
return list.Adapt<List<BookingOrderContactOutput>>();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// 批量保存关系人(同时新增、删除、修改)
|
|
|
|
|
/// </summary>
|
|
|
|
|
/// <param name="input"></param>
|
|
|
|
|
/// <returns></returns>
|
|
|
|
|
[HttpPost("/BookingOrderContact/savebatch"), SqlSugarUnitOfWork]
|
|
|
|
|
public async Task SaveBatch(List<UpdateBookingOrderContactInput> input)
|
|
|
|
|
{
|
|
|
|
|
if (input!=null||input.Count==0) {
|
|
|
|
|
throw Oops.Oh($"请传入正确数据");
|
|
|
|
|
}
|
|
|
|
|
var bookingId = input.First().BookingId;
|
|
|
|
|
_rep.Delete(x => x.BookingId == bookingId);
|
|
|
|
|
foreach (var item in input)
|
|
|
|
|
{
|
|
|
|
|
await _rep.InsertAsync(item.Adapt<BookingOrderContact>());
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
///// <summary>
|
|
|
|
|
///// 获取订舱关系人列表
|
|
|
|
|
///// </summary>
|
|
|
|
|
///// <param name="input"></param>
|
|
|
|
|
///// <returns></returns>
|
|
|
|
|
//[HttpGet("/BookingOrderContact/list")]
|
|
|
|
|
//public async Task<dynamic> List([FromQuery] QueryBookingOrderContactInput input)
|
|
|
|
|
//{
|
|
|
|
|
// return await _rep.ToListAsync();
|
|
|
|
|
//}
|
|
|
|
|
}
|
|
|
|
|
}
|