package com.bohuikeji.frame.module.admin.handler;

import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONArray;
import com.bohuikeji.frame.module.admin.entity.vo.FileVo;
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;
import java.util.List;

/*@MappedJdbcTypes(JdbcType.VARCHAR)
@MappedTypes(FileVo.class)
public class FileVoTypeHander extends BaseTypeHandler<FileVo> {

    @Override
    public void setNonNullParameter(PreparedStatement ps, int i, FileVo parameter, JdbcType jdbcType) throws SQLException {
        ps.setString(i,JSON.toJSONString(parameter));
    }

    @Override
    public FileVo getNullableResult(ResultSet rs, String columnName) throws SQLException {
        return JSON.parseObject(rs.getString(columnName),FileVo.class);
    }

    @Override
    public FileVo getNullableResult(ResultSet rs, int columnIndex) throws SQLException {
        return JSON.parseObject(rs.getString(columnIndex),FileVo.class);
    }

    @Override
    public FileVo getNullableResult(CallableStatement cs, int columnIndex) throws SQLException {
        return JSON.parseObject(cs.getString(columnIndex),FileVo.class);
    }*/

   /* @Override
    public void setNonNullParameter(PreparedStatement ps, int i, List<FileVo> parameter, JdbcType jdbcType) throws SQLException {
        System.out.println("测试11111");
        ps.setString(i, JSONArray.toJSONString(parameter));
    }*/


   /* @Override
    public List<FileVo> getNullableResult(ResultSet rs, String columnName) throws SQLException {
        return JSONArray.parseArray(rs.getString(columnName),FileVo.class);

    }

    @Override
    public List<FileVo> getNullableResult(ResultSet rs, int columnIndex) throws SQLException {
        return JSONArray.parseArray(rs.getString(columnIndex),FileVo.class);
    }*/

   /* @Override
    public List<FileVo> getNullableResult(CallableStatement cs, int columnIndex) throws SQLException {
        return JSONArray.parseArray(cs.getString(columnIndex),FileVo.class);
    }*/
//}
