Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
Z
zhichan
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
蒋勇
zhichan
Commits
8e16b35c
Commit
8e16b35c
authored
May 09, 2020
by
庄冰
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
feishu
parent
7115f4e8
Hide whitespace changes
Inline
Side-by-side
Showing
7 changed files
with
355 additions
and
15 deletions
+355
-15
center-channel/app/base/db/cache/feishuAppAccessTokenCache.js
+33
-0
center-channel/app/base/db/cache/feishuAppTicketCache.js
+33
-0
center-channel/app/base/db/cache/feishuUserAccessTokenCache.js
+42
-0
center-channel/app/base/service/impl/common/feishuLoginSve.js
+47
-0
center-channel/app/base/service/impl/utilsSve/utilsFeishuSve.js
+133
-0
center-channel/app/config/routes/api.js
+52
-0
center-channel/app/front/entry/public/apidoc/platform/icpOrder.md
+15
-15
No files found.
center-channel/app/base/db/cache/feishuAppAccessTokenCache.js
0 → 100644
View file @
8e16b35c
const
CacheBase
=
require
(
"../cache.base"
);
const
system
=
require
(
"../../system"
);
// const OpenplatformWxop = require("../../wxop/impl/openplatformWxop");
/**
* 飞书小程序--AppAccessToken缓存--有效时间7100s
*/
class
feishuAppAccessTokenCache
extends
CacheBase
{
constructor
(){
super
();
this
.
restClient
=
system
.
getObject
(
"util.restClient"
);
this
.
prefix
=
"feishu_appAccessToken_9e28dcb1d637100d"
;
}
desc
()
{
return
"应用UI配置缓存"
;
}
prefix
()
{
return
"feishu_appAccessToken_9e28dcb1d637100d"
;
}
async
get
(){
var
key
=
this
.
prefix
;
var
result
=
await
this
.
redisClient
.
get
(
key
);
return
result
;
}
async
set
(
accessToken
){
var
key
=
this
.
prefix
;
if
(
accessToken
){
await
this
.
redisClient
.
setWithEx
(
key
,
accessToken
,
7100
);
}
return
accessToken
;
}
}
module
.
exports
=
feishuAppAccessTokenCache
;
\ No newline at end of file
center-channel/app/base/db/cache/feishuAppTicketCache.js
0 → 100644
View file @
8e16b35c
const
CacheBase
=
require
(
"../cache.base"
);
const
system
=
require
(
"../../system"
);
// const OpenplatformWxop = require("../../wxop/impl/openplatformWxop");
/**
* 飞书小程序--AppTicket缓存--有效时间7100s
*/
class
feishuAppTicketCache
extends
CacheBase
{
constructor
(){
super
();
this
.
restClient
=
system
.
getObject
(
"util.restClient"
);
this
.
prefix
=
"feishu_appTicket_cli_9e28dcb1d637100d"
;
}
desc
()
{
return
"应用UI配置缓存"
;
}
prefix
()
{
return
"feishu_appTicket_cli_9e28dcb1d637100d"
;
}
async
get
(){
var
key
=
this
.
prefix
;
var
result
=
await
this
.
redisClient
.
get
(
key
);
return
result
}
async
set
(
appTicket
){
var
key
=
this
.
prefix
;
if
(
appTicket
){
await
this
.
redisClient
.
setWithEx
(
key
,
appTicket
,
7100
);
}
return
appTicket
;
}
}
module
.
exports
=
feishuAppTicketCache
;
\ No newline at end of file
center-channel/app/base/db/cache/feishuUserAccessTokenCache.js
0 → 100644
View file @
8e16b35c
const
CacheBase
=
require
(
"../cache.base"
);
const
system
=
require
(
"../../system"
);
// const OpenplatformWxop = require("../../wxop/impl/openplatformWxop");
/**
* 飞书小程序--UserAccessTokenCache缓存--有效时间7100s
*/
class
feishuUserAccessTokenCache
extends
CacheBase
{
constructor
(){
super
();
this
.
restClient
=
system
.
getObject
(
"util.restClient"
);
this
.
prefix
=
"feishu_userAccessToken_9e28dcb1d637100d"
;
}
desc
()
{
return
"应用UI配置缓存"
;
}
prefix
()
{
return
"feishu_userAccessToken_9e28dcb1d637100d"
;
}
async
get
(
openid
){
var
key
=
this
.
prefix
+
"_"
+
openid
;
var
result
=
await
this
.
redisClient
.
get
(
key
);
var
obj
=
null
;
if
(
result
){
obj
=
JSON
.
parse
(
result
);
}
if
(
obj
&&
obj
.
access_token
){
return
obj
;
}
return
null
;
}
async
set
(
obj
,
openid
){
var
key
=
this
.
prefix
+
"_"
+
openid
;
if
(
obj
&&
obj
.
access_token
){
var
stringobj
=
JSON
.
stringify
(
obj
);
await
this
.
redisClient
.
setWithEx
(
key
,
stringobj
,
7100
);
return
obj
;
}
return
null
;
}
}
module
.
exports
=
feishuUserAccessTokenCache
;
\ No newline at end of file
center-channel/app/base/service/impl/common/feishuLoginSve.js
0 → 100644
View file @
8e16b35c
const
system
=
require
(
"../../../system"
);
const
crypto
=
require
(
'crypto'
);
var
settings
=
require
(
"../../../../config/settings"
);
class
feishuLoginService
{
constructor
()
{
this
.
utilsFeishuSve
=
system
.
getObject
(
"service.utilsSve.utilsFeishuSve"
);
};
//用户登录
async
checkAndLogin
(
pobj
){
if
(
!
pobj
.
code
){
return
system
.
getResultFail
(
-
100
,
"code参数不能为空"
);
}
//获取 app_access_token(应用商店应用)
var
appAccessTokenRes
=
await
this
.
utilsFeishuSve
.
getAppAccessToken
();
if
(
appAccessTokenRes
.
status
!=
0
){
return
appAccessTokenRes
;
}
var
app_access_token
=
appAccessTokenRes
.
data
;
//获取飞书登录用户身份
var
userAccessTokenParams
=
{
"code"
:
pobj
.
code
,
"app_access_token"
:
app_access_token
,
"open_id"
:
pobj
.
open_id
||
""
};
var
userAccessTokenRes
=
await
this
.
utilsFeishuSve
.
getUserAccessToken
(
userAccessTokenParams
);
if
(
userAccessTokenRes
.
status
!=
0
){
return
userAccessTokenRes
;
}
var
userAccessTokenObj
=
userAccessTokenRes
.
data
;
//获取飞书用户信息
var
userInfoParams
=
{
user_access_token
:
userAccessTokenObj
.
access_token
};
var
userInfoRes
=
await
this
.
utilsFeishuSve
.
getUserInfo
(
userInfoParams
);
if
(
userInfoRes
.
status
!=
0
){
return
userInfoRes
;
}
var
userInfoObj
=
userInfoRes
.
data
;
var
createUserParams
=
{
};
}
}
module
.
exports
=
feishuLoginService
;
\ No newline at end of file
center-channel/app/base/service/impl/utilsSve/utilsFeishuSve.js
0 → 100644
View file @
8e16b35c
const
system
=
require
(
"../../../system"
);
var
settings
=
require
(
"../../../../config/settings"
);
/**
* 飞书小程序相关接口
*/
class
UtilsFeishuService
{
constructor
()
{
this
.
execClient
=
system
.
getObject
(
"util.execClient"
);
this
.
cacheManager
=
system
.
getObject
(
"db.common.cacheManager"
);
this
.
appConfig
=
{
app_id
:
"cli_9e28dcb1d637100d"
,
app_secret
:
"zL1uRrWFzwhFbLWZrmSuCh72JGjJXQg0"
}
};
//订阅验证
async
subscribeVerification
(
pobj
){
if
(
pobj
&&
pobj
.
challenge
){
return
system
.
getResultSuccess
(
pobj
.
challenge
);
}
else
{
return
system
.
getResultFail
();
}
}
//接收app_ticket
async
receiveAppTicket
(
pobj
){
if
(
pobj
&&
pobj
.
event
&&
pobj
.
event
.
app_ticket
&&
pobj
.
event
.
type
&&
pobj
.
event
.
type
==
"app_ticket"
){
//将app_ticket保存到缓存
await
this
.
cacheManager
[
"feishuAppTicketCache"
].
set
(
pobj
.
event
.
app_ticket
);
return
system
.
getResultSuccess
();
}
return
system
.
getResultFail
();
}
//重新推送app_ticket(主动触发)
async
resendAppTicket
(){
var
url
=
"https://open.feishu.cn/open-apis/auth/v3/app_ticket/resend"
;
var
pobj
=
{
app_id
:
this
.
appConfig
.
app_id
,
//应用唯一标识,创建应用后获得
app_secret
:
this
.
appConfig
.
app_secret
//应用秘钥,创建应用后获得
};
var
rtn
=
await
this
.
execClient
.
execPost
(
pobj
,
url
);
if
(
!
rtn
||
!
rtn
.
stdout
)
{
return
system
.
getResult
(
null
,
"execPost data is empty"
);
}
var
result
=
JSON
.
parse
(
rtn
.
stdout
);
if
(
result
.
code
==
0
){
return
system
.
getResultSuccess
();
}
return
system
.
getResult
(
null
,
"execPost data is empty.错误码:"
+
result
.
code
);
}
//获取app_access_token(应用商店应用)
async
getAppAccessToken
(){
var
appAccessToken
=
await
this
.
cacheManager
[
"feishuAppAccessTokenCache"
].
get
();
if
(
appAccessToken
){
return
system
.
getResultSuccess
(
appAccessToken
);
}
var
app_ticket
=
await
this
.
cacheManager
[
"feishuAppTicketCache"
].
get
();
if
(
!
app_ticket
){
await
this
.
resendAppTicket
();
//重新推送app_ticket
return
system
.
getResultFail
(
"app_ticket不存在"
);
}
var
url
=
"https://open.feishu.cn/open-apis/auth/v3/app_access_token"
;
var
obj
=
{
app_id
:
this
.
appConfig
.
app_id
,
//应用唯一标识,创建应用后获得
app_secret
:
this
.
appConfig
.
app_secret
,
//应用秘钥,创建应用后获得
app_ticket
:
app_ticket
//平台定时推送给应用的临时凭证,通过事件监听机制获得,详见订阅事件
};
var
rtn
=
await
this
.
execClient
.
execPost
(
obj
,
url
);
if
(
!
rtn
||
!
rtn
.
stdout
)
{
return
system
.
getResult
(
null
,
"execPost data is empty"
);
}
var
result
=
JSON
.
parse
(
rtn
.
stdout
);
if
(
result
.
code
==
0
&&
result
.
app_access_token
){
//缓存AppAccessToken
await
this
.
cacheManager
[
"feishuAppAccessTokenCache"
].
set
(
result
.
app_access_token
);
return
system
.
getResultSuccess
(
result
.
app_access_token
);
}
return
system
.
getResultFail
(
"获取appAccessToken失败"
);
}
//获取登录用户身份
async
getUserAccessToken
(
obj
){
var
resData
=
{};
if
(
obj
.
open_id
){
//缓存中获取登录用户身份
resData
=
await
this
.
cacheManager
[
"feishuUserAccessTokenCache"
].
get
(
obj
.
open_id
);
}
//缓存中存在 直接返回
if
(
resData
&&
resData
.
access_token
){
return
system
.
getResultSuccess
(
resData
);
}
if
(
!
obj
.
code
){
return
system
.
getResultFail
(
"code参数不能为空"
);
}
if
(
!
obj
.
app_access_token
){
return
system
.
getResultFail
(
"app_access_token参数不能为空"
);
}
var
url
=
"https://open.feishu.cn/open-apis/authen/v1/access_token"
;
var
fsObj
=
{
app_access_token
:
obj
.
app_access_token
,
//应用的 app_access_token,必须与请求身份验证中的应用保持一致
grant_type
:
"authorization_code"
,
//在本流程中,此值为 authorization_code
code
:
obj
.
code
//来自请求身份验证(新)流程,用户扫码登录后会自动302到redirect_uri并带上此参数
};
var
rtn
=
await
this
.
execClient
.
execPost
(
fsObj
,
url
);
if
(
!
rtn
||
!
rtn
.
stdout
)
{
return
system
.
getResult
(
null
,
"execPost data is empty"
);
}
var
result
=
JSON
.
parse
(
rtn
.
stdout
);
if
(
result
.
code
==
0
&&
result
.
data
){
//缓存AppAccessToken
await
this
.
cacheManager
[
"feishuUserAccessTokenCache"
].
set
(
result
.
data
,
result
.
data
.
open_id
);
return
system
.
getResultSuccess
(
result
.
data
);
}
return
system
.
getResult
(
null
,
"获取飞书登录用户身份失败"
);
}
//获取用户信息
async
getUserInfo
(
pobj
){
if
(
!
pobj
.
user_access_token
){
return
system
.
getResultFail
(
"user_access_token参数不能为空"
)
}
var
url
=
"https://open.feishu.cn/open-apis/authen/v1/user_info"
;
var
obj
=
{
user_access_token
:
pobj
.
user_access_token
};
var
rtn
=
await
this
.
execClient
.
execGet
(
obj
,
url
);
if
(
!
rtn
||
!
rtn
.
stdout
)
{
return
system
.
getResult
(
null
,
"execPost data is empty"
);
}
var
result
=
JSON
.
parse
(
rtn
.
stdout
);
if
(
result
.
code
==
0
&&
result
.
data
){
return
system
.
getResultSuccess
(
result
.
data
);
}
return
system
.
getResult
(
null
,
"获取飞书用户信息失败"
);
}
}
module
.
exports
=
UtilsFeishuService
;
center-channel/app/config/routes/api.js
View file @
8e16b35c
...
@@ -3,6 +3,7 @@ var system = require("../../base/system");
...
@@ -3,6 +3,7 @@ var system = require("../../base/system");
const
utilsAuthSve
=
system
.
getObject
(
"service.utilsSve.utilsAuthSve"
);
const
utilsAuthSve
=
system
.
getObject
(
"service.utilsSve.utilsAuthSve"
);
const
logCtl
=
system
.
getObject
(
"service.common.oplogSve"
);
const
logCtl
=
system
.
getObject
(
"service.common.oplogSve"
);
const
utilsOrderSve
=
system
.
getObject
(
"service.utilsSve.utilsOrderSve"
);
const
utilsOrderSve
=
system
.
getObject
(
"service.utilsSve.utilsOrderSve"
);
const
utilsFeishuSve
=
system
.
getObject
(
"service.utilsSve.utilsFeishuSve"
);
module
.
exports
=
function
(
app
)
{
module
.
exports
=
function
(
app
)
{
//-----------------------新的模式---------web---------开始
//-----------------------新的模式---------web---------开始
...
@@ -324,4 +325,55 @@ module.exports = function (app) {
...
@@ -324,4 +325,55 @@ module.exports = function (app) {
//-----------------------新的模式---------api---------结束
//-----------------------新的模式---------api---------结束
//----------------------飞书小程序---------------------------------------------开始
//接收appTicket信息
app
.
use
(
'/feishu/appTicket'
,
async
function
(
req
,
res
)
{
try
{
var
client_ip
=
system
.
get_client_ip
(
req
);
var
result
=
await
utilsFeishuSve
.
receiveAppTicket
(
req
.
body
);
logCtl
.
info
({
optitle
:
(
new
Date
()).
Format
(
"yyyy-MM-dd hh:mm:ss"
)
+
"飞书小程序记录回调处理结果:,method=appTicket"
,
op
:
"app/config/routes/api.js/feishu/appTicket"
,
content
:
"回调参数:"
+
JSON
.
stringify
(
req
.
body
)
+
"回调结果:"
+
JSON
.
stringify
(
result
),
clientIp
:
client_ip
||
""
});
if
(
result
.
status
!=
0
)
{
return
res
.
end
(
"FAIL"
);
}
return
res
.
end
(
"success"
);
}
catch
(
error
)
{
logCtl
.
error
({
optitle
:
(
new
Date
()).
Format
(
"yyyy-MM-dd hh:mm:ss"
)
+
"飞书小程序记录回调处理结果异常,method=appTicket"
,
op
:
"app/config/routes/api.js/feishu/appTicket"
,
content
:
"回调参数:"
+
JSON
.
stringify
(
req
.
body
)
+
"error:"
+
error
.
stack
,
clientIp
:
client_ip
||
""
});
}
});
//订阅验证
app
.
use
(
'/feishu/subscribeVerification'
,
async
function
(
req
,
res
)
{
try
{
var
client_ip
=
system
.
get_client_ip
(
req
);
var
result
=
await
utilsFeishuSve
.
subscribeVerification
(
req
.
body
);
logCtl
.
info
({
optitle
:
(
new
Date
()).
Format
(
"yyyy-MM-dd hh:mm:ss"
)
+
"飞书小程序记录回调处理结果,method=subscribeVerification"
,
op
:
"app/config/routes/api.js/feishu/subscribeVerification"
,
content
:
"回调参数:"
+
JSON
.
stringify
(
req
.
body
)
+
"回调结果:"
+
JSON
.
stringify
(
result
),
clientIp
:
client_ip
||
""
});
if
(
result
.
status
!=
0
)
{
return
res
.
end
(
"fail"
);
}
return
res
.
end
(
result
.
data
);
}
catch
(
error
)
{
logCtl
.
error
({
optitle
:
(
new
Date
()).
Format
(
"yyyy-MM-dd hh:mm:ss"
)
+
"飞书小程序记录回调处理结果异常:,method=subscribeVerification"
,
op
:
"app/config/routes/api.js/feishu/subscribeVerification"
,
content
:
"回调参数:"
+
JSON
.
stringify
(
req
.
body
)
+
"error:"
+
error
.
stack
,
clientIp
:
client_ip
||
""
});
}
});
//----------------------飞书小程序---------------------------------------------结束
};
};
center-channel/app/front/entry/public/apidoc/platform/icpOrder.md
View file @
8e16b35c
...
@@ -62,14 +62,14 @@
...
@@ -62,14 +62,14 @@
{
{
"actionType"
:
"submitIcpMaterial"
,
"actionType"
:
"submitIcpMaterial"
,
"actionBody"
:{
"actionBody"
:{
"BizId"
:
"S20200323174838000zhb"
,
//渠道方案号 同channelSolutionNo
"BizId"
:
"S20200323174838000zhb"
,
//渠道方案号 同channelSolutionNo
必填
"material"
:{
"material"
:{
//材料信息
"Domain"
:
"备案域名"
,
"Domain"
:
"备案域名"
,
//必填
"CorporateName"
:
"法人名称"
,
"CorporateName"
:
"法人名称"
,
//必填
"IncludeForeignInvestment"
:
true
,
"IncludeForeignInvestment"
:
true
,
//必填
"PartnerBusinessLicense"
:
"营业执照"
,
"PartnerBusinessLicense"
:
"营业执照"
,
//必填
"PartnerIdCardList"
:[
"相关人员身份证"
],
"PartnerIdCardList"
:[
"相关人员身份证"
],
//必填
"PartnerDomainCertificate"
:
"域名证书"
,
"PartnerDomainCertificate"
:
"域名证书"
,
//必填
"PartnerPreviewOtherList"
:[
"合作方递交其他供预览的件,只能传递ZIP包"
],
"PartnerPreviewOtherList"
:[
"合作方递交其他供预览的件,只能传递ZIP包"
],
"PartnerPlan"
:
"收费方案计划书"
,
"PartnerPlan"
:
"收费方案计划书"
,
"PartnerForeignInvestment"
:
"股东追溯不涉及外资承诺书"
,
"PartnerForeignInvestment"
:
"股东追溯不涉及外资承诺书"
,
...
@@ -108,7 +108,7 @@
...
@@ -108,7 +108,7 @@
{
{
"actionType"
:
"getProgrammeInfoByChannelNeedNo"
,
"actionType"
:
"getProgrammeInfoByChannelNeedNo"
,
"actionBody"
:{
"actionBody"
:{
"needNo"
:
"20200413210610000001"
//渠道需求号
"needNo"
:
"20200413210610000001"
//渠道需求号
必填
}
}
}
}
...
@@ -349,9 +349,9 @@
...
@@ -349,9 +349,9 @@
{
{
"actionType"
:
"acceptIcpPartnerNotification"
,
"actionType"
:
"acceptIcpPartnerNotification"
,
"actionBody"
:{
"actionBody"
:{
"BizId"
:
"S20200323174838000zhb"
,
//渠道方案号 同channelSolutionNo
"BizId"
:
"S20200323174838000zhb"
,
//渠道方案号 同channelSolutionNo
必填
"OfficialFileUrl"
:
"官⽂下载地址"
,
"OfficialFileUrl"
:
"官⽂下载地址"
,
//官文 非必填
"ApplicationStatus"
:
"507"
"ApplicationStatus"
:
"507"
//状态码 必填
}
}
}
}
ApplicationStatus
:
ApplicationStatus
:
...
@@ -387,8 +387,8 @@ ApplicationStatus:
...
@@ -387,8 +387,8 @@ ApplicationStatus:
{
{
"actionType"
:
"abolishIcpProgramme"
,
"actionType"
:
"abolishIcpProgramme"
,
"actionBody"
:{
"actionBody"
:{
"BizId"
:
"S20200323174838000zhb"
,
//渠道方案号 同channelSolutionNo
"BizId"
:
"S20200323174838000zhb"
,
//渠道方案号 同channelSolutionNo
必填
"Note"
:
"备注"
"Note"
:
"备注"
//关闭原因 必填
}
}
}
}
```
```
...
@@ -417,7 +417,7 @@ ApplicationStatus:
...
@@ -417,7 +417,7 @@ ApplicationStatus:
{
{
"actionType"
:
"getNeedSolutionDetailByUser"
,
"actionType"
:
"getNeedSolutionDetailByUser"
,
"actionBody"
:{
"actionBody"
:{
"solutionNo"
:
"NS202004131008iKPRDB"
//方案号
"solutionNo"
:
"NS202004131008iKPRDB"
//方案号
必填
}
}
}
}
```
```
...
...
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