api授权接口

optimize
wanghaomei 2 years ago
parent 15d221df26
commit 645534fcf7

@ -9963,6 +9963,191 @@
租户ID
</summary>
</member>
<member name="T:Myshipping.Application.DataSyncService">
<summary>
数据同步服务
</summary>
</member>
<member name="T:Myshipping.Application.DjyCustomerSyncDto">
<summary>
订舱客户同步
</summary>
</member>
<member name="P:Myshipping.Application.DjyCustomerSyncDto.Id">
<summary>
主键
</summary>
</member>
<member name="P:Myshipping.Application.DjyCustomerSyncDto.CodeName">
<summary>
代码
</summary>
</member>
<member name="P:Myshipping.Application.DjyCustomerSyncDto.ShortName">
<summary>
简称
</summary>
</member>
<member name="P:Myshipping.Application.DjyCustomerSyncDto.FullName">
<summary>
全称
</summary>
</member>
<member name="P:Myshipping.Application.DjyCustomerSyncDto.Chief">
<summary>
负责人
</summary>
</member>
<member name="P:Myshipping.Application.DjyCustomerSyncDto.Tel">
<summary>
电话
</summary>
</member>
<member name="P:Myshipping.Application.DjyCustomerSyncDto.Email">
<summary>
邮箱
</summary>
</member>
<member name="P:Myshipping.Application.DjyCustomerSyncDto.QQ">
<summary>
QQ
</summary>
</member>
<member name="P:Myshipping.Application.DjyCustomerSyncDto.WebUrl">
<summary>
网址
</summary>
</member>
<member name="P:Myshipping.Application.DjyCustomerSyncDto.Province">
<summary>
省份
</summary>
</member>
<member name="P:Myshipping.Application.DjyCustomerSyncDto.City">
<summary>
城市
</summary>
</member>
<member name="P:Myshipping.Application.DjyCustomerSyncDto.Addr">
<summary>
地址
</summary>
</member>
<member name="P:Myshipping.Application.DjyCustomerSyncDto.FullNameEN">
<summary>
英文全名
</summary>
</member>
<member name="P:Myshipping.Application.DjyCustomerSyncDto.AddrEN">
<summary>
英文地址
</summary>
</member>
<member name="P:Myshipping.Application.DjyCustomerSyncDto.PropString">
<summary>
属性字符串
</summary>
</member>
<member name="P:Myshipping.Application.DjyCustomerSyncDto.InvTitle">
<summary>
发票抬头
</summary>
</member>
<member name="P:Myshipping.Application.DjyCustomerSyncDto.TaxNO">
<summary>
纳税人识别号
</summary>
</member>
<member name="P:Myshipping.Application.DjyCustomerSyncDto.InvAddrTel">
<summary>
发票地址电话
</summary>
</member>
<member name="P:Myshipping.Application.DjyCustomerSyncDto.RMBBank">
<summary>
人民币开户行
</summary>
</member>
<member name="P:Myshipping.Application.DjyCustomerSyncDto.RmbAccount">
<summary>
人民币账号
</summary>
</member>
<member name="P:Myshipping.Application.DjyCustomerSyncDto.USDBank">
<summary>
美元开户行
</summary>
</member>
<member name="P:Myshipping.Application.DjyCustomerSyncDto.USDAccount">
<summary>
美元账号
</summary>
</member>
<member name="P:Myshipping.Application.DjyCustomerSyncDto.Remark">
<summary>
备注
</summary>
</member>
<member name="P:Myshipping.Application.DjyCustomerSyncDto.ContactList">
<summary>
联系人
</summary>
</member>
<member name="T:Myshipping.Application.DjyCustomerContactSyncDto">
<summary>
订舱客户联系人同步
</summary>
</member>
<member name="P:Myshipping.Application.DjyCustomerContactSyncDto.Id">
<summary>
主键
</summary>
</member>
<member name="P:Myshipping.Application.DjyCustomerContactSyncDto.CustomerId">
<summary>
客户Id
</summary>
</member>
<member name="P:Myshipping.Application.DjyCustomerContactSyncDto.RoleCode">
<summary>
角色ID
</summary>
</member>
<member name="P:Myshipping.Application.DjyCustomerContactSyncDto.RoleName">
<summary>
角色名称
</summary>
</member>
<member name="P:Myshipping.Application.DjyCustomerContactSyncDto.Name">
<summary>
名称
</summary>
</member>
<member name="P:Myshipping.Application.DjyCustomerContactSyncDto.Tel">
<summary>
电话
</summary>
</member>
<member name="P:Myshipping.Application.DjyCustomerContactSyncDto.Email">
<summary>
邮箱
</summary>
</member>
<member name="P:Myshipping.Application.DjyCustomerContactSyncDto.QQ">
<summary>
QQ
</summary>
</member>
<member name="P:Myshipping.Application.DjyCustomerContactSyncDto.Sort">
<summary>
排序号
</summary>
</member>
<member name="P:Myshipping.Application.DjyCustomerContactSyncDto.Remark">
<summary>
备注
</summary>
</member>
<member name="P:Myshipping.Application.ParaContractNoDto.Id">
<summary>
主键

@ -73,5 +73,13 @@ namespace Myshipping.Application
#region 下载数据
#endregion
#region 其他
[HttpGet("/DataSync/Test"), ApiUser]
public async Task<string> Test()
{
return $"当前用户:{UserManager.UserId} {UserManager.Name} ,当前租户:{UserManager.TENANT_ID} {UserManager.TENANT_NAME},管理员类型:{(UserManager.IsSuperAdmin ? "" : (UserManager.IsTenantAdmin ? "" : ""))}";
}
#endregion
}
}

@ -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;
@ -20,19 +21,25 @@ namespace Myshipping.Core
{
if (metadata.GetType() == typeof(ApiUserAttribute))
{
if (context.HttpContext.Request.Headers.ContainsKey(CommonConst.API_USER_HEADER_KEY)
&& context.HttpContext.Request.Headers.ContainsKey(CommonConst.API_USER_HEADER_SECRET))
//if (context.HttpContext.Request.Headers.ContainsKey(CommonConst.API_USER_HEADER_KEY)
//&& context.HttpContext.Request.Headers.ContainsKey(CommonConst.API_USER_HEADER_SECRET))
{
var httpContext = App.GetService<IHttpContextAccessor>().HttpContext;
var repTenant = App.GetService<SqlSugarRepository<SysTenant>>();
var repUser = App.GetService<SqlSugarRepository<SysUser>>();
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;
}

Loading…
Cancel
Save