|
|
|
|
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.Core.Entity;
|
|
|
|
|
using Microsoft.Extensions.Logging;
|
|
|
|
|
using Furion.FriendlyException;
|
|
|
|
|
|
|
|
|
|
namespace Myshipping.Core.Service
|
|
|
|
|
{
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// 网站账号维护服务
|
|
|
|
|
/// </summary>
|
|
|
|
|
[ApiDescriptionSettings(Name = "DjyWebsiteAccountConfig", Order = 1)]
|
|
|
|
|
public class DjyWebsiteAccountConfigService : IDjyWebsiteAccountConfigService, IDynamicApiController, ITransient
|
|
|
|
|
{
|
|
|
|
|
private readonly SqlSugarRepository<DjyWebsiteAccountConfig> _rep;
|
|
|
|
|
private readonly ILogger<DjyWebsiteAccountConfig> _logger;
|
|
|
|
|
|
|
|
|
|
public DjyWebsiteAccountConfigService(SqlSugarRepository<DjyWebsiteAccountConfig> rep, ILogger<DjyWebsiteAccountConfig> logger)
|
|
|
|
|
{
|
|
|
|
|
_rep = rep;
|
|
|
|
|
_logger = logger;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// 分页查询网站账号维护
|
|
|
|
|
/// </summary>
|
|
|
|
|
/// <param name="input"></param>
|
|
|
|
|
/// <returns></returns>
|
|
|
|
|
[HttpGet("/DjyWebsiteAccountConfig/page")]
|
|
|
|
|
public async Task<dynamic> Page([FromQuery] QueryDjyWebsiteAccountConfigInput input)
|
|
|
|
|
{
|
|
|
|
|
var entities = await _rep.AsQueryable()
|
|
|
|
|
.Where(m => m.CreatedUserId == UserManager.UserId)
|
|
|
|
|
.WhereIF(!string.IsNullOrWhiteSpace(input.TypeCode), u => u.TypeCode == input.TypeCode)
|
|
|
|
|
.WhereIF(!string.IsNullOrWhiteSpace(input.Account), u => u.Account.Contains(input.Account.Trim()))
|
|
|
|
|
.ToPagedListAsync(input.PageNo, input.PageSize);
|
|
|
|
|
return entities.XnPagedResult();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// 增加网站账号维护(同一用户、同类型账号不允许重复)
|
|
|
|
|
/// </summary>
|
|
|
|
|
/// <param name="input"></param>
|
|
|
|
|
/// <returns></returns>
|
|
|
|
|
[HttpPost("/DjyWebsiteAccountConfig/add")]
|
|
|
|
|
public async Task<long> Add(AddDjyWebsiteAccountConfigInput input)
|
|
|
|
|
{
|
|
|
|
|
var cc = _rep.Count(x => x.TypeCode == input.TypeCode && x.CreatedUserId == UserManager.UserId);
|
|
|
|
|
if (cc > 0)
|
|
|
|
|
{
|
|
|
|
|
throw Oops.Bah("已存在同类型账号");
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
var entity = input.Adapt<DjyWebsiteAccountConfig>();
|
|
|
|
|
await _rep.InsertAsync(entity);
|
|
|
|
|
return entity.Id;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// 更新网站账号维护
|
|
|
|
|
/// </summary>
|
|
|
|
|
/// <param name="input"></param>
|
|
|
|
|
/// <returns></returns>
|
|
|
|
|
[HttpPost("/DjyWebsiteAccountConfig/edit")]
|
|
|
|
|
public async Task<long> 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();
|
|
|
|
|
return entity.Id;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// 删除网站账号维护
|
|
|
|
|
/// </summary>
|
|
|
|
|
/// <param name="input"></param>
|
|
|
|
|
/// <returns></returns>
|
|
|
|
|
[HttpPost("/DjyWebsiteAccountConfig/delete")]
|
|
|
|
|
public async Task Delete(GetDjyWebsiteAccountConfigInput input)
|
|
|
|
|
{
|
|
|
|
|
var entity = await _rep.FirstOrDefaultAsync(u => u.Id == input.Id);
|
|
|
|
|
await _rep.DeleteAsync(entity);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|