Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
P
performance
Overview
Overview
Details
Activity
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
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
zry
performance
Commits
8fe5b418
Commit
8fe5b418
authored
Jun 09, 2022
by
1391696987
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
优化代码
parent
35c049ae
Hide whitespace changes
Inline
Side-by-side
Showing
7 changed files
with
79 additions
and
25 deletions
+79
-25
performance/Performance.Api/Controllers/AccountController.cs
+39
-16
performance/Performance.Api/appsettings.Development.json
+4
-0
performance/Performance.Api/appsettings.Localhost.json
+4
-0
performance/Performance.Api/appsettings.json
+4
-0
performance/Performance.Api/wwwroot/Performance.Api.xml
+12
-0
performance/Performance.DtoModels/AppSettings/Wechat.cs
+2
-0
performance/Performance.Services/UserService.cs
+14
-9
No files found.
performance/Performance.Api/Controllers/AccountController.cs
View file @
8fe5b418
...
...
@@ -107,31 +107,54 @@ public ApiResponse WechatLogin(string code)
InterfaceRequest
interfaceRequest
=
new
InterfaceRequest
()
{
Url
=
"https://qyapi.weixin.qq.com/cgi-bin/gettoken"
,
Url
=
_wechat
.
Value
.
Access_Token
,
Function
=
"GatAccess_token"
};
var
getAccess_tokenDic
=
_userService
.
AccessInterface
(
interfaceRequest
,
out
string
content
);
string
access_token
=
""
;
if
(
getAccess_tokenDic
.
ContainsKey
(
"access_token"
))
access_token
=
getAccess_tokenDic
[
"access_token"
].
ToString
();
string
access_token
=
getAccess_tokenDic
.
GetValue
(
"access_token"
,
""
);
interfaceRequest
.
Url
=
"https://qyapi.weixin.qq.com/cgi-bin/user/getuserinfo"
;
interfaceRequest
.
Url
=
_wechat
.
Value
.
GetUserInfo
;
interfaceRequest
.
Function
=
"GetUserId"
;
interfaceRequest
.
Access_token
=
access_token
;
interfaceRequest
.
Code
=
code
;
var
getUserIdDic
=
_userService
.
AccessInterface
(
interfaceRequest
,
out
string
conten
);
string
userId
=
""
;
if
(
getUserIdDic
.
ContainsKey
(
"UserId"
))
userId
=
getUserIdDic
[
"UserId"
].
ToString
();
string
userId
=
getUserIdDic
.
GetValue
(
"userid"
,
""
);
var
empCode
=
_userService
.
GetWxUserEmpCode
(
userId
);
return
new
ApiResponse
(
ResponseType
.
OK
,
new
{
userId
,
empCode
});
}
/// <summary>
/// 微信获取Access_token假接口
/// </summary>
/// <returns></returns>
[
HttpPost
]
[
Route
(
"GetAccess_token"
)]
[
AllowAnonymous
]
public
dynamic
GetUserId
()
{
string
json
=
"{\"errcode\":0,\"errmsg\":\"ok\",\"access_token\":\"UEmj20gO_efJs-nlQ_fY-iimJ8ZSBI315maQAmtMMGcHb_Fyqci9v1L5bFL14b-GqdnNXUwuOkX_RkrCDcmHl6qyLIkwBOw1_9_A_uXoAg_D1mMB9wbIoavL1zOzCy1CvL6elbf8Gf7CyV2dpykaC7C1Ju07s4jVXJch4GNFeYr6AQMwCg6KmWrJrgKTn6nms2Xc2qPYXWTobyqCImNElg\",\"expires_in\":7200}"
;
var
dic
=
JsonHelper
.
Deserialize
<
Dictionary
<
string
,
object
>>(
json
);
return
dic
;
}
/// <summary>
/// 微信获取UserId假接口
/// </summary>
/// <returns></returns>
[
HttpPost
]
[
Route
(
"GetUserId"
)]
[
AllowAnonymous
]
public
dynamic
GetUserId
(
string
code
)
{
string
json
=
"{\"UserId\":\""
+
code
+
"\",\"DeviceId\":\"526fda7a-d269-44df-a7e1-376e8a0efbe3\",\"errcode\":0,\"errmsg\":\"ok\"}"
;
var
dic
=
JsonHelper
.
Deserialize
<
Dictionary
<
string
,
object
>>(
json
);
return
dic
;
}
/// <summary>
/// 梧州Token假接口
/// </summary>
...
...
@@ -141,8 +164,8 @@ public ApiResponse WechatLogin(string code)
[
AllowAnonymous
]
public
dynamic
WuzhouToken
()
{
string
json
1
=
"{\"success\":true,\"status\":{\"code\":0,\"msg\":\"处理成功。\"},\"extraMsg\":\"\",\"item\":{\"id\":\"9f1e83f1-6a9d-4bc4-8e93-611cb41991ba\",\"timeout\":7200000,\"startTimestamp\":\"2022-06-01 16:47:42.049\"}}"
;
var
dic
=
JsonHelper
.
Deserialize
<
Dictionary
<
string
,
object
>>(
json
1
);
string
json
=
"{\"success\":true,\"status\":{\"code\":0,\"msg\":\"处理成功。\"},\"extraMsg\":\"\",\"item\":{\"id\":\"9f1e83f1-6a9d-4bc4-8e93-611cb41991ba\",\"timeout\":7200000,\"startTimestamp\":\"2022-06-01 16:47:42.049\"}}"
;
var
dic
=
JsonHelper
.
Deserialize
<
Dictionary
<
string
,
object
>>(
json
);
return
dic
;
}
/// <summary>
...
...
@@ -154,8 +177,8 @@ public dynamic WuzhouToken()
[
AllowAnonymous
]
public
dynamic
WuzhouValidPass
()
{
string
json
1
=
"{\"success\":true,\"status\":{\"code\":0,\"msg\":\"处理成功。\"},\"extraMsg\":\"\",\"item\":true}"
;
var
dic
=
JsonHelper
.
Deserialize
<
Dictionary
<
string
,
object
>>(
json
1
);
string
json
=
"{\"success\":true,\"status\":{\"code\":0,\"msg\":\"处理成功。\"},\"extraMsg\":\"\",\"item\":true}"
;
var
dic
=
JsonHelper
.
Deserialize
<
Dictionary
<
string
,
object
>>(
json
);
return
dic
;
}
/// <summary>
...
...
@@ -186,9 +209,9 @@ public dynamic WuzhouLogin([FromBody] WuzhouLoginRequest request)
string
token
=
""
;
if
(
getTokenDic
.
GetValue
(
"success"
,
false
)
==
true
)
{
var
item
=
getTokenDic
[
"item"
]
;
var
itemdic
=
JsonHelper
.
Deserialize
<
Dictionary
<
string
,
object
>>(
item
.
ToString
()
);
token
=
itemdic
[
"id"
].
ToString
(
);
var
item
=
getTokenDic
.
GetValue
(
"item"
,
""
)
;
var
itemdic
=
JsonHelper
.
Deserialize
<
Dictionary
<
string
,
object
>>(
item
);
interfaceRequest
.
X_Token
=
itemdic
.
GetValue
(
"id"
,
""
);
}
else
{
...
...
performance/Performance.Api/appsettings.Development.json
View file @
8fe5b418
...
...
@@ -7,6 +7,10 @@
}
},
"Wechat"
:
{
"Access_token"
:
"https://qyapi.weixin.qq.com/cgi-bin/gettoken"
,
"GetUserInfo"
:
"https://qyapi.weixin.qq.com/cgi-bin/user/getuserinfo"
,
//
"Access_token"
:
"http://localhost:5001/api/Account/GetAccess_token"
,
//
"GetUserInfo"
:
"http://localhost:5001/api/Account/GetUserId"
,
"CorpId"
:
"ww58ec167201a95da7"
,
"CorpSecret"
:
"1rgWzgJBIZ3r0Q2sW1trVw5QdXOHmgUhepk90ecI2rk"
},
...
...
performance/Performance.Api/appsettings.Localhost.json
View file @
8fe5b418
...
...
@@ -6,6 +6,10 @@
}
},
"Wechat"
:
{
"Access_token"
:
"https://qyapi.weixin.qq.com/cgi-bin/gettoken"
,
"GetUserInfo"
:
"https://qyapi.weixin.qq.com/cgi-bin/user/getuserinfo"
,
//
"Access_token"
:
"http://localhost:5001/api/Account/GetAccess_token"
,
//
"GetUserInfo"
:
"http://localhost:5001/api/Account/GetUserId"
,
"CorpId"
:
"ww58ec167201a95da7"
,
"CorpSecret"
:
"1rgWzgJBIZ3r0Q2sW1trVw5QdXOHmgUhepk90ecI2rk"
},
...
...
performance/Performance.Api/appsettings.json
View file @
8fe5b418
...
...
@@ -5,6 +5,10 @@
}
},
"Wechat"
:
{
"Access_token"
:
"https://qyapi.weixin.qq.com/cgi-bin/gettoken"
,
"GetUserInfo"
:
"https://qyapi.weixin.qq.com/cgi-bin/user/getuserinfo"
,
//
"Access_token"
:
"http://localhost:5001/api/Account/GetAccess_token"
,
//
"GetUserInfo"
:
"http://localhost:5001/api/Account/GetUserId"
,
"CorpId"
:
"ww58ec167201a95da7"
,
"CorpSecret"
:
"1rgWzgJBIZ3r0Q2sW1trVw5QdXOHmgUhepk90ecI2rk"
},
...
...
performance/Performance.Api/wwwroot/Performance.Api.xml
View file @
8fe5b418
...
...
@@ -31,6 +31,18 @@
<param
name=
"code"
></param>
<returns></returns>
</member>
<member
name=
"M:Performance.Api.Controllers.AccountController.GetUserId"
>
<summary>
微信获取Access_token假接口
</summary>
<returns></returns>
</member>
<member
name=
"M:Performance.Api.Controllers.AccountController.GetUserId(System.String)"
>
<summary>
微信获取UserId假接口
</summary>
<returns></returns>
</member>
<member
name=
"M:Performance.Api.Controllers.AccountController.WuzhouToken"
>
<summary>
梧州Token假接口
...
...
performance/Performance.DtoModels/AppSettings/Wechat.cs
View file @
8fe5b418
...
...
@@ -8,6 +8,8 @@ namespace Performance.DtoModels.AppSettings
{
public
class
Wechat
{
public
string
Access_Token
{
get
;
set
;
}
public
string
GetUserInfo
{
get
;
set
;
}
public
string
CorpId
{
get
;
set
;
}
public
string
CorpSecret
{
get
;
set
;
}
...
...
performance/Performance.Services/UserService.cs
View file @
8fe5b418
...
...
@@ -106,8 +106,8 @@ public class UserService : IAutoInjection
request
.
AddQueryParameter
(
"code"
,
interfaceRequest
.
Code
);
break
;
case
"GetX_Token"
:
request
.
AddQueryParameter
(
"
Code
"
,
_wzOAuth
.
Value
.
Code
);
request
.
AddQueryParameter
(
"
Token
"
,
_wzOAuth
.
Value
.
Token
);
request
.
AddQueryParameter
(
"
user
"
,
_wzOAuth
.
Value
.
Code
);
request
.
AddQueryParameter
(
"
pwd
"
,
_wzOAuth
.
Value
.
Token
);
break
;
case
"ValidPass"
:
request
.
AddHeader
(
"x-token"
,
interfaceRequest
.
X_Token
);
...
...
@@ -117,19 +117,24 @@ public class UserService : IAutoInjection
request
.
AddQueryParameter
(
"mobile"
,
interfaceRequest
.
wuzhouLoginRequest
.
Mobile
);
break
;
}
logger
.
LogInformation
(
$"开始请求第三方接口:
{
interfaceRequest
.
Url
}
"
);
IRestResponse
response
=
restClient
.
Execute
(
request
);
content
=
response
.
Content
;
if
(
response
.
StatusCode
==
System
.
Net
.
HttpStatusCode
.
OK
)
logger
.
LogInformation
(
$"第三方接口请求结束:
{
JsonHelper
.
Serialize
(
new
{
interfaceRequest
.
Url
,
response
.
StatusCode
,
content
})}
"
);
try
{
return
JsonHelper
.
Deserialize
<
Dictionary
<
string
,
object
>>(
response
.
Content
);
if
(
response
.
StatusCode
==
System
.
Net
.
HttpStatusCode
.
OK
)
{
return
JsonHelper
.
Deserialize
<
Dictionary
<
string
,
object
>>(
response
.
Content
);
}
}
else
catch
(
Exception
ex
)
{
logger
.
LogError
(
$"接口请求错误:
{
response
.
StatusCode
}
,
{
response
.
Content
}
"
);
return
null
;
logger
.
LogError
(
$"接口请求错误:
{
ex
}
"
);
}
return
null
;
}
/// <summary>
/// 获取微信绑定用户的工号
...
...
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