171 lines
5.3 KiB
Java
171 lines
5.3 KiB
Java
package com.lz.mysql;
|
||
|
||
import com.lz.common.utils.StringUtil;
|
||
import com.lz.modules.flow.entity.FlowChartRole;
|
||
import org.springframework.util.ResourceUtils;
|
||
import org.springframework.util.StopWatch;
|
||
|
||
import java.io.File;
|
||
import java.util.ArrayList;
|
||
import java.util.HashMap;
|
||
import java.util.List;
|
||
import java.util.Map;
|
||
import java.util.function.Function;
|
||
import java.util.stream.Collectors;
|
||
|
||
public class MysqlMain {
|
||
|
||
public static String package_name = "com.sina.model.entity";
|
||
public static String package_name_model = "com.chengyi.user.dao";
|
||
/*
|
||
|
||
//public static String save_path = "C:\\Users\\linzi\\Desktop\\mysql";
|
||
|
||
//public static String save_path ="C:\\workspace\\life";
|
||
public static String save_path = "C:\\workspace\\ideaworkspace\\api";
|
||
|
||
public static String mysql_url = "jdbc:mysql://rr-bp1ih900km0q3e0ur.mysql.rds.aliyuncs.com:3306";
|
||
public static String pre = "";
|
||
public static String mysql_dbname = "igo";
|
||
public static String mysql_username = "igo_readonly";
|
||
public static String mysql_password = "qEJMAwIjY45F";
|
||
*/
|
||
|
||
|
||
//public static String save_path = "C:\\Users\\linzi\\Desktop\\mysql";
|
||
|
||
//public static String save_path ="C:\\workspace\\life";
|
||
public static String save_path = "C:\\workspace\\ideaworkspace\\api";
|
||
|
||
public static String mysql_url = "jdbc:mysql://172.16.157.238:3306";
|
||
|
||
|
||
public static String pre = "";
|
||
|
||
|
||
public static String mysql_dbname = "lz_management";
|
||
|
||
public static String mysql_username = "ldd_biz";
|
||
public static String mysql_password = "Hello1234";
|
||
public static String dto_exclude = ",is_delete,gmt_create,gmt_modified,";//生成dto时排除字段,前后都要加英文逗号
|
||
public static String req_exclude = ",,";//生成Req时排除字段,前后都要加英文逗号
|
||
|
||
public static class TestStaticAndHuo{
|
||
public static int compare(Long a, Long b){
|
||
return a.compareTo(b);
|
||
}
|
||
|
||
public static boolean isEmpt(String str){
|
||
return str == null || str.length() == 0;
|
||
}
|
||
}
|
||
|
||
/**
|
||
* @param args
|
||
*/
|
||
public static void main(String[] args) throws Exception {
|
||
|
||
/*Long a = 2l;
|
||
Long b = 3l;
|
||
String value = "aaa";
|
||
StopWatch stopWatch = new StopWatch();
|
||
stopWatch.start("测试静态方法");
|
||
for(int i = 0; i < 10000; i++){
|
||
if(TestStaticAndHuo.isEmpt(value)){
|
||
|
||
}
|
||
}
|
||
stopWatch.stop();
|
||
|
||
stopWatch.start("测试对象方法");
|
||
for(int i = 0; i < 10000; i++){
|
||
if(value == null || value.length() == 0){
|
||
|
||
}
|
||
}
|
||
stopWatch.stop();
|
||
|
||
System.out.println(stopWatch.prettyPrint());*/
|
||
|
||
/*List<TestMap> testMaps = new ArrayList<>();
|
||
TestMap test = new TestMap();
|
||
test.setName("123");
|
||
test.setMobile("18969093321");
|
||
testMaps.add(test);
|
||
|
||
test = new TestMap();
|
||
test.setName("123");
|
||
test.setMobile("18969093321");
|
||
testMaps.add(test);
|
||
|
||
Map<String, TestMap> t = testMaps.stream().collect(Collectors.toMap(TestMap::getName, testMap -> testMap));
|
||
List<Long> flowChartRoles = new ArrayList<>();
|
||
flowChartRoles.add(1L);
|
||
flowChartRoles.add(2L);
|
||
flowChartRoles.add(3L);
|
||
flowChartRoles.add(4L);
|
||
String roles = flowChartRoles.stream().map(new Function<Long, String>() {
|
||
@Override
|
||
public String apply(Long flowChartRole) {
|
||
return flowChartRole.toString();
|
||
}
|
||
}).collect(Collectors.joining(","));*/
|
||
|
||
String path = ResourceUtils.getURL("classpath:").getPath();
|
||
System.out.println(path);
|
||
String dir = null;
|
||
if (StringUtil.isNotBlank(path)) {
|
||
dir = path.split("target")[0];
|
||
}
|
||
save_path = dir + "src/test/tmp";
|
||
System.out.println(save_path);
|
||
File file = new File(save_path);
|
||
if (!file.exists()) {
|
||
file.mkdirs();
|
||
}
|
||
List<TablesBean> list = new ArrayList<TablesBean>();
|
||
|
||
|
||
list.add(new TablesBean("lz_result_score"));
|
||
|
||
List<TablesBean> list2 = new ArrayList<TablesBean>();
|
||
Map<String, String> map = MysqlUtil2ShowCreateTable.getComments();
|
||
for (int i = 0; i < list.size(); i++) {
|
||
TablesBean obj = list.get(i);
|
||
String tableName = list.get(i).getTableName();
|
||
List<FieldBean> itemList = MysqlUtil2ShowCreateTable.readTableDetail(tableName);
|
||
obj.setFieldList(itemList);
|
||
obj.setComment(map.get(tableName));
|
||
list2.add(obj);
|
||
}
|
||
|
||
for (int i = 0; i < list2.size(); i++) {
|
||
MysqlUtilTable2Bean.printEntity(list2.get(i));
|
||
MysqlUtilTable2Bean.printReq(list2.get(i));
|
||
MysqlUtilTable2Bean.printDto(list2.get(i));
|
||
}
|
||
|
||
|
||
for (int i = 0; i < list2.size(); i++) {
|
||
MysqlUtilTable2Contoller.printController(list2.get(i));
|
||
}
|
||
|
||
|
||
for (int i = 0; i < list2.size(); i++) {
|
||
MysqlUtilTable2Mapper.printDao(list2.get(i));
|
||
}
|
||
|
||
for (int i = 0; i < list2.size(); i++) {
|
||
MysqlUtilTable2Service.printService(list2.get(i));
|
||
MysqlUtilTable2Service.printServiceImpl(list2.get(i));
|
||
}
|
||
|
||
for (int i = 0; i < list2.size(); i++) {
|
||
MysqlUtilTable2XML.printXMLForMap(list2.get(i));
|
||
}
|
||
|
||
|
||
}
|
||
|
||
}
|