|
|
|
@ -8,6 +8,7 @@ using System.Linq;
|
|
|
|
|
using System.Threading.Tasks;
|
|
|
|
|
using Myshipping.Core.Entity;
|
|
|
|
|
using Microsoft.Extensions.Logging;
|
|
|
|
|
using Furion.FriendlyException;
|
|
|
|
|
|
|
|
|
|
namespace Myshipping.Core.Service
|
|
|
|
|
{
|
|
|
|
@ -42,24 +43,21 @@ namespace Myshipping.Core.Service
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// 增加网站账号维护(同一用户、同类型账号不会重复插入)
|
|
|
|
|
/// 增加网站账号维护(同一用户、同类型账号不允许重复)
|
|
|
|
|
/// </summary>
|
|
|
|
|
/// <param name="input"></param>
|
|
|
|
|
/// <returns></returns>
|
|
|
|
|
[HttpPost("/DjyWebsiteAccountConfig/add")]
|
|
|
|
|
public async Task Add(AddDjyWebsiteAccountConfigInput input)
|
|
|
|
|
{
|
|
|
|
|
var entity = _rep.FirstOrDefault(x => x.TypeCode == input.TypeCode && x.CreatedUserId == UserManager.UserId);
|
|
|
|
|
if (entity == null)
|
|
|
|
|
var cc = _rep.Count(x => x.TypeCode == input.TypeCode && x.CreatedUserId == UserManager.UserId);
|
|
|
|
|
if (cc > 0)
|
|
|
|
|
{
|
|
|
|
|
entity = input.Adapt<DjyWebsiteAccountConfig>();
|
|
|
|
|
await _rep.InsertAsync(entity);
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
entity = input.Adapt(entity);
|
|
|
|
|
await _rep.UpdateAsync(entity);
|
|
|
|
|
throw Oops.Bah("已存在同类型账号");
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
var entity = input.Adapt<DjyWebsiteAccountConfig>();
|
|
|
|
|
await _rep.InsertAsync(entity);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
@ -70,6 +68,12 @@ namespace Myshipping.Core.Service
|
|
|
|
|
[HttpPost("/DjyWebsiteAccountConfig/edit")]
|
|
|
|
|
public async Task Update(UpdateDjyWebsiteAccountConfigInput input)
|
|
|
|
|
{
|
|
|
|
|
var cc = _rep.Count(x => x.TypeCode == input.TypeCode && x.CreatedUserId == UserManager.UserId && x.Id != input.Id);
|
|
|
|
|
if (cc > 0)
|
|
|
|
|
{
|
|
|
|
|
throw Oops.Bah("已存在同类型账号");
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
var entity = input.Adapt<DjyWebsiteAccountConfig>();
|
|
|
|
|
await _rep.AsUpdateable(entity).IgnoreColumns(ignoreAllNullColumns: true).ExecuteCommandAsync();
|
|
|
|
|
}
|
|
|
|
|