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 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 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", "未处理"),
SUCCESS("SUCCESS", "成功"),
FAIL("FAIL", "失败");
SUCCESS("SUCCESS", "处理完成");
private final String code;
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)
.build();
public String getToken(String appId, String srcret) {
private JSONObject execute(Request request){
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.put("app_id", appId);
map.put("app_secret", srcret);
@ -35,15 +53,8 @@ public class LarkTokenHelper {
.method("POST", RequestBody.create(JSONObject.toJSONString(map), MediaType.get("application/json")))
.url("https://open.feishu.cn/open-apis/auth/v3/app_access_token/internal")
.build();
try {
execute = client.newCall(request).execute();
if (ObjectUtil.isNotNull(execute) && execute.isSuccessful()) {
return execute.body().string();
}
} catch (IOException e) {
log.error("http post 请求失败--{}", e);
}
return null;
return execute(request).getString(tokenType);
}
/**
@ -51,48 +62,58 @@ public class LarkTokenHelper {
* @param token
* @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;
Request request = new Request.Builder()
.url(url)
.addHeader("Authorization",String.format("Bearer %s",token))
.build();
try {
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;
return execute(request);
}
public String postLark(String url,Map<Object, Object> body, String token) {
Response execute = null;
public JSONObject postLark(String url,Map<Object, Object> body, String token) {
Request request = new Request.Builder()
.method("POST", RequestBody
.create(JSONObject.toJSONString(body), MediaType.get("application/json")))
.url(url)
// .addHeader("Authorization",String.format("Bearer %s",token))
.addHeader("Authorization",String.format("Bearer %s",token))
.build();
try {
execute = client.newCall(request).execute();
if (ObjectUtil.isNotNull(execute) && execute.isSuccessful()) {
return execute.body().string();
}
} catch (IOException e) {
log.error("http post 请求失败--{}", e);
return execute(request);
}
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);
}
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 null;
return execute(builder.build());
}
public static void main(String[] args) {
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);
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 {
/**
* 线
*/
@ -56,7 +55,7 @@ public class LarkApplicationRunner implements ApplicationRunner {
/**
* 线
*/
private static final Integer WAIT_TIME = 5000;
private static final Integer WAIT_TIME = 10000;
@Autowired
private EventMapper eventMapper;
@ -73,8 +72,9 @@ public class LarkApplicationRunner implements ApplicationRunner {
threadPool.execute(() -> {
while (true) {
List<String> statusList = Arrays.asList(EventOperateStatus.PENDING.getCode(),EventOperateStatus.FAIL.getCode());
List<Event> eventList = eventMapper.queryListOperate(statusList);
Event query = new Event();
query.setOperateStatus(EventOperateStatus.PENDING.getCode());
List<Event> eventList = eventMapper.selectEventList(query);
if (CollectionUtils.isEmpty(eventList)) {
try {
// 没有订单,休息一下

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

@ -5,11 +5,12 @@ import org.apache.commons.lang3.builder.ToStringStyle;
import com.ruoyi.common.annotation.Excel;
import com.ruoyi.common.core.domain.BaseEntity;
/**
* event
*
*
* @author ruoyi
* @date 2023-03-12
* @date 2023-03-15
*/
public class Event extends BaseEntity
{
@ -17,72 +18,110 @@ public class Event extends BaseEntity
/** $column.columnComment */
private Long id;
private Integer numbers;
private String eventCode;
/** $column.columnComment */
@Excel(name = "${comment}", readConverterExp = "$column.readConverterExp()")
private String message;
/** pendingsuccessfaild */
@Excel(name = "pendingsuccessfaild")
private String flag;
/** id */
@Excel(name = "id")
private String appToken;
public Integer getNumbers() {
return numbers;
}
/** id */
@Excel(name = "id")
private String tableId;
public void setNumbers(Integer numbers) {
this.numbers = numbers;
}
/** id */
@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)
{
this.id = id;
}
public Long getId()
public Long getId()
{
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() {
return eventCode;
public String getOperateStatus()
{
return operateStatus;
}
public void setFlag(Long flag)
{
this.flag = flag;
}
public void setEventCode(String eventCode) {
this.eventCode = eventCode;
public Long getFlag()
{
return flag;
}
@Override
public String toString() {
return new ToStringBuilder(this,ToStringStyle.MULTI_LINE_STYLE)
.append("id", getId())
.append("message", getMessage())
.append("numbers", getMessage())
.append("createBy", getCreateBy())
.append("createTime", getCreateTime())
.append("updateBy", getUpdateBy())
.append("updateTime", getUpdateTime())
.append("flag", getFlag())
.append("remark", getRemark())
.toString();
.append("id", getId())
.append("appToken", getAppToken())
.append("tableId", getTableId())
.append("recordId", getRecordId())
.append("numbers", getNumbers())
.append("operateStatus", getOperateStatus())
.append("createBy", getCreateBy())
.append("createTime", getCreateTime())
.append("updateBy", getUpdateBy())
.append("updateTime", getUpdateTime())
.append("flag", getFlag())
.append("remark", getRemark())
.toString();
}
}

@ -5,78 +5,71 @@ import org.apache.commons.lang3.builder.ToStringStyle;
import com.ruoyi.common.annotation.Excel;
import com.ruoyi.common.core.domain.BaseEntity;
import java.util.Date;
/**
* event_log
*
*
* @author ruoyi
* @date 2023-03-12
* @date 2023-03-15
*/
public class EventLog extends BaseEntity
{
private static final long serialVersionUID = 1L;
/** $column.columnComment */
private Long id;
public EventLog() {
}
/** id */
@Excel(name = "id")
private String tableId;
public EventLog(Long eventId, String operateType, String operateInfo) {
this.eventId = eventId;
this.operateType = operateType;
this.operateInfo = operateInfo;
this.setCreateTime(new Date());
this.setCreateBy("System");
}
/** id */
@Excel(name = "id")
private String recordId;
public EventLog(Long eventId, String operateType, String operateInfo, String errorCode, String errorMessage) {
this.eventId = eventId;
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 */
@Excel(name = "id")
/** $column.columnComment */
@Excel(name = "${comment}", readConverterExp = "$column.readConverterExp()")
private Long eventId;
/** $column.columnComment */
@Excel(name = "id")
@Excel(name = "${comment}", readConverterExp = "$column.readConverterExp()")
private String operateType;
/** $column.columnComment */
@Excel(name = "id")
private String operateStatus;
@Excel(name = "${comment}", readConverterExp = "$column.readConverterExp()")
private String operateInfo;
/** $column.columnComment */
@Excel(name = "id")
@Excel(name = "${comment}", readConverterExp = "$column.readConverterExp()")
private String errorCode;
/** $column.columnComment */
@Excel(name = "id")
@Excel(name = "${comment}", readConverterExp = "$column.readConverterExp()")
private String errorMessage;
/** 01 */
@Excel(name = "01")
private Long flag;
public void setId(Long id)
public void setId(Long id)
{
this.id = id;
}
public Long getId()
public Long getId()
{
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)
{
this.eventId = eventId;
@ -86,69 +79,57 @@ public class EventLog extends BaseEntity
{
return eventId;
}
public void setOperateType(String operateType)
public void setOperateType(String operateType)
{
this.operateType = operateType;
}
public String getOperateType()
public String getOperateType()
{
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)
{
this.errorCode = errorCode;
}
public String getErrorCode()
public String getErrorCode()
{
return errorCode;
}
public void setErrorMessage(String errorMessage)
public void setErrorMessage(String errorMessage)
{
this.errorMessage = errorMessage;
}
public String getErrorMessage()
public String getErrorMessage()
{
return errorMessage;
}
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("tableId", getTableId())
.append("recordId", getRecordId())
.append("eventId", getEventId())
.append("operateType", getOperateType())
.append("operateStatus", getOperateStatus())
.append("operateInfo", getOperateInfo())
.append("errorCode", getErrorCode())
.append("errorMessage", getErrorMessage())
.append("remark", getRemark())
.append("createBy", getCreateBy())
.append("createTime", getCreateTime())
.append("updateBy", getUpdateBy())
.append("updateTime", getUpdateTime())
.append("flag", getFlag())
.append("remark", getRemark())
.toString();
}
}

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

@ -1,7 +1,12 @@
package com.ruoyi.flyingbook.domain;
import com.alibaba.fastjson.JSONObject;
import com.ruoyi.common.enums.EventOperateType;
import lombok.Data;
import java.util.List;
import java.util.Map;
/**
* @author yuxiangyong
* @create 2023-03-12 16:00
@ -13,10 +18,12 @@ public class LarkRequest {
*
*/
private String token;
private String appId;
private String url;
private String fromAppToken;
private String toAppToken;
private String errorCode;
private String errorMessage;
/**
* ApprovalCallback
*/
@ -26,5 +33,21 @@ public class LarkRequest {
/**
* 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 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
*
* @author ruoyi
* @date 2023-03-12
* @date 2023-03-15
*/
public class LarkTableRelation extends BaseEntity
{
@ -22,17 +22,21 @@ public class LarkTableRelation extends BaseEntity
@Excel(name = "id")
private Long larkCompanyRelationId;
/** $column.columnComment */
@Excel(name = "id")
private String fromAppToken;
/** $column.columnComment */
@Excel(name = "id")
private String fromTableId;
/** $column.columnComment */
@Excel(name = "id")
private String toTableId;
private String toAppToken;
/** url */
@Excel(name = "url")
private Long url;
/** $column.columnComment */
@Excel(name = "id")
private String toTableId;
/** 01 */
@Excel(name = "01")
@ -56,6 +60,15 @@ public class LarkTableRelation extends BaseEntity
{
return larkCompanyRelationId;
}
public void setFromAppToken(String fromAppToken)
{
this.fromAppToken = fromAppToken;
}
public String getFromAppToken()
{
return fromAppToken;
}
public void setFromTableId(String fromTableId)
{
this.fromTableId = fromTableId;
@ -65,23 +78,23 @@ public class LarkTableRelation extends BaseEntity
{
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)
{
@ -98,9 +111,10 @@ public class LarkTableRelation extends BaseEntity
return new ToStringBuilder(this,ToStringStyle.MULTI_LINE_STYLE)
.append("id", getId())
.append("larkCompanyRelationId", getLarkCompanyRelationId())
.append("fromAppToken", getFromAppToken())
.append("fromTableId", getFromTableId())
.append("toAppToken", getToAppToken())
.append("toTableId", getToTableId())
.append("url", getUrl())
.append("createBy", getCreateBy())
.append("createTime", getCreateTime())
.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 List<Event> queryListOperate(@Param("statusList") List<String> statusList);
public int updateStatus(@Param("id") Long id,@Param("status") String status);
}

@ -2,6 +2,7 @@ package com.ruoyi.flyingbook.mapper;
import com.ruoyi.flyingbook.domain.LarkTableRelation;
import org.apache.ibatis.annotations.Param;
import java.util.List;
@ -60,4 +61,5 @@ public interface LarkTableRelationMapper
* @return
*/
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
*/
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 LarkCompanyRelation getByCompanyName(String companyName);
public LarkCompanyRelation getByCompanyName(String companyName,String appType);
}

@ -60,4 +60,6 @@ public interface ILarkTableRelationService
* @return
*/
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);
}
@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 com.ruoyi.common.enums.FlagStatus;
import com.ruoyi.common.utils.StringUtils;
import com.ruoyi.flyingbook.domain.LarkCompanyRelation;
import com.ruoyi.flyingbook.mapper.LarkCompanyRelationMapper;
@ -104,12 +105,15 @@ public class LarkCompanyRelationServiceImpl implements ILarkCompanyRelationServi
* @return
*/
@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;
}
LarkCompanyRelation relation = new LarkCompanyRelation();
relation.setCompanyName(companyName);
relation.setAppType(appType);
relation.setFlag(FlagStatus.OK.getCode());
List<LarkCompanyRelation> larkCompanyRelations = larkCompanyRelationMapper.selectLarkCompanyRelationList(relation);
return CollectionUtils.isEmpty(larkCompanyRelations) ? null : larkCompanyRelations.get(0);
}

@ -1,7 +1,9 @@
package com.ruoyi.flyingbook.service.impl;
import java.util.ArrayList;
import java.util.List;
import com.ruoyi.common.utils.StringUtils;
import com.ruoyi.flyingbook.domain.LarkTableRelation;
import com.ruoyi.flyingbook.mapper.LarkTableRelationMapper;
import com.ruoyi.flyingbook.service.ILarkTableRelationService;
@ -94,4 +96,5 @@ public class LarkTableRelationServiceImpl implements ILarkTableRelationService
{
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;
import com.ruoyi.common.enums.EventOperateType;
import com.ruoyi.flyingbook.domain.EventLog;
import com.ruoyi.flyingbook.domain.LarkRequest;
import lombok.extern.slf4j.Slf4j;
@ -21,10 +23,20 @@ public abstract class LarkOperateAbstract{
preOperate(request);
//真正的业务处理逻辑
businessProcessing(request);
//业务处理完成后的系列操作,例如日志
endHandle(request);
}catch (Exception 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);
@ -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;
import com.alibaba.fastjson.JSONArray;
import com.alibaba.fastjson.JSONObject;
import com.ruoyi.flyingbook.domain.Event;
import com.ruoyi.flyingbook.domain.EventLog;
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.EventOperateType;
import com.ruoyi.common.enums.FlagStatus;
import com.sun.corba.se.impl.orbutil.RepIdDelegator;
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.data.redis.core.RedisTemplate;
import org.springframework.stereotype.Service;
import java.util.Date;
import java.util.List;
/**
* @author yuxiangyong
@ -33,22 +39,53 @@ public class ApprovalCallback extends CallbackAbstract {
@Override
protected Boolean check(LarkRequest request) {
String message = "";
return Boolean.TRUE;
}
@Override
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
protected void businessProcessing(LarkRequest request) {
String message = request.getMessage();
Event event = this.buildDto(message);
int i = eventService.insertEvent(event);
String cacheKey = String.format("%s_%s_%s_%s", RedisConstants.MULTIPLE_TABLE_RECORD, request.getFromAppToken(),request.getFromTableId(), request.getFromRecordId());
String eventStr = (String)redisTemplate.opsForValue().get(cacheKey);
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());
}
@Override
@ -56,17 +93,13 @@ public class ApprovalCallback extends CallbackAbstract {
if (request.getEventId() == null){
return;
}
redisTemplate.opsForList().rightPush(RedisConstants.MULTIDIMENSIONALTABULARFEEDBACK,request.getEventId());
EventLog eventLog = new EventLog();
eventLog.setCreateBy("Syetem");
eventLog.setCreateTime(new Date());
eventLog.setFlag(FlagStatus.OK.getCode());
eventLog.setOperateStatus(EventOperateStatus.PENDING.getCode());
eventLog.setOperateType(EventOperateType.CALL_BACK.getCode());
eventLog.setEventId(request.getEventId());
if (StringUtils.isNotBlank(request.getErrorMessage())){
}
EventLog eventLog = StringUtils.isBlank(request.getErrorMessage()) ?
new EventLog(request.getEventId(),EventOperateType.CALL_BACK.getCode(),request.getMessage())
: new EventLog(request.getEventId(),EventOperateType.CALL_BACK.getCode(),request.getMessage(),request.getErrorCode(),request.getErrorMessage());
eventLogService.insertEventLog(eventLog);
Object o = redisTemplate.opsForList().leftPop(RedisConstants.MULTIDIMENSIONALTABULARFEEDBACK);
System.out.println(String.valueOf(o));
}
@Override
@ -80,14 +113,31 @@ public class ApprovalCallback extends CallbackAbstract {
return this.getClass().getSimpleName();
}
private Event queryEvent(String appToken,String tableId,String recordId){
private Event buildDto(String message){
Event event = new Event();
event.setFlag(EventOperateStatus.PENDING.getCode());
event.setMessage(message);
event.setEventCode("test");
event.setAppToken(appToken);
event.setTableId(tableId);
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.setCreateTime(new Date());
event.setUpdateTime(new Date());
event.setUpdateBy("System");
return event;
}

@ -21,12 +21,8 @@ public abstract class LarkAbstract extends LarkOperateAbstract {
/**
* 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.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.domain.Event;
import com.ruoyi.flyingbook.domain.LarkCompanyRelation;
import com.ruoyi.flyingbook.domain.LarkRequest;
import com.ruoyi.flyingbook.service.IEventService;
import com.ruoyi.flyingbook.service.ILarkCompanyRelationService;
import com.ruoyi.flyingbook.domain.*;
import com.ruoyi.flyingbook.service.*;
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.data.redis.core.RedisTemplate;
import org.springframework.stereotype.Component;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
/**
*
*
* @author yuxiangyong
* @create 2023-03-13 20:47
*/
@Slf4j
@Component("MultidimensionalTableOperate")
public class MultidimensionalTableOperate extends LarkAbstract {
@ -29,54 +39,198 @@ public class MultidimensionalTableOperate extends LarkAbstract {
protected ILarkCompanyRelationService larkCompanyRelationService;
@Autowired
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
protected void preOperate(LarkRequest request) {
Event event = request.getEvent();
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) {
return;
}
String token = larkTokenHelper.getToken(relation.getAppId(), relation.getSecret());
if (StringUtils.isBlank(token)) {
return;
String errorMessage = String.format("获取app值为空 companyName:{} appType:{}", CompanyNameConstants.COMPANY_NAME, AppType.APPROVAL.getCode());
log.error("larkCompanyRelationService.getByCompanyName:{}", errorMessage);
throw new RuntimeException(errorMessage);
}
//用于后续追加row时候做关联关系
request.setCompanyRelationId(relation.getId());
//关联关系表填充
this.fillTableRelation(request);
String token = larkTokenHelper.getToken(relation.getAppId(), relation.getSecret(),"tenant_access_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
protected void businessProcessing(LarkRequest request) {
if (StringUtils.isBlank(request.getToken()) || request.getEvent() == null || StringUtils.isBlank(request.getEvent().getMessage())) {
return;
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;
}
send(request.getOperateType(), url, body, request);
}
send(getUrl(request), getBody(request.getMessage()), request.getToken());
}
@Override
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;
}
@Override
protected Map<Object, Object> getBody(String message) {
return null;
protected Map<Object, Object> getBody(LarkRequest request) {
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
protected JSONObject send(String url, Map<Object, Object> body, String token) {
larkTokenHelper.postLark(url,body,token);
return null;
protected void endHandle(LarkRequest request) {
Event event = request.getEvent();
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

@ -1,125 +1,94 @@
<?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">
PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
"http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="com.ruoyi.flyingbook.mapper.EventLogMapper">
<resultMap type="EventLog" id="EventLogResult">
<result property="id" column="id"/>
<result property="tableId" column="table_id"/>
<result property="recordId" column="record_id"/>
<result property="eventId" column="event_id"/>
<result property="operateType" column="operate_type"/>
<result property="operateStatus" column="operate_status"/>
<result property="errorCode" column="error_code"/>
<result property="errorMessage" column="error_message"/>
<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 type="com.ruoyi.flyingbook.domain.EventLog" id="EventLogResult">
<result property="id" column="id" />
<result property="eventId" column="event_id" />
<result property="operateType" column="operate_type" />
<result property="operateInfo" column="operate_info" />
<result property="errorCode" column="error_code" />
<result property="errorMessage" column="error_message" />
<result property="remark" column="remark" />
<result property="createBy" column="create_by" />
<result property="createTime" column="create_time" />
<result property="updateBy" column="update_by" />
<result property="updateTime" column="update_time" />
</resultMap>
<sql id="selectEventLogVo">
select id,
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
select id, event_id, operate_type, operate_info, error_code, error_message, remark, create_by, create_time, update_by, update_time from event_log
</sql>
<select id="selectEventLogList" parameterType="EventLog" resultMap="EventLogResult">
<select id="selectEventLogList" parameterType="com.ruoyi.flyingbook.domain.EventLog" resultMap="EventLogResult">
<include refid="selectEventLogVo"/>
<where>
<if test="tableId != null and tableId != ''">and table_id = #{tableId}</if>
<if test="recordId != null and recordId != ''">and record_id = #{recordId}</if>
<if test="eventId != null">and event_id = #{eventId}</if>
<if test="operateType != null and operateType != ''">and operate_type = #{operateType}</if>
<if test="operateStatus != null and operateStatus != ''">and operate_status = #{operateStatus}</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>
<if test="eventId != null "> and event_id = #{eventId}</if>
<if test="operateType != null and operateType != ''"> and operate_type = #{operateType}</if>
<if test="operateInfo != null and operateInfo != ''"> and operate_info = #{operateInfo}</if>
<if test="errorCode != null and errorCode != ''"> and error_code = #{errorCode}</if>
<if test="errorMessage != null and errorMessage != ''"> and error_message = #{errorMessage}</if>
</where>
</select>
<select id="selectEventLogById" parameterType="Long" resultMap="EventLogResult">
<include refid="selectEventLogVo"/>
where id = #{id}
</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
<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="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="errorMessage != null">error_message,</if>
<if test="remark != null">remark,</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>
<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="operateType != null">#{operateType},</if>
<if test="operateStatus != null">#{operateStatus},</if>
<if test="operateInfo != null">#{operateInfo},</if>
<if test="errorCode != null">#{errorCode},</if>
<if test="errorMessage != null">#{errorMessage},</if>
<if test="remark != null">#{remark},</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>
</trim>
</insert>
<update id="updateEventLog" parameterType="EventLog">
<update id="updateEventLog" parameterType="com.ruoyi.flyingbook.domain.EventLog">
update event_log
<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="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="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="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="deleteEventLogById" parameterType="Long">
delete
from event_log
where id = #{id}
delete from event_log where id = #{id}
</delete>
<delete id="deleteEventLogByIds" parameterType="String">
delete from event_log where id in
delete from event_log where id in
<foreach item="id" collection="array" open="(" separator="," close=")">
#{id}
</foreach>

@ -1,110 +1,105 @@
<?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">
PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
"http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="com.ruoyi.flyingbook.mapper.EventMapper">
<resultMap type="Event" id="EventResult">
<result property="id" column="id"/>
<result property="event_code" column="eventCode"/>
<result property="message" column="message"/>
<result property="numbers" column="numbers"/>
<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 type="com.ruoyi.flyingbook.domain.Event" id="EventResult">
<result property="id" column="id" />
<result property="appToken" column="app_token" />
<result property="tableId" column="table_id" />
<result property="recordId" column="record_id" />
<result property="numbers" column="numbers" />
<result property="operateStatus" column="operate_status" />
<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="selectEventVo">
select id,
event_code,
message,
numbers,
create_by,
create_time,
update_by,
update_time,
flag,
remark
from event
select id, app_token, table_id, record_id, numbers, operate_status, create_by, create_time, update_by, update_time, flag, remark from event
</sql>
<select id="selectEventList" parameterType="Event" resultMap="EventResult">
<select id="selectEventList" parameterType="com.ruoyi.flyingbook.domain.Event" resultMap="EventResult">
<include refid="selectEventVo"/>
<where>
<if test="message != null and message != ''">and message = #{message}</if>
<if test="flag != null and flag != ''">and flag = #{flag}</if>
<where>
<if test="appToken != null and appToken != ''"> and app_token = #{appToken}</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>
</select>
<select id="selectEventById" parameterType="Long" resultMap="EventResult">
<include refid="selectEventVo"/>
where id = #{id}
</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
<trim prefix="(" suffix=")" suffixOverrides=",">
<if test="eventCode != null">event_code,</if>
<if test="message != null">message,</if>
<if test="appToken != null">app_token,</if>
<if test="tableId != null">table_id,</if>
<if test="recordId != null">record_id,</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="createTime != null">create_time,</if>
<if test="updateBy != null">update_by,</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>
</trim>
</trim>
<trim prefix="values (" suffix=")" suffixOverrides=",">
<if test="eventCode != null">#{event_code},</if>
<if test="message != null">#{message},</if>
<if test="appToken != null">#{appToken},</if>
<if test="tableId != null">#{tableId},</if>
<if test="recordId != null">#{recordId},</if>
<if test="numbers != null">#{numbers},</if>
<if test="operateStatus != null">#{operateStatus},</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 and flag != ''">#{flag},</if>
<if test="flag != null">#{flag},</if>
<if test="remark != null">#{remark},</if>
</trim>
</trim>
</insert>
<update id="updateEvent" parameterType="Event">
<update id="updateEvent" parameterType="com.ruoyi.flyingbook.domain.Event">
update event
<trim prefix="SET" suffixOverrides=",">
<if test="eventCode != null and eventCode != ''">message = #{event_code},</if>
<if test="message != null and message != ''">message = #{message},</if>
<if test="numbers != null">message = #{numbers},</if>
<if test="appToken != null">app_token = #{appToken},</if>
<if test="tableId != null">table_id = #{tableId},</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="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 and flag != ''">flag = #{flag},</if>
<if test="flag != null">flag = #{flag},</if>
<if test="remark != null">remark = #{remark},</if>
</trim>
where id = #{id}
</update>
<delete id="deleteEventById" parameterType="Long">
delete
from event
where id = #{id}
delete from event where id = #{id}
</delete>
<delete id="deleteEventByIds" parameterType="String">
delete from event where id in
delete from event where id in
<foreach item="id" collection="array" open="(" separator="," close=")">
#{id}
</foreach>
</delete>
<select id="queryListOperate" resultMap="EventResult">
<include refid="selectEventVo"/>
where 3 > numbers
and flag in
<foreach collection="statusList" item="status" open="(" close=")" separator=",">
#{status}
</foreach>
</select>
<update id="updateStatus" parameterType="com.ruoyi.flyingbook.domain.Event">
update event set operate_status = #{status} where id = #{id}
</update>
</mapper>

@ -1,92 +1,83 @@
<?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">
PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
"http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="com.ruoyi.flyingbook.mapper.LarkCompanyRelationMapper">
<resultMap type="LarkCompanyRelation" id="LarkCompanyRelationResult">
<result property="id" column="id"/>
<result property="companyId" column="company_id"/>
<result property="companyName" column="company_name"/>
<result property="appId" column="app_id"/>
<result property="secret" column="secret"/>
<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 type="com.ruoyi.flyingbook.domain.LarkCompanyRelation" id="LarkCompanyRelationResult">
<result property="id" column="id" />
<result property="companyId" column="company_id" />
<result property="companyName" column="company_name" />
<result property="appId" column="app_id" />
<result property="secret" column="secret" />
<result property="appType" column="app_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="selectLarkCompanyRelationVo">
select id,
company_id,
company_name,
app_id,
secret,
create_by,
create_time,
update_by,
update_time,
flag,
remark
from lark_company_relation
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
</sql>
<select id="selectLarkCompanyRelationList" parameterType="LarkCompanyRelation"
resultMap="LarkCompanyRelationResult">
<select id="selectLarkCompanyRelationList" parameterType="com.ruoyi.flyingbook.domain.LarkCompanyRelation" resultMap="LarkCompanyRelationResult">
<include refid="selectLarkCompanyRelationVo"/>
<where>
<if test="companyId != null ">and company_id = #{companyId}</if>
<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 test="secret != null and secret != ''">and secret = #{secret}</if>
<if test="flag != null ">and flag = #{flag}</if>
<where>
<if test="companyId != null "> and company_id = #{companyId}</if>
<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 test="secret != null and secret != ''"> and secret = #{secret}</if>
<if test="appType != null and appType != ''"> and app_type = #{appType}</if>
<if test="flag != null "> and flag = #{flag}</if>
</where>
</select>
<select id="selectLarkCompanyRelationById" parameterType="Long" resultMap="LarkCompanyRelationResult">
<include refid="selectLarkCompanyRelationVo"/>
where id = #{id}
</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
<trim prefix="(" suffix=")" suffixOverrides=",">
<if test="companyId != null">company_id,</if>
<if test="companyName != null">company_name,</if>
<if test="appId != null and appId != ''">app_id,</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="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>
<trim prefix="values (" suffix=")" suffixOverrides=",">
<if test="companyId != null">#{companyId},</if>
<if test="companyName != null">#{companyName},</if>
<if test="appId != null and appId != ''">#{appId},</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="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>
</trim>
</insert>
<update id="updateLarkCompanyRelation" parameterType="LarkCompanyRelation">
<update id="updateLarkCompanyRelation" parameterType="com.ruoyi.flyingbook.domain.LarkCompanyRelation">
update lark_company_relation
<trim prefix="SET" suffixOverrides=",">
<if test="companyId != null">company_id = #{companyId},</if>
<if test="companyName != null">company_name = #{companyName},</if>
<if test="appId != null and appId != ''">app_id = #{appId},</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="createTime != null">create_time = #{createTime},</if>
<if test="updateBy != null">update_by = #{updateBy},</if>
@ -98,13 +89,11 @@
</update>
<delete id="deleteLarkCompanyRelationById" parameterType="Long">
delete
from lark_company_relation
where id = #{id}
delete from lark_company_relation where id = #{id}
</delete>
<delete id="deleteLarkCompanyRelationByIds" parameterType="String">
delete from lark_company_relation where id in
delete from lark_company_relation where id in
<foreach item="id" collection="array" open="(" separator="," close=")">
#{id}
</foreach>

@ -1,89 +1,83 @@
<?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">
PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
"http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="com.ruoyi.flyingbook.mapper.LarkTableRelationMapper">
<resultMap type="LarkTableRelation" id="LarkTableRelationResult">
<result property="id" column="id"/>
<result property="larkCompanyRelationId" column="lark_company_relation_id"/>
<result property="fromTableId" column="from_table_id"/>
<result property="toTableId" column="to_table_id"/>
<result property="url" column="url"/>
<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 type="com.ruoyi.flyingbook.domain.LarkTableRelation" id="LarkTableRelationResult">
<result property="id" column="id" />
<result property="larkCompanyRelationId" column="lark_company_relation_id" />
<result property="fromAppToken" column="from_app_token" />
<result property="fromTableId" column="from_table_id" />
<result property="toAppToken" column="to_app_token" />
<result property="toTableId" column="to_table_id" />
<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="selectLarkTableRelationVo">
select id,
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
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
</sql>
<select id="selectLarkTableRelationList" parameterType="LarkTableRelation" resultMap="LarkTableRelationResult">
<select id="selectLarkTableRelationList" parameterType="com.ruoyi.flyingbook.domain.LarkTableRelation" resultMap="LarkTableRelationResult">
<include refid="selectLarkTableRelationVo"/>
<where>
<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="toTableId != null and toTableId != ''">and to_table_id = #{toTableId}</if>
<if test="url != null ">and url = #{url}</if>
<if test="flag != null ">and flag = #{flag}</if>
<where>
<if test="larkCompanyRelationId != null "> and lark_company_relation_id = #{larkCompanyRelationId}</if>
<if test="fromAppToken != null and fromAppToken != ''"> and from_app_token = #{fromAppToken}</if>
<if test="fromTableId != null and fromTableId != ''"> and from_table_id = #{fromTableId}</if>
<if test="toAppToken != null and toAppToken != ''"> and to_app_token = #{toAppToken}</if>
<if test="toTableId != null and toTableId != ''"> and to_table_id = #{toTableId}</if>
<if test="flag != null "> and flag = #{flag}</if>
</where>
</select>
<select id="selectLarkTableRelationById" parameterType="Long" resultMap="LarkTableRelationResult">
<include refid="selectLarkTableRelationVo"/>
where id = #{id}
</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
<trim prefix="(" suffix=")" suffixOverrides=",">
<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="toAppToken != null">to_app_token,</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="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>
<trim prefix="values (" suffix=")" suffixOverrides=",">
<if test="larkCompanyRelationId != null">#{larkCompanyRelationId},</if>
<if test="fromAppToken != null">#{fromAppToken},</if>
<if test="fromTableId != null">#{fromTableId},</if>
<if test="toAppToken != null">#{toAppToken},</if>
<if test="toTableId != null">#{toTableId},</if>
<if test="url != null">#{url},</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>
</trim>
</insert>
<update id="updateLarkTableRelation" parameterType="LarkTableRelation">
<update id="updateLarkTableRelation" parameterType="com.ruoyi.flyingbook.domain.LarkTableRelation">
update lark_table_relation
<trim prefix="SET" suffixOverrides=",">
<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="toAppToken != null">to_app_token = #{toAppToken},</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="createTime != null">create_time = #{createTime},</if>
<if test="updateBy != null">update_by = #{updateBy},</if>
@ -95,13 +89,11 @@
</update>
<delete id="deleteLarkTableRelationById" parameterType="Long">
delete
from lark_table_relation
where id = #{id}
delete from lark_table_relation where id = #{id}
</delete>
<delete id="deleteLarkTableRelationByIds" parameterType="String">
delete from lark_table_relation where id in
delete from lark_table_relation where id in
<foreach item="id" collection="array" open="(" separator="," close=")">
#{id}
</foreach>

@ -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`
(
`id` bigint NOT NULL AUTO_INCREMENT COMMENT '唯一主键',
@ -6,6 +41,7 @@ CREATE TABLE `lark_company_relation`
`company_name` varchar(255) DEFAULT NULL COMMENT '公司名称',
`app_id` 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_time` datetime NOT NULL,
`update_by` varchar(255) DEFAULT NULL,
@ -14,58 +50,40 @@ CREATE TABLE `lark_company_relation`
`remark` varchar(255) DEFAULT NULL COMMENT '备注',
PRIMARY KEY (`id`)
) ENGINE=InnoDB;
-- AppId-table关联表
DROP TABLE IF EXISTS `lark_table_relation`;
CREATE TABLE `lark_table_relation`
(
`id` BIGINT NOT NULL AUTO_INCREMENT COMMENT '唯一主键',
`lark_company_relation_id` BIGINT DEFAULT NULL COMMENT '公司与飞书关联表id',
`from_table_id` VARCHAR(255) DEFAULT NULL COMMENT '来源表',
`to_table_id` VARCHAR(255) DEFAULT NULL COMMENT '对应更新表',
`url` BIGINT DEFAULT NULL COMMENT 'url地址',
`create_by` VARCHAR(255) NOT NULL,
`id` bigint NOT NULL AUTO_INCREMENT COMMENT '唯一主键',
`lark_company_relation_id` bigint DEFAULT NULL COMMENT '公司与飞书关联表id',
`from_app_token` varchar(255) DEFAULT NULL,
`from_table_id` varchar(255) DEFAULT NULL COMMENT '来源表',
`to_app_token` varchar(255) DEFAULT NULL,
`to_table_id` varchar(255) DEFAULT NULL COMMENT '对应更新表',
`create_by` varchar(255) NOT NULL,
`create_time` datetime NOT NULL,
`update_by` VARCHAR(255) DEFAULT 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 '备注',
`flag` tinyint NOT NULL DEFAULT '0' COMMENT '删除标记0未删除、1已删除',
`remark` varchar(255) DEFAULT NULL COMMENT '备注',
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;
-- 事务详情
CREATE TABLE `event`
DROP TABLE IF EXISTS `lark_table_row_relation`;
CREATE TABLE `lark_table_row_relation`
(
`id` BIGINT NOT NULL AUTO_INCREMENT COMMENT '唯一主键',
`message` text 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` VARCHAR(20) NOT NULL COMMENT '状态标记pending处理中、success成功、faild失败',
`remark` VARCHAR(255) DEFAULT NULL COMMENT '备注',
`id` bigint NOT NULL AUTO_INCREMENT COMMENT '唯一主键',
`table_relation_id` bigint DEFAULT NULL COMMENT '公司与飞书关联表id',
`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,
`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;
) ENGINE=InnoDB;

Loading…
Cancel
Save