|
@@ -0,0 +1,39 @@
|
|
|
+package com.github.zuihou.business.operationManagementCenter.typeHandler;
|
|
|
+
|
|
|
+
|
|
|
+import com.baidubce.util.JsonUtils;
|
|
|
+import com.github.zuihou.business.productionResourceCenter.entity.ResourceAutoCode;
|
|
|
+import org.apache.ibatis.type.BaseTypeHandler;
|
|
|
+import org.apache.ibatis.type.JdbcType;
|
|
|
+import org.apache.ibatis.type.MappedJdbcTypes;
|
|
|
+import org.apache.ibatis.type.MappedTypes;
|
|
|
+
|
|
|
+import java.sql.CallableStatement;
|
|
|
+import java.sql.PreparedStatement;
|
|
|
+import java.sql.ResultSet;
|
|
|
+import java.sql.SQLException;
|
|
|
+
|
|
|
+@MappedTypes(ResourceAutoCode.class)
|
|
|
+@MappedJdbcTypes(JdbcType.VARCHAR)
|
|
|
+public class ResourceAutoCodeHandler extends BaseTypeHandler<ResourceAutoCode> {
|
|
|
+
|
|
|
+ @Override
|
|
|
+ public void setNonNullParameter(PreparedStatement preparedStatement, int i, ResourceAutoCode resourceAutoCode, JdbcType jdbcType) throws SQLException {
|
|
|
+ preparedStatement.setString(i, resourceAutoCode.getId().toString());
|
|
|
+ }
|
|
|
+
|
|
|
+ @Override
|
|
|
+ public ResourceAutoCode getNullableResult(ResultSet resultSet, String columnName) throws SQLException {
|
|
|
+ return JsonUtils.fromJsonString(resultSet.getString(columnName), ResourceAutoCode.class);
|
|
|
+ }
|
|
|
+
|
|
|
+ @Override
|
|
|
+ public ResourceAutoCode getNullableResult(ResultSet resultSet, int columnIndex) throws SQLException {
|
|
|
+ return JsonUtils.fromJsonString(resultSet.getString(columnIndex), ResourceAutoCode.class);
|
|
|
+ }
|
|
|
+
|
|
|
+ @Override
|
|
|
+ public ResourceAutoCode getNullableResult(CallableStatement callableStatement, int columnIndex) throws SQLException {
|
|
|
+ return JsonUtils.fromJsonString(callableStatement.getString(columnIndex), ResourceAutoCode.class);
|
|
|
+ }
|
|
|
+}
|