``` java
@
Component@
CanalTable("table_name")
public class OrderHeaderHandler implements EntryHandler {
@
Autowired private XxxService xxxService;
@
Override public void update(Map<String, String> before, Map<String, String> after, Set<String> updateColumns) {
//获取需要记录日志的列
Map<String, String> filedMap = FieldUtils.objectToMap(TableName.class, updateColumns);
String tableId= before.get("tableId");
String records = "";
if (filedMap != null && filedMap.keySet().size() > 0) {
for (String update : filedMap.keySet()) {
String comment = filedMap.get(update);
String beforeValue = before.get(update);
String afterValue = after.get(update);
records = records.concat(String.format("%s 由 %s 改为 %s", comment, StringUtils.isEmpty(beforeValue) ? "空" : beforeValue
, StringUtils.isEmpty(afterValue) ? "空" : afterValue) + ";");
}
//记录日志
OperationRecords operationRecords = new OperationRecords();
operationRecords.setLinkedId(Long.parseLong(orderId));
operationRecords.setRecords(records);
operationRecords.setTableName("container_transport_order_header");
operationRecords.setCreateTime(new Date());
operationRecords.setCreateUserId(parseLongUserId(after.get("updateUserId")));
operationRecordsService.save(operationRecords);
}
}
```