From 29857a529cbc388ca37095f3720fe9431de6a8a0 Mon Sep 17 00:00:00 2001 From: zhu-mingye <934230207@qq.com> Date: Fri, 13 Oct 2023 14:21:23 +0800 Subject: [PATCH] add typehandler --- .../flink/CheckpointConfigTypeHandler.java | 42 +++++++++++++++++++ .../CheckpointingStatisticsTypeHandler.java | 42 +++++++++++++++++++ 2 files changed, 84 insertions(+) create mode 100644 dinky-admin/src/main/java/org/dinky/data/typehandler/flink/CheckpointConfigTypeHandler.java create mode 100644 dinky-admin/src/main/java/org/dinky/data/typehandler/flink/CheckpointingStatisticsTypeHandler.java diff --git a/dinky-admin/src/main/java/org/dinky/data/typehandler/flink/CheckpointConfigTypeHandler.java b/dinky-admin/src/main/java/org/dinky/data/typehandler/flink/CheckpointConfigTypeHandler.java new file mode 100644 index 00000000000..5f019b6a357 --- /dev/null +++ b/dinky-admin/src/main/java/org/dinky/data/typehandler/flink/CheckpointConfigTypeHandler.java @@ -0,0 +1,42 @@ +/* + * + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + */ + +package org.dinky.data.typehandler.flink; + +import org.apache.flink.runtime.rest.messages.checkpoints.CheckpointConfigInfo; +import org.apache.ibatis.type.JdbcType; +import org.apache.ibatis.type.MappedJdbcTypes; +import org.apache.ibatis.type.MappedTypes; + +import com.baomidou.mybatisplus.extension.handlers.AbstractJsonTypeHandler; + +import cn.hutool.json.JSONUtil; + +@MappedTypes({CheckpointConfigInfo.class}) +@MappedJdbcTypes({JdbcType.VARCHAR}) +public class CheckpointConfigTypeHandler extends AbstractJsonTypeHandler { + protected CheckpointConfigInfo parse(String json) { + return JSONUtil.toBean(json, CheckpointConfigInfo.class); + } + + @Override + protected String toJson(CheckpointConfigInfo obj) { + return JSONUtil.toJsonStr(obj); + } +} diff --git a/dinky-admin/src/main/java/org/dinky/data/typehandler/flink/CheckpointingStatisticsTypeHandler.java b/dinky-admin/src/main/java/org/dinky/data/typehandler/flink/CheckpointingStatisticsTypeHandler.java new file mode 100644 index 00000000000..0b5b266a012 --- /dev/null +++ b/dinky-admin/src/main/java/org/dinky/data/typehandler/flink/CheckpointingStatisticsTypeHandler.java @@ -0,0 +1,42 @@ +/* + * + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + */ + +package org.dinky.data.typehandler.flink; + +import org.apache.flink.runtime.rest.messages.checkpoints.CheckpointingStatistics; +import org.apache.ibatis.type.JdbcType; +import org.apache.ibatis.type.MappedJdbcTypes; +import org.apache.ibatis.type.MappedTypes; + +import com.baomidou.mybatisplus.extension.handlers.AbstractJsonTypeHandler; + +import cn.hutool.json.JSONUtil; + +@MappedTypes({CheckpointingStatistics.class}) +@MappedJdbcTypes({JdbcType.VARCHAR}) +public class CheckpointingStatisticsTypeHandler extends AbstractJsonTypeHandler { + protected CheckpointingStatistics parse(String json) { + return JSONUtil.toBean(json, CheckpointingStatistics.class); + } + + @Override + protected String toJson(CheckpointingStatistics obj) { + return JSONUtil.toJsonStr(obj); + } +}