Commit 888b1969 authored by guozhipeng's avatar guozhipeng

飞书修改-odata跳转

parent 65bea225
......@@ -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
}
......@@ -11,9 +11,3 @@ service feishuService {
//视图
entity FeiShuApprovalCodeView as projection on feishuDB.FeiShuApprovalCodeView;//飞书审批定义视图
}
//开放接口
service openFeishuService @(requires: 'any'){
//实体
entity FeiShuApprover as projection on feishuDB.FeiShuApprover;
}
......@@ -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);
......
......@@ -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) {
......
......@@ -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");
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment