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.
77 lines
2.6 KiB
C#
77 lines
2.6 KiB
C#
using Furion.DependencyInjection;
|
|
using Furion.DynamicApiController;
|
|
using Furion.FriendlyException;
|
|
using Mapster;
|
|
using Microsoft.AspNetCore.Mvc;
|
|
using Myshipping.Application.Entity;
|
|
using Myshipping.Application.Service.MonthlyPayAccount.Dto;
|
|
using Myshipping.Core;
|
|
using System.Collections.Generic;
|
|
using System.ComponentModel.DataAnnotations;
|
|
using System.Linq;
|
|
using System.Threading.Tasks;
|
|
|
|
namespace Myshipping.Application
|
|
{
|
|
/// <summary>
|
|
/// 月结账户操作服务
|
|
/// </summary>
|
|
[ApiDescriptionSettings("Application", Name = "MonthlyPayAccount", Description = "月结账户操作服务", Order = 20)]
|
|
[Route("/MonthlyPayAccount")]
|
|
public class MonthlyPayAccountService : IMonthlyPayAccountService, IDynamicApiController, ITransient
|
|
{
|
|
|
|
private readonly SqlSugarRepository<MonthlyPayAccount> _monthlyRep;
|
|
private readonly string[] UpdateIgnoreColumns = new string[] { "CreatedTime", "CreatedUserId", "CreatedUserName", "TenantId" };
|
|
|
|
public MonthlyPayAccountService(SqlSugarRepository<MonthlyPayAccount> monthlyRep)
|
|
{
|
|
_monthlyRep = monthlyRep;
|
|
}
|
|
|
|
[HttpPost("SaveOrUpdate")]
|
|
public async Task SaveOrUpdate(MonthlyPayAccountDto input)
|
|
{
|
|
if (string.IsNullOrEmpty(input.Account))
|
|
{
|
|
throw Oops.Bah("户头不能为空");
|
|
}
|
|
if (string.IsNullOrWhiteSpace(input.CardNo))
|
|
{
|
|
throw Oops.Bah("卡号不能为空");
|
|
}
|
|
|
|
if (await _monthlyRep.IsExistsAsync(m => m.Account == input.Account && m.CardNo == input.CardNo))
|
|
{
|
|
throw Oops.Bah("已存在同户头同卡号的月结账户");
|
|
}
|
|
|
|
MonthlyPayAccount model = input.Adapt<MonthlyPayAccount>();
|
|
|
|
if ((input.Id ?? 0) == 0)
|
|
{
|
|
await _monthlyRep.InsertAsync(model);
|
|
}
|
|
else
|
|
{
|
|
await _monthlyRep.AsUpdateable(model).IgnoreColumns(UpdateIgnoreColumns).ExecuteCommandAsync();
|
|
}
|
|
}
|
|
|
|
[HttpGet("List")]
|
|
public async Task<List<MonthlyPayAccountDto>> List()
|
|
{
|
|
var modelList = await _monthlyRep.ToListAsync();
|
|
var result = modelList.Adapt<List<MonthlyPayAccountDto>>();
|
|
return result;
|
|
}
|
|
|
|
[HttpPost("Delete")]
|
|
public async Task Delete([Required] string ids)
|
|
{
|
|
long[] idArr = ids.Split(',').Adapt<long[]>();
|
|
await _monthlyRep.UpdateAsync(m => idArr.Contains(m.Id), m => new MonthlyPayAccount() { IsDeleted = true });
|
|
}
|
|
}
|
|
}
|