Merge branch '于相涌/Lark' into test

test
bob 2 years ago
commit d248f40301

@ -7,7 +7,7 @@ package com.ruoyi.common.constant;
public class RedisConstants { public class RedisConstants {
public static void main(String[] args) { public static void main(String[] args) {
System.out.println("Multidimensional tabular feedback".replaceAll(" ","").toUpperCase()); System.out.println("multiple tabular feedback".replaceAll(" ","").toUpperCase());
} }
/** /**
@ -15,4 +15,10 @@ public class RedisConstants {
*/ */
public static final String MULTIDIMENSIONALTABULARFEEDBACK = "MULTIDIMENSIONALTABULARFEEDBACK"; public static final String MULTIDIMENSIONALTABULARFEEDBACK = "MULTIDIMENSIONALTABULARFEEDBACK";
/**
*
*/
public static final String MULTIPLE_TABLE_RECORD = "MULTIPLE_TABLE_RECORD";
} }

@ -0,0 +1,29 @@
package com.ruoyi.common.enums;
/**
*
*
* @author ruoyi
*/
public enum AppType {
/**
*
*/
APPROVAL("APPROVAL", "多维表格");
private final String code;
private final String info;
AppType(String code, String info) {
this.code = code;
this.info = info;
}
public String getCode() {
return code;
}
public String getInfo() {
return info;
}
}

@ -11,8 +11,7 @@ public enum EventOperateStatus {
* *
*/ */
PENDING("PENDING", "未处理"), PENDING("PENDING", "未处理"),
SUCCESS("SUCCESS", "成功"), SUCCESS("SUCCESS", "处理完成");
FAIL("FAIL", "失败");
private final String code; private final String code;
private final String info; private final String info;

@ -0,0 +1,29 @@
package com.ruoyi.common.enums;
/**
* @author ruoyi
*/
public enum TableDetailRelationTypeEnum {
/**
*
*/
ROW("ROW", "行"),
COL("COL", "列");
private final String code;
private final String info;
TableDetailRelationTypeEnum(String code, String info) {
this.code = code;
this.info = info;
}
public String getCode() {
return code;
}
public String getInfo() {
return info;
}
}

@ -25,9 +25,27 @@ public class LarkTokenHelper {
.readTimeout(10, TimeUnit.SECONDS) .readTimeout(10, TimeUnit.SECONDS)
.build(); .build();
private JSONObject execute(Request request){
public String getToken(String appId, String srcret) {
Response execute = null; Response execute = null;
try {
execute = client.newCall(request).execute();
} catch (IOException e) {
String errorMessage = String.format("飞书接口调用失败:{}",e.getMessage());
throw new RuntimeException(errorMessage);
}
if (execute == null || execute.body() == null){
throw new RuntimeException("飞书返回结果为空");
}
JSONObject jsonObject = JSONObject.parseObject(execute.body().toString());
if ("0".equals(jsonObject.getString("code"))){
return jsonObject;
}else {
String errorMessage = String.format("%s##%s", jsonObject.getString("code"), jsonObject.getString("msg"));
throw new RuntimeException(errorMessage);
}
}
public String getToken(String appId, String srcret,String tokenType) {
Map<String, String> map = new HashMap<>(); Map<String, String> map = new HashMap<>();
map.put("app_id", appId); map.put("app_id", appId);
map.put("app_secret", srcret); map.put("app_secret", srcret);
@ -35,15 +53,8 @@ public class LarkTokenHelper {
.method("POST", RequestBody.create(JSONObject.toJSONString(map), MediaType.get("application/json"))) .method("POST", RequestBody.create(JSONObject.toJSONString(map), MediaType.get("application/json")))
.url("https://open.feishu.cn/open-apis/auth/v3/app_access_token/internal") .url("https://open.feishu.cn/open-apis/auth/v3/app_access_token/internal")
.build(); .build();
try {
execute = client.newCall(request).execute(); return execute(request).getString(tokenType);
if (ObjectUtil.isNotNull(execute) && execute.isSuccessful()) {
return execute.body().string();
}
} catch (IOException e) {
log.error("http post 请求失败--{}", e);
}
return null;
} }
/** /**
@ -51,48 +62,58 @@ public class LarkTokenHelper {
* @param token * @param token
* @return * @return
*/ */
public String getLark(String url,Map<String, String> body, String token) { public JSONObject getLark(String url,Map<String, String> body, String token) {
Response execute = null; Response execute = null;
Request request = new Request.Builder() Request request = new Request.Builder()
.url(url) .url(url)
.addHeader("Authorization",String.format("Bearer %s",token)) .addHeader("Authorization",String.format("Bearer %s",token))
.build(); .build();
try { return execute(request);
execute = client.newCall(request).execute();
log.info(JSONObject.toJSONString(execute.body().string()));
if (ObjectUtil.isNotNull(execute) && execute.isSuccessful()) {
return execute.body().string();
}
} catch (IOException e) {
log.error("http get 请求失败--{}", e);
}
return null;
} }
public String postLark(String url,Map<Object, Object> body, String token) { public JSONObject postLark(String url,Map<Object, Object> body, String token) {
Response execute = null;
Request request = new Request.Builder() Request request = new Request.Builder()
.method("POST", RequestBody .method("POST", RequestBody
.create(JSONObject.toJSONString(body), MediaType.get("application/json"))) .create(JSONObject.toJSONString(body), MediaType.get("application/json")))
.url(url) .url(url)
// .addHeader("Authorization",String.format("Bearer %s",token)) .addHeader("Authorization",String.format("Bearer %s",token))
.build(); .build();
try { return execute(request);
execute = client.newCall(request).execute();
if (ObjectUtil.isNotNull(execute) && execute.isSuccessful()) {
return execute.body().string();
} }
} catch (IOException e) {
log.error("http post 请求失败--{}", e); public JSONObject putLark(String url,Map<Object, Object> body, String token) {
Request request = new Request.Builder()
.put(RequestBody
.create(JSONObject.toJSONString(body), MediaType.get("application/json")))
.url(url)
.addHeader("Authorization",String.format("Bearer %s",token))
.build();
return execute(request);
} }
return null;
public JSONObject deleteLark(String url,Map<Object, Object> body, String token) {
Request.Builder builder = new Request.Builder()
.url(url)
.addHeader("Authorization", String.format("Bearer %s", token));
if (body == null || body.isEmpty()){
builder.delete();
}else {
builder.delete(RequestBody
.create(JSONObject.toJSONString(body), MediaType.get("application/json")));
}
return execute(builder.build());
} }
public static void main(String[] args) { public static void main(String[] args) {
LarkTokenHelper helper = new LarkTokenHelper(); LarkTokenHelper helper = new LarkTokenHelper();
String token = helper.getToken( "cli_a482a8572cbc9013", "lZNXbCLlOslWbwBIVc4qvgxOdnfA8Mos"); String token = helper.getToken( "cli_a482a8572cbc9013", "lZNXbCLlOslWbwBIVc4qvgxOdnfA8Mos","tenant_access_token");
System.out.println(token); System.out.println(token);
JSONObject jsonObject = JSONObject.parseObject(token); JSONObject jsonObject = JSONObject.parseObject(token);
helper.getLark("https://open.feishu.cn/open-apis/approval/v4/instances/81D31358-93AF-92D6-7425-01A5D67C4E71",null,jsonObject.getString("tenant_access_token")); Map<Object,Object> map = new HashMap<>();
JSONObject b = new JSONObject();
map.put("fields",b);
b.put("多行文本","345");
helper.putLark("https://open.feishu.cn/open-apis/bitable/v1/apps/Gyu1b8VAFaYiEysfEUjcCKomnVc/tables/tbloMVR0ACW2uO33/records/rece1nuKGU",map,jsonObject.getString("tenant_access_token"));
} }
} }

@ -0,0 +1,77 @@
package com.ruoyi.flyingbook.LarkHelper;
/**
* @author yuxiangyong
* @create 2023-03-14 21:24
*/
public class MultidimensionalTableParamHelper {
public static Object analyseParam(String param,Integer type){
Object result = null;
switch (type){
case 1:
//多行文本
break;
case 2:
//数字
break;
case 3:
//单选
break;
case 4:
//多选
break;
case 5:
//日期
break;
case 7:
//复选框
break;
case 11:
//人员
break;
case 13:
//电话号码
break;
case 15:
//超链接
break;
case 17:
//附件
break;
case 18:
//单向关联
break;
case 19:
//查找引用
break;
case 20:
//公式
break;
case 21:
//双向关联
break;
case 22:
//地理位置
break;
case 1001:
//创建时间
break;
case 1002:
//最后更新时间
break;
case 1003:
//创建人
break;
case 1004:
//修改人
break;
case 1005:
//自动编号
break;
}
return result;
}
}

@ -35,7 +35,6 @@ import java.util.concurrent.TimeUnit;
public class LarkApplicationRunner implements ApplicationRunner { public class LarkApplicationRunner implements ApplicationRunner {
/** /**
* 线 * 线
*/ */
@ -56,7 +55,7 @@ public class LarkApplicationRunner implements ApplicationRunner {
/** /**
* 线 * 线
*/ */
private static final Integer WAIT_TIME = 5000; private static final Integer WAIT_TIME = 10000;
@Autowired @Autowired
private EventMapper eventMapper; private EventMapper eventMapper;
@ -73,8 +72,9 @@ public class LarkApplicationRunner implements ApplicationRunner {
threadPool.execute(() -> { threadPool.execute(() -> {
while (true) { while (true) {
List<String> statusList = Arrays.asList(EventOperateStatus.PENDING.getCode(),EventOperateStatus.FAIL.getCode()); Event query = new Event();
List<Event> eventList = eventMapper.queryListOperate(statusList); query.setOperateStatus(EventOperateStatus.PENDING.getCode());
List<Event> eventList = eventMapper.selectEventList(query);
if (CollectionUtils.isEmpty(eventList)) { if (CollectionUtils.isEmpty(eventList)) {
try { try {
// 没有订单,休息一下 // 没有订单,休息一下

@ -37,9 +37,9 @@ public class EventController extends BaseController {
result = jsonObject.getString("challenge"); result = jsonObject.getString("challenge");
log.info("/event/test1/approval request:{} challenge:{}", jsonObject.toJSONString(), result); log.info("/event/test1/approval request:{} challenge:{}", jsonObject.toJSONString(), result);
} }
LarkRequest larkRequest = new LarkRequest(); // LarkRequest larkRequest = new LarkRequest();
larkRequest.setMessage(result); // larkRequest.setMessage(result);
approvalCallback.execute(larkRequest); // approvalCallback.execute(larkRequest);
return result; return result;
} }
} }

@ -5,11 +5,12 @@ import org.apache.commons.lang3.builder.ToStringStyle;
import com.ruoyi.common.annotation.Excel; import com.ruoyi.common.annotation.Excel;
import com.ruoyi.common.core.domain.BaseEntity; import com.ruoyi.common.core.domain.BaseEntity;
/** /**
* event * event
* *
* @author ruoyi * @author ruoyi
* @date 2023-03-12 * @date 2023-03-15
*/ */
public class Event extends BaseEntity public class Event extends BaseEntity
{ {
@ -17,23 +18,30 @@ public class Event extends BaseEntity
/** $column.columnComment */ /** $column.columnComment */
private Long id; private Long id;
private Integer numbers;
private String eventCode;
/** $column.columnComment */
@Excel(name = "${comment}", readConverterExp = "$column.readConverterExp()")
private String message;
/** pendingsuccessfaild */ /** id */
@Excel(name = "pendingsuccessfaild") @Excel(name = "id")
private String flag; private String appToken;
public Integer getNumbers() { /** id */
return numbers; @Excel(name = "id")
} private String tableId;
public void setNumbers(Integer numbers) { /** id */
this.numbers = numbers; @Excel(name = "id")
} private String recordId;
/** $column.columnComment */
@Excel(name = "id")
private Long numbers;
/** () */
@Excel(name = "()")
private String operateStatus;
/** (01) */
@Excel(name = "(01)")
private Long flag;
public void setId(Long id) public void setId(Long id)
{ {
@ -44,39 +52,70 @@ public class Event extends BaseEntity
{ {
return id; return id;
} }
public void setMessage(String message) public void setAppToken(String appToken)
{ {
this.message = message; this.appToken = appToken;
} }
public String getMessage() public String getAppToken()
{ {
return message; return appToken;
} }
public void setFlag(String flag) public void setTableId(String tableId)
{ {
this.flag = flag; this.tableId = tableId;
} }
public String getFlag() public String getTableId()
{ {
return flag; return tableId;
}
public void setRecordId(String recordId)
{
this.recordId = recordId;
}
public String getRecordId()
{
return recordId;
}
public void setNumbers(Long numbers)
{
this.numbers = numbers;
}
public Long getNumbers()
{
return numbers;
}
public void setOperateStatus(String operateStatus)
{
this.operateStatus = operateStatus;
} }
public String getEventCode() { public String getOperateStatus()
return eventCode; {
return operateStatus;
}
public void setFlag(Long flag)
{
this.flag = flag;
} }
public void setEventCode(String eventCode) { public Long getFlag()
this.eventCode = eventCode; {
return flag;
} }
@Override @Override
public String toString() { public String toString() {
return new ToStringBuilder(this,ToStringStyle.MULTI_LINE_STYLE) return new ToStringBuilder(this,ToStringStyle.MULTI_LINE_STYLE)
.append("id", getId()) .append("id", getId())
.append("message", getMessage()) .append("appToken", getAppToken())
.append("numbers", getMessage()) .append("tableId", getTableId())
.append("recordId", getRecordId())
.append("numbers", getNumbers())
.append("operateStatus", getOperateStatus())
.append("createBy", getCreateBy()) .append("createBy", getCreateBy())
.append("createTime", getCreateTime()) .append("createTime", getCreateTime())
.append("updateBy", getUpdateBy()) .append("updateBy", getUpdateBy())

@ -5,51 +5,62 @@ import org.apache.commons.lang3.builder.ToStringStyle;
import com.ruoyi.common.annotation.Excel; import com.ruoyi.common.annotation.Excel;
import com.ruoyi.common.core.domain.BaseEntity; import com.ruoyi.common.core.domain.BaseEntity;
import java.util.Date;
/** /**
* event_log * event_log
* *
* @author ruoyi * @author ruoyi
* @date 2023-03-12 * @date 2023-03-15
*/ */
public class EventLog extends BaseEntity public class EventLog extends BaseEntity
{ {
private static final long serialVersionUID = 1L; private static final long serialVersionUID = 1L;
/** $column.columnComment */ public EventLog() {
private Long id; }
/** id */ public EventLog(Long eventId, String operateType, String operateInfo) {
@Excel(name = "id") this.eventId = eventId;
private String tableId; this.operateType = operateType;
this.operateInfo = operateInfo;
this.setCreateTime(new Date());
this.setCreateBy("System");
}
/** id */ public EventLog(Long eventId, String operateType, String operateInfo, String errorCode, String errorMessage) {
@Excel(name = "id") this.eventId = eventId;
private String recordId; this.operateType = operateType;
this.operateInfo = operateInfo;
this.errorCode = errorCode;
this.errorMessage = errorMessage;
this.setCreateTime(new Date());
this.setCreateBy("System");
}
/** $column.columnComment */
private Long id;
/** id */ /** $column.columnComment */
@Excel(name = "id") @Excel(name = "${comment}", readConverterExp = "$column.readConverterExp()")
private Long eventId; private Long eventId;
/** $column.columnComment */ /** $column.columnComment */
@Excel(name = "id") @Excel(name = "${comment}", readConverterExp = "$column.readConverterExp()")
private String operateType; private String operateType;
/** $column.columnComment */ /** $column.columnComment */
@Excel(name = "id") @Excel(name = "${comment}", readConverterExp = "$column.readConverterExp()")
private String operateStatus; private String operateInfo;
/** $column.columnComment */ /** $column.columnComment */
@Excel(name = "id") @Excel(name = "${comment}", readConverterExp = "$column.readConverterExp()")
private String errorCode; private String errorCode;
/** $column.columnComment */ /** $column.columnComment */
@Excel(name = "id") @Excel(name = "${comment}", readConverterExp = "$column.readConverterExp()")
private String errorMessage; private String errorMessage;
/** 01 */
@Excel(name = "01")
private Long flag;
public void setId(Long id) public void setId(Long id)
{ {
this.id = id; this.id = id;
@ -59,24 +70,6 @@ public class EventLog extends BaseEntity
{ {
return id; return id;
} }
public void setTableId(String tableId)
{
this.tableId = tableId;
}
public String getTableId()
{
return tableId;
}
public void setRecordId(String recordId)
{
this.recordId = recordId;
}
public String getRecordId()
{
return recordId;
}
public void setEventId(Long eventId) public void setEventId(Long eventId)
{ {
this.eventId = eventId; this.eventId = eventId;
@ -95,14 +88,14 @@ public class EventLog extends BaseEntity
{ {
return operateType; return operateType;
} }
public void setOperateStatus(String operateStatus) public void setOperateInfo(String operateInfo)
{ {
this.operateStatus = operateStatus; this.operateInfo = operateInfo;
} }
public String getOperateStatus() public String getOperateInfo()
{ {
return operateStatus; return operateInfo;
} }
public void setErrorCode(String errorCode) public void setErrorCode(String errorCode)
{ {
@ -122,33 +115,21 @@ public class EventLog extends BaseEntity
{ {
return errorMessage; return errorMessage;
} }
public void setFlag(Long flag)
{
this.flag = flag;
}
public Long getFlag()
{
return flag;
}
@Override @Override
public String toString() { public String toString() {
return new ToStringBuilder(this,ToStringStyle.MULTI_LINE_STYLE) return new ToStringBuilder(this,ToStringStyle.MULTI_LINE_STYLE)
.append("id", getId()) .append("id", getId())
.append("tableId", getTableId())
.append("recordId", getRecordId())
.append("eventId", getEventId()) .append("eventId", getEventId())
.append("operateType", getOperateType()) .append("operateType", getOperateType())
.append("operateStatus", getOperateStatus()) .append("operateInfo", getOperateInfo())
.append("errorCode", getErrorCode()) .append("errorCode", getErrorCode())
.append("errorMessage", getErrorMessage()) .append("errorMessage", getErrorMessage())
.append("remark", getRemark())
.append("createBy", getCreateBy()) .append("createBy", getCreateBy())
.append("createTime", getCreateTime()) .append("createTime", getCreateTime())
.append("updateBy", getUpdateBy()) .append("updateBy", getUpdateBy())
.append("updateTime", getUpdateTime()) .append("updateTime", getUpdateTime())
.append("flag", getFlag())
.append("remark", getRemark())
.toString(); .toString();
} }
} }

@ -9,7 +9,7 @@ import com.ruoyi.common.core.domain.BaseEntity;
* lark_company_relation * lark_company_relation
* *
* @author ruoyi * @author ruoyi
* @date 2023-03-12 * @date 2023-03-15
*/ */
public class LarkCompanyRelation extends BaseEntity public class LarkCompanyRelation extends BaseEntity
{ {
@ -34,6 +34,10 @@ public class LarkCompanyRelation extends BaseEntity
@Excel(name = "+appId") @Excel(name = "+appId")
private String secret; private String secret;
/** app */
@Excel(name = "app")
private String appType;
/** 01 */ /** 01 */
@Excel(name = "01") @Excel(name = "01")
private Long flag; private Long flag;
@ -83,6 +87,15 @@ public class LarkCompanyRelation extends BaseEntity
{ {
return secret; return secret;
} }
public void setAppType(String appType)
{
this.appType = appType;
}
public String getAppType()
{
return appType;
}
public void setFlag(Long flag) public void setFlag(Long flag)
{ {
this.flag = flag; this.flag = flag;
@ -101,6 +114,7 @@ public class LarkCompanyRelation extends BaseEntity
.append("companyName", getCompanyName()) .append("companyName", getCompanyName())
.append("appId", getAppId()) .append("appId", getAppId())
.append("secret", getSecret()) .append("secret", getSecret())
.append("appType", getAppType())
.append("createBy", getCreateBy()) .append("createBy", getCreateBy())
.append("createTime", getCreateTime()) .append("createTime", getCreateTime())
.append("updateBy", getUpdateBy()) .append("updateBy", getUpdateBy())

@ -1,7 +1,12 @@
package com.ruoyi.flyingbook.domain; package com.ruoyi.flyingbook.domain;
import com.alibaba.fastjson.JSONObject;
import com.ruoyi.common.enums.EventOperateType;
import lombok.Data; import lombok.Data;
import java.util.List;
import java.util.Map;
/** /**
* @author yuxiangyong * @author yuxiangyong
* @create 2023-03-12 16:00 * @create 2023-03-12 16:00
@ -13,10 +18,12 @@ public class LarkRequest {
* *
*/ */
private String token; private String token;
private String appId; private String fromAppToken;
private String url; private String toAppToken;
private String errorCode;
private String errorMessage; private String errorMessage;
/** /**
* ApprovalCallback * ApprovalCallback
*/ */
@ -26,5 +33,21 @@ public class LarkRequest {
/** /**
* MultidimensionalTableOperate * MultidimensionalTableOperate
*/ */
private JSONObject record;
private Long companyRelationId;
private Long tableRelationId;
private String fromTableId;
private String toTableId;
private String fromRecordId;
private String toRecordId;
private String operateType;
private String callBackMessage;
private Event event; private Event event;
private EventOperateType eventOperateType;
/**
*
*/
private Map<String/**toToken+toTable*/, Long/**id*/> tableRelationMap;
private Map<Long/**tableRelationId*/,Map<String/**fromRow*/,String/**toRow*/>> tableRowRelationMap;
private Map<Long/**tableRelationId*/,Map<String/**fromCol*/,String/**toCol*/>> tableColRelationMap;
} }

@ -9,7 +9,7 @@ import com.ruoyi.common.core.domain.BaseEntity;
* lark_table_relation * lark_table_relation
* *
* @author ruoyi * @author ruoyi
* @date 2023-03-12 * @date 2023-03-15
*/ */
public class LarkTableRelation extends BaseEntity public class LarkTableRelation extends BaseEntity
{ {
@ -22,17 +22,21 @@ public class LarkTableRelation extends BaseEntity
@Excel(name = "id") @Excel(name = "id")
private Long larkCompanyRelationId; private Long larkCompanyRelationId;
/** $column.columnComment */
@Excel(name = "id")
private String fromAppToken;
/** $column.columnComment */ /** $column.columnComment */
@Excel(name = "id") @Excel(name = "id")
private String fromTableId; private String fromTableId;
/** $column.columnComment */ /** $column.columnComment */
@Excel(name = "id") @Excel(name = "id")
private String toTableId; private String toAppToken;
/** url */ /** $column.columnComment */
@Excel(name = "url") @Excel(name = "id")
private Long url; private String toTableId;
/** 01 */ /** 01 */
@Excel(name = "01") @Excel(name = "01")
@ -56,6 +60,15 @@ public class LarkTableRelation extends BaseEntity
{ {
return larkCompanyRelationId; return larkCompanyRelationId;
} }
public void setFromAppToken(String fromAppToken)
{
this.fromAppToken = fromAppToken;
}
public String getFromAppToken()
{
return fromAppToken;
}
public void setFromTableId(String fromTableId) public void setFromTableId(String fromTableId)
{ {
this.fromTableId = fromTableId; this.fromTableId = fromTableId;
@ -65,23 +78,23 @@ public class LarkTableRelation extends BaseEntity
{ {
return fromTableId; return fromTableId;
} }
public void setToTableId(String toTableId) public void setToAppToken(String toAppToken)
{ {
this.toTableId = toTableId; this.toAppToken = toAppToken;
} }
public String getToTableId() public String getToAppToken()
{ {
return toTableId; return toAppToken;
} }
public void setUrl(Long url) public void setToTableId(String toTableId)
{ {
this.url = url; this.toTableId = toTableId;
} }
public Long getUrl() public String getToTableId()
{ {
return url; return toTableId;
} }
public void setFlag(Long flag) public void setFlag(Long flag)
{ {
@ -98,9 +111,10 @@ public class LarkTableRelation extends BaseEntity
return new ToStringBuilder(this,ToStringStyle.MULTI_LINE_STYLE) return new ToStringBuilder(this,ToStringStyle.MULTI_LINE_STYLE)
.append("id", getId()) .append("id", getId())
.append("larkCompanyRelationId", getLarkCompanyRelationId()) .append("larkCompanyRelationId", getLarkCompanyRelationId())
.append("fromAppToken", getFromAppToken())
.append("fromTableId", getFromTableId()) .append("fromTableId", getFromTableId())
.append("toAppToken", getToAppToken())
.append("toTableId", getToTableId()) .append("toTableId", getToTableId())
.append("url", getUrl())
.append("createBy", getCreateBy()) .append("createBy", getCreateBy())
.append("createTime", getCreateTime()) .append("createTime", getCreateTime())
.append("updateBy", getUpdateBy()) .append("updateBy", getUpdateBy())

@ -0,0 +1,140 @@
package com.ruoyi.flyingbook.domain;
import com.ruoyi.common.enums.FlagStatus;
import org.apache.commons.lang3.builder.ToStringBuilder;
import org.apache.commons.lang3.builder.ToStringStyle;
import com.ruoyi.common.annotation.Excel;
import com.ruoyi.common.core.domain.BaseEntity;
/**
* lark_table_row_relation
*
* @author ruoyi
* @date 2023-03-15
*/
public class LarkTableRowRelation extends BaseEntity
{
private static final long serialVersionUID = 1L;
public LarkTableRowRelation() {
}
public LarkTableRowRelation(Long tableRelationId, String fromId, String toId, String type, String subType) {
this.tableRelationId = tableRelationId;
this.fromId = fromId;
this.toId = toId;
this.type = type;
this.subType = subType;
this.flag = FlagStatus.OK.getCode();
}
/** $column.columnComment */
private Long id;
/** id */
@Excel(name = "id")
private Long tableRelationId;
/** $column.columnComment */
@Excel(name = "id")
private String fromId;
/** $column.columnComment */
@Excel(name = "id")
private String toId;
/** */
@Excel(name = " ")
private String type;
/** $column.columnComment */
@Excel(name = " ")
private String subType;
/** 01 */
@Excel(name = "01")
private Long flag;
public void setId(Long id)
{
this.id = id;
}
public Long getId()
{
return id;
}
public void setTableRelationId(Long tableRelationId)
{
this.tableRelationId = tableRelationId;
}
public Long getTableRelationId()
{
return tableRelationId;
}
public void setFromId(String fromId)
{
this.fromId = fromId;
}
public String getFromId()
{
return fromId;
}
public void setToId(String toId)
{
this.toId = toId;
}
public String getToId()
{
return toId;
}
public void setType(String type)
{
this.type = type;
}
public String getType()
{
return type;
}
public void setSubType(String subType)
{
this.subType = subType;
}
public String getSubType()
{
return subType;
}
public void setFlag(Long flag)
{
this.flag = flag;
}
public Long getFlag()
{
return flag;
}
@Override
public String toString() {
return new ToStringBuilder(this,ToStringStyle.MULTI_LINE_STYLE)
.append("id", getId())
.append("tableRelationId", getTableRelationId())
.append("fromId", getFromId())
.append("toId", getToId())
.append("type", getType())
.append("subType", getSubType())
.append("createBy", getCreateBy())
.append("createTime", getCreateTime())
.append("updateBy", getUpdateBy())
.append("updateTime", getUpdateTime())
.append("flag", getFlag())
.append("remark", getRemark())
.toString();
}
}

@ -62,8 +62,7 @@ public interface EventMapper
*/ */
public int deleteEventByIds(Long[] ids); public int deleteEventByIds(Long[] ids);
/**
* public int updateStatus(@Param("id") Long id,@Param("status") String status);
*/
public List<Event> queryListOperate(@Param("statusList") List<String> statusList);
} }

@ -2,6 +2,7 @@ package com.ruoyi.flyingbook.mapper;
import com.ruoyi.flyingbook.domain.LarkTableRelation; import com.ruoyi.flyingbook.domain.LarkTableRelation;
import org.apache.ibatis.annotations.Param;
import java.util.List; import java.util.List;
@ -60,4 +61,5 @@ public interface LarkTableRelationMapper
* @return * @return
*/ */
public int deleteLarkTableRelationByIds(Long[] ids); public int deleteLarkTableRelationByIds(Long[] ids);
} }

@ -0,0 +1,66 @@
package com.ruoyi.flyingbook.mapper;
import com.ruoyi.flyingbook.domain.LarkTableRowRelation;
import org.apache.ibatis.annotations.Param;
import java.util.List;
/**
* Mapper
*
* @author ruoyi
* @date 2023-03-15
*/
public interface LarkTableRowRelationMapper
{
/**
*
*
* @param id ID
* @return
*/
public LarkTableRowRelation selectLarkTableRowRelationById(Long id);
/**
*
*
* @param larkTableRowRelation
* @return
*/
public List<LarkTableRowRelation> selectLarkTableRowRelationList(LarkTableRowRelation larkTableRowRelation);
/**
*
*
* @param larkTableRowRelation
* @return
*/
public int insertLarkTableRowRelation(LarkTableRowRelation larkTableRowRelation);
/**
*
*
* @param larkTableRowRelation
* @return
*/
public int updateLarkTableRowRelation(LarkTableRowRelation larkTableRowRelation);
/**
*
*
* @param id ID
* @return
*/
public int deleteLarkTableRowRelationById(Long id);
/**
*
*
* @param ids ID
* @return
*/
public int deleteLarkTableRowRelationByIds(Long[] ids);
public List<LarkTableRowRelation> queryListByTableRelationIdList(@Param("tableRelationIdList") List<Long> tableRelationIdList);
}

@ -60,4 +60,6 @@ public interface IEventService
* @return * @return
*/ */
public int deleteEventById(Long id); public int deleteEventById(Long id);
public int updateStatus(Long id,String status);
} }

@ -61,5 +61,5 @@ public interface ILarkCompanyRelationService
*/ */
public int deleteLarkCompanyRelationById(Long id); public int deleteLarkCompanyRelationById(Long id);
public LarkCompanyRelation getByCompanyName(String companyName); public LarkCompanyRelation getByCompanyName(String companyName,String appType);
} }

@ -60,4 +60,6 @@ public interface ILarkTableRelationService
* @return * @return
*/ */
public int deleteLarkTableRelationById(Long id); public int deleteLarkTableRelationById(Long id);
} }

@ -0,0 +1,65 @@
package com.ruoyi.flyingbook.service;
import com.ruoyi.flyingbook.domain.LarkTableRowRelation;
import java.util.List;
/**
* Service
*
* @author ruoyi
* @date 2023-03-15
*/
public interface ILarkTableRowRelationService
{
/**
*
*
* @param id ID
* @return
*/
public LarkTableRowRelation selectLarkTableRowRelationById(Long id);
/**
*
*
* @param larkTableRowRelation
* @return
*/
public List<LarkTableRowRelation> selectLarkTableRowRelationList(LarkTableRowRelation larkTableRowRelation);
/**
*
*
* @param larkTableRowRelation
* @return
*/
public int insertLarkTableRowRelation(LarkTableRowRelation larkTableRowRelation);
/**
*
*
* @param larkTableRowRelation
* @return
*/
public int updateLarkTableRowRelation(LarkTableRowRelation larkTableRowRelation);
/**
*
*
* @param ids ID
* @return
*/
public int deleteLarkTableRowRelationByIds(Long[] ids);
/**
*
*
* @param id ID
* @return
*/
public int deleteLarkTableRowRelationById(Long id);
public List<LarkTableRowRelation> queryListByTableRelationIdList(List<Long> tableRelationIdList);
}

@ -95,4 +95,9 @@ public class EventServiceImpl implements IEventService
{ {
return eventMapper.deleteEventById(id); return eventMapper.deleteEventById(id);
} }
@Override
public int updateStatus(Long id, String status) {
return 0;
}
} }

@ -2,6 +2,7 @@ package com.ruoyi.flyingbook.service.impl;
import java.util.List; import java.util.List;
import com.ruoyi.common.enums.FlagStatus;
import com.ruoyi.common.utils.StringUtils; import com.ruoyi.common.utils.StringUtils;
import com.ruoyi.flyingbook.domain.LarkCompanyRelation; import com.ruoyi.flyingbook.domain.LarkCompanyRelation;
import com.ruoyi.flyingbook.mapper.LarkCompanyRelationMapper; import com.ruoyi.flyingbook.mapper.LarkCompanyRelationMapper;
@ -104,12 +105,15 @@ public class LarkCompanyRelationServiceImpl implements ILarkCompanyRelationServi
* @return * @return
*/ */
@Override @Override
public LarkCompanyRelation getByCompanyName(String companyName) public LarkCompanyRelation getByCompanyName(String companyName,String appType)
{ {
if (StringUtils.isEmpty(companyName)){ if (StringUtils.isEmpty(companyName) || StringUtils.isEmpty(appType)){
return null; return null;
} }
LarkCompanyRelation relation = new LarkCompanyRelation(); LarkCompanyRelation relation = new LarkCompanyRelation();
relation.setCompanyName(companyName);
relation.setAppType(appType);
relation.setFlag(FlagStatus.OK.getCode());
List<LarkCompanyRelation> larkCompanyRelations = larkCompanyRelationMapper.selectLarkCompanyRelationList(relation); List<LarkCompanyRelation> larkCompanyRelations = larkCompanyRelationMapper.selectLarkCompanyRelationList(relation);
return CollectionUtils.isEmpty(larkCompanyRelations) ? null : larkCompanyRelations.get(0); return CollectionUtils.isEmpty(larkCompanyRelations) ? null : larkCompanyRelations.get(0);
} }

@ -1,7 +1,9 @@
package com.ruoyi.flyingbook.service.impl; package com.ruoyi.flyingbook.service.impl;
import java.util.ArrayList;
import java.util.List; import java.util.List;
import com.ruoyi.common.utils.StringUtils;
import com.ruoyi.flyingbook.domain.LarkTableRelation; import com.ruoyi.flyingbook.domain.LarkTableRelation;
import com.ruoyi.flyingbook.mapper.LarkTableRelationMapper; import com.ruoyi.flyingbook.mapper.LarkTableRelationMapper;
import com.ruoyi.flyingbook.service.ILarkTableRelationService; import com.ruoyi.flyingbook.service.ILarkTableRelationService;
@ -94,4 +96,5 @@ public class LarkTableRelationServiceImpl implements ILarkTableRelationService
{ {
return larkTableRelationMapper.deleteLarkTableRelationById(id); return larkTableRelationMapper.deleteLarkTableRelationById(id);
} }
} }

@ -0,0 +1,107 @@
package com.ruoyi.flyingbook.service.impl;
import com.ruoyi.common.utils.DateUtils;
import com.ruoyi.flyingbook.domain.LarkTableRowRelation;
import com.ruoyi.flyingbook.mapper.LarkTableRowRelationMapper;
import com.ruoyi.flyingbook.service.ILarkTableRowRelationService;
import org.apache.commons.collections4.CollectionUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import java.util.ArrayList;
import java.util.List;
/**
* Service
*
* @author ruoyi
* @date 2023-03-15
*/
@Service
public class LarkTableRowRelationServiceImpl implements ILarkTableRowRelationService
{
@Autowired
private LarkTableRowRelationMapper larkTableRowRelationMapper;
/**
*
*
* @param id ID
* @return
*/
@Override
public LarkTableRowRelation selectLarkTableRowRelationById(Long id)
{
return larkTableRowRelationMapper.selectLarkTableRowRelationById(id);
}
/**
*
*
* @param larkTableRowRelation
* @return
*/
@Override
public List<LarkTableRowRelation> selectLarkTableRowRelationList(LarkTableRowRelation larkTableRowRelation)
{
return larkTableRowRelationMapper.selectLarkTableRowRelationList(larkTableRowRelation);
}
/**
*
*
* @param larkTableRowRelation
* @return
*/
@Override
public int insertLarkTableRowRelation(LarkTableRowRelation larkTableRowRelation)
{
larkTableRowRelation.setCreateTime(DateUtils.getNowDate());
return larkTableRowRelationMapper.insertLarkTableRowRelation(larkTableRowRelation);
}
/**
*
*
* @param larkTableRowRelation
* @return
*/
@Override
public int updateLarkTableRowRelation(LarkTableRowRelation larkTableRowRelation)
{
larkTableRowRelation.setUpdateTime(DateUtils.getNowDate());
return larkTableRowRelationMapper.updateLarkTableRowRelation(larkTableRowRelation);
}
/**
*
*
* @param ids ID
* @return
*/
@Override
public int deleteLarkTableRowRelationByIds(Long[] ids)
{
return larkTableRowRelationMapper.deleteLarkTableRowRelationByIds(ids);
}
/**
*
*
* @param id ID
* @return
*/
@Override
public int deleteLarkTableRowRelationById(Long id)
{
return larkTableRowRelationMapper.deleteLarkTableRowRelationById(id);
}
@Override
public List<LarkTableRowRelation> queryListByTableRelationIdList(List<Long> tableRelationIdList) {
if (CollectionUtils.isEmpty(tableRelationIdList)){
return new ArrayList<>();
}
return larkTableRowRelationMapper.queryListByTableRelationIdList(tableRelationIdList);
}
}

@ -1,5 +1,7 @@
package com.ruoyi.flyingbook.strategy; package com.ruoyi.flyingbook.strategy;
import com.ruoyi.common.enums.EventOperateType;
import com.ruoyi.flyingbook.domain.EventLog;
import com.ruoyi.flyingbook.domain.LarkRequest; import com.ruoyi.flyingbook.domain.LarkRequest;
import lombok.extern.slf4j.Slf4j; import lombok.extern.slf4j.Slf4j;
@ -21,10 +23,20 @@ public abstract class LarkOperateAbstract{
preOperate(request); preOperate(request);
//真正的业务处理逻辑 //真正的业务处理逻辑
businessProcessing(request); businessProcessing(request);
//业务处理完成后的系列操作,例如日志
endHandle(request);
}catch (Exception e){ }catch (Exception e){
log.error("{} execute error: {}",getName(),e); log.error("{} execute error: {}",getName(),e);
String message = e.getMessage();
if (message.contains("##")){
String[] split = message.split("##");
request.setErrorCode(split[0]);
request.setErrorMessage(split[1]);
}else {
request.setErrorMessage(message);
}
}finally {
//业务处理完成后的系列操作,例如日志
endHandle(request);
} }
//构建返回对象并返回 //构建返回对象并返回
return buildResult(request); return buildResult(request);
@ -52,9 +64,7 @@ public abstract class LarkOperateAbstract{
/** /**
* *
*/ */
protected void endHandle(LarkRequest request){ protected void endHandle(LarkRequest request){};
}
/** /**
* *

@ -1,5 +1,7 @@
package com.ruoyi.flyingbook.strategy.callback; package com.ruoyi.flyingbook.strategy.callback;
import com.alibaba.fastjson.JSONArray;
import com.alibaba.fastjson.JSONObject;
import com.ruoyi.flyingbook.domain.Event; import com.ruoyi.flyingbook.domain.Event;
import com.ruoyi.flyingbook.domain.EventLog; import com.ruoyi.flyingbook.domain.EventLog;
import com.ruoyi.flyingbook.service.IEventLogService; import com.ruoyi.flyingbook.service.IEventLogService;
@ -9,12 +11,16 @@ import com.ruoyi.common.constant.RedisConstants;
import com.ruoyi.common.enums.EventOperateStatus; import com.ruoyi.common.enums.EventOperateStatus;
import com.ruoyi.common.enums.EventOperateType; import com.ruoyi.common.enums.EventOperateType;
import com.ruoyi.common.enums.FlagStatus; import com.ruoyi.common.enums.FlagStatus;
import com.sun.corba.se.impl.orbutil.RepIdDelegator;
import lombok.extern.slf4j.Slf4j; import lombok.extern.slf4j.Slf4j;
import org.apache.commons.collections4.CollectionUtils;
import org.apache.commons.lang3.StringUtils;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.redis.core.RedisTemplate; import org.springframework.data.redis.core.RedisTemplate;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
import java.util.Date; import java.util.Date;
import java.util.List;
/** /**
* @author yuxiangyong * @author yuxiangyong
@ -33,22 +39,53 @@ public class ApprovalCallback extends CallbackAbstract {
@Override @Override
protected Boolean check(LarkRequest request) { protected Boolean check(LarkRequest request) {
String message = "";
return Boolean.TRUE; return Boolean.TRUE;
} }
@Override @Override
protected void preOperate(LarkRequest request) { protected void preOperate(LarkRequest request) {
if (StringUtils.isBlank(request.getMessage())) {
return;
}
String message = request.getMessage();
JSONObject jsonObject = JSONObject.parseObject(message);
JSONObject event = jsonObject.getJSONObject("event");
if (event == null) {
return;
}
request.setFromAppToken(event.getString("file_token"));
request.setFromTableId(event.getString("table_id"));
JSONArray actionList = event.getJSONArray("action_list");
if (CollectionUtils.isEmpty(actionList)) {
return;
}
JSONObject action = actionList.getJSONObject(0);
String recordId = action.getString("record_id");
request.setFromRecordId(recordId);
} }
@Override @Override
protected void businessProcessing(LarkRequest request) { protected void businessProcessing(LarkRequest request) {
String message = request.getMessage(); String cacheKey = String.format("%s_%s_%s_%s", RedisConstants.MULTIPLE_TABLE_RECORD, request.getFromAppToken(),request.getFromTableId(), request.getFromRecordId());
Event event = this.buildDto(message); String eventStr = (String)redisTemplate.opsForValue().get(cacheKey);
int i = eventService.insertEvent(event); Event event = null;
if (StringUtils.isBlank(eventStr)){
event = queryEvent(request.getFromAppToken(),request.getFromTableId(), request.getFromRecordId());
}else {
event = JSONObject.parseObject(eventStr,Event.class);
}
//如果已经存在处理中的就不需要操作数据库了
if (event != null && EventOperateStatus.PENDING.getCode().equals(event.getOperateStatus())){
return;
}
this.buildDto(request,event);
if (event.getId() == null){
eventService.insertEvent(event);
redisTemplate.opsForValue().set(cacheKey,JSONObject.toJSONString(event));
}else {
eventService.updateStatus(event.getId(),EventOperateStatus.PENDING.getCode());
}
request.setEventId(event.getId()); request.setEventId(event.getId());
} }
@Override @Override
@ -56,17 +93,13 @@ public class ApprovalCallback extends CallbackAbstract {
if (request.getEventId() == null){ if (request.getEventId() == null){
return; return;
} }
redisTemplate.opsForList().rightPush(RedisConstants.MULTIDIMENSIONALTABULARFEEDBACK,request.getEventId()); if (StringUtils.isNotBlank(request.getErrorMessage())){
EventLog eventLog = new EventLog();
eventLog.setCreateBy("Syetem"); }
eventLog.setCreateTime(new Date()); EventLog eventLog = StringUtils.isBlank(request.getErrorMessage()) ?
eventLog.setFlag(FlagStatus.OK.getCode()); new EventLog(request.getEventId(),EventOperateType.CALL_BACK.getCode(),request.getMessage())
eventLog.setOperateStatus(EventOperateStatus.PENDING.getCode()); : new EventLog(request.getEventId(),EventOperateType.CALL_BACK.getCode(),request.getMessage(),request.getErrorCode(),request.getErrorMessage());
eventLog.setOperateType(EventOperateType.CALL_BACK.getCode());
eventLog.setEventId(request.getEventId());
eventLogService.insertEventLog(eventLog); eventLogService.insertEventLog(eventLog);
Object o = redisTemplate.opsForList().leftPop(RedisConstants.MULTIDIMENSIONALTABULARFEEDBACK);
System.out.println(String.valueOf(o));
} }
@Override @Override
@ -80,14 +113,31 @@ public class ApprovalCallback extends CallbackAbstract {
return this.getClass().getSimpleName(); return this.getClass().getSimpleName();
} }
private Event queryEvent(String appToken,String tableId,String recordId){
private Event buildDto(String message){
Event event = new Event(); Event event = new Event();
event.setFlag(EventOperateStatus.PENDING.getCode()); event.setAppToken(appToken);
event.setMessage(message); event.setTableId(tableId);
event.setEventCode("test"); event.setRecordId(recordId);
List<Event> events = eventService.selectEventList(event);
if (CollectionUtils.isNotEmpty(events)){
return events.get(0);
}
return null;
}
private Event buildDto(LarkRequest request,Event event){
event = event == null ? new Event() :event;
event.setFlag(FlagStatus.OK.getCode());
event.setAppToken(request.getFromAppToken());
event.setTableId(request.getFromTableId());
event.setRecordId(request.getFromRecordId());
event.setNumbers(0L);
event.setOperateStatus(EventOperateStatus.PENDING.getCode());
event.setCreateBy("System"); event.setCreateBy("System");
event.setCreateTime(new Date()); event.setCreateTime(new Date());
event.setUpdateTime(new Date());
event.setUpdateBy("System");
return event; return event;
} }

@ -21,12 +21,8 @@ public abstract class LarkAbstract extends LarkOperateAbstract {
/** /**
* body * body
*/ */
protected abstract Map<Object,Object> getBody(String message); protected abstract Map<Object,Object> getBody(LarkRequest request);
/**
*
*/
protected abstract JSONObject send(String url,Map<Object,Object> body,String token);

@ -2,24 +2,34 @@ package com.ruoyi.flyingbook.strategy.operate;
import com.alibaba.fastjson.JSONObject; import com.alibaba.fastjson.JSONObject;
import com.ruoyi.common.constant.CompanyNameConstants; import com.ruoyi.common.constant.CompanyNameConstants;
import com.ruoyi.common.constant.RedisConstants;
import com.ruoyi.common.enums.AppType;
import com.ruoyi.common.enums.EventOperateStatus;
import com.ruoyi.common.enums.FlagStatus;
import com.ruoyi.common.enums.TableDetailRelationTypeEnum;
import com.ruoyi.flyingbook.LarkHelper.LarkTokenHelper; import com.ruoyi.flyingbook.LarkHelper.LarkTokenHelper;
import com.ruoyi.flyingbook.domain.Event; import com.ruoyi.flyingbook.domain.*;
import com.ruoyi.flyingbook.domain.LarkCompanyRelation; import com.ruoyi.flyingbook.service.*;
import com.ruoyi.flyingbook.domain.LarkRequest; import lombok.extern.slf4j.Slf4j;
import com.ruoyi.flyingbook.service.IEventService; import org.apache.commons.collections4.CollectionUtils;
import com.ruoyi.flyingbook.service.ILarkCompanyRelationService;
import org.apache.commons.lang3.StringUtils; import org.apache.commons.lang3.StringUtils;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.redis.core.RedisTemplate;
import org.springframework.stereotype.Component; import org.springframework.stereotype.Component;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map; import java.util.Map;
/** /**
* *
*
* @author yuxiangyong * @author yuxiangyong
* @create 2023-03-13 20:47 * @create 2023-03-13 20:47
*/ */
@Slf4j
@Component("MultidimensionalTableOperate") @Component("MultidimensionalTableOperate")
public class MultidimensionalTableOperate extends LarkAbstract { public class MultidimensionalTableOperate extends LarkAbstract {
@ -29,54 +39,198 @@ public class MultidimensionalTableOperate extends LarkAbstract {
protected ILarkCompanyRelationService larkCompanyRelationService; protected ILarkCompanyRelationService larkCompanyRelationService;
@Autowired @Autowired
protected IEventService iEventService; protected IEventService iEventService;
@Autowired
private RedisTemplate redisTemplate;
@Autowired
protected ILarkTableRelationService iLarkTableRelationService;
@Autowired
protected ILarkTableRowRelationService iLarkTableRowRelationService;
@Autowired
private IEventService eventService;
@Autowired
private IEventLogService eventLogService;
/**
*
*/
private static final String DETAIL = "DETAIL";
private String getDetail = "https://open.feishu.cn/open-apis/bitable/v1/apps/:app_token/tables/:table_id/records/:record_id";
//新增明细行
private static final String CREATE_OPERATE = "CREATE_OPERATE";
private String addLine = "https://open.feishu.cn/open-apis/bitable/v1/apps/:app_token/tables/:table_id/records";
//修改明细行
private static final String UPDATE_OPERATE = "UPDATE_OPERATE";
private String updateLine = "https://open.feishu.cn/open-apis/bitable/v1/apps/:app_token/tables/:table_id/records/:record_id";
//删除明细行
private static final String DELETE_OPERATE = "DELETE_OPERATE";
private String deleteLine = "https://open.feishu.cn/open-apis/bitable/v1/apps/:app_token/tables/:table_id/records/:record_id";
private String getDetailUrl = "https://open.feishu.cn/open-apis/approval/v4/instances/:instance_id";
private void fillTableRelation(LarkRequest request) {
LarkTableRelation tableRelation = new LarkTableRelation();
tableRelation.setLarkCompanyRelationId(request.getCompanyRelationId());
tableRelation.setFromTableId(request.getEvent().getTableId());
tableRelation.setFlag(FlagStatus.OK.getCode());
List<LarkTableRelation> larkTableRelations = iLarkTableRelationService.selectLarkTableRelationList(tableRelation);
if (CollectionUtils.isEmpty(larkTableRelations)) {
String errorMessage = String.format("tableId:{}表关系未配置", request.getEvent().getTableId());
log.error("iLarkTableRelationService.selectLarkTableRelationList:{}", errorMessage);
throw new RuntimeException(errorMessage);
}
//主表与副表的列对应关系
List<Long> tableRelationIdList = new ArrayList<>();
Map<String, Long> tableRelationMap = new HashMap<>();
for (LarkTableRelation larkTableRelation : larkTableRelations) {
String to = String.format("%s_%s", larkTableRelation.getToAppToken(), larkTableRelation.getToTableId());
tableRelationMap.put(to, larkTableRelation.getId());
tableRelationIdList.add(larkTableRelation.getId());
}
request.setTableRelationMap(tableRelationMap);
//主表与副表的行对应关系
List<LarkTableRowRelation> larkTableRowRelations = iLarkTableRowRelationService.queryListByTableRelationIdList(tableRelationIdList);
Map<Long, Map<String, String>> tableRowRelationMap = new HashMap<>();
Map<Long, Map<String, String>> tableColRelationMap = new HashMap<>();
for (LarkTableRowRelation larkTableRowRelation : larkTableRowRelations) {
Map<String, String> map = new HashMap<>();
map.put(larkTableRowRelation.getFromId(), larkTableRowRelation.getToId());
if (TableDetailRelationTypeEnum.ROW.getCode().equals(larkTableRowRelation.getType())) {
tableRowRelationMap.put(larkTableRowRelation.getTableRelationId(), map);
} else if (TableDetailRelationTypeEnum.COL.getCode().equals(larkTableRowRelation.getType())) {
tableColRelationMap.put(larkTableRowRelation.getTableRelationId(), map);
}
}
if (tableColRelationMap.isEmpty()) {
String errorMessage = String.format("tableId:{} 列关系未配置", request.getEvent().getTableId());
log.error("iLarkTableRowRelationService.queryListByTableRelationIdList:{}", errorMessage);
throw new RuntimeException(errorMessage);
}
request.setTableRowRelationMap(tableRowRelationMap);
request.setTableColRelationMap(tableColRelationMap);
}
@Override @Override
protected void preOperate(LarkRequest request) { protected void preOperate(LarkRequest request) {
Event event = request.getEvent(); Event event = request.getEvent();
if (event == null) { if (event == null) {
return; throw new RuntimeException("当前事件为空");
} }
LarkCompanyRelation relation = larkCompanyRelationService.getByCompanyName(CompanyNameConstants.COMPANY_NAME); LarkCompanyRelation relation = larkCompanyRelationService.getByCompanyName(CompanyNameConstants.COMPANY_NAME, AppType.APPROVAL.getCode());
if (relation == null) { if (relation == null) {
return; String errorMessage = String.format("获取app值为空 companyName:{} appType:{}", CompanyNameConstants.COMPANY_NAME, AppType.APPROVAL.getCode());
} log.error("larkCompanyRelationService.getByCompanyName:{}", errorMessage);
String token = larkTokenHelper.getToken(relation.getAppId(), relation.getSecret()); throw new RuntimeException(errorMessage);
if (StringUtils.isBlank(token)) {
return;
} }
//用于后续追加row时候做关联关系
request.setCompanyRelationId(relation.getId());
//关联关系表填充
this.fillTableRelation(request);
String token = larkTokenHelper.getToken(relation.getAppId(), relation.getSecret(),"tenant_access_token");
request.setToken(token); request.setToken(token);
if (StringUtils.isNotBlank(event.getMessage())) {
return;
}
getDetailUrl.replace(":instance_id", "aaa");
String message = larkTokenHelper.postLark(getDetailUrl, null, token);
event.setMessage(message);
} }
@Override @Override
protected void businessProcessing(LarkRequest request) { protected void businessProcessing(LarkRequest request) {
if (StringUtils.isBlank(request.getToken()) || request.getEvent() == null || StringUtils.isBlank(request.getEvent().getMessage())) { request.setOperateType(DETAIL);
JSONObject message = larkTokenHelper.getLark(getUrl(request), null, request.getToken());
request.setRecord(message);
for (Map.Entry<String, Long> entry : request.getTableRelationMap().entrySet()) {
request.setToTableId(entry.getKey());
request.setTableRelationId(entry.getValue());
Map<Object, Object> body = getBody(request);
String url = getUrl(request);
if (StringUtils.isBlank(url)) {
return; return;
} }
send(getUrl(request), getBody(request.getMessage()), request.getToken()); send(request.getOperateType(), url, body, request);
}
} }
@Override @Override
protected String getUrl(LarkRequest request) { protected String getUrl(LarkRequest request) {
Event event = request.getEvent();
Map<String, String> rowRelation = request.getTableRowRelationMap().get(request.getTableRelationId());
String cacheKey = String.format("%s_%s_%s_%s", RedisConstants.MULTIPLE_TABLE_RECORD, event.getAppToken(), event.getTableId(), event.getRecordId());
redisTemplate.delete(cacheKey);
if (UPDATE_OPERATE.equals(request.getOperateType())) {
if (rowRelation.containsKey(event.getRecordId())) {
return updateLine.replace(":app_token", event.getAppToken()).replace(":table_id", request.getToTableId()).replace(":record_id", rowRelation.get(event.getRecordId()));
}
} else if (CREATE_OPERATE.equals(request.getOperateType())) {
return addLine.replace(":app_token", event.getAppToken()).replace(":table_id", request.getToTableId());
} else if (DELETE_OPERATE.equals(request.getOperateType())) {
if (rowRelation.containsKey(event.getRecordId())) {
return deleteLine.replace(":app_token", event.getAppToken()).replace(":table_id", event.getTableId()).replace(":record_id", rowRelation.get(event.getRecordId()));
}
} else if (DETAIL.equals(request.getOperateType())) {
return getDetail.replace(":app_token", event.getAppToken()).replace(":table_id", event.getTableId()).replace(":record_id", event.getRecordId());
}
return null; return null;
} }
@Override @Override
protected Map<Object, Object> getBody(String message) { protected Map<Object, Object> getBody(LarkRequest request) {
return null; Map<Object, Object> result = new HashMap<>();
JSONObject record = request.getRecord();
String responseCode = record.getString("code");
Map<String, String> rowMap = request.getTableRowRelationMap().get(request.getTableRelationId());
if ("1254043".equals(responseCode)) {
request.setOperateType(DELETE_OPERATE);
} else if ("0".equals(responseCode)) {
result = parseMap(request);
if (rowMap.containsKey(request.getEvent().getRecordId())) {
request.setOperateType(UPDATE_OPERATE);
} else {
request.setOperateType(CREATE_OPERATE);
}
}
return result;
}
private Map<Object, Object> parseMap(LarkRequest request) {
Map<Object, Object> result = new HashMap<>();
JSONObject record = request.getRecord();
Map<String, String> colRelation = request.getTableColRelationMap().get(request.getToTableId());
String fields = record.getJSONObject("data").getJSONObject("record").getString("fields");
Map<Object, Object> midMap = JSONObject.parseObject(fields, Map.class);
for (Map.Entry<Object, Object> entry : midMap.entrySet()) {
String key = String.valueOf(entry);
if (!colRelation.containsKey(key)) {
continue;
}
result.put(colRelation.get(key), entry.getValue());
}
Map<Object, Map<Object, Object>> map = new HashMap<>();
map.put("fields",result);
return result;
}
protected void send(String type, String url, Map<Object, Object> body, LarkRequest request) {
String token = request.getToken();
if (CREATE_OPERATE.equals(type)) {
JSONObject result = larkTokenHelper.postLark(url, body, token);
JSONObject data = result.getJSONObject("data");
if (data != null) {
JSONObject record = data.getJSONObject("record");
if (record != null && StringUtils.isNotBlank(record.getString("record_id"))) {
String recordId = record.getString("record_id");
LarkTableRowRelation rowRelation = new LarkTableRowRelation(request.getCompanyRelationId(), request.getEvent().getRecordId(), recordId, TableDetailRelationTypeEnum.ROW.getCode(), TableDetailRelationTypeEnum.ROW.getCode());
iLarkTableRowRelationService.insertLarkTableRowRelation(rowRelation);
}
}
} else if (UPDATE_OPERATE.equals(type)) {
larkTokenHelper.putLark(url, body, token);
} else if (DELETE_OPERATE.equals(type)) {
larkTokenHelper.deleteLark(url, body, token);
}
} }
@Override @Override
protected JSONObject send(String url, Map<Object, Object> body, String token) { protected void endHandle(LarkRequest request) {
larkTokenHelper.postLark(url,body,token); Event event = request.getEvent();
return null; eventService.updateStatus(event.getId(), EventOperateStatus.SUCCESS.getCode());
EventLog eventLog = StringUtils.isBlank(request.getErrorMessage()) ?
new EventLog(event.getId(), request.getEventOperateType().getCode(), request.getMessage())
: new EventLog(event.getId(), request.getEventOperateType().getCode(), request.getMessage(), request.getErrorCode(), request.getErrorMessage());
eventLogService.insertEventLog(eventLog);
} }
@Override @Override

@ -1,55 +1,35 @@
<?xml version="1.0" encoding="UTF-8" ?> <?xml version="1.0" encoding="UTF-8" ?>
<!DOCTYPE mapper <!DOCTYPE mapper
PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
"http://mybatis.org/dtd/mybatis-3-mapper.dtd"> "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="com.ruoyi.flyingbook.mapper.EventLogMapper"> <mapper namespace="com.ruoyi.flyingbook.mapper.EventLogMapper">
<resultMap type="EventLog" id="EventLogResult"> <resultMap type="com.ruoyi.flyingbook.domain.EventLog" id="EventLogResult">
<result property="id" column="id"/> <result property="id" column="id" />
<result property="tableId" column="table_id"/> <result property="eventId" column="event_id" />
<result property="recordId" column="record_id"/> <result property="operateType" column="operate_type" />
<result property="eventId" column="event_id"/> <result property="operateInfo" column="operate_info" />
<result property="operateType" column="operate_type"/> <result property="errorCode" column="error_code" />
<result property="operateStatus" column="operate_status"/> <result property="errorMessage" column="error_message" />
<result property="errorCode" column="error_code"/> <result property="remark" column="remark" />
<result property="errorMessage" column="error_message"/> <result property="createBy" column="create_by" />
<result property="createBy" column="create_by"/> <result property="createTime" column="create_time" />
<result property="createTime" column="create_time"/> <result property="updateBy" column="update_by" />
<result property="updateBy" column="update_by"/> <result property="updateTime" column="update_time" />
<result property="updateTime" column="update_time"/>
<result property="flag" column="flag"/>
<result property="remark" column="remark"/>
</resultMap> </resultMap>
<sql id="selectEventLogVo"> <sql id="selectEventLogVo">
select id, select id, event_id, operate_type, operate_info, error_code, error_message, remark, create_by, create_time, update_by, update_time from event_log
table_id,
record_id,
event_id,
operate_type,
operate_status,
error_code,
error_message,
create_by,
create_time,
update_by,
update_time,
flag,
remark
from event_log
</sql> </sql>
<select id="selectEventLogList" parameterType="EventLog" resultMap="EventLogResult"> <select id="selectEventLogList" parameterType="com.ruoyi.flyingbook.domain.EventLog" resultMap="EventLogResult">
<include refid="selectEventLogVo"/> <include refid="selectEventLogVo"/>
<where> <where>
<if test="tableId != null and tableId != ''">and table_id = #{tableId}</if> <if test="eventId != null "> and event_id = #{eventId}</if>
<if test="recordId != null and recordId != ''">and record_id = #{recordId}</if> <if test="operateType != null and operateType != ''"> and operate_type = #{operateType}</if>
<if test="eventId != null">and event_id = #{eventId}</if> <if test="operateInfo != null and operateInfo != ''"> and operate_info = #{operateInfo}</if>
<if test="operateType != null and operateType != ''">and operate_type = #{operateType}</if> <if test="errorCode != null and errorCode != ''"> and error_code = #{errorCode}</if>
<if test="operateStatus != null and operateStatus != ''">and operate_status = #{operateStatus}</if> <if test="errorMessage != null and errorMessage != ''"> and error_message = #{errorMessage}</if>
<if test="errorCode != null and errorCode != ''">and error_code = #{errorCode}</if>
<if test="errorMessage != null and errorMessage != ''">and error_message = #{errorMessage}</if>
<if test="flag != null ">and flag = #{flag}</if>
</where> </where>
</select> </select>
@ -58,64 +38,53 @@
where id = #{id} where id = #{id}
</select> </select>
<insert id="insertEventLog" parameterType="EventLog" useGeneratedKeys="true" keyProperty="id"> <insert id="insertEventLog" parameterType="com.ruoyi.flyingbook.domain.EventLog" useGeneratedKeys="true" keyProperty="id">
insert into event_log insert into event_log
<trim prefix="(" suffix=")" suffixOverrides=","> <trim prefix="(" suffix=")" suffixOverrides=",">
<if test="tableId != null">table_id,</if>
<if test="recordId != null">record_id,</if>
<if test="eventId != null">event_id,</if> <if test="eventId != null">event_id,</if>
<if test="operateType != null">operate_type,</if> <if test="operateType != null">operate_type,</if>
<if test="operateStatus != null">operate_status,</if> <if test="operateInfo != null">operate_info,</if>
<if test="errorCode != null">error_code,</if> <if test="errorCode != null">error_code,</if>
<if test="errorMessage != null">error_message,</if> <if test="errorMessage != null">error_message,</if>
<if test="remark != null">remark,</if>
<if test="createBy != null and createBy != ''">create_by,</if> <if test="createBy != null and createBy != ''">create_by,</if>
<if test="createTime != null">create_time,</if> <if test="createTime != null">create_time,</if>
<if test="updateBy != null">update_by,</if> <if test="updateBy != null">update_by,</if>
<if test="updateTime != null">update_time,</if> <if test="updateTime != null">update_time,</if>
<if test="flag != null">flag,</if>
<if test="remark != null">remark,</if>
</trim> </trim>
<trim prefix="values (" suffix=")" suffixOverrides=","> <trim prefix="values (" suffix=")" suffixOverrides=",">
<if test="tableId != null">#{tableId},</if>
<if test="recordId != null">#{recordId},</if>
<if test="eventId != null">#{eventId},</if> <if test="eventId != null">#{eventId},</if>
<if test="operateType != null">#{operateType},</if> <if test="operateType != null">#{operateType},</if>
<if test="operateStatus != null">#{operateStatus},</if> <if test="operateInfo != null">#{operateInfo},</if>
<if test="errorCode != null">#{errorCode},</if> <if test="errorCode != null">#{errorCode},</if>
<if test="errorMessage != null">#{errorMessage},</if> <if test="errorMessage != null">#{errorMessage},</if>
<if test="remark != null">#{remark},</if>
<if test="createBy != null and createBy != ''">#{createBy},</if> <if test="createBy != null and createBy != ''">#{createBy},</if>
<if test="createTime != null">#{createTime},</if> <if test="createTime != null">#{createTime},</if>
<if test="updateBy != null">#{updateBy},</if> <if test="updateBy != null">#{updateBy},</if>
<if test="updateTime != null">#{updateTime},</if> <if test="updateTime != null">#{updateTime},</if>
<if test="flag != null">#{flag},</if>
<if test="remark != null">#{remark},</if>
</trim> </trim>
</insert> </insert>
<update id="updateEventLog" parameterType="EventLog"> <update id="updateEventLog" parameterType="com.ruoyi.flyingbook.domain.EventLog">
update event_log update event_log
<trim prefix="SET" suffixOverrides=","> <trim prefix="SET" suffixOverrides=",">
<if test="tableId != null">table_id = #{tableId},</if>
<if test="recordId != null">record_id = #{recordId},</if>
<if test="eventId != null">event_id = #{eventId},</if> <if test="eventId != null">event_id = #{eventId},</if>
<if test="operateType != null">operate_type = #{operateType},</if> <if test="operateType != null">operate_type = #{operateType},</if>
<if test="operateStatus != null">operate_status = #{operateStatus},</if> <if test="operateInfo != null">operate_info = #{operateInfo},</if>
<if test="errorCode != null">error_code = #{errorCode},</if> <if test="errorCode != null">error_code = #{errorCode},</if>
<if test="errorMessage != null">error_message = #{errorMessage},</if> <if test="errorMessage != null">error_message = #{errorMessage},</if>
<if test="remark != null">remark = #{remark},</if>
<if test="createBy != null and createBy != ''">create_by = #{createBy},</if> <if test="createBy != null and createBy != ''">create_by = #{createBy},</if>
<if test="createTime != null">create_time = #{createTime},</if> <if test="createTime != null">create_time = #{createTime},</if>
<if test="updateBy != null">update_by = #{updateBy},</if> <if test="updateBy != null">update_by = #{updateBy},</if>
<if test="updateTime != null">update_time = #{updateTime},</if> <if test="updateTime != null">update_time = #{updateTime},</if>
<if test="flag != null">flag = #{flag},</if>
<if test="remark != null">remark = #{remark},</if>
</trim> </trim>
where id = #{id} where id = #{id}
</update> </update>
<delete id="deleteEventLogById" parameterType="Long"> <delete id="deleteEventLogById" parameterType="Long">
delete delete from event_log where id = #{id}
from event_log
where id = #{id}
</delete> </delete>
<delete id="deleteEventLogByIds" parameterType="String"> <delete id="deleteEventLogByIds" parameterType="String">

@ -1,41 +1,37 @@
<?xml version="1.0" encoding="UTF-8" ?> <?xml version="1.0" encoding="UTF-8" ?>
<!DOCTYPE mapper <!DOCTYPE mapper
PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
"http://mybatis.org/dtd/mybatis-3-mapper.dtd"> "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="com.ruoyi.flyingbook.mapper.EventMapper"> <mapper namespace="com.ruoyi.flyingbook.mapper.EventMapper">
<resultMap type="Event" id="EventResult"> <resultMap type="com.ruoyi.flyingbook.domain.Event" id="EventResult">
<result property="id" column="id"/> <result property="id" column="id" />
<result property="event_code" column="eventCode"/> <result property="appToken" column="app_token" />
<result property="message" column="message"/> <result property="tableId" column="table_id" />
<result property="numbers" column="numbers"/> <result property="recordId" column="record_id" />
<result property="createBy" column="create_by"/> <result property="numbers" column="numbers" />
<result property="createTime" column="create_time"/> <result property="operateStatus" column="operate_status" />
<result property="updateBy" column="update_by"/> <result property="createBy" column="create_by" />
<result property="updateTime" column="update_time"/> <result property="createTime" column="create_time" />
<result property="flag" column="flag"/> <result property="updateBy" column="update_by" />
<result property="remark" column="remark"/> <result property="updateTime" column="update_time" />
<result property="flag" column="flag" />
<result property="remark" column="remark" />
</resultMap> </resultMap>
<sql id="selectEventVo"> <sql id="selectEventVo">
select id, select id, app_token, table_id, record_id, numbers, operate_status, create_by, create_time, update_by, update_time, flag, remark from event
event_code,
message,
numbers,
create_by,
create_time,
update_by,
update_time,
flag,
remark
from event
</sql> </sql>
<select id="selectEventList" parameterType="Event" resultMap="EventResult"> <select id="selectEventList" parameterType="com.ruoyi.flyingbook.domain.Event" resultMap="EventResult">
<include refid="selectEventVo"/> <include refid="selectEventVo"/>
<where> <where>
<if test="message != null and message != ''">and message = #{message}</if> <if test="appToken != null and appToken != ''"> and app_token = #{appToken}</if>
<if test="flag != null and flag != ''">and flag = #{flag}</if> <if test="tableId != null and tableId != ''"> and table_id = #{tableId}</if>
<if test="recordId != null and recordId != ''"> and record_id = #{recordId}</if>
<if test="numbers != null "> and numbers = #{numbers}</if>
<if test="operateStatus != null and operateStatus != ''"> and operate_status = #{operateStatus}</if>
<if test="flag != null "> and flag = #{flag}</if>
</where> </where>
</select> </select>
@ -44,52 +40,56 @@
where id = #{id} where id = #{id}
</select> </select>
<insert id="insertEvent" parameterType="Event" useGeneratedKeys="true" keyProperty="id"> <insert id="insertEvent" parameterType="com.ruoyi.flyingbook.domain.Event" useGeneratedKeys="true" keyProperty="id">
insert into event insert into event
<trim prefix="(" suffix=")" suffixOverrides=","> <trim prefix="(" suffix=")" suffixOverrides=",">
<if test="eventCode != null">event_code,</if> <if test="appToken != null">app_token,</if>
<if test="message != null">message,</if> <if test="tableId != null">table_id,</if>
<if test="recordId != null">record_id,</if>
<if test="numbers != null">numbers,</if> <if test="numbers != null">numbers,</if>
<if test="operateStatus != null">operate_status,</if>
<if test="createBy != null and createBy != ''">create_by,</if> <if test="createBy != null and createBy != ''">create_by,</if>
<if test="createTime != null">create_time,</if> <if test="createTime != null">create_time,</if>
<if test="updateBy != null">update_by,</if> <if test="updateBy != null">update_by,</if>
<if test="updateTime != null">update_time,</if> <if test="updateTime != null">update_time,</if>
<if test="flag != null and flag != ''">flag,</if> <if test="flag != null">flag,</if>
<if test="remark != null">remark,</if> <if test="remark != null">remark,</if>
</trim> </trim>
<trim prefix="values (" suffix=")" suffixOverrides=","> <trim prefix="values (" suffix=")" suffixOverrides=",">
<if test="eventCode != null">#{event_code},</if> <if test="appToken != null">#{appToken},</if>
<if test="message != null">#{message},</if> <if test="tableId != null">#{tableId},</if>
<if test="recordId != null">#{recordId},</if>
<if test="numbers != null">#{numbers},</if> <if test="numbers != null">#{numbers},</if>
<if test="operateStatus != null">#{operateStatus},</if>
<if test="createBy != null and createBy != ''">#{createBy},</if> <if test="createBy != null and createBy != ''">#{createBy},</if>
<if test="createTime != null">#{createTime},</if> <if test="createTime != null">#{createTime},</if>
<if test="updateBy != null">#{updateBy},</if> <if test="updateBy != null">#{updateBy},</if>
<if test="updateTime != null">#{updateTime},</if> <if test="updateTime != null">#{updateTime},</if>
<if test="flag != null and flag != ''">#{flag},</if> <if test="flag != null">#{flag},</if>
<if test="remark != null">#{remark},</if> <if test="remark != null">#{remark},</if>
</trim> </trim>
</insert> </insert>
<update id="updateEvent" parameterType="Event"> <update id="updateEvent" parameterType="com.ruoyi.flyingbook.domain.Event">
update event update event
<trim prefix="SET" suffixOverrides=","> <trim prefix="SET" suffixOverrides=",">
<if test="eventCode != null and eventCode != ''">message = #{event_code},</if> <if test="appToken != null">app_token = #{appToken},</if>
<if test="message != null and message != ''">message = #{message},</if> <if test="tableId != null">table_id = #{tableId},</if>
<if test="numbers != null">message = #{numbers},</if> <if test="recordId != null">record_id = #{recordId},</if>
<if test="numbers != null">numbers = #{numbers},</if>
<if test="operateStatus != null">operate_status = #{operateStatus},</if>
<if test="createBy != null and createBy != ''">create_by = #{createBy},</if> <if test="createBy != null and createBy != ''">create_by = #{createBy},</if>
<if test="createTime != null">create_time = #{createTime},</if> <if test="createTime != null">create_time = #{createTime},</if>
<if test="updateBy != null">update_by = #{updateBy},</if> <if test="updateBy != null">update_by = #{updateBy},</if>
<if test="updateTime != null">update_time = #{updateTime},</if> <if test="updateTime != null">update_time = #{updateTime},</if>
<if test="flag != null and flag != ''">flag = #{flag},</if> <if test="flag != null">flag = #{flag},</if>
<if test="remark != null">remark = #{remark},</if> <if test="remark != null">remark = #{remark},</if>
</trim> </trim>
where id = #{id} where id = #{id}
</update> </update>
<delete id="deleteEventById" parameterType="Long"> <delete id="deleteEventById" parameterType="Long">
delete delete from event where id = #{id}
from event
where id = #{id}
</delete> </delete>
<delete id="deleteEventByIds" parameterType="String"> <delete id="deleteEventByIds" parameterType="String">
@ -99,12 +99,7 @@
</foreach> </foreach>
</delete> </delete>
<select id="queryListOperate" resultMap="EventResult"> <update id="updateStatus" parameterType="com.ruoyi.flyingbook.domain.Event">
<include refid="selectEventVo"/> update event set operate_status = #{status} where id = #{id}
where 3 > numbers </update>
and flag in
<foreach collection="statusList" item="status" open="(" close=")" separator=",">
#{status}
</foreach>
</select>
</mapper> </mapper>

@ -1,49 +1,37 @@
<?xml version="1.0" encoding="UTF-8" ?> <?xml version="1.0" encoding="UTF-8" ?>
<!DOCTYPE mapper <!DOCTYPE mapper
PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
"http://mybatis.org/dtd/mybatis-3-mapper.dtd"> "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="com.ruoyi.flyingbook.mapper.LarkCompanyRelationMapper"> <mapper namespace="com.ruoyi.flyingbook.mapper.LarkCompanyRelationMapper">
<resultMap type="LarkCompanyRelation" id="LarkCompanyRelationResult"> <resultMap type="com.ruoyi.flyingbook.domain.LarkCompanyRelation" id="LarkCompanyRelationResult">
<result property="id" column="id"/> <result property="id" column="id" />
<result property="companyId" column="company_id"/> <result property="companyId" column="company_id" />
<result property="companyName" column="company_name"/> <result property="companyName" column="company_name" />
<result property="appId" column="app_id"/> <result property="appId" column="app_id" />
<result property="secret" column="secret"/> <result property="secret" column="secret" />
<result property="createBy" column="create_by"/> <result property="appType" column="app_type" />
<result property="createTime" column="create_time"/> <result property="createBy" column="create_by" />
<result property="updateBy" column="update_by"/> <result property="createTime" column="create_time" />
<result property="updateTime" column="update_time"/> <result property="updateBy" column="update_by" />
<result property="flag" column="flag"/> <result property="updateTime" column="update_time" />
<result property="remark" column="remark"/> <result property="flag" column="flag" />
<result property="remark" column="remark" />
</resultMap> </resultMap>
<sql id="selectLarkCompanyRelationVo"> <sql id="selectLarkCompanyRelationVo">
select id, select id, company_id, company_name, app_id, secret, app_type, create_by, create_time, update_by, update_time, flag, remark from lark_company_relation
company_id,
company_name,
app_id,
secret,
create_by,
create_time,
update_by,
update_time,
flag,
remark
from lark_company_relation
</sql> </sql>
<select id="selectLarkCompanyRelationList" parameterType="LarkCompanyRelation" <select id="selectLarkCompanyRelationList" parameterType="com.ruoyi.flyingbook.domain.LarkCompanyRelation" resultMap="LarkCompanyRelationResult">
resultMap="LarkCompanyRelationResult">
<include refid="selectLarkCompanyRelationVo"/> <include refid="selectLarkCompanyRelationVo"/>
<where> <where>
<if test="companyId != null ">and company_id = #{companyId}</if> <if test="companyId != null "> and company_id = #{companyId}</if>
<if test="companyName != null and companyName != ''">and company_name like concat('%', #{companyName}, <if test="companyName != null and companyName != ''"> and company_name like concat('%', #{companyName}, '%')</if>
'%') <if test="appId != null and appId != ''"> and app_id = #{appId}</if>
</if> <if test="secret != null and secret != ''"> and secret = #{secret}</if>
<if test="appId != null and appId != ''">and app_id = #{appId}</if> <if test="appType != null and appType != ''"> and app_type = #{appType}</if>
<if test="secret != null and secret != ''">and secret = #{secret}</if> <if test="flag != null "> and flag = #{flag}</if>
<if test="flag != null ">and flag = #{flag}</if>
</where> </where>
</select> </select>
@ -52,13 +40,14 @@
where id = #{id} where id = #{id}
</select> </select>
<insert id="insertLarkCompanyRelation" parameterType="LarkCompanyRelation" useGeneratedKeys="true" keyProperty="id"> <insert id="insertLarkCompanyRelation" parameterType="com.ruoyi.flyingbook.domain.LarkCompanyRelation" useGeneratedKeys="true" keyProperty="id">
insert into lark_company_relation insert into lark_company_relation
<trim prefix="(" suffix=")" suffixOverrides=","> <trim prefix="(" suffix=")" suffixOverrides=",">
<if test="companyId != null">company_id,</if> <if test="companyId != null">company_id,</if>
<if test="companyName != null">company_name,</if> <if test="companyName != null">company_name,</if>
<if test="appId != null and appId != ''">app_id,</if> <if test="appId != null and appId != ''">app_id,</if>
<if test="secret != null and secret != ''">secret,</if> <if test="secret != null and secret != ''">secret,</if>
<if test="appType != null">app_type,</if>
<if test="createBy != null and createBy != ''">create_by,</if> <if test="createBy != null and createBy != ''">create_by,</if>
<if test="createTime != null">create_time,</if> <if test="createTime != null">create_time,</if>
<if test="updateBy != null">update_by,</if> <if test="updateBy != null">update_by,</if>
@ -71,6 +60,7 @@
<if test="companyName != null">#{companyName},</if> <if test="companyName != null">#{companyName},</if>
<if test="appId != null and appId != ''">#{appId},</if> <if test="appId != null and appId != ''">#{appId},</if>
<if test="secret != null and secret != ''">#{secret},</if> <if test="secret != null and secret != ''">#{secret},</if>
<if test="appType != null">#{appType},</if>
<if test="createBy != null and createBy != ''">#{createBy},</if> <if test="createBy != null and createBy != ''">#{createBy},</if>
<if test="createTime != null">#{createTime},</if> <if test="createTime != null">#{createTime},</if>
<if test="updateBy != null">#{updateBy},</if> <if test="updateBy != null">#{updateBy},</if>
@ -80,13 +70,14 @@
</trim> </trim>
</insert> </insert>
<update id="updateLarkCompanyRelation" parameterType="LarkCompanyRelation"> <update id="updateLarkCompanyRelation" parameterType="com.ruoyi.flyingbook.domain.LarkCompanyRelation">
update lark_company_relation update lark_company_relation
<trim prefix="SET" suffixOverrides=","> <trim prefix="SET" suffixOverrides=",">
<if test="companyId != null">company_id = #{companyId},</if> <if test="companyId != null">company_id = #{companyId},</if>
<if test="companyName != null">company_name = #{companyName},</if> <if test="companyName != null">company_name = #{companyName},</if>
<if test="appId != null and appId != ''">app_id = #{appId},</if> <if test="appId != null and appId != ''">app_id = #{appId},</if>
<if test="secret != null and secret != ''">secret = #{secret},</if> <if test="secret != null and secret != ''">secret = #{secret},</if>
<if test="appType != null">app_type = #{appType},</if>
<if test="createBy != null and createBy != ''">create_by = #{createBy},</if> <if test="createBy != null and createBy != ''">create_by = #{createBy},</if>
<if test="createTime != null">create_time = #{createTime},</if> <if test="createTime != null">create_time = #{createTime},</if>
<if test="updateBy != null">update_by = #{updateBy},</if> <if test="updateBy != null">update_by = #{updateBy},</if>
@ -98,9 +89,7 @@
</update> </update>
<delete id="deleteLarkCompanyRelationById" parameterType="Long"> <delete id="deleteLarkCompanyRelationById" parameterType="Long">
delete delete from lark_company_relation where id = #{id}
from lark_company_relation
where id = #{id}
</delete> </delete>
<delete id="deleteLarkCompanyRelationByIds" parameterType="String"> <delete id="deleteLarkCompanyRelationByIds" parameterType="String">

@ -1,46 +1,37 @@
<?xml version="1.0" encoding="UTF-8" ?> <?xml version="1.0" encoding="UTF-8" ?>
<!DOCTYPE mapper <!DOCTYPE mapper
PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
"http://mybatis.org/dtd/mybatis-3-mapper.dtd"> "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="com.ruoyi.flyingbook.mapper.LarkTableRelationMapper"> <mapper namespace="com.ruoyi.flyingbook.mapper.LarkTableRelationMapper">
<resultMap type="LarkTableRelation" id="LarkTableRelationResult"> <resultMap type="com.ruoyi.flyingbook.domain.LarkTableRelation" id="LarkTableRelationResult">
<result property="id" column="id"/> <result property="id" column="id" />
<result property="larkCompanyRelationId" column="lark_company_relation_id"/> <result property="larkCompanyRelationId" column="lark_company_relation_id" />
<result property="fromTableId" column="from_table_id"/> <result property="fromAppToken" column="from_app_token" />
<result property="toTableId" column="to_table_id"/> <result property="fromTableId" column="from_table_id" />
<result property="url" column="url"/> <result property="toAppToken" column="to_app_token" />
<result property="createBy" column="create_by"/> <result property="toTableId" column="to_table_id" />
<result property="createTime" column="create_time"/> <result property="createBy" column="create_by" />
<result property="updateBy" column="update_by"/> <result property="createTime" column="create_time" />
<result property="updateTime" column="update_time"/> <result property="updateBy" column="update_by" />
<result property="flag" column="flag"/> <result property="updateTime" column="update_time" />
<result property="remark" column="remark"/> <result property="flag" column="flag" />
<result property="remark" column="remark" />
</resultMap> </resultMap>
<sql id="selectLarkTableRelationVo"> <sql id="selectLarkTableRelationVo">
select id, select id, lark_company_relation_id, from_app_token, from_table_id, to_app_token, to_table_id, create_by, create_time, update_by, update_time, flag, remark from lark_table_relation
lark_company_relation_id,
from_table_id,
to_table_id,
url,
create_by,
create_time,
update_by,
update_time,
flag,
remark
from lark_table_relation
</sql> </sql>
<select id="selectLarkTableRelationList" parameterType="LarkTableRelation" resultMap="LarkTableRelationResult"> <select id="selectLarkTableRelationList" parameterType="com.ruoyi.flyingbook.domain.LarkTableRelation" resultMap="LarkTableRelationResult">
<include refid="selectLarkTableRelationVo"/> <include refid="selectLarkTableRelationVo"/>
<where> <where>
<if test="larkCompanyRelationId != null ">and lark_company_relation_id = #{larkCompanyRelationId}</if> <if test="larkCompanyRelationId != null "> and lark_company_relation_id = #{larkCompanyRelationId}</if>
<if test="fromTableId != null and fromTableId != ''">and from_table_id = #{fromTableId}</if> <if test="fromAppToken != null and fromAppToken != ''"> and from_app_token = #{fromAppToken}</if>
<if test="toTableId != null and toTableId != ''">and to_table_id = #{toTableId}</if> <if test="fromTableId != null and fromTableId != ''"> and from_table_id = #{fromTableId}</if>
<if test="url != null ">and url = #{url}</if> <if test="toAppToken != null and toAppToken != ''"> and to_app_token = #{toAppToken}</if>
<if test="flag != null ">and flag = #{flag}</if> <if test="toTableId != null and toTableId != ''"> and to_table_id = #{toTableId}</if>
<if test="flag != null "> and flag = #{flag}</if>
</where> </where>
</select> </select>
@ -49,13 +40,14 @@
where id = #{id} where id = #{id}
</select> </select>
<insert id="insertLarkTableRelation" parameterType="LarkTableRelation" useGeneratedKeys="true" keyProperty="id"> <insert id="insertLarkTableRelation" parameterType="com.ruoyi.flyingbook.domain.LarkTableRelation" useGeneratedKeys="true" keyProperty="id">
insert into lark_table_relation insert into lark_table_relation
<trim prefix="(" suffix=")" suffixOverrides=","> <trim prefix="(" suffix=")" suffixOverrides=",">
<if test="larkCompanyRelationId != null">lark_company_relation_id,</if> <if test="larkCompanyRelationId != null">lark_company_relation_id,</if>
<if test="fromAppToken != null">from_app_token,</if>
<if test="fromTableId != null">from_table_id,</if> <if test="fromTableId != null">from_table_id,</if>
<if test="toAppToken != null">to_app_token,</if>
<if test="toTableId != null">to_table_id,</if> <if test="toTableId != null">to_table_id,</if>
<if test="url != null">url,</if>
<if test="createBy != null and createBy != ''">create_by,</if> <if test="createBy != null and createBy != ''">create_by,</if>
<if test="createTime != null">create_time,</if> <if test="createTime != null">create_time,</if>
<if test="updateBy != null">update_by,</if> <if test="updateBy != null">update_by,</if>
@ -65,9 +57,10 @@
</trim> </trim>
<trim prefix="values (" suffix=")" suffixOverrides=","> <trim prefix="values (" suffix=")" suffixOverrides=",">
<if test="larkCompanyRelationId != null">#{larkCompanyRelationId},</if> <if test="larkCompanyRelationId != null">#{larkCompanyRelationId},</if>
<if test="fromAppToken != null">#{fromAppToken},</if>
<if test="fromTableId != null">#{fromTableId},</if> <if test="fromTableId != null">#{fromTableId},</if>
<if test="toAppToken != null">#{toAppToken},</if>
<if test="toTableId != null">#{toTableId},</if> <if test="toTableId != null">#{toTableId},</if>
<if test="url != null">#{url},</if>
<if test="createBy != null and createBy != ''">#{createBy},</if> <if test="createBy != null and createBy != ''">#{createBy},</if>
<if test="createTime != null">#{createTime},</if> <if test="createTime != null">#{createTime},</if>
<if test="updateBy != null">#{updateBy},</if> <if test="updateBy != null">#{updateBy},</if>
@ -77,13 +70,14 @@
</trim> </trim>
</insert> </insert>
<update id="updateLarkTableRelation" parameterType="LarkTableRelation"> <update id="updateLarkTableRelation" parameterType="com.ruoyi.flyingbook.domain.LarkTableRelation">
update lark_table_relation update lark_table_relation
<trim prefix="SET" suffixOverrides=","> <trim prefix="SET" suffixOverrides=",">
<if test="larkCompanyRelationId != null">lark_company_relation_id = #{larkCompanyRelationId},</if> <if test="larkCompanyRelationId != null">lark_company_relation_id = #{larkCompanyRelationId},</if>
<if test="fromAppToken != null">from_app_token = #{fromAppToken},</if>
<if test="fromTableId != null">from_table_id = #{fromTableId},</if> <if test="fromTableId != null">from_table_id = #{fromTableId},</if>
<if test="toAppToken != null">to_app_token = #{toAppToken},</if>
<if test="toTableId != null">to_table_id = #{toTableId},</if> <if test="toTableId != null">to_table_id = #{toTableId},</if>
<if test="url != null">url = #{url},</if>
<if test="createBy != null and createBy != ''">create_by = #{createBy},</if> <if test="createBy != null and createBy != ''">create_by = #{createBy},</if>
<if test="createTime != null">create_time = #{createTime},</if> <if test="createTime != null">create_time = #{createTime},</if>
<if test="updateBy != null">update_by = #{updateBy},</if> <if test="updateBy != null">update_by = #{updateBy},</if>
@ -95,9 +89,7 @@
</update> </update>
<delete id="deleteLarkTableRelationById" parameterType="Long"> <delete id="deleteLarkTableRelationById" parameterType="Long">
delete delete from lark_table_relation where id = #{id}
from lark_table_relation
where id = #{id}
</delete> </delete>
<delete id="deleteLarkTableRelationByIds" parameterType="String"> <delete id="deleteLarkTableRelationByIds" parameterType="String">

@ -0,0 +1,125 @@
<?xml version="1.0" encoding="UTF-8" ?>
<!DOCTYPE mapper
PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
"http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="com.ruoyi.flyingbook.mapper.LarkTableRowRelationMapper">
<resultMap type="com.ruoyi.flyingbook.domain.LarkTableRowRelation" id="LarkTableRowRelationResult">
<result property="id" column="id"/>
<result property="tableRelationId" column="table_relation_id"/>
<result property="fromId" column="from_id"/>
<result property="toId" column="to_id"/>
<result property="type" column="type"/>
<result property="subType" column="sub_type"/>
<result property="createBy" column="create_by"/>
<result property="createTime" column="create_time"/>
<result property="updateBy" column="update_by"/>
<result property="updateTime" column="update_time"/>
<result property="flag" column="flag"/>
<result property="remark" column="remark"/>
</resultMap>
<sql id="selectLarkTableRowRelationVo">
select id,
table_relation_id,
from_id,
to_id,
type,
sub_type,
create_by,
create_time,
update_by,
update_time,
flag,
remark
from lark_table_row_relation
</sql>
<select id="selectLarkTableRowRelationList" parameterType="com.ruoyi.flyingbook.domain.LarkTableRowRelation"
resultMap="LarkTableRowRelationResult">
<include refid="selectLarkTableRowRelationVo"/>
<where>
<if test="tableRelationId != null ">and table_relation_id = #{tableRelationId}</if>
<if test="fromId != null and fromId != ''">and from_id = #{fromId}</if>
<if test="toId != null and toId != ''">and to_id = #{toId}</if>
<if test="type != null and type != ''">and type = #{type}</if>
<if test="subType != null and subType != ''">and sub_type = #{subType}</if>
<if test="flag != null ">and flag = #{flag}</if>
</where>
</select>
<select id="selectLarkTableRowRelationById" parameterType="Long" resultMap="LarkTableRowRelationResult">
<include refid="selectLarkTableRowRelationVo"/>
where id = #{id}
</select>
<insert id="insertLarkTableRowRelation" parameterType="com.ruoyi.flyingbook.domain.LarkTableRowRelation"
useGeneratedKeys="true" keyProperty="id">
insert into lark_table_row_relation
<trim prefix="(" suffix=")" suffixOverrides=",">
<if test="tableRelationId != null">table_relation_id,</if>
<if test="fromId != null">from_id,</if>
<if test="toId != null">to_id,</if>
<if test="type != null">type,</if>
<if test="subType != null">sub_type,</if>
<if test="createBy != null and createBy != ''">create_by,</if>
<if test="createTime != null">create_time,</if>
<if test="updateBy != null">update_by,</if>
<if test="updateTime != null">update_time,</if>
<if test="flag != null">flag,</if>
<if test="remark != null">remark,</if>
</trim>
<trim prefix="values (" suffix=")" suffixOverrides=",">
<if test="tableRelationId != null">#{tableRelationId},</if>
<if test="fromId != null">#{fromId},</if>
<if test="toId != null">#{toId},</if>
<if test="type != null">#{type},</if>
<if test="subType != null">#{subType},</if>
<if test="createBy != null and createBy != ''">#{createBy},</if>
<if test="createTime != null">#{createTime},</if>
<if test="updateBy != null">#{updateBy},</if>
<if test="updateTime != null">#{updateTime},</if>
<if test="flag != null">#{flag},</if>
<if test="remark != null">#{remark},</if>
</trim>
</insert>
<update id="updateLarkTableRowRelation" parameterType="com.ruoyi.flyingbook.domain.LarkTableRowRelation">
update lark_table_row_relation
<trim prefix="SET" suffixOverrides=",">
<if test="tableRelationId != null">table_relation_id = #{tableRelationId},</if>
<if test="fromId != null">from_id = #{fromId},</if>
<if test="toId != null">to_id = #{toId},</if>
<if test="type != null">type = #{type},</if>
<if test="subType != null">sub_type = #{subType},</if>
<if test="createBy != null and createBy != ''">create_by = #{createBy},</if>
<if test="createTime != null">create_time = #{createTime},</if>
<if test="updateBy != null">update_by = #{updateBy},</if>
<if test="updateTime != null">update_time = #{updateTime},</if>
<if test="flag != null">flag = #{flag},</if>
<if test="remark != null">remark = #{remark},</if>
</trim>
where id = #{id}
</update>
<delete id="deleteLarkTableRowRelationById" parameterType="Long">
delete
from lark_table_row_relation
where id = #{id}
</delete>
<delete id="deleteLarkTableRowRelationByIds" parameterType="String">
delete from lark_table_row_relation where id in
<foreach item="id" collection="array" open="(" separator="," close=")">
#{id}
</foreach>
</delete>
<select id="queryListByTableRelationIdList" parameterType="Long" resultMap="LarkTableRowRelationResult">
<include refid="selectLarkTableRowRelationVo"/>
where table_relation_id in
<foreach collection="tableRelationIdList" item="tableRelationId" separator="," open="(" close=")">
#{tableRelationId}
</foreach>
</select>
</mapper>

@ -1,11 +0,0 @@
package com.ruoyi.system.domain;
import com.ruoyi.common.base.LarkRequest;
/**
* @author yuxiangyong
* @create 2023-03-12 16:00
*/
public class LarkCallbackRequest extends LarkRequest {
}

@ -1,4 +1,39 @@
-- 飞书-公司关联表 DROP TABLE IF EXISTS `event`;
CREATE TABLE `event`
(
`id` bigint NOT NULL AUTO_INCREMENT COMMENT '唯一主键',
`app_token` varchar(255) DEFAULT NULL COMMENT '文件id',
`table_id` varchar(255) DEFAULT NULL COMMENT '表格id',
`record_id` varchar(255) DEFAULT NULL COMMENT '行id',
`numbers` int DEFAULT '0' COMMENT '重推次数',
`operate_status` varchar(255) DEFAULT NULL COMMENT '状态标记(未处理,处理完成)',
`create_by` varchar(255) NOT NULL,
`create_time` datetime NOT NULL,
`update_by` varchar(255) DEFAULT NULL,
`update_time` datetime DEFAULT NULL,
`flag` tinyint NOT NULL DEFAULT '0' COMMENT '删除标记(0未删除1删除)',
`remark` varchar(255) DEFAULT NULL COMMENT '备注',
PRIMARY KEY (`id`)
) ENGINE=InnoDB;
DROP TABLE IF EXISTS `event_log`;
CREATE TABLE `event_log`
(
`id` bigint NOT NULL AUTO_INCREMENT COMMENT '唯一主键',
`event_id` bigint DEFAULT NULL,
`operate_type` varchar(255) DEFAULT NULL COMMENT '操作类型',
`operate_info` text COMMENT '操作日志',
`error_code` varchar(255) DEFAULT NULL COMMENT '错误编码',
`error_message` varchar(255) DEFAULT NULL COMMENT '错误信息',
`remark` varchar(255) DEFAULT NULL COMMENT '备注',
`create_by` varchar(255) NOT NULL,
`create_time` datetime NOT NULL,
`update_by` varchar(255) DEFAULT NULL,
`update_time` datetime DEFAULT NULL,
PRIMARY KEY (`id`)
) ENGINE=InnoDB;
DROP TABLE IF EXISTS `lark_company_relation`;
CREATE TABLE `lark_company_relation` CREATE TABLE `lark_company_relation`
( (
`id` bigint NOT NULL AUTO_INCREMENT COMMENT '唯一主键', `id` bigint NOT NULL AUTO_INCREMENT COMMENT '唯一主键',
@ -6,6 +41,7 @@ CREATE TABLE `lark_company_relation`
`company_name` varchar(255) DEFAULT NULL COMMENT '公司名称', `company_name` varchar(255) DEFAULT NULL COMMENT '公司名称',
`app_id` varchar(255) NOT NULL COMMENT '飞书的appId', `app_id` varchar(255) NOT NULL COMMENT '飞书的appId',
`secret` varchar(255) NOT NULL COMMENT '公司+appId对应的唯一密钥', `secret` varchar(255) NOT NULL COMMENT '公司+appId对应的唯一密钥',
`app_type` varchar(255) DEFAULT NULL COMMENT 'app应用类型',
`create_by` varchar(255) NOT NULL, `create_by` varchar(255) NOT NULL,
`create_time` datetime NOT NULL, `create_time` datetime NOT NULL,
`update_by` varchar(255) DEFAULT NULL, `update_by` varchar(255) DEFAULT NULL,
@ -14,58 +50,40 @@ CREATE TABLE `lark_company_relation`
`remark` varchar(255) DEFAULT NULL COMMENT '备注', `remark` varchar(255) DEFAULT NULL COMMENT '备注',
PRIMARY KEY (`id`) PRIMARY KEY (`id`)
) ENGINE=InnoDB; ) ENGINE=InnoDB;
-- AppId-table关联表
DROP TABLE IF EXISTS `lark_table_relation`;
CREATE TABLE `lark_table_relation` CREATE TABLE `lark_table_relation`
( (
`id` BIGINT NOT NULL AUTO_INCREMENT COMMENT '唯一主键', `id` bigint NOT NULL AUTO_INCREMENT COMMENT '唯一主键',
`lark_company_relation_id` BIGINT DEFAULT NULL COMMENT '公司与飞书关联表id', `lark_company_relation_id` bigint DEFAULT NULL COMMENT '公司与飞书关联表id',
`from_table_id` VARCHAR(255) DEFAULT NULL COMMENT '来源表', `from_app_token` varchar(255) DEFAULT NULL,
`to_table_id` VARCHAR(255) DEFAULT NULL COMMENT '对应更新表', `from_table_id` varchar(255) DEFAULT NULL COMMENT '来源表',
`url` BIGINT DEFAULT NULL COMMENT 'url地址', `to_app_token` varchar(255) DEFAULT NULL,
`create_by` VARCHAR(255) NOT NULL, `to_table_id` varchar(255) DEFAULT NULL COMMENT '对应更新表',
`create_by` varchar(255) NOT NULL,
`create_time` datetime NOT NULL, `create_time` datetime NOT NULL,
`update_by` VARCHAR(255) DEFAULT NULL, `update_by` varchar(255) DEFAULT NULL,
`update_time` datetime DEFAULT NULL, `update_time` datetime DEFAULT NULL,
`flag` TINYINT NOT NULL DEFAULT '0' COMMENT '删除标记0未删除、1已删除', `flag` tinyint NOT NULL DEFAULT '0' COMMENT '删除标记0未删除、1已删除',
`remark` VARCHAR(255) DEFAULT NULL COMMENT '备注', `remark` varchar(255) DEFAULT NULL COMMENT '备注',
PRIMARY KEY (`id`) PRIMARY KEY (`id`)
) ENGINE = INNODB; ) ENGINE=InnoDB;
-- 事务操作日志
CREATE TABLE `event_log`
(
`id` BIGINT NOT NULL AUTO_INCREMENT COMMENT '唯一主键',
`table_id` VARCHAR(255) DEFAULT NULL COMMENT '多维表格id',
`record_id` VARCHAR(255) DEFAULT NULL COMMENT '实际行id',
`event_id` BIGINT DEFAULT NULL COMMENT '实际事务id',
`operate_type` VARCHAR(255) DEFAULT NULL COMMENT '操作类型',
`operate_status` VARCHAR(255) DEFAULT NULL COMMENT '操作编码',
`error_code` VARCHAR(255) DEFAULT NULL COMMENT '错误编码',
`error_message` VARCHAR(255) DEFAULT NULL COMMENT '错误信息',
`create_by` VARCHAR(255) NOT NULL,
`create_time` datetime NOT NULL,
`update_by` VARCHAR(255) DEFAULT NULL,
`update_time` datetime DEFAULT NULL,
`flag` TINYINT NOT NULL DEFAULT '0' COMMENT '删除标记0未删除、1已删除',
`remark` VARCHAR(255) DEFAULT NULL COMMENT '备注',
PRIMARY KEY (`id`)
) ENGINE = INNODB;
-- 事务详情 DROP TABLE IF EXISTS `lark_table_row_relation`;
CREATE TABLE `event` CREATE TABLE `lark_table_row_relation`
( (
`id` BIGINT NOT NULL AUTO_INCREMENT COMMENT '唯一主键', `id` bigint NOT NULL AUTO_INCREMENT COMMENT '唯一主键',
`message` text DEFAULT NULL COMMENT '回调信息', `table_relation_id` bigint DEFAULT NULL COMMENT '公司与飞书关联表id',
`create_by` VARCHAR(255) NOT NULL, `from_id` varchar(255) DEFAULT NULL COMMENT '来源表',
`to_id` varchar(255) DEFAULT NULL COMMENT '对应更新表',
`type` varchar(20) DEFAULT NULL COMMENT '行,或者 列',
`sub_type` varchar(20) DEFAULT NULL COMMENT '列或行的明细属性',
`create_by` varchar(255) NOT NULL,
`create_time` datetime NOT NULL, `create_time` datetime NOT NULL,
`update_by` VARCHAR(255) DEFAULT NULL, `update_by` varchar(255) DEFAULT NULL,
`update_time` datetime DEFAULT NULL, `update_time` datetime DEFAULT NULL,
`flag` VARCHAR(20) NOT NULL COMMENT '状态标记pending处理中、success成功、faild失败', `flag` tinyint NOT NULL DEFAULT '0' COMMENT '删除标记0未删除、1已删除',
`remark` VARCHAR(255) DEFAULT NULL COMMENT '备注', `remark` varchar(255) DEFAULT NULL COMMENT '备注',
PRIMARY KEY (`id`) PRIMARY KEY (`id`)
) ENGINE = INNODB; ) ENGINE=InnoDB;

Loading…
Cancel
Save