optimize
hao 11 months ago
parent 3649dab625
commit 30cc0c39d2

@ -30,6 +30,7 @@ using Myshipping.Application.Event;
using Microsoft.AspNetCore.Authorization; using Microsoft.AspNetCore.Authorization;
using Furion.DatabaseAccessor; using Furion.DatabaseAccessor;
using static ICSharpCode.SharpZipLib.Zip.ExtendedUnixData; using static ICSharpCode.SharpZipLib.Zip.ExtendedUnixData;
using Myshipping.Application.Service.BookingOrder.Dto;
namespace Myshipping.Application namespace Myshipping.Application
@ -113,7 +114,7 @@ namespace Myshipping.Application
/// <param name="input"></param> /// <param name="input"></param>
/// <returns></returns> /// <returns></returns>
[HttpPost("/BookingSlot/save")] [HttpPost("/BookingSlot/save")]
public async Task<BookingSlotBaseSaveDto> Save(BookingSlotBaseSaveDto input) public async Task<BookingSlotBaseSaveOutput> Save(BookingSlotBaseSaveInput input)
{ {
BookingSlotBase model = null; BookingSlotBase model = null;
if (input.Id > 0) //修改 if (input.Id > 0) //修改
@ -125,6 +126,7 @@ namespace Myshipping.Application
} }
model = _repBase.FirstOrDefault(x => x.Id == input.Id); model = _repBase.FirstOrDefault(x => x.Id == input.Id);
var oldObj = model.Adapt<BookingSlotBaseSaveInput>();
input.Adapt(model); input.Adapt(model);
@ -137,6 +139,8 @@ namespace Myshipping.Application
newCtn.SLOT_ID = model.Id; newCtn.SLOT_ID = model.Id;
await _repCtn.InsertAsync(newCtn); await _repCtn.InsertAsync(newCtn);
} }
await InsLog("Update", model.Id, typeof(BookingSlotBaseSaveInput), oldObj, input, "CtnList");
} }
else else
{ {
@ -210,13 +214,30 @@ namespace Myshipping.Application
/// <param name="id"></param> /// <param name="id"></param>
/// <returns></returns> /// <returns></returns>
[HttpGet("/BookingSlot/detail")] [HttpGet("/BookingSlot/detail")]
public async Task<BookingSlotBaseSaveDto> Detail(long id) public async Task<BookingSlotBaseSaveOutput> Detail(long id)
{ {
var slotBase = await _repBase.FirstOrDefaultAsync(u => u.Id == id); var slotBase = await _repBase.FirstOrDefaultAsync(u => u.Id == id);
var ctns = await _repCtn.Where(x => x.SLOT_ID == id).ToListAsync(); var ctns = await _repCtn.Where(x => x.SLOT_ID == id).ToListAsync();
var rtn = slotBase.Adapt<BookingSlotBaseSaveDto>(); var rtn = slotBase.Adapt<BookingSlotBaseSaveOutput>();
rtn.CtnList = ctns.Adapt<List<BookingSlotCtnSaveInput>>(); rtn.CtnList = ctns.Adapt<List<BookingSlotCtnSaveInput>>();
List<BookingLogDto> list = new List<BookingLogDto>();
var main = await _repBookingLog.AsQueryable().Where(u => u.BookingId == slotBase.Id).ToListAsync();
var mailidlist = main.Select(x => x.Id).ToList();
list = main.Adapt<List<BookingLogDto>>();
if (list != null)
{
var bookinglogdetail = await _repBookingLogDetail.AsQueryable().Where(x => mailidlist.Contains(x.PId)).ToListAsync();
foreach (var item in list)
{
var details = bookinglogdetail.Where(x => x.PId == item.Id).ToList();
item.details = details;
}
}
rtn.LogList = list;
return rtn; return rtn;
} }
@ -272,7 +293,7 @@ namespace Myshipping.Application
await _repCtn.InsertAsync(newCtn); await _repCtn.InsertAsync(newCtn);
} }
await InsLog("update", model.Id, typeof(BookingSlotBaseApiSaveDto), oldObj, dto.DataObj, "CtnList"); await InsLog("Update", model.Id, typeof(BookingSlotBaseApiSaveDto), oldObj, dto.DataObj, "CtnList");
} }
else if (dto.OpType == "del") else if (dto.OpType == "del")
{ {

@ -1,4 +1,5 @@
using Myshipping.Core; using Myshipping.Application.Service.BookingOrder.Dto;
using Myshipping.Core;
using SqlSugar; using SqlSugar;
using System; using System;
using System.Collections.Generic; using System.Collections.Generic;
@ -314,9 +315,9 @@ namespace Myshipping.Application.Service.BookingSlot.Dto
} }
/// <summary> /// <summary>
/// 保存舱位dto /// 保存舱位输入
/// </summary> /// </summary>
public class BookingSlotBaseSaveDto : BookingSlotBaseDto public class BookingSlotBaseSaveInput : BookingSlotBaseDto
{ {
/// <summary> /// <summary>
/// Id /// Id
@ -330,6 +331,17 @@ namespace Myshipping.Application.Service.BookingSlot.Dto
public List<BookingSlotCtnSaveInput> CtnList { get; set; } public List<BookingSlotCtnSaveInput> CtnList { get; set; }
} }
/// <summary>
/// 保存舱位输出
/// </summary>
public class BookingSlotBaseSaveOutput : BookingSlotBaseSaveInput
{
/// <summary>
/// 日志
/// </summary>
public List<BookingLogDto> LogList { get; set; }
}
public class BookingSlotBaseListOutput : BookingSlotBaseDto public class BookingSlotBaseListOutput : BookingSlotBaseDto
{ {
/// <summary> /// <summary>

Loading…
Cancel
Save