Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
M
mall.oytour.com
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
黄奎
mall.oytour.com
Commits
0c072646
Commit
0c072646
authored
Jul 14, 2020
by
吴春
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
提交代码
parent
c08e34a3
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
76 additions
and
76 deletions
+76
-76
UserInfo.cs
Mall.Common/API/UserInfo.cs
+14
-14
TenantController.cs
Mall.WebApi/Controllers/User/TenantController.cs
+62
-62
No files found.
Mall.Common/API/UserInfo.cs
View file @
0c072646
...
...
@@ -127,20 +127,20 @@ namespace Mall.Common
/// </summary>
public
int
EmpId
{
get
;
set
;
}
public
string
erptoken
{
get
;
set
;
}
/// <summary>
/// erp用户id
/// </summary>
public
int
ERPEmpId
{
get
;
set
;
}
/// <summary>
/// erp公司id
/// </summary>
public
int
ERPBranchId
{
get
;
set
;
}
/// <summary>
/// erp集团id
/// </summary>
public
int
ERPGroupId
{
get
;
set
;
}
//
public string erptoken { get; set; }
///
//
<summary>
///
//
erp用户id
///
//
</summary>
//
public int ERPEmpId { get; set; }
///
//
<summary>
///
//
erp公司id
///
//
</summary>
//
public int ERPBranchId { get; set; }
///
//
<summary>
///
//
erp集团id
///
//
</summary>
//
public int ERPGroupId { get; set; }
}
}
Mall.WebApi/Controllers/User/TenantController.cs
View file @
0c072646
...
...
@@ -77,7 +77,7 @@ namespace Mall.WebApi.Controllers.User
private
ProductModule
productModule
=
new
ProductModule
();
private
Module
.
Property
.
AuthorizeModule
authorizeModule
=
new
Module
.
Property
.
AuthorizeModule
();
//
private Module.Property.AuthorizeModule authorizeModule = new Module.Property.AuthorizeModule();
#
region
商户信息
[
AllowAnonymous
]
...
...
@@ -115,63 +115,63 @@ namespace Mall.WebApi.Controllers.User
#
region
add
by
:
W
2020
-
07
-
06
erp
授权信息
var
erpUserInfo
=
new
Mall
.
Model
.
Entity
.
Property
.
RB_Employee
();
string
erptoken
=
""
;
if
(
model
.
EmpId
>
0
)
{
//判断当前登录人是否有erp账号信息
var
authorizeModel
=
authorizeModule
.
GetAuthorizeList
(
new
Model
.
Extend
.
Property
.
RB_ERP_Authorize_Extend
{
TenantId
=
model
.
TenantId
,
MallBaseId
=
model
.
MallBaseId
,
MallUserId
=
model
.
EmpId
,
Type
=
1
}).
FirstOrDefault
();
if
(
authorizeModel
!=
null
&&
authorizeModel
.
Status
==
2
)
{
//先查询是否存在是否是登陆手机号登陆
erpUserInfo
=
authorizeModule
.
GetByLoginMobileAndPwd
(
authorizeModel
.
Account
,
authorizeModel
.
Password
,
authorizeModel
.
ERPGroupId
);
if
(
erpUserInfo
==
null
)
{
//再查询是否存在是否是账号登陆
erpUserInfo
=
authorizeModule
.
GetNewByAccountAndPwd
(
authorizeModel
.
Account
,
authorizeModel
.
Password
,
authorizeModel
.
ERPGroupId
);
}
if
(
erpUserInfo
!=
null
&&
!
string
.
IsNullOrWhiteSpace
(
erpUserInfo
.
EmLoginMobile
)
&&
erpUserInfo
.
IsLeave
==
0
)
{
TokenUserInfo
erpUserInfoToken
=
new
TokenUserInfo
{
uid
=
erpUserInfo
.
EmployeeId
.
ToString
(),
requestFrom
=
Common
.
Enum
.
ApiRequestFromEnum
.
ERP
};
#
region
JWT
IDateTimeProvider
erpprovider
=
new
UtcDateTimeProvider
();
var
erpnow
=
erpprovider
.
GetNow
().
AddMinutes
(-
1
);
var
erpunixEpoch
=
new
DateTime
(
1970
,
1
,
1
,
0
,
0
,
0
,
DateTimeKind
.
Utc
);
// or use JwtValidator.UnixEpoch
var
erpsecondsSinceEpoch
=
Math
.
Round
((
erpnow
-
erpunixEpoch
).
TotalSeconds
);
var
erppayload
=
new
Dictionary
<
string
,
object
>
{
{
"iat"
,
erpsecondsSinceEpoch
},
{
"exp"
,
erpsecondsSinceEpoch
+
Config
.
JwtExpirTime
},
{
"userInfo"
,
erpUserInfoToken
}
};
IJwtAlgorithm
erpalgorithm
=
new
HMACSHA256Algorithm
();
IJsonSerializer
erpserializer
=
new
JsonNetSerializer
();
IBase64UrlEncoder
erpurlEncoder
=
new
JwtBase64UrlEncoder
();
IJwtEncoder
erpencoder
=
new
JwtEncoder
(
erpalgorithm
,
erpserializer
,
erpurlEncoder
);
string
erpsecret
=
Config
.
JwtSecretKey
;
erptoken
=
erpencoder
.
Encode
(
erppayload
,
erpsecret
);
#
endregion
//ERPUserInfo erpObj = new ERPUserInfo
//{
// Domain = authorizeModel.DomainName,
// emName = erpUserInfo.EmName,
// EmployeeId = erpUserInfo.EmployeeId,
// RB_Group_id = erpUserInfo.RB_Group_id,
// RB_Branch_id = erpUserInfo.RB_Branch_id,
// RB_Post_Id = erpUserInfo.RB_Post_Id,
// RB_Department_Id = erpUserInfo.RB_Department_Id,
// token = erptoken,
// SecretKey = erpUserInfo.SecretKey,
// //ImAccount = imAccount?.AccID ?? model.EmLoginMobile, //model.EmLoginMobile,
// //ImToken = IMService.DefaultPassword(),
//};
//UserReidsCache.UserInfoSet(UserModuleCacheKeyConfig.ERP_Login_Info_+ erpUserInfo.EmployeeId, erpObj, Config.JwtExpirTime);
}
}
}
//
var erpUserInfo = new Mall.Model.Entity.Property.RB_Employee();
//
string erptoken = "";
//
if (model.EmpId > 0)
//
{
//
//判断当前登录人是否有erp账号信息
//
var authorizeModel = authorizeModule.GetAuthorizeList(new Model.Extend.Property.RB_ERP_Authorize_Extend { TenantId = model.TenantId, MallBaseId = model.MallBaseId, MallUserId = model.EmpId, Type = 1 }).FirstOrDefault();
//
if (authorizeModel != null && authorizeModel.Status == 2)
//
{
//
//先查询是否存在是否是登陆手机号登陆
//
erpUserInfo = authorizeModule.GetByLoginMobileAndPwd(authorizeModel.Account, authorizeModel.Password, authorizeModel.ERPGroupId);
//
if (erpUserInfo == null)
//
{
//
//再查询是否存在是否是账号登陆
//
erpUserInfo = authorizeModule.GetNewByAccountAndPwd(authorizeModel.Account, authorizeModel.Password, authorizeModel.ERPGroupId);
//
}
//
if (erpUserInfo != null && !string.IsNullOrWhiteSpace(erpUserInfo.EmLoginMobile) && erpUserInfo.IsLeave == 0)
//
{
//
TokenUserInfo erpUserInfoToken = new TokenUserInfo { uid = erpUserInfo.EmployeeId.ToString(), requestFrom = Common.Enum.ApiRequestFromEnum.ERP };
//
#region JWT
//
IDateTimeProvider erpprovider = new UtcDateTimeProvider();
//
var erpnow = erpprovider.GetNow().AddMinutes(-1);
//
var erpunixEpoch = new DateTime(1970, 1, 1, 0, 0, 0, DateTimeKind.Utc); // or use JwtValidator.UnixEpoch
//
var erpsecondsSinceEpoch = Math.Round((erpnow - erpunixEpoch).TotalSeconds);
//
var erppayload = new Dictionary<string, object>
//
{
//
{"iat",erpsecondsSinceEpoch },
//
{"exp",erpsecondsSinceEpoch+Config.JwtExpirTime},
//
{"userInfo",erpUserInfoToken }
//
};
//
IJwtAlgorithm erpalgorithm = new HMACSHA256Algorithm();
//
IJsonSerializer erpserializer = new JsonNetSerializer();
//
IBase64UrlEncoder erpurlEncoder = new JwtBase64UrlEncoder();
//
IJwtEncoder erpencoder = new JwtEncoder(erpalgorithm, erpserializer, erpurlEncoder);
//
string erpsecret = Config.JwtSecretKey;
//
erptoken = erpencoder.Encode(erppayload, erpsecret);
//
#endregion
//
//ERPUserInfo erpObj = new ERPUserInfo
//
//{
//
// Domain = authorizeModel.DomainName,
//
// emName = erpUserInfo.EmName,
//
// EmployeeId = erpUserInfo.EmployeeId,
//
// RB_Group_id = erpUserInfo.RB_Group_id,
//
// RB_Branch_id = erpUserInfo.RB_Branch_id,
//
// RB_Post_Id = erpUserInfo.RB_Post_Id,
//
// RB_Department_Id = erpUserInfo.RB_Department_Id,
//
// token = erptoken,
//
// SecretKey = erpUserInfo.SecretKey,
//
// //ImAccount = imAccount?.AccID ?? model.EmLoginMobile, //model.EmLoginMobile,
//
// //ImToken = IMService.DefaultPassword(),
//
//};
//
//UserReidsCache.UserInfoSet(UserModuleCacheKeyConfig.ERP_Login_Info_+ erpUserInfo.EmployeeId, erpObj, Config.JwtExpirTime);
//
}
//
}
//
}
#
endregion
...
...
@@ -210,10 +210,10 @@ namespace Mall.WebApi.Controllers.User
SecretKey
=
""
,
MallBaseId
=
0
,
EmpId
=
model
.
EmpId
,
erptoken
=
erptoken
,
ERPEmpId
=
erpUserInfo
.
EmployeeId
,
ERPBranchId
=
erpUserInfo
.
RB_Branch_id
,
ERPGroupId
=
erpUserInfo
.
RB_Group_id
//
erptoken = erptoken,
//
ERPEmpId = erpUserInfo.EmployeeId,
//
ERPBranchId = erpUserInfo.RB_Branch_id,
//
ERPGroupId = erpUserInfo.RB_Group_id
};
UserReidsCache
.
UserInfoSet
(
UserModuleCacheKeyConfig
.
Mall_Login_Info
+
model
.
TenantId
,
obj
,
Config
.
JwtExpirTime
);
return
ApiResult
.
Success
(
""
,
obj
);
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment