已修改17个文件
已重命名1个文件
已添加1个文件
ÎļþÃû´Ó sql/ry_20201128.sql ÐÞ¸Ä |
| | |
| | | table_id bigint(20) not null auto_increment comment 'ç¼å·',
|
| | | table_name varchar(200) default '' comment '表åç§°',
|
| | | table_comment varchar(500) default '' comment '表æè¿°',
|
| | | sub_table_name varchar(64) default null comment 'å
³èå表ç表å',
|
| | | sub_table_fk_name varchar(64) default null comment 'å表å
³èçå¤é®å',
|
| | | class_name varchar(100) default '' comment 'å®ä½ç±»åç§°',
|
| | | tpl_category varchar(200) default 'crud' comment '使ç¨ç模æ¿ï¼crudå表æä½ treeæ 表æä½ï¼',
|
| | | package_name varchar(100) comment 'çæå
è·¯å¾',
|
| | |
| | | /** æ 表ï¼å¢å æ¹æ¥ï¼ */
|
| | | public static final String TPL_TREE = "tree";
|
| | |
|
| | | /** 主å表ï¼å¢å æ¹æ¥ï¼ */
|
| | | public static final String TPL_SUB = "sub";
|
| | |
|
| | | /** æ ç¼ç åæ®µ */
|
| | | public static final String TREE_CODE = "treeCode";
|
| | |
|
| | |
| | | public AjaxResult getInfo(@PathVariable Long talbleId)
|
| | | {
|
| | | GenTable table = genTableService.selectGenTableById(talbleId);
|
| | | List<GenTable> tables = genTableService.selectGenTableAll();
|
| | | List<GenTableColumn> list = genTableColumnService.selectGenTableColumnListByTableId(talbleId);
|
| | | Map<String, Object> map = new HashMap<String, Object>();
|
| | | map.put("info", table);
|
| | | map.put("rows", list);
|
| | | map.put("tables", tables);
|
| | | return AjaxResult.success(map);
|
| | | }
|
| | |
|
| | |
| | | @NotBlank(message = "表æè¿°ä¸è½ä¸ºç©º")
|
| | | private String tableComment;
|
| | |
|
| | | /** å
³èç¶è¡¨ç表å */
|
| | | private String subTableName;
|
| | |
|
| | | /** æ¬è¡¨å
³èç¶è¡¨çå¤é®å */
|
| | | private String subTableFkName;
|
| | |
|
| | | /** å®ä½ç±»åç§°(é¦åæ¯å¤§å) */
|
| | | @NotBlank(message = "å®ä½ç±»åç§°ä¸è½ä¸ºç©º")
|
| | | private String className;
|
| | |
|
| | | /** 使ç¨ç模æ¿ï¼crudå表æä½ treeæ 表æä½ï¼ */
|
| | | /** 使ç¨ç模æ¿ï¼crudå表æä½ treeæ 表æä½ sub主å表æä½ï¼ */
|
| | | private String tplCategory;
|
| | |
|
| | | /** çæå
è·¯å¾ */
|
| | |
| | |
|
| | | /** 主é®ä¿¡æ¯ */
|
| | | private GenTableColumn pkColumn;
|
| | |
|
| | | /** åè¡¨ä¿¡æ¯ */
|
| | | private GenTable subTable;
|
| | |
|
| | | /** 表åä¿¡æ¯ */
|
| | | @Valid
|
| | |
| | | public void setTableComment(String tableComment)
|
| | | {
|
| | | this.tableComment = tableComment;
|
| | | }
|
| | |
|
| | | public String getSubTableName()
|
| | | {
|
| | | return subTableName;
|
| | | }
|
| | |
|
| | | public void setSubTableName(String subTableName)
|
| | | {
|
| | | this.subTableName = subTableName;
|
| | | }
|
| | |
|
| | | public String getSubTableFkName()
|
| | | {
|
| | | return subTableFkName;
|
| | | }
|
| | |
|
| | | public void setSubTableFkName(String subTableFkName)
|
| | | {
|
| | | this.subTableFkName = subTableFkName;
|
| | | }
|
| | |
|
| | | public String getClassName()
|
| | |
| | | this.pkColumn = pkColumn;
|
| | | }
|
| | |
|
| | | public GenTable getSubTable()
|
| | | {
|
| | | return subTable;
|
| | | }
|
| | |
|
| | | public void setSubTable(GenTable subTable)
|
| | | {
|
| | | this.subTable = subTable;
|
| | | }
|
| | |
|
| | | public List<GenTableColumn> getColumns()
|
| | | {
|
| | | return columns;
|
| | |
| | | this.parentMenuName = parentMenuName;
|
| | | }
|
| | |
|
| | | public boolean isSub()
|
| | | {
|
| | | return isSub(this.tplCategory);
|
| | | }
|
| | |
|
| | | public static boolean isSub(String tplCategory)
|
| | | {
|
| | | return tplCategory != null && StringUtils.equals(GenConstants.TPL_SUB, tplCategory);
|
| | | }
|
| | |
|
| | | public boolean isTree()
|
| | | {
|
| | | return isTree(this.tplCategory);
|
| | |
| | | return javaField;
|
| | | }
|
| | |
|
| | | public String getCapJavaField()
|
| | | {
|
| | | return StringUtils.capitalize(javaField);
|
| | | }
|
| | |
|
| | | public void setIsPk(String isPk)
|
| | | {
|
| | | this.isPk = isPk;
|
| | |
| | | public List<GenTable> selectDbTableListByNames(String[] tableNames);
|
| | |
|
| | | /**
|
| | | * æ¥è¯¢ææè¡¨ä¿¡æ¯
|
| | | * |
| | | * @return 表信æ¯éå
|
| | | */
|
| | | public List<GenTable> selectGenTableAll();
|
| | |
|
| | | /**
|
| | | * æ¥è¯¢è¡¨IDä¸å¡ä¿¡æ¯
|
| | | *
|
| | | * @param id ä¸å¡ID
|
| | |
| | | }
|
| | |
|
| | | /**
|
| | | * æ¥è¯¢ææè¡¨ä¿¡æ¯
|
| | | * |
| | | * @return 表信æ¯éå
|
| | | */
|
| | | @Override
|
| | | public List<GenTable> selectGenTableAll()
|
| | | {
|
| | | return genTableMapper.selectGenTableAll();
|
| | | }
|
| | |
|
| | | /**
|
| | | * ä¿®æ¹ä¸å¡
|
| | | *
|
| | | * @param genTable ä¸å¡ä¿¡æ¯
|
| | |
| | | Map<String, String> dataMap = new LinkedHashMap<>();
|
| | | // æ¥è¯¢è¡¨ä¿¡æ¯
|
| | | GenTable table = genTableMapper.selectGenTableById(tableId);
|
| | | // æ¥è¯¢åä¿¡æ¯
|
| | | List<GenTableColumn> columns = table.getColumns();
|
| | | setPkColumn(table, columns);
|
| | | // 设置主å表信æ¯
|
| | | setSubTable(table);
|
| | | // 设置主é®åä¿¡æ¯
|
| | | setPkColumn(table);
|
| | | VelocityInitializer.initVelocity();
|
| | |
|
| | | VelocityContext context = VelocityUtils.prepareContext(table);
|
| | |
| | | {
|
| | | // æ¥è¯¢è¡¨ä¿¡æ¯
|
| | | GenTable table = genTableMapper.selectGenTableByName(tableName);
|
| | | // æ¥è¯¢åä¿¡æ¯
|
| | | List<GenTableColumn> columns = table.getColumns();
|
| | | setPkColumn(table, columns);
|
| | | // 设置主å表信æ¯
|
| | | setSubTable(table);
|
| | | // 设置主é®åä¿¡æ¯
|
| | | setPkColumn(table);
|
| | |
|
| | | VelocityInitializer.initVelocity();
|
| | |
|
| | |
| | | List<String> tableColumnNames = tableColumns.stream().map(GenTableColumn::getColumnName).collect(Collectors.toList());
|
| | |
|
| | | List<GenTableColumn> dbTableColumns = genTableColumnMapper.selectDbTableColumnsByName(tableName);
|
| | | if (StringUtils.isEmpty(dbTableColumns))
|
| | | {
|
| | | throw new CustomException("åæ¥æ°æ®å¤±è´¥ï¼åè¡¨ç»æä¸åå¨");
|
| | | }
|
| | | List<String> dbTableColumnNames = dbTableColumns.stream().map(GenTableColumn::getColumnName).collect(Collectors.toList());
|
| | |
|
| | | dbTableColumns.forEach(column -> {
|
| | |
| | | {
|
| | | // æ¥è¯¢è¡¨ä¿¡æ¯
|
| | | GenTable table = genTableMapper.selectGenTableByName(tableName);
|
| | | // æ¥è¯¢åä¿¡æ¯
|
| | | List<GenTableColumn> columns = table.getColumns();
|
| | | setPkColumn(table, columns);
|
| | | // 设置主å表信æ¯
|
| | | setSubTable(table);
|
| | | // 设置主é®åä¿¡æ¯
|
| | | setPkColumn(table);
|
| | |
|
| | | VelocityInitializer.initVelocity();
|
| | |
|
| | |
| | | throw new CustomException("æ åç§°åæ®µä¸è½ä¸ºç©º");
|
| | | }
|
| | | }
|
| | | else if (GenConstants.TPL_SUB.equals(genTable.getTplCategory()))
|
| | | {
|
| | | if (StringUtils.isEmpty(genTable.getSubTableName()))
|
| | | {
|
| | | throw new CustomException("å
³èå表ç表åä¸è½ä¸ºç©º");
|
| | | }
|
| | | else if (StringUtils.isEmpty(genTable.getSubTableFkName()))
|
| | | {
|
| | | throw new CustomException("å表å
³èçå¤é®åä¸è½ä¸ºç©º");
|
| | | }
|
| | | }
|
| | | }
|
| | |
|
| | | /**
|
| | | * 设置主é®åä¿¡æ¯
|
| | | *
|
| | | * @param table ä¸å¡è¡¨ä¿¡æ¯
|
| | | * @param columns ä¸å¡å段å表
|
| | | */
|
| | | public void setPkColumn(GenTable table, List<GenTableColumn> columns)
|
| | | public void setPkColumn(GenTable table)
|
| | | {
|
| | | for (GenTableColumn column : columns)
|
| | | for (GenTableColumn column : table.getColumns())
|
| | | {
|
| | | if (column.isPk())
|
| | | {
|
| | |
| | | }
|
| | | if (StringUtils.isNull(table.getPkColumn()))
|
| | | {
|
| | | table.setPkColumn(columns.get(0));
|
| | | table.setPkColumn(table.getColumns().get(0));
|
| | | }
|
| | | if (GenConstants.TPL_SUB.equals(table.getTplCategory()))
|
| | | {
|
| | | for (GenTableColumn column : table.getSubTable().getColumns())
|
| | | {
|
| | | if (column.isPk())
|
| | | {
|
| | | table.getSubTable().setPkColumn(column);
|
| | | break;
|
| | | }
|
| | | }
|
| | | if (StringUtils.isNull(table.getSubTable().getPkColumn()))
|
| | | {
|
| | | table.getSubTable().setPkColumn(table.getSubTable().getColumns().get(0));
|
| | | }
|
| | | }
|
| | | }
|
| | |
|
| | | /**
|
| | | * 设置主å表信æ¯
|
| | | * |
| | | * @param table ä¸å¡è¡¨ä¿¡æ¯
|
| | | */
|
| | | public void setSubTable(GenTable table)
|
| | | {
|
| | | String subTableName = table.getSubTableName();
|
| | | if (StringUtils.isNotEmpty(subTableName))
|
| | | {
|
| | | table.setSubTable(genTableMapper.selectGenTableByName(subTableName));
|
| | | }
|
| | | }
|
| | |
|
| | |
| | | public List<GenTable> selectDbTableListByNames(String[] tableNames);
|
| | |
|
| | | /**
|
| | | * æ¥è¯¢ææè¡¨ä¿¡æ¯
|
| | | * |
| | | * @return 表信æ¯éå
|
| | | */
|
| | | public List<GenTable> selectGenTableAll();
|
| | |
|
| | | /**
|
| | | * æ¥è¯¢ä¸å¡ä¿¡æ¯
|
| | | *
|
| | | * @param id ä¸å¡ID
|
| | |
| | | /**
|
| | | * VelocityEngineå·¥å
|
| | | *
|
| | | * @author RuoYi
|
| | | * @author ruoyi
|
| | | */
|
| | | public class VelocityInitializer
|
| | | {
|
| | |
| | | velocityContext.put("author", genTable.getFunctionAuthor());
|
| | | velocityContext.put("datetime", DateUtils.getDate());
|
| | | velocityContext.put("pkColumn", genTable.getPkColumn());
|
| | | velocityContext.put("importList", getImportList(genTable.getColumns()));
|
| | | velocityContext.put("importList", getImportList(genTable));
|
| | | velocityContext.put("permissionPrefix", getPermissionPrefix(moduleName, businessName));
|
| | | velocityContext.put("columns", genTable.getColumns());
|
| | | velocityContext.put("table", genTable);
|
| | |
| | | if (GenConstants.TPL_TREE.equals(tplCategory))
|
| | | {
|
| | | setTreeVelocityContext(velocityContext, genTable);
|
| | | }
|
| | | if (GenConstants.TPL_SUB.equals(tplCategory))
|
| | | {
|
| | | setSubVelocityContext(velocityContext, genTable);
|
| | | }
|
| | | return velocityContext;
|
| | | }
|
| | |
| | | }
|
| | | }
|
| | |
|
| | | public static void setSubVelocityContext(VelocityContext context, GenTable genTable)
|
| | | {
|
| | | GenTable subTable = genTable.getSubTable();
|
| | | String subTableName = genTable.getSubTableName();
|
| | | String subTableFkName = genTable.getSubTableFkName();
|
| | | String subClassName = genTable.getSubTable().getClassName();
|
| | | String subTableFkClassName = StringUtils.convertToCamelCase(subTableFkName);
|
| | |
|
| | | context.put("subTable", subTable);
|
| | | context.put("subTableName", subTableName);
|
| | | context.put("subTableFkName", subTableFkName);
|
| | | context.put("subTableFkClassName", subTableFkClassName);
|
| | | context.put("subTableFkclassName", StringUtils.uncapitalize(subTableFkClassName));
|
| | | context.put("subClassName", subClassName);
|
| | | context.put("subclassName", StringUtils.uncapitalize(subClassName));
|
| | | context.put("subImportList", getImportList(genTable.getSubTable()));
|
| | | }
|
| | | /**
|
| | | * è·å模æ¿ä¿¡æ¯
|
| | | *
|
| | |
| | | else if (GenConstants.TPL_TREE.equals(tplCategory))
|
| | | {
|
| | | templates.add("vm/vue/index-tree.vue.vm");
|
| | | }
|
| | | else if (GenConstants.TPL_SUB.equals(tplCategory))
|
| | | {
|
| | | templates.add("vm/vue/index.vue.vm");
|
| | | templates.add("vm/java/sub-domain.java.vm");
|
| | | }
|
| | | return templates;
|
| | | }
|
| | |
| | | if (template.contains("domain.java.vm"))
|
| | | {
|
| | | fileName = StringUtils.format("{}/domain/{}.java", javaPath, className);
|
| | | }
|
| | | if (template.contains("sub-domain.java.vm") && StringUtils.equals(GenConstants.TPL_SUB, genTable.getTplCategory()))
|
| | | {
|
| | | fileName = StringUtils.format("{}/domain/{}.java", javaPath, genTable.getSubTable().getClassName());
|
| | | }
|
| | | else if (template.contains("mapper.java.vm"))
|
| | | {
|
| | |
| | | /**
|
| | | * æ ¹æ®åç±»åè·å导å
¥å
|
| | | *
|
| | | * @param column åéå
|
| | | * @param genTable ä¸å¡è¡¨å¯¹è±¡
|
| | | * @return è¿åéè¦å¯¼å
¥çå
å表
|
| | | */
|
| | | public static HashSet<String> getImportList(List<GenTableColumn> columns)
|
| | | public static HashSet<String> getImportList(GenTable genTable)
|
| | | {
|
| | | List<GenTableColumn> columns = genTable.getColumns();
|
| | | GenTable subGenTable = genTable.getSubTable();
|
| | | HashSet<String> importList = new HashSet<String>();
|
| | | if (StringUtils.isNotNull(subGenTable))
|
| | | {
|
| | | importList.add("java.util.List");
|
| | | }
|
| | | for (GenTableColumn column : columns)
|
| | | {
|
| | | if (!column.isSuperColumn() && GenConstants.TYPE_DATE.equals(column.getJavaType()))
|
| | |
| | | <mapper namespace="com.ruoyi.project.tool.gen.mapper.GenTableMapper">
|
| | |
|
| | | <resultMap type="GenTable" id="GenTableResult">
|
| | | <id property="tableId" column="table_id" />
|
| | | <result property="tableName" column="table_name" />
|
| | | <result property="tableComment" column="table_comment" />
|
| | | <result property="className" column="class_name" />
|
| | | <result property="tplCategory" column="tpl_category" />
|
| | | <result property="packageName" column="package_name" />
|
| | | <result property="moduleName" column="module_name" />
|
| | | <result property="businessName" column="business_name" />
|
| | | <result property="functionName" column="function_name" />
|
| | | <result property="functionAuthor" column="function_author" />
|
| | | <result property="genType" column="gen_type" />
|
| | | <result property="genPath" column="gen_path" />
|
| | | <result property="options" column="options" />
|
| | | <result property="createBy" column="create_by" />
|
| | | <result property="createTime" column="create_time" />
|
| | | <result property="updateBy" column="update_by" />
|
| | | <result property="updateTime" column="update_time" />
|
| | | <result property="remark" column="remark" />
|
| | | <id property="tableId" column="table_id" />
|
| | | <result property="tableName" column="table_name" />
|
| | | <result property="tableComment" column="table_comment" />
|
| | | <result property="subTableName" column="sub_table_name" />
|
| | | <result property="subTableFkName" column="sub_table_fk_name" />
|
| | | <result property="className" column="class_name" />
|
| | | <result property="tplCategory" column="tpl_category" />
|
| | | <result property="packageName" column="package_name" />
|
| | | <result property="moduleName" column="module_name" />
|
| | | <result property="businessName" column="business_name" />
|
| | | <result property="functionName" column="function_name" />
|
| | | <result property="functionAuthor" column="function_author" />
|
| | | <result property="genType" column="gen_type" />
|
| | | <result property="genPath" column="gen_path" />
|
| | | <result property="options" column="options" />
|
| | | <result property="createBy" column="create_by" />
|
| | | <result property="createTime" column="create_time" />
|
| | | <result property="updateBy" column="update_by" />
|
| | | <result property="updateTime" column="update_time" />
|
| | | <result property="remark" column="remark" />
|
| | | <collection property="columns" javaType="java.util.List" resultMap="GenTableColumnResult" />
|
| | | </resultMap>
|
| | |
|
| | |
| | | </resultMap>
|
| | |
|
| | | <sql id="selectGenTableVo">
|
| | | select table_id, table_name, table_comment, class_name, tpl_category, package_name, module_name, business_name, function_name, function_author, gen_type, gen_path, options, create_by, create_time, update_by, update_time, remark from gen_table
|
| | | select table_id, table_name, table_comment, sub_table_name, sub_table_fk_name, class_name, tpl_category, package_name, module_name, business_name, function_name, function_author, gen_type, gen_path, options, create_by, create_time, update_by, update_time, remark from gen_table
|
| | | </sql>
|
| | |
|
| | | <select id="selectGenTableList" parameterType="GenTable" resultMap="GenTableResult">
|
| | |
| | | </select>
|
| | |
|
| | | <select id="selectGenTableById" parameterType="Long" resultMap="GenTableResult">
|
| | | SELECT t.table_id, t.table_name, t.table_comment, t.class_name, t.tpl_category, t.package_name, t.module_name, t.business_name, t.function_name, t.function_author, t.gen_type, t.gen_path, t.options, t.remark,
|
| | | SELECT t.table_id, t.table_name, t.table_comment, t.sub_table_name, t.sub_table_fk_name, t.class_name, t.tpl_category, t.package_name, t.module_name, t.business_name, t.function_name, t.function_author, t.gen_type, t.gen_path, t.options, t.remark,
|
| | | c.column_id, c.column_name, c.column_comment, c.column_type, c.java_type, c.java_field, c.is_pk, c.is_increment, c.is_required, c.is_insert, c.is_edit, c.is_list, c.is_query, c.query_type, c.html_type, c.dict_type, c.sort
|
| | | FROM gen_table t
|
| | | LEFT JOIN gen_table_column c ON t.table_id = c.table_id
|
| | |
| | | </select>
|
| | |
|
| | | <select id="selectGenTableByName" parameterType="String" resultMap="GenTableResult">
|
| | | SELECT t.table_id, t.table_name, t.table_comment, t.class_name, t.tpl_category, t.package_name, t.module_name, t.business_name, t.function_name, t.function_author, t.gen_type, t.gen_path, t.options, t.remark,
|
| | | SELECT t.table_id, t.table_name, t.table_comment, t.sub_table_name, t.sub_table_fk_name, t.class_name, t.tpl_category, t.package_name, t.module_name, t.business_name, t.function_name, t.function_author, t.gen_type, t.gen_path, t.options, t.remark,
|
| | | c.column_id, c.column_name, c.column_comment, c.column_type, c.java_type, c.java_field, c.is_pk, c.is_increment, c.is_required, c.is_insert, c.is_edit, c.is_list, c.is_query, c.query_type, c.html_type, c.dict_type, c.sort
|
| | | FROM gen_table t
|
| | | LEFT JOIN gen_table_column c ON t.table_id = c.table_id
|
| | | where t.table_name = #{tableName} order by c.sort
|
| | | </select>
|
| | | |
| | | <select id="selectGenTableAll" parameterType="String" resultMap="GenTableResult">
|
| | | SELECT t.table_id, t.table_name, t.table_comment, t.sub_table_name, t.sub_table_fk_name, t.class_name, t.tpl_category, t.package_name, t.module_name, t.business_name, t.function_name, t.function_author, t.options, t.remark,
|
| | | c.column_id, c.column_name, c.column_comment, c.column_type, c.java_type, c.java_field, c.is_pk, c.is_increment, c.is_required, c.is_insert, c.is_edit, c.is_list, c.is_query, c.query_type, c.html_type, c.dict_type, c.sort
|
| | | FROM gen_table t
|
| | | LEFT JOIN gen_table_column c ON t.table_id = c.table_id
|
| | | order by c.sort
|
| | | </select>
|
| | |
|
| | | <insert id="insertGenTable" parameterType="GenTable" useGeneratedKeys="true" keyProperty="tableId">
|
| | |
| | | <set>
|
| | | <if test="tableName != null">table_name = #{tableName},</if>
|
| | | <if test="tableComment != null and tableComment != ''">table_comment = #{tableComment},</if>
|
| | | <if test="subTableName != null">sub_table_name = #{subTableName},</if>
|
| | | <if test="subTableFkName != null">sub_table_fk_name = #{subTableFkName},</if>
|
| | | <if test="className != null and className != ''">class_name = #{className},</if>
|
| | | <if test="functionAuthor != null and functionAuthor != ''">function_author = #{functionAuthor},</if>
|
| | | <if test="genType != null and genType != ''">gen_type = #{genType},</if>
|
| | |
| | | import com.ruoyi.framework.web.controller.BaseController;
|
| | | import com.ruoyi.framework.web.domain.AjaxResult;
|
| | | import com.ruoyi.common.utils.poi.ExcelUtil;
|
| | | #if($table.crud)
|
| | | #if($table.crud || $table.sub)
|
| | | import com.ruoyi.framework.web.page.TableDataInfo;
|
| | | #elseif($table.tree)
|
| | | #end
|
| | |
| | | */
|
| | | @PreAuthorize("@ss.hasPermi('${permissionPrefix}:list')")
|
| | | @GetMapping("/list")
|
| | | #if($table.crud)
|
| | | #if($table.crud || $table.sub)
|
| | | public TableDataInfo list(${ClassName} ${className})
|
| | | {
|
| | | startPage();
|
| | |
| | | import org.apache.commons.lang3.builder.ToStringBuilder;
|
| | | import org.apache.commons.lang3.builder.ToStringStyle;
|
| | | import com.ruoyi.framework.aspectj.lang.annotation.Excel;
|
| | | #if($table.crud)
|
| | | #if($table.crud || $table.sub)
|
| | | import com.ruoyi.framework.web.domain.BaseEntity;
|
| | | #elseif($table.tree)
|
| | | import com.ruoyi.framework.web.domain.TreeEntity;
|
| | |
| | | * @author ${author}
|
| | | * @date ${datetime}
|
| | | */
|
| | | #if($table.crud)
|
| | | #if($table.crud || $table.sub)
|
| | | #set($Entity="BaseEntity")
|
| | | #elseif($table.tree)
|
| | | #set($Entity="TreeEntity")
|
| | |
| | |
|
| | | #end
|
| | | #end
|
| | | #if($table.sub)
|
| | | /** $table.subTable.functionNameä¿¡æ¯ */
|
| | | private List<${subClassName}> ${subclassName}List;
|
| | |
|
| | | #end
|
| | | #foreach ($column in $columns)
|
| | | #if(!$table.isSuperColumn($column.javaField))
|
| | | #if($column.javaField.length() > 2 && $column.javaField.substring(1,2).matches("[A-Z]"))
|
| | |
| | | #end
|
| | | #end
|
| | |
|
| | | #if($table.sub)
|
| | | public List<${subClassName}> get${subClassName}List()
|
| | | {
|
| | | return ${subclassName}List;
|
| | | }
|
| | |
|
| | | public void set${subClassName}List(List<${subClassName}> ${subclassName}List)
|
| | | {
|
| | | this.${subclassName}List = ${subclassName}List;
|
| | | }
|
| | |
|
| | | #end
|
| | | @Override
|
| | | public String toString() {
|
| | | return new ToStringBuilder(this,ToStringStyle.MULTI_LINE_STYLE)
|
| | |
| | | #end
|
| | | .append("${column.javaField}", get${AttrName}())
|
| | | #end
|
| | | #if($table.sub)
|
| | | .append("${subclassName}List", get${subClassName}List())
|
| | | #end
|
| | | .toString();
|
| | | }
|
| | | }
|
| | |
| | |
|
| | | import java.util.List;
|
| | | import ${packageName}.domain.${ClassName};
|
| | | #if($table.sub)
|
| | | import ${packageName}.domain.${subClassName};
|
| | | #end
|
| | |
|
| | | /**
|
| | | * ${functionName}Mapperæ¥å£
|
| | |
| | | * @return ç»æ
|
| | | */
|
| | | public int delete${ClassName}ByIds(${pkColumn.javaType}[] ${pkColumn.javaField}s);
|
| | | #if($table.sub)
|
| | |
|
| | | /**
|
| | | * æ¹éå é¤${subTable.functionName}
|
| | | * |
| | | * @param customerIds éè¦å é¤çæ°æ®ID
|
| | | * @return ç»æ
|
| | | */
|
| | | public int delete${subClassName}By${subTableFkClassName}s(${pkColumn.javaType}[] ${pkColumn.javaField}s);
|
| | | |
| | | /**
|
| | | * æ¹éæ°å¢${subTable.functionName}
|
| | | * |
| | | * @param ${subclassName}List ${subTable.functionName}å表
|
| | | * @return ç»æ
|
| | | */
|
| | | public int batch${subClassName}(List<${subClassName}> ${subclassName}List);
|
| | | |
| | |
|
| | | /**
|
| | | * éè¿${functionName}IDå é¤${subTable.functionName}ä¿¡æ¯
|
| | | * |
| | | * @param roleId è§è²ID
|
| | | * @return ç»æ
|
| | | */
|
| | | public int delete${subClassName}By${subTableFkClassName}(${pkColumn.javaType} ${pkColumn.javaField});
|
| | | #end
|
| | | }
|
| | |
| | | #end
|
| | | import org.springframework.beans.factory.annotation.Autowired;
|
| | | import org.springframework.stereotype.Service;
|
| | | #if($table.sub)
|
| | | import java.util.ArrayList;
|
| | | import com.ruoyi.common.utils.StringUtils;
|
| | | import org.springframework.transaction.annotation.Transactional;
|
| | | import ${packageName}.domain.${subClassName};
|
| | | #end
|
| | | import ${packageName}.mapper.${ClassName}Mapper;
|
| | | import ${packageName}.domain.${ClassName};
|
| | | import ${packageName}.service.I${ClassName}Service;
|
| | |
| | | * @param ${className} ${functionName}
|
| | | * @return ç»æ
|
| | | */
|
| | | #if($table.sub)
|
| | | @Transactional
|
| | | #end
|
| | | @Override
|
| | | public int insert${ClassName}(${ClassName} ${className})
|
| | | {
|
| | |
| | | ${className}.setCreateTime(DateUtils.getNowDate());
|
| | | #end
|
| | | #end
|
| | | #if($table.sub)
|
| | | int rows = ${className}Mapper.insert${ClassName}(${className});
|
| | | insert${subClassName}(${className});
|
| | | return rows;
|
| | | #else
|
| | | return ${className}Mapper.insert${ClassName}(${className});
|
| | | #end
|
| | | }
|
| | |
|
| | | /**
|
| | |
| | | * @param ${className} ${functionName}
|
| | | * @return ç»æ
|
| | | */
|
| | | #if($table.sub)
|
| | | @Transactional
|
| | | #end
|
| | | @Override
|
| | | public int update${ClassName}(${ClassName} ${className})
|
| | | {
|
| | |
| | | #if($column.javaField == 'updateTime')
|
| | | ${className}.setUpdateTime(DateUtils.getNowDate());
|
| | | #end
|
| | | #end
|
| | | #if($table.sub)
|
| | | ${className}Mapper.delete${subClassName}By${subTableFkClassName}(${className}.get${pkColumn.capJavaField}());
|
| | | insert${subClassName}(${className});
|
| | | #end
|
| | | return ${className}Mapper.update${ClassName}(${className});
|
| | | }
|
| | |
| | | * @param ${pkColumn.javaField}s éè¦å é¤ç${functionName}ID
|
| | | * @return ç»æ
|
| | | */
|
| | | #if($table.sub)
|
| | | @Transactional
|
| | | #end
|
| | | @Override
|
| | | public int delete${ClassName}ByIds(${pkColumn.javaType}[] ${pkColumn.javaField}s)
|
| | | {
|
| | | #if($table.sub)
|
| | | ${className}Mapper.delete${subClassName}By${subTableFkClassName}s(${pkColumn.javaField}s);
|
| | | #end
|
| | | return ${className}Mapper.delete${ClassName}ByIds(${pkColumn.javaField}s);
|
| | | }
|
| | |
|
| | |
| | | @Override
|
| | | public int delete${ClassName}ById(${pkColumn.javaType} ${pkColumn.javaField})
|
| | | {
|
| | | #if($table.sub)
|
| | | ${className}Mapper.delete${subClassName}By${subTableFkClassName}(${pkColumn.javaField});
|
| | | #end
|
| | | return ${className}Mapper.delete${ClassName}ById(${pkColumn.javaField});
|
| | | }
|
| | | #if($table.sub)
|
| | |
|
| | | /**
|
| | | * æ°å¢${subTable.functionName}ä¿¡æ¯
|
| | | * |
| | | * @param ${className} ${functionName}对象
|
| | | */
|
| | | public void insert${subClassName}(${ClassName} ${className})
|
| | | {
|
| | | List<${subClassName}> ${subclassName}List = ${className}.get${subClassName}List();
|
| | | Long ${pkColumn.javaField} = ${className}.get${pkColumn.capJavaField}();
|
| | | if (StringUtils.isNotNull(${subclassName}List))
|
| | | {
|
| | | List<${subClassName}> list = new ArrayList<${subClassName}>();
|
| | | for (${subClassName} ${subclassName} : ${subclassName}List)
|
| | | {
|
| | | ${subclassName}.set${subTableFkClassName}(${pkColumn.javaField});
|
| | | list.add(${subclassName});
|
| | | }
|
| | | if (list.size() > 0)
|
| | | {
|
| | | ${className}Mapper.batch${subClassName}(list);
|
| | | }
|
| | | }
|
| | | }
|
| | | #end
|
| | | }
|
¶Ô±ÈÐÂÎļþ |
| | |
| | | package ${packageName}.domain;
|
| | |
|
| | | #foreach ($import in $subImportList)
|
| | | import ${import};
|
| | | #end
|
| | | import org.apache.commons.lang3.builder.ToStringBuilder;
|
| | | import org.apache.commons.lang3.builder.ToStringStyle;
|
| | | import com.ruoyi.framework.aspectj.lang.annotation.Excel;
|
| | | import com.ruoyi.framework.web.domain.BaseEntity;
|
| | |
|
| | | /**
|
| | | * ${subTable.functionName}对象 ${subTableName}
|
| | | * |
| | | * @author ${author}
|
| | | * @date ${datetime}
|
| | | */
|
| | | public class ${subClassName} extends BaseEntity
|
| | | {
|
| | | private static final long serialVersionUID = 1L;
|
| | |
|
| | | #foreach ($column in $subTable.columns)
|
| | | #if(!$table.isSuperColumn($column.javaField))
|
| | | /** $column.columnComment */
|
| | | #if($column.list)
|
| | | #set($parentheseIndex=$column.columnComment.indexOf("ï¼"))
|
| | | #if($parentheseIndex != -1)
|
| | | #set($comment=$column.columnComment.substring(0, $parentheseIndex))
|
| | | #else
|
| | | #set($comment=$column.columnComment)
|
| | | #end
|
| | | #if($parentheseIndex != -1)
|
| | | @Excel(name = "${comment}", readConverterExp = "$column.readConverterExp()")
|
| | | #elseif($column.javaType == 'Date')
|
| | | @JsonFormat(pattern = "yyyy-MM-dd")
|
| | | @Excel(name = "${comment}", width = 30, dateFormat = "yyyy-MM-dd")
|
| | | #else
|
| | | @Excel(name = "${comment}")
|
| | | #end
|
| | | #end
|
| | | private $column.javaType $column.javaField;
|
| | |
|
| | | #end
|
| | | #end
|
| | | #foreach ($column in $subTable.columns)
|
| | | #if(!$table.isSuperColumn($column.javaField))
|
| | | #if($column.javaField.length() > 2 && $column.javaField.substring(1,2).matches("[A-Z]"))
|
| | | #set($AttrName=$column.javaField)
|
| | | #else
|
| | | #set($AttrName=$column.javaField.substring(0,1).toUpperCase() + ${column.javaField.substring(1)})
|
| | | #end
|
| | | public void set${AttrName}($column.javaType $column.javaField) |
| | | {
|
| | | this.$column.javaField = $column.javaField;
|
| | | }
|
| | |
|
| | | public $column.javaType get${AttrName}() |
| | | {
|
| | | return $column.javaField;
|
| | | }
|
| | | #end
|
| | | #end
|
| | |
|
| | | @Override
|
| | | public String toString() {
|
| | | return new ToStringBuilder(this,ToStringStyle.MULTI_LINE_STYLE)
|
| | | #foreach ($column in $subTable.columns)
|
| | | #if($column.javaField.length() > 2 && $column.javaField.substring(1,2).matches("[A-Z]"))
|
| | | #set($AttrName=$column.javaField)
|
| | | #else
|
| | | #set($AttrName=$column.javaField.substring(0,1).toUpperCase() + ${column.javaField.substring(1)})
|
| | | #end
|
| | | .append("${column.javaField}", get${AttrName}())
|
| | | #end
|
| | | .toString();
|
| | | }
|
| | | }
|
| | |
| | | <el-col :span="1.5">
|
| | | <el-button
|
| | | type="primary"
|
| | | plain
|
| | | plain
|
| | | icon="el-icon-plus"
|
| | | size="mini"
|
| | | @click="handleAdd"
|
| | |
| | | <el-col :span="1.5">
|
| | | <el-button
|
| | | type="primary"
|
| | | plain
|
| | | plain
|
| | | icon="el-icon-plus"
|
| | | size="mini"
|
| | | @click="handleAdd"
|
| | |
| | | <el-col :span="1.5">
|
| | | <el-button
|
| | | type="success"
|
| | | plain
|
| | | plain
|
| | | icon="el-icon-edit"
|
| | | size="mini"
|
| | | :disabled="single"
|
| | |
| | | <el-col :span="1.5">
|
| | | <el-button
|
| | | type="danger"
|
| | | plain
|
| | | plain
|
| | | icon="el-icon-delete"
|
| | | size="mini"
|
| | | :disabled="multiple"
|
| | |
| | | <el-col :span="1.5">
|
| | | <el-button
|
| | | type="warning"
|
| | | plain
|
| | | plain
|
| | | icon="el-icon-download"
|
| | | size="mini"
|
| | | @click="handleExport"
|
| | |
| | | #end
|
| | | #end
|
| | | #end
|
| | | #if($table.sub)
|
| | | <el-divider content-position="center">${subTable.functionName}ä¿¡æ¯</el-divider>
|
| | | <el-row :gutter="10" class="mb8">
|
| | | <el-col :span="1.5">
|
| | | <el-button type="primary" icon="el-icon-plus" size="mini" @click="handleAdd${subClassName}">æ·»å </el-button>
|
| | | </el-col>
|
| | | <el-col :span="1.5">
|
| | | <el-button type="danger" icon="el-icon-delete" size="mini" @click="handleDelete${subClassName}">å é¤</el-button>
|
| | | </el-col>
|
| | | </el-row>
|
| | | <el-table :data="${subclassName}List" :row-class-name="row${subClassName}Index" @selection-change="handle${subClassName}SelectionChange" ref="${subclassName}">
|
| | | <el-table-column type="selection" width="50" align="center" />
|
| | | <el-table-column label="åºå·" align="center" prop="index" width="50"/>
|
| | | #foreach($column in $subTable.columns)
|
| | | #set($javaField=$column.javaField)
|
| | | #set($parentheseIndex=$column.columnComment.indexOf("ï¼"))
|
| | | #if($parentheseIndex != -1)
|
| | | #set($comment=$column.columnComment.substring(0, $parentheseIndex))
|
| | | #else
|
| | | #set($comment=$column.columnComment)
|
| | | #end
|
| | | #if($column.pk || $javaField == ${subTableFkclassName})
|
| | | #elseif($column.list && "" != $javaField)
|
| | | <el-table-column label="$comment" prop="${javaField}">
|
| | | <template slot-scope="scope">
|
| | | <el-input v-model="scope.row.$javaField" placeholder="请è¾å
¥$comment" />
|
| | | </template>
|
| | | </el-table-column>
|
| | | #end
|
| | | #end
|
| | | </el-table>
|
| | | #end
|
| | | </el-form>
|
| | | <div slot="footer" class="dialog-footer">
|
| | | <el-button type="primary" @click="submitForm">ç¡® å®</el-button>
|
| | |
| | | loading: true,
|
| | | // é䏿°ç»
|
| | | ids: [],
|
| | | #if($table.sub)
|
| | | // å表é䏿°æ®
|
| | | checked${subClassName}: [],
|
| | | #end
|
| | | // éå个ç¦ç¨
|
| | | single: true,
|
| | | // éå¤ä¸ªç¦ç¨
|
| | |
| | | total: 0,
|
| | | // ${functionName}è¡¨æ ¼æ°æ®
|
| | | ${businessName}List: [],
|
| | | #if($table.sub)
|
| | | // ${subTable.functionName}è¡¨æ ¼æ°æ®
|
| | | ${subclassName}List: [],
|
| | | #end
|
| | | // å¼¹åºå±æ é¢
|
| | | title: "",
|
| | | // æ¯å¦æ¾ç¤ºå¼¹åºå±
|
| | |
| | | #end
|
| | | #end
|
| | | };
|
| | | #if($table.sub)
|
| | | this.${subclassName}List = [];
|
| | | #end
|
| | | this.resetForm("form");
|
| | | },
|
| | | /** æç´¢æé®æä½ */
|
| | |
| | | this.form.$column.javaField = this.form.${column.javaField}.split(",");
|
| | | #end
|
| | | #end
|
| | | #if($table.sub)
|
| | | this.${subclassName}List = response.data.${subclassName}List;
|
| | | #end
|
| | | this.open = true;
|
| | | this.title = "ä¿®æ¹${functionName}";
|
| | | });
|
| | |
| | | #if($column.htmlType == "checkbox")
|
| | | this.form.$column.javaField = this.form.${column.javaField}.join(",");
|
| | | #end
|
| | | #end
|
| | | #if($table.sub)
|
| | | this.form.${subclassName}List = this.${subclassName}List;
|
| | | #end
|
| | | if (this.form.${pkColumn.javaField} != null) {
|
| | | update${BusinessName}(this.form).then(response => {
|
| | |
| | | this.msgSuccess("å 餿å");
|
| | | })
|
| | | },
|
| | | #if($table.sub)
|
| | | /** ${subTable.functionName}åºå· */
|
| | | row${subClassName}Index({ row, rowIndex }) {
|
| | | row.index = rowIndex + 1;
|
| | | },
|
| | | /** ${subTable.functionName}æ·»å æé®æä½ */
|
| | | handleAdd${subClassName}() {
|
| | | let obj = {};
|
| | | #foreach($column in $subTable.columns)
|
| | | #if($column.pk || $column.javaField == ${subTableFkclassName})
|
| | | #elseif($column.list && "" != $javaField)
|
| | | obj.$column.javaField = "";
|
| | | #end
|
| | | #end
|
| | | this.${subclassName}List.push(obj);
|
| | | },
|
| | | /** ${subTable.functionName}å é¤æé®æä½ */
|
| | | handleDelete${subClassName}() {
|
| | | if (this.checked${subClassName}.length == 0) {
|
| | | this.$alert("请å
éæ©è¦å é¤ç${subTable.functionName}æ°æ®", "æç¤º", { confirmButtonText: "ç¡®å®", });
|
| | | } else {
|
| | | this.${subclassName}List.splice(this.checked${subClassName}[0].index - 1, 1);
|
| | | }
|
| | | },
|
| | | /** åéæ¡é䏿°æ® */
|
| | | handle${subClassName}SelectionChange(selection) {
|
| | | if (selection.length > 1) {
|
| | | this.$refs.${subclassName}.clearSelection();
|
| | | this.$refs.${subclassName}.toggleRowSelection(selection.pop());
|
| | | } else {
|
| | | this.checked${subClassName} = selection;
|
| | | }
|
| | | },
|
| | | #end
|
| | | /** å¯¼åºæé®æä½ */
|
| | | handleExport() {
|
| | | const queryParams = this.queryParams;
|
| | |
| | | <result property="${column.javaField}" column="${column.columnName}" />
|
| | | #end
|
| | | </resultMap>
|
| | | #if($table.sub)
|
| | |
|
| | | <resultMap id="${ClassName}${subClassName}Result" type="${ClassName}" extends="${ClassName}Result">
|
| | | <collection property="${subclassName}List" notNullColumn="${subTable.pkColumn.columnName}" javaType="java.util.List" resultMap="${subClassName}Result" />
|
| | | </resultMap>
|
| | |
|
| | | <resultMap type="${subClassName}" id="${subClassName}Result">
|
| | | #foreach ($column in $subTable.columns)
|
| | | <result property="${column.javaField}" column="${column.columnName}" />
|
| | | #end
|
| | | </resultMap>
|
| | | #end
|
| | |
|
| | | <sql id="select${ClassName}Vo">
|
| | | select#foreach($column in $columns) $column.columnName#if($velocityCount != $columns.size()),#end#end from ${tableName}
|
| | |
| | | </where>
|
| | | </select>
|
| | |
|
| | | <select id="select${ClassName}ById" parameterType="${pkColumn.javaType}" resultMap="${ClassName}Result">
|
| | | <select id="select${ClassName}ById" parameterType="${pkColumn.javaType}" resultMap="#if($table.sub)${ClassName}${subClassName}Result#else${ClassName}Result#end">
|
| | | #if($table.crud || $table.tree)
|
| | | <include refid="select${ClassName}Vo"/>
|
| | | where ${pkColumn.columnName} = #{${pkColumn.javaField}}
|
| | | #elseif($table.sub)
|
| | | select#foreach($column in $columns) a.$column.columnName#if($velocityCount != $columns.size()),#end#end,
|
| | | #foreach($column in $subTable.columns) b.$column.columnName#if($velocityCount != $subTable.columns.size()),#end#end
|
| | |
|
| | | from ${tableName} a
|
| | | left join ${subTableName} b on b.${subTableFkName} = a.${pkColumn.columnName}
|
| | | where a.${pkColumn.columnName} = #{${pkColumn.javaField}}
|
| | | #end
|
| | | </select>
|
| | |
|
| | | <insert id="insert${ClassName}" parameterType="${ClassName}"#if($pkColumn.increment) useGeneratedKeys="true" keyProperty="$pkColumn.javaField"#end>
|
| | |
| | | #{${pkColumn.javaField}}
|
| | | </foreach>
|
| | | </delete>
|
| | | #if($table.sub)
|
| | |
|
| | | <delete id="delete${subClassName}By${subTableFkClassName}s" parameterType="String">
|
| | | delete from ${subTableName} where ${subTableFkName} in |
| | | <foreach item="${subTableFkclassName}" collection="array" open="(" separator="," close=")">
|
| | | #{${subTableFkclassName}}
|
| | | </foreach>
|
| | | </delete>
|
| | |
|
| | | <delete id="delete${subClassName}By${subTableFkClassName}" parameterType="Long">
|
| | | delete from ${subTableName} where ${subTableFkName} = #{${subTableFkclassName}}
|
| | | </delete>
|
| | |
|
| | | <insert id="batch${subClassName}">
|
| | | insert into ${subTableName}(#foreach($column in $subTable.columns) $column.columnName#if($velocityCount != $subTable.columns.size()),#end#end) values
|
| | | <foreach item="item" index="index" collection="list" separator=",">
|
| | | (#foreach($column in $subTable.columns) #{item.$column.javaField}#if($velocityCount != $subTable.columns.size()),#end#end)
|
| | | </foreach>
|
| | | </insert>
|
| | | #end
|
| | | </mapper> |