网站账号修改

booking_auth_dev
wanghaomei 2 years ago
parent 695e351520
commit a53a6fd1ad

@ -8520,7 +8520,7 @@
</member>
<member name="M:Myshipping.Core.Service.DjyWebsiteAccountConfigService.Add(Myshipping.Core.Service.AddDjyWebsiteAccountConfigInput)">
<summary>
增加网站账号维护(同一用户、同类型账号不会重复插入
增加网站账号维护(同一用户、同类型账号不允许重复
</summary>
<param name="input"></param>
<returns></returns>

@ -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();
}

Loading…
Cancel
Save