|
@@ -0,0 +1,35 @@
|
|
|
|
+package com.persagy.fm.scheduling.typehandler;
|
|
|
|
+
|
|
|
|
+import com.persagy.fm.scheduling.constant.enums.WorkTime;
|
|
|
|
+import org.apache.ibatis.type.JdbcType;
|
|
|
|
+import org.apache.ibatis.type.TypeHandler;
|
|
|
|
+
|
|
|
|
+import java.sql.CallableStatement;
|
|
|
|
+import java.sql.PreparedStatement;
|
|
|
|
+import java.sql.ResultSet;
|
|
|
|
+import java.sql.SQLException;
|
|
|
|
+
|
|
|
|
+public class WorkTimeTypeHandler implements TypeHandler<WorkTime> {
|
|
|
|
+ @Override
|
|
|
|
+ public void setParameter(PreparedStatement ps, int i, WorkTime parameter, JdbcType jdbcType) throws SQLException {
|
|
|
|
+ ps.setInt(i, parameter.getValue());
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ @Override
|
|
|
|
+ public WorkTime getResult(ResultSet rs, String columnName) throws SQLException {
|
|
|
|
+ int anInt = rs.getInt(columnName);
|
|
|
|
+ return WorkTime.getByValue(anInt);
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ @Override
|
|
|
|
+ public WorkTime getResult(ResultSet rs, int columnIndex) throws SQLException {
|
|
|
|
+ int anInt = rs.getInt(columnIndex);
|
|
|
|
+ return WorkTime.getByValue(anInt);
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ @Override
|
|
|
|
+ public WorkTime getResult(CallableStatement cs, int columnIndex) throws SQLException {
|
|
|
|
+ int anInt = cs.getInt(columnIndex);
|
|
|
|
+ return WorkTime.getByValue(anInt);
|
|
|
|
+ }
|
|
|
|
+}
|