|
|
|
|
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 Furion.FriendlyException;
|
|
|
|
|
using Myshipping.Application.Enum;
|
|
|
|
|
using System.ComponentModel;
|
|
|
|
|
using System.Collections.Generic;
|
|
|
|
|
using System.IO;
|
|
|
|
|
using MiniExcelLibs;
|
|
|
|
|
using NPOI.HSSF.UserModel;
|
|
|
|
|
using Myshipping.Core.Helper;
|
|
|
|
|
using NPOI.SS.UserModel;
|
|
|
|
|
using Furion;
|
|
|
|
|
using System;
|
|
|
|
|
using System.Web;
|
|
|
|
|
using System.Text;
|
|
|
|
|
using Myshipping.Application.ConfigOption;
|
|
|
|
|
using Myshipping.Core.Service;
|
|
|
|
|
|
|
|
|
|
namespace Myshipping.Application
|
|
|
|
|
{
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// 订舱业务来源服务
|
|
|
|
|
/// </summary>
|
|
|
|
|
[ApiDescriptionSettings("Application", Name = "BookingSource", Order = 1)]
|
|
|
|
|
public class BookingSourceService : IBookingSourceService, IDynamicApiController, ITransient
|
|
|
|
|
{
|
|
|
|
|
private readonly SqlSugarRepository<BookingSource> _rep;
|
|
|
|
|
private readonly ILogger<BookingSource> _logger;
|
|
|
|
|
private readonly ISysCacheService _cache;
|
|
|
|
|
|
|
|
|
|
public BookingSourceService(SqlSugarRepository<BookingSource> rep, ILogger<BookingSource> logger, ISysCacheService cache)
|
|
|
|
|
{
|
|
|
|
|
_rep = rep;
|
|
|
|
|
_logger = logger;
|
|
|
|
|
_cache = cache;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// 分页查询订舱业务来源
|
|
|
|
|
/// </summary>
|
|
|
|
|
/// <param name="input"></param>
|
|
|
|
|
/// <returns></returns>
|
|
|
|
|
[HttpGet("/BookingSource/page")]
|
|
|
|
|
public async Task<dynamic> Page([FromQuery] QueryBookingSourceInput input)
|
|
|
|
|
{
|
|
|
|
|
var entities = await _rep.AsQueryable()
|
|
|
|
|
.WhereIF(!string.IsNullOrEmpty(input.Code), u => u.Code.Contains(input.Code))
|
|
|
|
|
.WhereIF(!string.IsNullOrEmpty(input.Name), u => u.Name.Contains(input.Name))
|
|
|
|
|
.ToPagedListAsync(input.PageNo, input.PageSize);
|
|
|
|
|
return entities.XnPagedResult();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// 保存订舱业务来源
|
|
|
|
|
/// </summary>
|
|
|
|
|
/// <param name="input"></param>
|
|
|
|
|
/// <returns></returns>
|
|
|
|
|
[HttpPost("/BookingSource/save")]
|
|
|
|
|
public async Task<long> Save(SaveBookingSourceInput input)
|
|
|
|
|
{
|
|
|
|
|
BookingSource model = null;
|
|
|
|
|
if (input.Id > 0)
|
|
|
|
|
{
|
|
|
|
|
if (_rep.Count(x => x.Code == input.Code && x.Id != input.Id) > 0)
|
|
|
|
|
{
|
|
|
|
|
throw Oops.Bah($"已存在相同代码:{input.Code}");
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
model = _rep.FirstOrDefault(x => x.Id == input.Id);
|
|
|
|
|
|
|
|
|
|
input.Adapt(model);
|
|
|
|
|
|
|
|
|
|
await _rep.UpdateAsync(model);
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
if (_rep.Count(x => x.Code == input.Code) > 0)
|
|
|
|
|
{
|
|
|
|
|
throw Oops.Bah($"已存在相同代码:{input.Code}");
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
model = input.Adapt<BookingSource>();
|
|
|
|
|
await _rep.InsertAsync(model);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return model.Id;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// 删除订舱业务来源
|
|
|
|
|
/// </summary>
|
|
|
|
|
/// <param name="id"></param>
|
|
|
|
|
/// <returns></returns>
|
|
|
|
|
[HttpPost("/BookingSource/delete")]
|
|
|
|
|
public async Task Delete(long id)
|
|
|
|
|
{
|
|
|
|
|
var entity = await _rep.FirstOrDefaultAsync(u => u.Id == id);
|
|
|
|
|
entity.IsDeleted = true;
|
|
|
|
|
await _rep.UpdateAsync(entity);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// 获取订舱业务来源
|
|
|
|
|
/// </summary>
|
|
|
|
|
/// <param name="id"></param>
|
|
|
|
|
/// <returns></returns>
|
|
|
|
|
[HttpGet("/BookingSource/detail")]
|
|
|
|
|
public async Task<BookingSource> Get(long id)
|
|
|
|
|
{
|
|
|
|
|
return await _rep.FirstOrDefaultAsync(u => u.Id == id);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
}
|