diff --git a/Myshipping.Application/Myshipping.Application.xml b/Myshipping.Application/Myshipping.Application.xml index 9cd8a635..cf3b89a9 100644 --- a/Myshipping.Application/Myshipping.Application.xml +++ b/Myshipping.Application/Myshipping.Application.xml @@ -9963,6 +9963,191 @@ 租户ID + + + 数据同步服务 + + + + + 订舱客户同步 + + + + + 主键 + + + + + 代码 + + + + + 简称 + + + + + 全称 + + + + + 负责人 + + + + + 电话 + + + + + 邮箱 + + + + + QQ + + + + + 网址 + + + + + 省份 + + + + + 城市 + + + + + 地址 + + + + + 英文全名 + + + + + 英文地址 + + + + + 属性字符串 + + + + + 发票抬头 + + + + + 纳税人识别号 + + + + + 发票地址电话 + + + + + 人民币开户行 + + + + + 人民币账号 + + + + + 美元开户行 + + + + + 美元账号 + + + + + 备注 + + + + + 联系人 + + + + + 订舱客户联系人同步 + + + + + 主键 + + + + + 客户Id + + + + + 角色ID + + + + + 角色名称 + + + + + 名称 + + + + + 电话 + + + + + 邮箱 + + + + + QQ + + + + + 排序号 + + + + + 备注 + + 主键 diff --git a/Myshipping.Application/Service/DataSync/DataSyncService.cs b/Myshipping.Application/Service/DataSync/DataSyncService.cs new file mode 100644 index 00000000..d343a194 --- /dev/null +++ b/Myshipping.Application/Service/DataSync/DataSyncService.cs @@ -0,0 +1,85 @@ +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.Application.Entity; +using Microsoft.AspNetCore.Authorization; +using Furion; +using Microsoft.AspNetCore.Http; +using Furion.DataEncryption; +using System.Collections.Generic; +using System.Security.Claims; +using Microsoft.AspNetCore.Authentication.Cookies; +using Microsoft.AspNetCore.Authentication; +using Microsoft.AspNetCore.Identity; +using Furion.FriendlyException; +using Furion.Logging; +using System; +using Microsoft.Extensions.Logging; +using System.Reflection; +using System.ComponentModel; +using Myshipping.Application.Service.BookingOrder.Dto; +using Myshipping.Application.ConfigOption; +using System.IO; +using Yitter.IdGenerator; +using Myshipping.Core.Entity; +using Furion.RemoteRequest.Extensions; +using System.Net.Http; +using Myshipping.Core.Service; + + +namespace Myshipping.Application +{ + /// + /// 数据同步服务 + /// + [ApiDescriptionSettings("Application", Name = "DataSync", Order = 1), AllowAnonymous] + public class DataSyncService : IDynamicApiController, ITransient + { + private readonly ILogger _logger; + private readonly ISysCacheService _cache; + private readonly SqlSugarRepository _rep; + private readonly SqlSugarRepository _repCtn; + private readonly SqlSugarRepository _repUser; + private readonly SqlSugarRepository _repTenant; + + public DataSyncService(ILogger logger, ISysCacheService cache, SqlSugarRepository rep, SqlSugarRepository repCtn, + SqlSugarRepository repUser, SqlSugarRepository repTenant) + { + this._logger = logger; + this._rep = rep; + this._repCtn = repCtn; + this._cache = cache; + this._repUser = repUser; + this._repTenant = repTenant; + } + + + #region 上传数据 + + [HttpPost("/DataSync/SyncCustomer"), ApiUser] + public async Task SyncCustomer(DjyCustomerSyncDto model) + { + + return 0; + } + + #endregion + + #region 下载数据 + + #endregion + + #region 其他 + [HttpGet("/DataSync/Test"), ApiUser] + public async Task Test() + { + return $"当前用户:{UserManager.UserId} {UserManager.Name} ,当前租户:{UserManager.TENANT_ID} {UserManager.TENANT_NAME},管理员类型:{(UserManager.IsSuperAdmin ? "超级管理员" : (UserManager.IsTenantAdmin ? "租户管理员" : "普通用户"))}"; + } + #endregion + } +} diff --git a/Myshipping.Application/Service/DataSync/Dto/DjyCustomerDto.cs b/Myshipping.Application/Service/DataSync/Dto/DjyCustomerDto.cs new file mode 100644 index 00000000..38ddd492 --- /dev/null +++ b/Myshipping.Application/Service/DataSync/Dto/DjyCustomerDto.cs @@ -0,0 +1,190 @@ +using System; +using System.Collections.Generic; +using Myshipping.Core; + +namespace Myshipping.Application +{ + /// + /// 订舱客户同步 + /// + public class DjyCustomerSyncDto + { + /// + /// 主键 + /// + public long? Id { get; set; } + + /// + /// 代码 + /// + public string CodeName { get; set; } + + /// + /// 简称 + /// + public string ShortName { get; set; } + + /// + /// 全称 + /// + public string FullName { get; set; } + + /// + /// 负责人 + /// + public string Chief { get; set; } + + /// + /// 电话 + /// + public string Tel { get; set; } + + /// + /// 邮箱 + /// + public string Email { get; set; } + + /// + /// QQ + /// + public string QQ { get; set; } + + /// + /// 网址 + /// + public string WebUrl { get; set; } + + /// + /// 省份 + /// + public string Province { get; set; } + + /// + /// 城市 + /// + public string City { get; set; } + + /// + /// 地址 + /// + public string Addr { get; set; } + + /// + /// 英文全名 + /// + public string FullNameEN { get; set; } + + /// + /// 英文地址 + /// + public string AddrEN { get; set; } + + /// + /// 属性字符串 + /// + public string PropString { get; set; } + + /// + /// 发票抬头 + /// + public string InvTitle { get; set; } + + /// + /// 纳税人识别号 + /// + public string TaxNO { get; set; } + + /// + /// 发票地址电话 + /// + public string InvAddrTel { get; set; } + + /// + /// 人民币开户行 + /// + public string RMBBank { get; set; } + + /// + /// 人民币账号 + /// + public string RmbAccount { get; set; } + + /// + /// 美元开户行 + /// + public string USDBank { get; set; } + + /// + /// 美元账号 + /// + public string USDAccount { get; set; } + + /// + /// 备注 + /// + public string Remark { get; set; } + + /// + /// 联系人 + /// + public List ContactList { get; set; } + } + + /// + /// 订舱客户联系人同步 + /// + public class DjyCustomerContactSyncDto + { + /// + /// 主键 + /// + public long? Id { get; set; } + + /// + /// 客户Id + /// + public long? CustomerId { get; set; } + + /// + /// 角色ID + /// + public string RoleCode { get; set; } + + /// + /// 角色名称 + /// + public string RoleName { get; set; } + + /// + /// 名称 + /// + public string Name { get; set; } + + /// + /// 电话 + /// + public string Tel { get; set; } + + /// + /// 邮箱 + /// + public string Email { get; set; } + + /// + /// QQ + /// + public string QQ { get; set; } + + /// + /// 排序号 + /// + public int? Sort { get; set; } + + /// + /// 备注 + /// + public string Remark { get; set; } + + + } +} diff --git a/Myshipping.Core/Filter/ApiUserFilter.cs b/Myshipping.Core/Filter/ApiUserFilter.cs index b3514675..210c8f6e 100644 --- a/Myshipping.Core/Filter/ApiUserFilter.cs +++ b/Myshipping.Core/Filter/ApiUserFilter.cs @@ -2,6 +2,7 @@ using Microsoft.AspNetCore.Http; using Microsoft.AspNetCore.Mvc.Controllers; using Microsoft.AspNetCore.Mvc.Filters; +using Myshipping.Core.Entity; using System; using System.Collections.Generic; using System.Linq; @@ -25,14 +26,20 @@ namespace Myshipping.Core { var httpContext = App.GetService().HttpContext; + var repTenant = App.GetService>(); + var repUser = App.GetService>(); + + var tenant = repTenant.AsQueryable().Filter(null, true).First(x => x.Id == 142307070918780L); + var user = repUser.AsQueryable().Filter(null, true).First(x => x.Id == 142307070910551L); + ClaimsIdentity identity = new ClaimsIdentity("AuthenticationTypes.Federation"); - identity.AddClaim(new Claim(type: ClaimConst.CLAINM_USERID, value: "111")); - identity.AddClaim(new Claim(type: ClaimConst.TENANT_ID, value: "10")); - identity.AddClaim(new Claim(type: ClaimConst.CLAINM_ACCOUNT, value: "admin")); - identity.AddClaim(new Claim(type: ClaimConst.CLAINM_NAME, value: "管理员")); - identity.AddClaim(new Claim(type: ClaimConst.CLAINM_SUPERADMIN, value: AdminType.Admin.ToString())); - identity.AddClaim(new Claim(type: ClaimConst.CLAINM_TENANT_TYPE, value: TenantTypeEnum.SYSTEM.ToString())); - identity.AddClaim(new Claim(type: ClaimConst.TENANT_NAME, value: "测试")); + identity.AddClaim(new Claim(type: ClaimConst.CLAINM_USERID, value: user.Id.ToString())); + identity.AddClaim(new Claim(type: ClaimConst.CLAINM_ACCOUNT, value: user.Account)); + identity.AddClaim(new Claim(type: ClaimConst.CLAINM_NAME, value: user.Name)); + identity.AddClaim(new Claim(type: ClaimConst.CLAINM_SUPERADMIN, value: ((int)user.AdminType).ToString())); + identity.AddClaim(new Claim(type: ClaimConst.CLAINM_TENANT_TYPE, value: tenant.TenantType.ToString())); + identity.AddClaim(new Claim(type: ClaimConst.TENANT_ID, value: tenant.Id.ToString())); + identity.AddClaim(new Claim(type: ClaimConst.TENANT_NAME, value: tenant.Name)); ClaimsPrincipal claimsPrincipal = new ClaimsPrincipal(identity); httpContext.User = claimsPrincipal; }