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.
90 lines
3.3 KiB
C#
90 lines
3.3 KiB
C#
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;
|
|
|
|
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()
|
|
.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 Add(AddDjyWebsiteAccountConfigInput input)
|
|
{
|
|
var entity = _rep.FirstOrDefault(x => x.TypeCode == input.TypeCode && x.CreatedUserId == UserManager.UserId);
|
|
if (entity == null)
|
|
{
|
|
entity = input.Adapt<DjyWebsiteAccountConfig>();
|
|
await _rep.InsertAsync(entity);
|
|
}
|
|
else
|
|
{
|
|
entity = input.Adapt(entity);
|
|
await _rep.UpdateAsync(entity);
|
|
}
|
|
}
|
|
|
|
/// <summary>
|
|
/// 更新网站账号维护
|
|
/// </summary>
|
|
/// <param name="input"></param>
|
|
/// <returns></returns>
|
|
[HttpPost("/DjyWebsiteAccountConfig/edit")]
|
|
public async Task Update(UpdateDjyWebsiteAccountConfigInput input)
|
|
{
|
|
var entity = input.Adapt<DjyWebsiteAccountConfig>();
|
|
await _rep.AsUpdateable(entity).IgnoreColumns(ignoreAllNullColumns: true).ExecuteCommandAsync();
|
|
}
|
|
|
|
/// <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);
|
|
}
|
|
}
|
|
}
|