package com.casic.missiles.mapper.injector;

import com.baomidou.mybatisplus.core.injector.AbstractMethod;
import com.baomidou.mybatisplus.core.metadata.TableInfo;
import org.apache.ibatis.mapping.MappedStatement;
import org.apache.ibatis.mapping.SqlSource;
import org.apache.ibatis.scripting.defaults.RawSqlSource;

/**
 * @Description:
 * @Author: wangpeng
 * @Date: 2022/11/28 11:52
 */
public class SelectXXX extends AbstractMethod {
    @Override
    public MappedStatement injectMappedStatement(Class<?> mapperClass, Class<?> modelClass, TableInfo tableInfo) {
        //mapper 接口方法名一致
        String method = "selectXXX";
        //执行 SQL ，动态 SQL 参考类 SqlMethod
        modelClass.getCanonicalName();
        modelClass.getFields();
        modelClass.getSimpleName();
        SqlSource sqlSource = new RawSqlSource(configuration, String.format("SELECT %s FROM %s",
                tableInfo.getKeyColumn(),
                tableInfo.getTableName()), Object.class);
        return this.addDeleteMappedStatement(mapperClass, method, sqlSource);
    }
}
