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
5d86f031
Commit
5d86f031
authored
Sep 23, 2021
by
黄奎
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
页面修改
parent
4189b2a8
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
113 additions
and
108 deletions
+113
-108
ApiRequestFromEnum.cs
Mall.Common/Enum/ApiRequestFromEnum.cs
+3
-10
CommerceConsultModule.cs
Mall.Module.TradePavilion/CommerceConsultModule.cs
+3
-0
RB_Commerce_ConsultRepository.cs
...Repository/TradePavilion/RB_Commerce_ConsultRepository.cs
+10
-0
ApiFilterAttribute.cs
Mall.WebApi/Filter/ApiFilterAttribute.cs
+41
-98
TokenHelper.cs
Mall.WebApi/Helper/TokenHelper.cs
+56
-0
No files found.
Mall.Common/Enum/ApiRequestFromEnum.cs
View file @
5d86f031
using
Mall.Common.Plugin
;
using
System
;
using
System.Collections.Generic
;
using
System.ComponentModel
;
using
System.IO
;
using
System.Linq
;
using
System.Text
;
namespace
Mall.Common.Enum
{
...
...
@@ -18,18 +12,17 @@ namespace Mall.Common.Enum
/// </summary>
[
EnumField
(
"Web端"
)]
Web
=
1
,
/// <summary>
/// 小程序
/// </summary>
[
EnumField
(
"小程序"
)]
MiniProgram
=
2
,
/// <summary>
/// erp
/// </summary>
[
EnumField
(
"erp"
)]
ERP
=
3
,
ERP
=
3
,
}
}
\ No newline at end of file
Mall.Module.TradePavilion/CommerceConsultModule.cs
View file @
5d86f031
...
...
@@ -77,6 +77,9 @@ namespace Mall.Module.TradePavilion
{
QActivityIds
=
activityIds
,
QUserIds
=
userids
,
CompanyName
=
query
.
CompanyName
,
LinkMan
=
query
.
LinkMan
,
UserId
=
query
.
UserId
,
});
foreach
(
var
item
in
userList
)
{
...
...
Mall.Repository/TradePavilion/RB_Commerce_ConsultRepository.cs
View file @
5d86f031
...
...
@@ -67,6 +67,11 @@ WHERE 1=1
builder
.
AppendFormat
(
" AND {0} LIKE @Name "
,
nameof
(
RB_Commerce_Consult_Extend
.
LinkMan
));
parameters
.
Add
(
"Name"
,
"%"
+
query
.
LinkMan
.
Trim
()
+
"%"
);
}
if
(!
string
.
IsNullOrEmpty
(
query
.
CompanyName
))
{
builder
.
AppendFormat
(
" AND {0} LIKE @CompanyName "
,
nameof
(
RB_Commerce_Consult_Extend
.
CompanyName
));
parameters
.
Add
(
"CompanyName"
,
"%"
+
query
.
CompanyName
.
Trim
()
+
"%"
);
}
if
(
query
.
ActivityId
>
0
)
{
builder
.
AppendFormat
(
" AND {0}={1} "
,
nameof
(
RB_Commerce_Consult_Extend
.
ActivityId
),
query
.
ActivityId
);
...
...
@@ -136,6 +141,11 @@ WHERE 1=1
builder
.
AppendFormat
(
" AND {0} LIKE @Name "
,
nameof
(
RB_Commerce_Consult_Extend
.
LinkMan
));
parameters
.
Add
(
"Name"
,
"%"
+
query
.
LinkMan
.
Trim
()
+
"%"
);
}
if
(!
string
.
IsNullOrEmpty
(
query
.
CompanyName
))
{
builder
.
AppendFormat
(
" AND {0} LIKE @CompanyName "
,
nameof
(
RB_Commerce_Consult_Extend
.
CompanyName
));
parameters
.
Add
(
"CompanyName"
,
"%"
+
query
.
CompanyName
.
Trim
()
+
"%"
);
}
if
(
query
.
ActivityId
>
0
)
{
builder
.
AppendFormat
(
" AND {0}={1} "
,
nameof
(
RB_Commerce_Consult_Extend
.
ActivityId
),
query
.
ActivityId
);
...
...
Mall.WebApi/Filter/ApiFilterAttribute.cs
View file @
5d86f031
...
...
@@ -108,67 +108,67 @@ namespace Mall.WebApi.Filter
});
}
}
}
#
region
签名校验权限校验
if
(
actionContext
.
HttpContext
.
Items
[
GlobalKey
.
TokenUserInfo
]
!=
null
)
{
string
openValidation
=
new
ConfigurationBuilder
().
Add
(
new
JsonConfigurationSource
{
Path
=
"appsettings.json"
}).
Build
().
GetSection
(
"OpenValidation"
).
Value
;
if
(
openValidation
.
Equals
(
"True"
))
{
string
openValidation
=
new
ConfigurationBuilder
().
Add
(
new
JsonConfigurationSource
{
Path
=
"appsettings.json"
}).
Build
().
GetSection
(
"OpenValidation"
).
Value
;
if
(
openValidation
.
Equals
(
"True"
))
TokenUserInfo
userInfo
=
JsonConvert
.
DeserializeObject
<
TokenUserInfo
>(
actionContext
.
HttpContext
.
Items
[
GlobalKey
.
TokenUserInfo
].
ToString
())
;
if
(
userInfo
!=
null
&&
(
userInfo
.
requestFrom
==
Mall
.
Common
.
Enum
.
ApiRequestFromEnum
.
Web
||
userInfo
.
requestFrom
==
Mall
.
Common
.
Enum
.
ApiRequestFromEnum
.
MiniProgram
))
{
TokenUserInfo
userInfo
=
JsonConvert
.
DeserializeObject
<
TokenUserInfo
>(
actionContext
.
HttpContext
.
Items
[
GlobalKey
.
TokenUserInfo
].
ToString
());
if
(
userInfo
!=
null
&&
(
userInfo
.
requestFrom
==
Mall
.
Common
.
Enum
.
ApiRequestFromEnum
.
Web
||
userInfo
.
requestFrom
==
Mall
.
Common
.
Enum
.
ApiRequestFromEnum
.
MiniProgram
))
{
SignValidat
(
actionContext
,
parm
);
}
else
{
#
region
权限校验
SignValidat
(
actionContext
,
parm
);
}
else
{
#
region
权限校验
if
(
userInfo
.
uid
!=
Config
.
AdminId
)
{
if
(
userInfo
.
uid
!=
Config
.
AdminId
)
{
SignValidat
(
actionContext
,
parm
);
//PermissionValidat(actionContext);
}
#
endregion
SignValidat
(
actionContext
,
parm
);
//PermissionValidat(actionContext);
}
#
endregion
}
}
#
endregion
}
#
endregion
#
region
验证表单重复提交
#
region
验证表单重复提交
string
controllerName
=
actionContext
.
ActionDescriptor
.
RouteValues
[
"controller"
].
ToString
().
ToLower
();
string
actionName
=
actionContext
.
ActionDescriptor
.
RouteValues
[
"action"
].
ToString
().
ToLower
();
if
(!
actionName
.
ToLower
().
Contains
(
"get"
))
string
controllerName
=
actionContext
.
ActionDescriptor
.
RouteValues
[
"controller"
].
ToString
().
ToLower
();
string
actionName
=
actionContext
.
ActionDescriptor
.
RouteValues
[
"action"
].
ToString
().
ToLower
();
if
(!
actionName
.
ToLower
().
Contains
(
"get"
))
{
string
cachedKey
=
SecurityHelper
.
MD5
(
string
.
Format
(
"cmd={0}&token={1}"
,
controllerName
+
"/"
+
actionName
,
token
));
try
{
string
cachedKey
=
SecurityHelper
.
MD5
(
string
.
Format
(
"cmd={0}&token={1}"
,
controllerName
+
"/"
+
actionName
,
token
));
try
if
(
UserReidsCache
.
Exists
(
cachedKey
))
//判断表单是否重复提交
{
if
(
UserReidsCache
.
Exists
(
cachedKey
))
//判断表单是否重复提交
{
actionContext
.
Result
=
new
Microsoft
.
AspNetCore
.
Mvc
.
JsonResult
(
new
ApiResult
{
resultCode
=
(
int
)
ResultCode
.
FormRepeatSubmit
,
message
=
"表单重复提交,请稍后再试"
,
data
=
null
});
}
else
actionContext
.
Result
=
new
Microsoft
.
AspNetCore
.
Mvc
.
JsonResult
(
new
ApiResult
{
//默认3秒钟之内不能重复提交
UserReidsCache
.
Set
(
cachedKey
,
1
,
3
);
}
resultCode
=
(
int
)
ResultCode
.
FormRepeatSubmit
,
message
=
"表单重复提交,请稍后再试"
,
data
=
null
});
}
catch
else
{
//默认3秒钟之内不能重复提交
UserReidsCache
.
Set
(
cachedKey
,
1
,
3
);
}
}
#
endregion
catch
{
}
}
#
endregion
}
/// <summary>
...
...
@@ -336,7 +336,7 @@ namespace Mall.WebApi.Filter
string
privateKey
=
""
;
//等封装了缓存再说
// UserInfo userInfo = UserReidsCache.GetUserLoginInfo(tokenUserInfo.uid);
// UserInfo userInfo = UserReidsCache.GetUserLoginInfo(tokenUserInfo.uid);
//if (userInfo != null)
//{
// privateKey = userInfo.SecretKey;
...
...
@@ -359,62 +359,5 @@ namespace Mall.WebApi.Filter
}
#
endregion
}
/// <summary>
/// 权限校验
/// </summary>
/// <param name="actionContext"></param>
private
static
void
PermissionValidat
(
ActionExecutingContext
actionContext
)
{
string
uid
=
actionContext
.
HttpContext
.
Items
[
GlobalKey
.
TokenUserInfo
]
!=
null
?
JsonConvert
.
DeserializeObject
<
TokenUserInfo
>(
actionContext
.
HttpContext
.
Items
[
GlobalKey
.
TokenUserInfo
].
ToString
()).
uid
:
"0"
;
//TODO查询用户权限
string
url
=
actionContext
.
HttpContext
.
Request
.
GetAbsoluteUri
();
bool
havPermission
=
true
;
//List<object> args = new List<object>() {
// uid
//};
//根据uid 判断用户是否拥有该权限
//Type type = (Type)_obj;
//MethodInfo meth = type.GetMethod(model.Method);
//try
//{
// permission = (string)meth.Invoke(Activator.CreateInstance(type), args.ToArray());
//}
//catch
//{
//}
//if (!string.IsNullOrWhiteSpace(permission))
//{
// if (permission.ToLower().Contains(url.ToLower()))
// {
// havPermission = true;
// }
// else//判断菜单是否存在
// {
// bool systemIsExit = RbUserCache.GetSystemHasMenu(url.ToLower());
// if (!systemIsExit)
// {
// havPermission = true;
// }
// }
//}
if
(
havPermission
==
false
)
{
actionContext
.
Result
=
new
Microsoft
.
AspNetCore
.
Mvc
.
JsonResult
(
new
ApiResult
{
resultCode
=
(
int
)
ResultCode
.
NoPermission
,
message
=
"权限不足"
,
data
=
null
});
}
}
}
}
\ No newline at end of file
Mall.WebApi/Helper/TokenHelper.cs
0 → 100644
View file @
5d86f031
using
JWT
;
using
JWT.Serializers
;
using
Mall.Common.API
;
using
Mall.Common.Plugin
;
using
Newtonsoft.Json.Linq
;
using
System
;
using
System.Collections.Generic
;
using
System.Linq
;
using
System.Threading.Tasks
;
namespace
Mall.WebApi.Helper
{
/// <summary>
/// Token帮助类
/// </summary>
public
class
TokenHelper
{
/// <summary>
/// 生成Token
/// </summary>
/// <returns></returns>
public
static
string
CreateToken
()
{
return
""
;
}
/// <summary>
/// 解析Token
/// </summary>
/// <param name="token"></param>
/// <returns></returns>
public
static
TokenUserInfo
ParsingToken
(
string
token
)
{
TokenUserInfo
tokenUser
=
new
TokenUserInfo
();
if
(
string
.
IsNullOrEmpty
(
token
))
{
IJsonSerializer
serializer
=
new
JsonNetSerializer
();
IDateTimeProvider
provider
=
new
UtcDateTimeProvider
();
IJwtValidator
validator
=
new
JwtValidator
(
serializer
,
provider
);
IBase64UrlEncoder
urlEncoder
=
new
JwtBase64UrlEncoder
();
IJwtDecoder
decoder
=
new
JwtDecoder
(
serializer
,
validator
,
urlEncoder
);
string
secret
=
Common
.
Config
.
JwtSecretKey
;
var
json
=
decoder
.
Decode
(
token
,
secret
,
verify
:
true
);
//token为之前生成的字符串
if
(!
string
.
IsNullOrEmpty
(
json
))
{
JObject
jwtJson
=
JObject
.
Parse
(
json
);
var
mall_userInfo
=
JObject
.
Parse
(
jwtJson
.
GetStringValue
(
"mall_userInfo"
));
tokenUser
.
requestFrom
=
(
Common
.
Enum
.
ApiRequestFromEnum
)
mall_userInfo
.
GetInt
(
"requestFrom"
);
tokenUser
.
uid
=
mall_userInfo
.
GetStringValue
(
"uid"
);
}
}
return
tokenUser
;
}
}
}
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