package com.cftech.core.mybatis.mybatis;

import com.cftech.core.mybatis.MybatisCodeTools;
import com.cftech.core.util.Constants;


/**
 * Created by lisw on 2016-08-05
 */
public class MyBatis {
	public static void main(String[] args) {
		String tableNames = "t_appmenu";//表名、可多个，用逗号分隔
		String module = "appmenu";  //模块名  tableNames的所有表必须同时属于此模块
		String author = "Neil";  //代码生成Java类时的作者注释
		MybatisCodeTools mybatisCodeTools = new MybatisCodeTools();
		mybatisCodeTools.setClassNamePrefix("t_");//生成Model时需要去除的前缀
		mybatisCodeTools.setAuthorName(author);//作者
		mybatisCodeTools.setPackageName("com.cftech.base."+module+".model");//实体类的包名
		mybatisCodeTools.setBasePackage("com.cftech.base."+module);//service,dao的包名
		mybatisCodeTools.setDriverName("com.mysql.jdbc.Driver");//数据库驱动
		mybatisCodeTools.setDsUrl("jdbc:mysql://56988d3d2d34d.sh.cdb.myqcloud.com:7989/cfwechat?useUnicode=true&characterEncoding=utf8");  //数据库连接
		mybatisCodeTools.setDsUserName("cdb_outerroot");  //数据库链接用户名
		mybatisCodeTools.setDsPassword("Changfu@123456");  //数据库密码
		String[] arrays = tableNames.split(Constants.VALUE_SIMPLE_SPLIT_CHAR);
		for(String tableName : arrays){
			mybatisCodeTools.setTableName(tableName);
			mybatisCodeTools.generateJavaFile();
		}
	}
}