Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
L
lcj-btp-java-app
Project
Project
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
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
郭智朋
lcj-btp-java-app
Commits
888b1969
Commit
888b1969
authored
Feb 19, 2025
by
guozhipeng
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
飞书修改-odata跳转
parent
65bea225
Show whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
48 additions
and
10 deletions
+48
-10
exampleService.cds
srv/exampleService.cds
+11
-0
feishuService.cds
srv/feishuService.cds
+0
-6
OperateAuthFilter.java
...stomer/lianchuangjie/common/filter/OperateAuthFilter.java
+31
-0
FeiShuController.java
...mer/lianchuangjie/feiShu/controller/FeiShuController.java
+2
-1
FeiShuApproverServiceImpl.java
...angjie/feiShu/service/impl/FeiShuApproverServiceImpl.java
+4
-3
OpenFeishuServiceHandler.java.txt
.../lianchuangjie/handlers/OpenFeishuServiceHandler.java.txt
+0
-0
No files found.
srv/exampleService.cds
View file @
888b1969
...
...
@@ -15,3 +15,14 @@ service exampleService {
//视图
entity ExampleView as projection on example.ExampleView;
}
//开放接口
service openFeishuService @(requires: 'any'){
//将 @cds.persistence.skip 添加到实体中,以指示应从生成的 DDL 脚本中跳过此实体,并且不要在其上生成 SQL 视图:
@cds.persistence.skip
entity ApproveFeiShuUserDeptEvent as projection on example.ExampleView;
@cds.persistence.skip
entity ApproveEvent as projection on example.ExampleView;
@cds.persistence.skip
entity ApaasLog as projection on example.ExampleView
}
srv/feishuService.cds
View file @
888b1969
...
...
@@ -11,9 +11,3 @@ service feishuService {
//视图
entity FeiShuApprovalCodeView as projection on feishuDB.FeiShuApprovalCodeView;//飞书审批定义视图
}
//开放接口
service openFeishuService @(requires: 'any'){
//实体
entity FeiShuApprover as projection on feishuDB.FeiShuApprover;
}
srv/src/main/java/customer/lianchuangjie/common/filter/OperateAuthFilter.java
View file @
888b1969
...
...
@@ -7,6 +7,8 @@ import customer.lianchuangjie.common.constant.CommonConstant;
import
customer.lianchuangjie.common.exception.BtpException
;
import
customer.lianchuangjie.common.util.*
;
import
customer.lianchuangjie.common.vo.Result
;
import
customer.lianchuangjie.feiShu.controller.FeiShuController
;
import
customer.lianchuangjie.feiShu.service.FeiShuBpService
;
import
customer.lianchuangjie.master.service.CommonService
;
import
jakarta.servlet.*
;
import
jakarta.servlet.http.Cookie
;
...
...
@@ -49,6 +51,10 @@ public class OperateAuthFilter implements Filter {
private
boolean
ipWhitelist
;
@Autowired
public
CommonService
commonService
;
@Autowired
public
FeiShuController
feiShuController
;
@Autowired
public
FeiShuBpService
feiShuBpService
;
@Override
public
void
init
(
FilterConfig
filterConfig
)
{
...
...
@@ -62,6 +68,9 @@ public class OperateAuthFilter implements Filter {
String
appKey
=
request
.
getHeader
(
"appKey"
);
//用户appKey
String
uri
=
request
.
getRequestURI
();
String
ip
=
request
.
getRemoteAddr
();
if
(
appKey
==
null
||
""
.
equals
(
appKey
))
{
appKey
=
request
.
getParameter
(
"appKey"
);
//地址栏中的参数
}
log
.
info
(
"requestIP:{}, requestURI:{}, method:{}, appKey:{}"
,
ip
,
uri
,
request
.
getMethod
(),
appKey
);
String
username
=
null
;
...
...
@@ -114,6 +123,28 @@ public class OperateAuthFilter implements Filter {
}
//处理ODATA接口 OData接口仅允许本机访问 只有odata接口需要从cookies中读取参数
if
(
Pattern
.
matches
(
"(.*/odata/v4/.*)"
,
uri
)
&&
!
"127.0.0.1"
.
equals
(
ip
)
&&
!
"0:0:0:0:0:0:0:1"
.
equals
(
ip
))
{
//拦截openFeishuService开放接口做特殊处理
if
(
Pattern
.
matches
(
"(.*/odata/v4/openFeishuService/.*)"
,
uri
)
&&
!
StringUtils
.
isEmpty
(
appKey
)
&&
appKey
.
equals
(
tokenForFeiShu
)
)
{
String
requestParamStr
=
request
.
getReader
().
lines
().
collect
(
Collectors
.
joining
(
System
.
lineSeparator
()));
log
.
info
(
"uri:{}, paramStr:{}, isJson:{}"
,
uri
,
requestParamStr
,
JsonUtil
.
isJsonObject
(
requestParamStr
));
Result
<?>
result
=
Result
.
ok
(
"openFeishuService调用成功!"
);
if
(
"/odata/v4/openFeishuService/ApproveFeiShuUserDeptEvent"
.
equals
(
uri
))
{
feiShuController
.
feiShuUserDeptEvent
(
request
,
response
);
}
if
(
"/odata/v4/openFeishuService/ApproveEvent"
.
equals
(
uri
))
{
feiShuController
.
event
(
request
,
response
);
}
if
(
"/odata/v4/openFeishuService/ApaasLog"
.
equals
(
uri
))
{
result
=
feiShuController
.
addApaasLog
(
JsonUtil
.
isJsonObject
(
requestParamStr
)?
JSONObject
.
parseObject
(
requestParamStr
):
new
JSONObject
());
}
writeResult
(
response
,
result
);
return
;
//返回结果
}
if
(
cookies
==
null
||
cookies
.
length
==
0
)
{
Result
<
Object
>
wrapResult
=
Result
.
error
(
"requestIP="
+
ip
+
" requestURI="
+
uri
+
" odata请求 cookies 不能为空!"
);
writeResult
(
response
,
wrapResult
);
...
...
srv/src/main/java/customer/lianchuangjie/feiShu/controller/FeiShuController.java
View file @
888b1969
...
...
@@ -365,7 +365,8 @@ public class FeiShuController {
}
}
private
final
EventDispatcher
EVENT_DISPATCHER
=
EventDispatcher
.
newBuilder
(
SymbolConstant
.
VERIFICATION_TOKEN
,
SymbolConstant
.
ENCRYPT_KEY
)
private
final
EventDispatcher
EVENT_DISPATCHER
=
EventDispatcher
.
newBuilder
(
"48Vg7plnyoS45JxgLSscrcWuyCbPA6CC"
,
""
)
//private final EventDispatcher EVENT_DISPATCHER = EventDispatcher.newBuilder(SymbolConstant.VERIFICATION_TOKEN, SymbolConstant.ENCRYPT_KEY)
.
onCustomizedEvent
(
"approval_instance"
,
new
CustomEventHandler
()
{
@Override
public
void
handle
(
EventReq
event
)
{
...
...
srv/src/main/java/customer/lianchuangjie/feiShu/service/impl/FeiShuApproverServiceImpl.java
View file @
888b1969
...
...
@@ -44,9 +44,10 @@ public class FeiShuApproverServiceImpl extends ServiceImpl<FeiShuApproverDao, Fe
public
Result
<?>
insertFeiShuApprover
(
EventReq
event
)
{
try
{
String
body
=
new
String
(
event
.
getBody
());
JSONObject
parse
=
(
JSONObject
)
JSONObject
.
parse
(
body
);
String
encrypt
=
DecryptUtil
.
syncDecrypt
(
parse
.
getString
(
"encrypt"
),
SymbolConstant
.
ENCRYPT_KEY
);
JSONObject
result
=
(
JSONObject
)
JSONObject
.
parse
(
encrypt
);
JSONObject
result
=
(
JSONObject
)
JSONObject
.
parse
(
body
);
// JSONObject parse = (JSONObject) JSONObject.parse(body);
// String encrypt = DecryptUtil.syncDecrypt(parse.getString("encrypt"), SymbolConstant.ENCRYPT_KEY);
// JSONObject result = (JSONObject) JSONObject.parse(encrypt);
log
.
info
(
" --- 同步任务调度开始 {},时间:{} --- "
,
this
.
getClass
().
getSimpleName
(),
result
);
JSONObject
eventResult
=
result
.
getJSONObject
(
"event"
);
String
status
=
eventResult
.
getString
(
"status"
);
...
...
srv/src/main/java/customer/lianchuangjie/handlers/OpenFeishuServiceHandler.java
→
srv/src/main/java/customer/lianchuangjie/handlers/OpenFeishuServiceHandler.java
.txt
View file @
888b1969
File moved
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