Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
E
Education
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
黄奎
Education
Commits
45f2b0e0
Commit
45f2b0e0
authored
Aug 16, 2021
by
罗超
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
修改部分功能
parent
fb4030f0
Hide whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
109 additions
and
12 deletions
+109
-12
UserReidsCache.cs
Edu.Cache/User/UserReidsCache.cs
+1
-3
Config.cs
Edu.Common/Config.cs
+11
-0
QYWeChatModule.cs
Edu.Module.QYWeChat/QYWeChatModule.cs
+5
-1
QYWeiXinHelper.cs
Edu.ThirdCore/QYWinXin/QYWeiXinHelper.cs
+30
-2
QYWeChatController.cs
Edu.WebApi/Controllers/QYWeChat/QYWeChatController.cs
+61
-6
appsettings.json
Edu.WebApi/appsettings.json
+1
-0
No files found.
Edu.Cache/User/UserReidsCache.cs
View file @
45f2b0e0
...
...
@@ -84,9 +84,7 @@ namespace Edu.Cache.User
/// 获取缓存
/// </summary>
/// <param name="cacheKey"></param>
/// <param name="Data"></param>
/// <param name="JwtExpirTime"></param>
public
static
object
Get
(
string
cacheKey
,
object
Data
,
int
JwtExpirTime
)
public
static
object
Get
(
string
cacheKey
)
{
try
{
...
...
Edu.Common/Config.cs
View file @
45f2b0e0
...
...
@@ -159,6 +159,17 @@ namespace Edu.Common
}
}
/// <summary>
/// 企业应用APP地址
/// </summary>
public
static
string
WorkAPPDomain
{
get
{
return
ReadConfigKey
(
"WorkAPPDomain"
);
}
}
/// <summary>
/// 获取Oss文件全路径
/// </summary>
...
...
Edu.Module.QYWeChat/QYWeChatModule.cs
View file @
45f2b0e0
...
...
@@ -10,6 +10,8 @@ using Edu.Model.CacheModel;
using
Edu.Model.ViewModel.WeChat
;
using
Edu.Repository.WeChat
;
using
Edu.ThirdCore.QYWinXin
;
using
Newtonsoft.Json.Linq
;
using
Senparc.Weixin.Work.AdvancedAPIs.OAuth2
;
using
VT.FW.DB
;
namespace
Edu.Module.QYWeChat
...
...
@@ -101,6 +103,8 @@ namespace Edu.Module.QYWeChat
}
}
#
endregion
#
endregion
}
}
Edu.ThirdCore/QYWinXin/QYWeiXinHelper.cs
View file @
45f2b0e0
using
System
;
using
System.Collections.Generic
;
using
System.Text
;
using
System.Web
;
using
Edu.Cache.User
;
using
Edu.Cache.WeChat
;
using
Edu.Common.Plugin
;
using
Newtonsoft.Json
;
using
Newtonsoft.Json.Linq
;
using
Senparc.Weixin.Work
;
...
...
@@ -50,8 +53,8 @@ namespace Edu.ThirdCore.QYWinXin
var
token
=
GetToken
(
groupId
);
if
(!
string
.
IsNullOrEmpty
(
token
))
{
var
result
=
Senparc
.
Weixin
.
Work
.
AdvancedAPIs
.
OAuth2Api
.
GetUserId
Async
(
token
,
code
);
return
(
true
,
result
.
Result
);
var
result
=
Senparc
.
Weixin
.
Work
.
AdvancedAPIs
.
OAuth2Api
.
GetUserId
(
token
,
code
);
return
(
true
,
result
);
}
else
{
...
...
@@ -59,6 +62,31 @@ namespace Edu.ThirdCore.QYWinXin
}
}
/// <summary>
/// 组装跳转地址
/// </summary>
/// <param name="groupId">集团编号</param>
/// <param name="mark">唯一标识</param>
/// <returns></returns>
public
string
GetUserAuthorizationCodePath
(
int
groupId
,
string
mark
)
{
var
config
=
WeChatReidsCache
.
GetWorkChatConfig
(
groupId
);
var
token
=
GetToken
(
groupId
);
if
(!
string
.
IsNullOrEmpty
(
token
))
{
string
redirect_uri
=
$"http://mobileapis.kookaku.com/api/QYWeChat/UserCodeCallBack"
;
string
state
=
mark
;
JObject
cacheContent
=
new
JObject
();
cacheContent
.
Add
(
"group_id"
,
groupId
);
UserReidsCache
.
Set
(
mark
,
cacheContent
,
60
);
return
Senparc
.
Weixin
.
Work
.
AdvancedAPIs
.
OAuth2Api
.
GetCode
(
config
.
WX_CorpId
,
redirect_uri
,
state
,
"1000004"
);
}
else
{
return
string
.
Empty
;
}
}
/// <summary>
/// 获取token
/// </summary>
...
...
Edu.WebApi/Controllers/QYWeChat/QYWeChatController.cs
View file @
45f2b0e0
...
...
@@ -3,6 +3,7 @@ using System.Collections.Generic;
using
System.Linq
;
using
System.Threading.Tasks
;
using
Edu.Cache.User
;
using
Edu.Common
;
using
Edu.Common.API
;
using
Edu.Common.Enum.Finance
;
using
Edu.Common.Plugin
;
...
...
@@ -128,9 +129,13 @@ namespace Edu.WebApi.Controllers.Finance
}
}
/// <summary>
/// 发起登录请求
/// </summary>
/// <returns></returns>
[
HttpPost
]
[
AllowAnonymous
]
public
ApiResult
SetUserLogin
()
public
ApiResult
SetUser
Auto
Login
()
{
var
referer
=
Request
.
Headers
[
"Origin"
].
ToString
().
Replace
(
"http://"
,
""
);
if
(!
string
.
IsNullOrEmpty
(
referer
))
...
...
@@ -139,15 +144,16 @@ namespace Edu.WebApi.Controllers.Finance
if
(
group
.
GId
!=
0
)
{
var
query
=
JObject
.
Parse
(
RequestParm
.
Msg
.
ToString
());
var
code
=
query
.
GetStringValue
(
"code
"
);
var
userInfo
=
new
QYWeiXinHelper
().
GetLoginWorkUserInfo
(
group
.
GId
,
code
);
if
(
userInfo
.
status
)
var
mark
=
query
.
GetStringValue
(
"mark
"
);
var
path
=
new
QYWeiXinHelper
().
GetUserAuthorizationCodePath
(
group
.
GId
,
mark
);
if
(
!
string
.
IsNullOrEmpty
(
path
)
)
{
return
ApiResult
.
Success
(
data
:
userInfo
.
result
);
HttpHelper
.
HttpGet
(
path
);
return
ApiResult
.
Success
(
data
:
path
);
}
else
{
return
ApiResult
.
Failed
(
message
:
"
解析用户
信息失败"
);
return
ApiResult
.
Failed
(
message
:
"
获取登录
信息失败"
);
}
}
...
...
@@ -163,6 +169,55 @@ namespace Edu.WebApi.Controllers.Finance
}
}
/// <summary>
/// 获取登录信息
/// </summary>
/// <returns></returns>
[
HttpPost
]
[
AllowAnonymous
]
public
ApiResult
GetLoginUserInfo
()
{
var
mark
=
JObject
.
FromObject
(
RequestParm
.
Msg
).
GetStringValue
(
"mark"
);
mark
+=
"_Finish"
;
if
(
UserReidsCache
.
Exists
(
mark
))
{
var
cacheObj
=
UserReidsCache
.
Get
(
mark
);
var
cacheContent
=
JObject
.
FromObject
(
cacheObj
);
return
ApiResult
.
Success
(
data
:
cacheContent
[
"user"
].
ToString
());
}
else
{
return
ApiResult
.
Success
(
data
:
""
);
}
}
/// <summary>
/// 获取用户Code
/// </summary>
/// <returns></returns>
[
HttpGet
]
[
AllowAnonymous
]
public
IActionResult
UserCodeCallBack
()
{
var
mark
=
Request
.
Query
[
"state"
].
ToString
();
var
code
=
Request
.
Query
[
"code"
].
ToString
();
var
cacheObj
=
UserReidsCache
.
Get
(
mark
);
if
(
cacheObj
!=
null
&&
!
string
.
IsNullOrEmpty
(
code
))
{
var
cacheContent
=
JObject
.
FromObject
(
cacheObj
);
var
userInfo
=
new
QYWeiXinHelper
().
GetLoginWorkUserInfo
(
cacheContent
.
GetInt
(
"group_id"
),
code
);
if
(
userInfo
.
status
)
{
cacheContent
.
Add
(
"user"
,
JObject
.
FromObject
(
userInfo
.
result
));
UserReidsCache
.
Set
(
mark
+
"_Finish"
,
cacheContent
,
60
);
}
}
var
redirect_url
=
$"
{
Config
.
WorkAPPDomain
}
/login?mark=
{
mark
}
"
;
return
Redirect
(
redirect_url
);
}
#
endregion
}
}
Edu.WebApi/appsettings.json
View file @
45f2b0e0
...
...
@@ -29,6 +29,7 @@
"UploadSiteUrl"
:
"http://192.168.1.36:8120"
,
"ViewFileSiteUrl"
:
"https://viitto-1301420277.cos.ap-chengdu.myqcloud.com"
,
"ErpViewFileSiteUrl"
:
"http://imgfile.oytour.com"
,
"WorkAPPDomain"
:
"http://mobile.kookaku.com"
,
"Mongo"
:
"mongodb://47.96.25.130:27017"
,
"MongoDBName"
:
"Edu"
,
"WkHtmlToPdfPath"
:
"D:/wkhtmltopdf/bin/"
,
...
...
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