|
@@ -1,43 +1,17 @@
|
|
|
package com.xjrsoft.xjrsoftboot;
|
|
|
|
|
|
-import cn.dev33.satoken.secure.SaSecureUtil;
|
|
|
-import cn.hutool.core.bean.BeanUtil;
|
|
|
-import cn.hutool.core.util.StrUtil;
|
|
|
import cn.hutool.db.ds.simple.SimpleDataSource;
|
|
|
-import cn.hutool.db.meta.Column;
|
|
|
-import cn.hutool.db.meta.MetaUtil;
|
|
|
-import cn.hutool.db.meta.Table;
|
|
|
-import cn.hutool.http.HttpUtil;
|
|
|
-import com.baomidou.mybatisplus.core.toolkit.StringPool;
|
|
|
-import com.xjrsoft.XjrSoftApplication;
|
|
|
import com.xjrsoft.common.constant.GlobalConstant;
|
|
|
-import com.xjrsoft.common.utils.DatasourceUtil;
|
|
|
-import com.xjrsoft.common.utils.JdbcToJavaUtil;
|
|
|
-import com.xjrsoft.module.generator.constant.EntityConstant;
|
|
|
import com.xjrsoft.module.generator.dto.ApiGenerateCodesDto;
|
|
|
-import com.xjrsoft.module.generator.entity.FieldConfig;
|
|
|
-import com.xjrsoft.module.generator.entity.GeneratorConfig;
|
|
|
import com.xjrsoft.module.generator.entity.TableConfig;
|
|
|
import com.xjrsoft.module.generator.service.IApiGeneratorService;
|
|
|
import com.xjrsoft.module.generator.service.impl.ApiGeneratorServiceImpl;
|
|
|
-import freemarker.template.Template;
|
|
|
-import freemarker.template.TemplateException;
|
|
|
-import lombok.AllArgsConstructor;
|
|
|
import org.junit.jupiter.api.Test;
|
|
|
-import org.junit.runner.RunWith;
|
|
|
-import org.springframework.beans.factory.annotation.Autowired;
|
|
|
-import org.springframework.boot.test.context.SpringBootTest;
|
|
|
-import org.springframework.test.context.junit4.SpringRunner;
|
|
|
-import org.springframework.ui.freemarker.FreeMarkerTemplateUtils;
|
|
|
-import org.springframework.web.servlet.view.freemarker.FreeMarkerConfigurer;
|
|
|
|
|
|
import javax.sql.DataSource;
|
|
|
-import java.io.FileNotFoundException;
|
|
|
import java.io.IOException;
|
|
|
-import java.time.LocalDate;
|
|
|
-import java.time.format.DateTimeFormatter;
|
|
|
-import java.util.*;
|
|
|
-import java.util.stream.Collectors;
|
|
|
+import java.util.ArrayList;
|
|
|
+import java.util.List;
|
|
|
|
|
|
public class FreeMarkerGeneratorTest {
|
|
|
|
|
@@ -730,6 +704,72 @@ public class FreeMarkerGeneratorTest {
|
|
|
params.setDs(ds);
|
|
|
|
|
|
|
|
|
+ IApiGeneratorService apiGeneratorService = new ApiGeneratorServiceImpl();
|
|
|
+
|
|
|
+ apiGeneratorService.generateCodes(params);
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 奖学金类型维护
|
|
|
+ */
|
|
|
+ @Test
|
|
|
+ public void gcBaseStudentScholarshipCategory() throws IOException {
|
|
|
+ List<TableConfig> tableConfigs = new ArrayList<>();
|
|
|
+ TableConfig mainTable = new TableConfig();
|
|
|
+ mainTable.setTableName("base_student_scholarship_category");//init_sql中的表名
|
|
|
+ mainTable.setIsMain(true);//是否是主表,一般默认为true
|
|
|
+ mainTable.setPkField(GlobalConstant.DEFAULT_PK);//设置主键
|
|
|
+ mainTable.setPkType(GlobalConstant.DEFAULT_PK_TYPE);//设置主键类型
|
|
|
+ tableConfigs.add(mainTable);
|
|
|
+
|
|
|
+ mainTable = new TableConfig();
|
|
|
+ mainTable.setTableName("base_student_scholarship_level");//init_sql中的表名
|
|
|
+ mainTable.setIsMain(false);//是否是主表,一般默认为true
|
|
|
+ mainTable.setPkField(GlobalConstant.DEFAULT_PK);//设置主键
|
|
|
+ mainTable.setPkType(GlobalConstant.DEFAULT_PK_TYPE);//设置主键类型
|
|
|
+ mainTable.setRelationField("base_student_scholarship_category_id");//设置外键
|
|
|
+ mainTable.setRelationTableField(GlobalConstant.DEFAULT_PK);//设置外键
|
|
|
+ tableConfigs.add(mainTable);
|
|
|
+
|
|
|
+ ApiGenerateCodesDto params = new ApiGenerateCodesDto();
|
|
|
+ params.setAuthor("dzx");//作者名称
|
|
|
+ params.setPackageName("student");//包名
|
|
|
+ params.setTableConfigs(tableConfigs);
|
|
|
+ params.setPage(true);//是否生成分页接口
|
|
|
+ params.setImport(false);//是否生成导入接口
|
|
|
+ params.setExport(false);//是否生成导出接口
|
|
|
+ params.setOutMainDir(true);//是否生成在主目录,前期测试可设置成false
|
|
|
+ params.setDs(ds);
|
|
|
+
|
|
|
+
|
|
|
+ IApiGeneratorService apiGeneratorService = new ApiGeneratorServiceImpl();
|
|
|
+
|
|
|
+ apiGeneratorService.generateCodes(params);
|
|
|
+ }
|
|
|
+
|
|
|
+ @Test
|
|
|
+ public void gcBasestudentScholarshipApplicant() throws IOException {
|
|
|
+ List<TableConfig> tableConfigs = new ArrayList<>();
|
|
|
+ TableConfig mainTable = new TableConfig();
|
|
|
+ mainTable.setTableName("base_student_scholarship_applicant");//init_sql中的表名
|
|
|
+ mainTable.setIsMain(true);//是否是主表,一般默认为true
|
|
|
+ mainTable.setPkField(GlobalConstant.DEFAULT_PK);//设置主键
|
|
|
+ mainTable.setPkType(GlobalConstant.DEFAULT_PK_TYPE);//设置主键类型
|
|
|
+ mainTable.setRelationField("base_student_scholarship_category_id");//设置外键
|
|
|
+ mainTable.setRelationTableField(GlobalConstant.DEFAULT_PK);//设置外键
|
|
|
+ tableConfigs.add(mainTable);
|
|
|
+
|
|
|
+ ApiGenerateCodesDto params = new ApiGenerateCodesDto();
|
|
|
+ params.setAuthor("dzx");//作者名称
|
|
|
+ params.setPackageName("student");//包名
|
|
|
+ params.setTableConfigs(tableConfigs);
|
|
|
+ params.setPage(true);//是否生成分页接口
|
|
|
+ params.setImport(false);//是否生成导入接口
|
|
|
+ params.setExport(false);//是否生成导出接口
|
|
|
+ params.setOutMainDir(true);//是否生成在主目录,前期测试可设置成false
|
|
|
+ params.setDs(ds);
|
|
|
+
|
|
|
+
|
|
|
IApiGeneratorService apiGeneratorService = new ApiGeneratorServiceImpl();
|
|
|
|
|
|
apiGeneratorService.generateCodes(params);
|