main
黄海 9 months ago
parent 2402bb6401
commit be9e37dfe9

@ -32,7 +32,7 @@ public class DataEaseModel {
* @return
*/
public List<Record> getDataSetByIdentityId(int identity_id, String area_name) {
String sql = "select t1.* from t_dp_dataset as t1 where t1.owner_id=? order by t1.dataease_id";
String sql = "select t1.* from t_dp_dataset as t1 where t1.owner_id=? order by t1.dataease_id where t1.b_use=1";
List<Record> list = Db.find(sql, identity_id);
if (!StrKit.isBlank(area_name)) {
for (Record record : list) {

@ -1,10 +1,16 @@
package com.dsideal.base.Test;
import com.github.shyiko.mysql.binlog.BinaryLogClient;
import com.github.shyiko.mysql.binlog.event.Event;
import com.github.shyiko.mysql.binlog.event.EventData;
import com.github.shyiko.mysql.binlog.event.TableMapEventData;
import com.github.shyiko.mysql.binlog.event.UpdateRowsEventData;
import com.github.shyiko.mysql.binlog.event.deserialization.EventDeserializer;
import java.io.IOException;
import java.io.Serializable;
import java.util.Arrays;
import java.util.List;
import java.util.Map;
//https://github.com/osheroff/mysql-binlog-connector-java
public class TestBinLog {
@ -16,10 +22,28 @@ public class TestBinLog {
EventDeserializer.CompatibilityMode.CHAR_AND_BINARY_AS_BYTE_ARRAY
);
client.setEventDeserializer(eventDeserializer);
client.registerEventListener(new BinaryLogClient.EventListener() {
client.registerEventListener(event -> {
EventData data = event.getData();
if (data instanceof TableMapEventData) {
System.out.println("TableMapEventData:" + data);
}
//只关心修改的信息
if (data instanceof UpdateRowsEventData) {
//注意:不要使用IDEA的建议修改为模式变量会造成JApiDoc生成失败
UpdateRowsEventData updateData = (UpdateRowsEventData) data;
List<Map.Entry<Serializable[], Serializable[]>> rows = updateData.getRows();
for (Map.Entry<Serializable[], Serializable[]> row : rows) {
//获取修改前的数据
Serializable[] beforeRow = row.getKey();
List<Serializable> beforeEntries = Arrays.asList(beforeRow);
System.out.println("beforeRow=" + beforeEntries);
@Override
public void onEvent(Event event) {
//获取修改后的数据
Serializable[] afterRow = row.getValue();
List<Serializable> afterEntries = Arrays.asList(afterRow);
System.out.println("afterRow=" + afterEntries);
}
}
});
client.connect();

Loading…
Cancel
Save