From 6883721a477f678f8ed815619229c5ec78f9703f Mon Sep 17 00:00:00 2001 From: zhangdaiscott <zhangdaiscott@163.com> Date: Sat, 7 May 2022 20:41:51 +0800 Subject: [PATCH] 修复代码生成器的一些bug --- jeecg-boot/jeecg-boot-module-system/src/main/resources/jeecg/code-template-online/default/one/java/${bussiPackage}/${entityPackage}/entity/${entityName}.javai | 2 +- jeecg-boot/jeecg-boot-module-system/src/main/resources/jeecg/code-template-online/default/onetomany/java/${bussiPackage}/${entityPackage}/entity/${entityName}.javai | 2 +- jeecg-boot/jeecg-boot-module-system/src/main/resources/jeecg/code-template-online/default/onetomany/java/${bussiPackage}/${entityPackage}/entity/[1-n]Entity.javai | 2 +- jeecg-boot/jeecg-boot-module-system/src/main/resources/jeecg/code-template-online/default/onetomany/java/${bussiPackage}/${entityPackage}/vo/${entityName}Page.javai | 2 +- jeecg-boot/jeecg-boot-module-system/src/main/resources/jeecg/code-template-online/default/tree/java/${bussiPackage}/${entityPackage}/controller/${entityName}Controller.javai | 64 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++- jeecg-boot/jeecg-boot-module-system/src/main/resources/jeecg/code-template-online/default/tree/java/${bussiPackage}/${entityPackage}/entity/${entityName}.javai | 2 +- jeecg-boot/jeecg-boot-module-system/src/main/resources/jeecg/code-template-online/default/tree/java/${bussiPackage}/${entityPackage}/mapper/${entityName}Mapper.javai | 15 ++++++++++++++- jeecg-boot/jeecg-boot-module-system/src/main/resources/jeecg/code-template-online/default/tree/java/${bussiPackage}/${entityPackage}/mapper/xml/${entityName}Mapper.xml | 32 +++++++++++++++++++++++++++++--- jeecg-boot/jeecg-boot-module-system/src/main/resources/jeecg/code-template-online/default/tree/java/${bussiPackage}/${entityPackage}/service/I${entityName}Service.javai | 44 ++++++++++++++++++++++++++++++++++++++++---- jeecg-boot/jeecg-boot-module-system/src/main/resources/jeecg/code-template-online/default/tree/java/${bussiPackage}/${entityPackage}/service/impl/${entityName}ServiceImpl.javai | 38 +++++++++++++++++++++++++++++++++----- jeecg-boot/jeecg-boot-module-system/src/main/resources/jeecg/code-template-online/default/tree/java/${bussiPackage}/${entityPackage}/vue3/${entityName}List.vuei | 29 ++++++++++++++++++++--------- jeecg-boot/jeecg-boot-module-system/src/main/resources/jeecg/code-template-online/default/tree/java/${bussiPackage}/${entityPackage}/vue3/${entityName}__api.tsi | 3 ++- jeecg-boot/jeecg-boot-module-system/src/main/resources/jeecg/code-template-online/default/tree/java/${bussiPackage}/${entityPackage}/vue3/${entityName}__data.tsi | 16 +++++++++++----- jeecg-boot/jeecg-boot-module-system/src/main/resources/jeecg/code-template-online/default/tree/java/${bussiPackage}/${entityPackage}/vue3/components/${entityName}Modal.vuei | 22 ++++++++++++++-------- jeecg-boot/jeecg-boot-module-system/src/main/resources/jeecg/code-template-online/erp/onetomany/java/${bussiPackage}/${entityPackage}/controller/${entityName}Controller.javai | 6 ++++-- jeecg-boot/jeecg-boot-module-system/src/main/resources/jeecg/code-template-online/erp/onetomany/java/${bussiPackage}/${entityPackage}/entity/${entityName}.javai | 2 +- jeecg-boot/jeecg-boot-module-system/src/main/resources/jeecg/code-template-online/erp/onetomany/java/${bussiPackage}/${entityPackage}/entity/[1-n]Entity.javai | 2 +- jeecg-boot/jeecg-boot-module-system/src/main/resources/jeecg/code-template-online/erp/onetomany/java/${bussiPackage}/${entityPackage}/mapper/[1-n]Mapper.javai | 14 +++++++++++++- jeecg-boot/jeecg-boot-module-system/src/main/resources/jeecg/code-template-online/erp/onetomany/java/${bussiPackage}/${entityPackage}/service/I${entityName}Service.javai | 4 ++++ jeecg-boot/jeecg-boot-module-system/src/main/resources/jeecg/code-template-online/erp/onetomany/java/${bussiPackage}/${entityPackage}/service/[1-n]Service.javai | 6 ++++++ jeecg-boot/jeecg-boot-module-system/src/main/resources/jeecg/code-template-online/erp/onetomany/java/${bussiPackage}/${entityPackage}/vue/${entityName}List.vuei | 4 ++-- jeecg-boot/jeecg-boot-module-system/src/main/resources/jeecg/code-template-online/inner-table/onetomany/java/${bussiPackage}/${entityPackage}/controller/${entityName}Controller.javai | 3 ++- jeecg-boot/jeecg-boot-module-system/src/main/resources/jeecg/code-template-online/inner-table/onetomany/java/${bussiPackage}/${entityPackage}/entity/${entityName}.javai | 2 +- jeecg-boot/jeecg-boot-module-system/src/main/resources/jeecg/code-template-online/inner-table/onetomany/java/${bussiPackage}/${entityPackage}/entity/[1-n]Entity.javai | 2 +- jeecg-boot/jeecg-boot-module-system/src/main/resources/jeecg/code-template-online/inner-table/onetomany/java/${bussiPackage}/${entityPackage}/mapper/[1-n]Mapper.javai | 14 +++++++++++++- jeecg-boot/jeecg-boot-module-system/src/main/resources/jeecg/code-template-online/inner-table/onetomany/java/${bussiPackage}/${entityPackage}/service/I${entityName}Service.javai | 16 ++++++++++++++-- jeecg-boot/jeecg-boot-module-system/src/main/resources/jeecg/code-template-online/inner-table/onetomany/java/${bussiPackage}/${entityPackage}/service/[1-n]Service.javai | 6 ++++++ jeecg-boot/jeecg-boot-module-system/src/main/resources/jeecg/code-template-online/inner-table/onetomany/java/${bussiPackage}/${entityPackage}/vo/${entityName}Page.javai | 2 +- jeecg-boot/jeecg-boot-module-system/src/main/resources/jeecg/code-template-online/inner-table/onetomany/java/${bussiPackage}/${entityPackage}/vue3/components/${entityName}Modal.vuei | 7 ++++--- jeecg-boot/jeecg-boot-module-system/src/main/resources/jeecg/code-template-online/jvxe/onetomany/java/${bussiPackage}/${entityPackage}/controller/${entityName}Controller.javai | 3 ++- jeecg-boot/jeecg-boot-module-system/src/main/resources/jeecg/code-template-online/jvxe/onetomany/java/${bussiPackage}/${entityPackage}/entity/${entityName}.javai | 2 +- jeecg-boot/jeecg-boot-module-system/src/main/resources/jeecg/code-template-online/jvxe/onetomany/java/${bussiPackage}/${entityPackage}/entity/[1-n]Entity.javai | 2 +- jeecg-boot/jeecg-boot-module-system/src/main/resources/jeecg/code-template-online/jvxe/onetomany/java/${bussiPackage}/${entityPackage}/mapper/[1-n]Mapper.javai | 14 +++++++++++++- jeecg-boot/jeecg-boot-module-system/src/main/resources/jeecg/code-template-online/jvxe/onetomany/java/${bussiPackage}/${entityPackage}/service/I${entityName}Service.javai | 16 ++++++++++++++-- jeecg-boot/jeecg-boot-module-system/src/main/resources/jeecg/code-template-online/jvxe/onetomany/java/${bussiPackage}/${entityPackage}/service/[1-n]Service.javai | 6 ++++++ jeecg-boot/jeecg-boot-module-system/src/main/resources/jeecg/code-template-online/jvxe/onetomany/java/${bussiPackage}/${entityPackage}/vo/${entityName}Page.javai | 2 +- jeecg-boot/jeecg-boot-module-system/src/main/resources/jeecg/code-template-online/jvxe/onetomany/java/${bussiPackage}/${entityPackage}/vue3/components/${entityName}Modal.vuei | 7 ++++--- jeecg-boot/jeecg-boot-module-system/src/main/resources/jeecg/code-template-online/tab/onetomany/java/${bussiPackage}/${entityPackage}/controller/${entityName}Controller.javai | 3 ++- jeecg-boot/jeecg-boot-module-system/src/main/resources/jeecg/code-template-online/tab/onetomany/java/${bussiPackage}/${entityPackage}/entity/${entityName}.javai | 2 +- jeecg-boot/jeecg-boot-module-system/src/main/resources/jeecg/code-template-online/tab/onetomany/java/${bussiPackage}/${entityPackage}/entity/[1-n]Entity.javai | 2 +- jeecg-boot/jeecg-boot-module-system/src/main/resources/jeecg/code-template-online/tab/onetomany/java/${bussiPackage}/${entityPackage}/mapper/[1-n]Mapper.javai | 14 +++++++++++++- jeecg-boot/jeecg-boot-module-system/src/main/resources/jeecg/code-template-online/tab/onetomany/java/${bussiPackage}/${entityPackage}/service/I${entityName}Service.javai | 16 ++++++++++++++-- jeecg-boot/jeecg-boot-module-system/src/main/resources/jeecg/code-template-online/tab/onetomany/java/${bussiPackage}/${entityPackage}/service/[1-n]Service.javai | 6 ++++++ jeecg-boot/jeecg-boot-module-system/src/main/resources/jeecg/code-template-online/tab/onetomany/java/${bussiPackage}/${entityPackage}/vo/${entityName}Page.javai | 2 +- jeecg-boot/jeecg-boot-module-system/src/main/resources/jeecg/code-template-online/tab/onetomany/java/${bussiPackage}/${entityPackage}/vue3/components/${entityName}Modal.vuei | 7 ++++--- jeecg-boot/jeecg-boot-module-system/src/main/resources/jeecg/code-template/onetomany/java/${bussiPackage}/${entityPackage}/vue3/modules/${entityName}Modal.vuei | 5 +++-- 46 files changed, 391 insertions(+), 81 deletions(-) diff --git a/jeecg-boot/jeecg-boot-module-system/src/main/resources/jeecg/code-template-online/default/one/java/${bussiPackage}/${entityPackage}/entity/${entityName}.javai b/jeecg-boot/jeecg-boot-module-system/src/main/resources/jeecg/code-template-online/default/one/java/${bussiPackage}/${entityPackage}/entity/${entityName}.javai index 41ac3aa..024fa25 100644 --- a/jeecg-boot/jeecg-boot-module-system/src/main/resources/jeecg/code-template-online/default/one/java/${bussiPackage}/${entityPackage}/entity/${entityName}.javai +++ b/jeecg-boot/jeecg-boot-module-system/src/main/resources/jeecg/code-template-online/default/one/java/${bussiPackage}/${entityPackage}/entity/${entityName}.javai @@ -52,7 +52,7 @@ public class ${entityName} implements Serializable { <#if po.fieldName == primaryKeyField> @TableId(type = IdType.ASSIGN_ID) <#else> - <#if po.fieldDbType =='Date'> + <#if po.fieldDbType =='Date' || po.fieldDbType =='Datetime'> <#if po.classType=='date'> <#if !excel_ignore_arr?seq_contains("${po.fieldName}")> @Excel(name = "${po.filedComment}", width = 15, format = "yyyy-MM-dd") diff --git a/jeecg-boot/jeecg-boot-module-system/src/main/resources/jeecg/code-template-online/default/onetomany/java/${bussiPackage}/${entityPackage}/entity/${entityName}.javai b/jeecg-boot/jeecg-boot-module-system/src/main/resources/jeecg/code-template-online/default/onetomany/java/${bussiPackage}/${entityPackage}/entity/${entityName}.javai index 3c329cb..2c9aba3 100644 --- a/jeecg-boot/jeecg-boot-module-system/src/main/resources/jeecg/code-template-online/default/onetomany/java/${bussiPackage}/${entityPackage}/entity/${entityName}.javai +++ b/jeecg-boot/jeecg-boot-module-system/src/main/resources/jeecg/code-template-online/default/onetomany/java/${bussiPackage}/${entityPackage}/entity/${entityName}.javai @@ -47,7 +47,7 @@ public class ${entityName} implements Serializable { <#if po.fieldName == primaryKeyField> @TableId(type = IdType.ASSIGN_ID) <#else> - <#if po.fieldDbType =='Date'> + <#if po.fieldDbType =='Date' || po.fieldDbType =='Datetime'> <#if po.classType=='date'> <#if !excel_ignore_arr?seq_contains("${po.fieldName}")> @Excel(name = "${po.filedComment}", width = 15, format = "yyyy-MM-dd") diff --git a/jeecg-boot/jeecg-boot-module-system/src/main/resources/jeecg/code-template-online/default/onetomany/java/${bussiPackage}/${entityPackage}/entity/[1-n]Entity.javai b/jeecg-boot/jeecg-boot-module-system/src/main/resources/jeecg/code-template-online/default/onetomany/java/${bussiPackage}/${entityPackage}/entity/[1-n]Entity.javai index ba02b61..cfc7129 100644 --- a/jeecg-boot/jeecg-boot-module-system/src/main/resources/jeecg/code-template-online/default/onetomany/java/${bussiPackage}/${entityPackage}/entity/[1-n]Entity.javai +++ b/jeecg-boot/jeecg-boot-module-system/src/main/resources/jeecg/code-template-online/default/onetomany/java/${bussiPackage}/${entityPackage}/entity/[1-n]Entity.javai @@ -48,7 +48,7 @@ public class ${subTab.entityName} implements Serializable { <#if po.fieldName == primaryKeyField> @TableId(type = IdType.ASSIGN_ID) <#else> - <#if po.fieldDbType =='Date'> + <#if po.fieldDbType =='Date' || po.fieldDbType =='Datetime'> <#if po.classType=='date'> <#if !excel_ignore_arr?seq_contains("${po.fieldName}")> @Excel(name = "${po.filedComment}", width = 15, format = "yyyy-MM-dd") diff --git a/jeecg-boot/jeecg-boot-module-system/src/main/resources/jeecg/code-template-online/default/onetomany/java/${bussiPackage}/${entityPackage}/vo/${entityName}Page.javai b/jeecg-boot/jeecg-boot-module-system/src/main/resources/jeecg/code-template-online/default/onetomany/java/${bussiPackage}/${entityPackage}/vo/${entityName}Page.javai index c080ca1..c10a67f 100644 --- a/jeecg-boot/jeecg-boot-module-system/src/main/resources/jeecg/code-template-online/default/onetomany/java/${bussiPackage}/${entityPackage}/vo/${entityName}Page.javai +++ b/jeecg-boot/jeecg-boot-module-system/src/main/resources/jeecg/code-template-online/default/onetomany/java/${bussiPackage}/${entityPackage}/vo/${entityName}Page.javai @@ -44,7 +44,7 @@ public class ${entityName}Page { /**${po.filedComment}*/ <#if po.fieldName == primaryKeyField> <#else> - <#if po.fieldDbType =='Date'> + <#if po.fieldDbType =='Date' || po.fieldDbType =='Datetime'> <#if po.classType=='date'> <#if !excel_ignore_arr?seq_contains("${po.fieldName}")> @Excel(name = "${po.filedComment}", width = 15, format = "yyyy-MM-dd") diff --git a/jeecg-boot/jeecg-boot-module-system/src/main/resources/jeecg/code-template-online/default/tree/java/${bussiPackage}/${entityPackage}/controller/${entityName}Controller.javai b/jeecg-boot/jeecg-boot-module-system/src/main/resources/jeecg/code-template-online/default/tree/java/${bussiPackage}/${entityPackage}/controller/${entityName}Controller.javai index b86d19f..ee6640a 100644 --- a/jeecg-boot/jeecg-boot-module-system/src/main/resources/jeecg/code-template-online/default/tree/java/${bussiPackage}/${entityPackage}/controller/${entityName}Controller.javai +++ b/jeecg-boot/jeecg-boot-module-system/src/main/resources/jeecg/code-template-online/default/tree/java/${bussiPackage}/${entityPackage}/controller/${entityName}Controller.javai @@ -12,6 +12,7 @@ import javax.servlet.http.HttpServletResponse; import org.jeecg.common.api.vo.Result; import org.jeecg.common.system.query.QueryGenerator; import org.jeecg.common.util.oConvertUtils; +import org.jeecg.common.system.vo.SelectTreeModel; import ${bussiPackage}.${entityPackage}.entity.${entityName}; import ${bussiPackage}.${entityPackage}.service.I${entityName}Service; @@ -55,7 +56,7 @@ import org.jeecg.common.aspect.annotation.AutoLog; public class ${entityName}Controller extends JeecgController<${entityName}, I${entityName}Service>{ @Autowired private I${entityName}Service ${entityName?uncap_first}Service; - + /** * 分页列表查询 * @@ -95,6 +96,67 @@ public class ${entityName}Controller extends JeecgController<${entityName}, I${e } /** + * 【vue3专用】加载节点的子数据 + * + * @param pid + * @return + */ + @RequestMapping(value = "/loadTreeChildren", method = RequestMethod.GET) + public Result<List<SelectTreeModel>> loadTreeChildren(@RequestParam(name = "pid") String pid) { + Result<List<SelectTreeModel>> result = new Result<>(); + try { + List<SelectTreeModel> ls = ${entityName?uncap_first}Service.queryListByPid(pid); + result.setResult(ls); + result.setSuccess(true); + } catch (Exception e) { + e.printStackTrace(); + result.setMessage(e.getMessage()); + result.setSuccess(false); + } + return result; + } + + /** + * 【vue3专用】加载一级节点/如果是同步 则所有数据 + * + * @param async + * @param pcode + * @return + */ + @RequestMapping(value = "/loadTreeRoot", method = RequestMethod.GET) + public Result<List<SelectTreeModel>> loadTreeRoot(@RequestParam(name = "async") Boolean async, @RequestParam(name = "pcode") String pcode) { + Result<List<SelectTreeModel>> result = new Result<>(); + try { + List<SelectTreeModel> ls = ${entityName?uncap_first}Service.queryListByCode(pcode); + if (!async) { + loadAllChildren(ls); + } + result.setResult(ls); + result.setSuccess(true); + } catch (Exception e) { + e.printStackTrace(); + result.setMessage(e.getMessage()); + result.setSuccess(false); + } + return result; + } + + /** + * 【vue3专用】递归求子节点 同步加载用到 + * + * @param ls + */ + private void loadAllChildren(List<SelectTreeModel> ls) { + for (SelectTreeModel tsm : ls) { + List<SelectTreeModel> temp = ${entityName?uncap_first}Service.queryListByPid(tsm.getKey()); + if (temp != null && temp.size() > 0) { + tsm.setChildren(temp); + loadAllChildren(temp); + } + } + } + + /** * 获取子数据 * @param ${entityName?uncap_first} * @param req diff --git a/jeecg-boot/jeecg-boot-module-system/src/main/resources/jeecg/code-template-online/default/tree/java/${bussiPackage}/${entityPackage}/entity/${entityName}.javai b/jeecg-boot/jeecg-boot-module-system/src/main/resources/jeecg/code-template-online/default/tree/java/${bussiPackage}/${entityPackage}/entity/${entityName}.javai index 3da8891..dfcd1b3 100644 --- a/jeecg-boot/jeecg-boot-module-system/src/main/resources/jeecg/code-template-online/default/tree/java/${bussiPackage}/${entityPackage}/entity/${entityName}.javai +++ b/jeecg-boot/jeecg-boot-module-system/src/main/resources/jeecg/code-template-online/default/tree/java/${bussiPackage}/${entityPackage}/entity/${entityName}.javai @@ -48,7 +48,7 @@ public class ${entityName} implements Serializable { <#if po.fieldName == primaryKeyField> @TableId(type = IdType.ASSIGN_ID) <#else> - <#if po.fieldDbType =='Date'> + <#if po.fieldDbType =='Date' || po.fieldDbType =='Datetime'> <#if po.classType=='date'> <#if !excel_ignore_arr?seq_contains("${po.fieldName}")> @Excel(name = "${po.filedComment}", width = 15, format = "yyyy-MM-dd") diff --git a/jeecg-boot/jeecg-boot-module-system/src/main/resources/jeecg/code-template-online/default/tree/java/${bussiPackage}/${entityPackage}/mapper/${entityName}Mapper.javai b/jeecg-boot/jeecg-boot-module-system/src/main/resources/jeecg/code-template-online/default/tree/java/${bussiPackage}/${entityPackage}/mapper/${entityName}Mapper.javai index 24a7f3e..d894ff1 100644 --- a/jeecg-boot/jeecg-boot-module-system/src/main/resources/jeecg/code-template-online/default/tree/java/${bussiPackage}/${entityPackage}/mapper/${entityName}Mapper.javai +++ b/jeecg-boot/jeecg-boot-module-system/src/main/resources/jeecg/code-template-online/default/tree/java/${bussiPackage}/${entityPackage}/mapper/${entityName}Mapper.javai @@ -1,8 +1,12 @@ package ${bussiPackage}.${entityPackage}.mapper; +import com.baomidou.mybatisplus.core.mapper.BaseMapper; import org.apache.ibatis.annotations.Param; +import org.jeecg.common.system.vo.SelectTreeModel; import ${bussiPackage}.${entityPackage}.entity.${entityName}; -import com.baomidou.mybatisplus.core.mapper.BaseMapper; + +import java.util.List; +import java.util.Map; /** * @Description: ${tableVo.ftlDescription} @@ -19,4 +23,13 @@ public interface ${entityName}Mapper extends BaseMapper<${entityName}> { */ void updateTreeNodeStatus(@Param("id") String id,@Param("status") String status); + /** + * 【vue3专用】根据父级ID查询树节点数据 + * + * @param pid + * @param query + * @return + */ + List<SelectTreeModel> queryListByPid(@Param("pid") String pid, @Param("query") Map<String, String> query); + } diff --git a/jeecg-boot/jeecg-boot-module-system/src/main/resources/jeecg/code-template-online/default/tree/java/${bussiPackage}/${entityPackage}/mapper/xml/${entityName}Mapper.xml b/jeecg-boot/jeecg-boot-module-system/src/main/resources/jeecg/code-template-online/default/tree/java/${bussiPackage}/${entityPackage}/mapper/xml/${entityName}Mapper.xml index 273c582..f224e0b 100644 --- a/jeecg-boot/jeecg-boot-module-system/src/main/resources/jeecg/code-template-online/default/tree/java/${bussiPackage}/${entityPackage}/mapper/xml/${entityName}Mapper.xml +++ b/jeecg-boot/jeecg-boot-module-system/src/main/resources/jeecg/code-template-online/default/tree/java/${bussiPackage}/${entityPackage}/mapper/xml/${entityName}Mapper.xml @@ -1,8 +1,18 @@ <#assign hasChildrenField = ""> +<#assign pidFieldName = ""> +<#assign textFieldName = ""> <#list originalColumns as po> -<#if po.fieldDbName == tableVo.extendParams.hasChildren> -<#assign hasChildrenField = po.fieldName> -</#if> + <#if po.fieldDbName == tableVo.extendParams.hasChildren> + <#assign hasChildrenField = po.fieldName> + </#if> + <#-- begin 【vue3专用】 --> + <#if po.fieldDbName == tableVo.extendParams.pidField> + <#assign pidFieldName = po.fieldName> + </#if> + <#if po.fieldDbName == tableVo.extendParams.textField> + <#assign textFieldName = po.fieldName> + </#if> + <#-- end 【vue3专用】 --> </#list> <?xml version="1.0" encoding="UTF-8"?> <!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd"> @@ -12,4 +22,20 @@ update ${tableName} set ${Format.humpToUnderline(hasChildrenField)} = ${r'#'}{status} where id = ${r'#'}{id} </update> + <!-- 【vue3专用】 --> + <select id="queryListByPid" parameterType="java.lang.Object" resultType="org.jeecg.common.system.vo.SelectTreeModel"> + select + id as "key", + ${textFieldName} as "title", + (case when ${Format.humpToUnderline(hasChildrenField)} = '1' then 0 else 1 end) as isLeaf, + ${pidFieldName} as parentId + from ${tableName} + where ${pidFieldName} = ${r'#'}{pid} + <if test="query != null"> + <foreach collection="query.entrySet()" item="value" index="key"> + and ${r'$'}{key} = ${r'#'}{value} + </foreach> + </if> + </select> + </mapper> \ No newline at end of file diff --git a/jeecg-boot/jeecg-boot-module-system/src/main/resources/jeecg/code-template-online/default/tree/java/${bussiPackage}/${entityPackage}/service/I${entityName}Service.javai b/jeecg-boot/jeecg-boot-module-system/src/main/resources/jeecg/code-template-online/default/tree/java/${bussiPackage}/${entityPackage}/service/I${entityName}Service.javai index 28490d4..701da1a 100644 --- a/jeecg-boot/jeecg-boot-module-system/src/main/resources/jeecg/code-template-online/default/tree/java/${bussiPackage}/${entityPackage}/service/I${entityName}Service.javai +++ b/jeecg-boot/jeecg-boot-module-system/src/main/resources/jeecg/code-template-online/default/tree/java/${bussiPackage}/${entityPackage}/service/I${entityName}Service.javai @@ -1,5 +1,6 @@ package ${bussiPackage}.${entityPackage}.service; +import org.jeecg.common.system.vo.SelectTreeModel; import ${bussiPackage}.${entityPackage}.entity.${entityName}; import com.baomidou.mybatisplus.extension.service.IService; import org.jeecg.common.exception.JeecgBootException; @@ -23,16 +24,51 @@ public interface I${entityName}Service extends IService<${entityName}> { /**树节点无子节点状态值*/ public static final String NOCHILD = "0"; - /**新增节点*/ + /** + * 新增节点 + * + * @param ${entityName?uncap_first} + */ void add${entityName}(${entityName} ${entityName?uncap_first}); - /**修改节点*/ + /** + * 修改节点 + * + * @param ${entityName?uncap_first} + * @throws JeecgBootException + */ void update${entityName}(${entityName} ${entityName?uncap_first}) throws JeecgBootException; - /**删除节点*/ + /** + * 删除节点 + * + * @param id + * @throws JeecgBootException + */ void delete${entityName}(String id) throws JeecgBootException; - /**查询所有数据,无分页*/ + /** + * 查询所有数据,无分页 + * + * @param queryWrapper + * @return List<${entityName}> + */ List<${entityName}> queryTreeListNoPage(QueryWrapper<${entityName}> queryWrapper); + /** + * 【vue3专用】根据父级编码加载分类字典的数据 + * + * @param parentCode + * @return + */ + List<SelectTreeModel> queryListByCode(String parentCode); + + /** + * 【vue3专用】根据pid查询子节点集合 + * + * @param pid + * @return + */ + List<SelectTreeModel> queryListByPid(String pid); + } diff --git a/jeecg-boot/jeecg-boot-module-system/src/main/resources/jeecg/code-template-online/default/tree/java/${bussiPackage}/${entityPackage}/service/impl/${entityName}ServiceImpl.javai b/jeecg-boot/jeecg-boot-module-system/src/main/resources/jeecg/code-template-online/default/tree/java/${bussiPackage}/${entityPackage}/service/impl/${entityName}ServiceImpl.javai index 9dd2f01..33ef42f 100644 --- a/jeecg-boot/jeecg-boot-module-system/src/main/resources/jeecg/code-template-online/default/tree/java/${bussiPackage}/${entityPackage}/service/impl/${entityName}ServiceImpl.javai +++ b/jeecg-boot/jeecg-boot-module-system/src/main/resources/jeecg/code-template-online/default/tree/java/${bussiPackage}/${entityPackage}/service/impl/${entityName}ServiceImpl.javai @@ -1,7 +1,9 @@ package ${bussiPackage}.${entityPackage}.service.impl; +import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; import org.jeecg.common.exception.JeecgBootException; import org.jeecg.common.util.oConvertUtils; +import org.jeecg.common.system.vo.SelectTreeModel; import ${bussiPackage}.${entityPackage}.entity.${entityName}; import ${bussiPackage}.${entityPackage}.mapper.${entityName}Mapper; import ${bussiPackage}.${entityPackage}.service.I${entityName}Service; @@ -84,8 +86,8 @@ public class ${entityName}ServiceImpl extends ServiceImpl<${entityName}Mapper, $ String pidVal = ${entityName?uncap_first}.get${pidFieldName?cap_first}(); //查询此节点上一级是否还有其他子节点 List<${entityName}> dataList = baseMapper.selectList(new QueryWrapper<${entityName}>().eq("${tableVo.extendParams.pidField}", pidVal).notIn("id",Arrays.asList(idArr))); - if((dataList == null || dataList.size()==0) && !Arrays.asList(idArr).contains(pidVal) - && !sb.toString().contains(pidVal)){ + boolean flag = (dataList == null || dataList.size() == 0) && !Arrays.asList(idArr).contains(pidVal) && !sb.toString().contains(pidVal); + if(flag){ //如果当前节点原本有子节点 现在木有了,更新状态 sb.append(pidVal).append(","); } @@ -115,7 +117,7 @@ public class ${entityName}ServiceImpl extends ServiceImpl<${entityName}Mapper, $ for(${entityName} data : dataList){ String pidVal = data.get${pidFieldName?cap_first}(); //递归查询子节点的根节点 - if(pidVal != null && !"0".equals(pidVal)){ + if(pidVal != null && !I${entityName}Service.NOCHILD.equals(pidVal)){ ${entityName} rootVal = this.getTreeRoot(pidVal); if(rootVal != null && !mapList.contains(rootVal)){ mapList.add(rootVal); @@ -128,7 +130,33 @@ public class ${entityName}ServiceImpl extends ServiceImpl<${entityName}Mapper, $ } return mapList; } - + + @Override + public List<SelectTreeModel> queryListByCode(String parentCode) { + String pid = ROOT_PID_VALUE; + if (oConvertUtils.isNotEmpty(parentCode)) { + LambdaQueryWrapper<${entityName}> queryWrapper = new LambdaQueryWrapper<>(); + queryWrapper.eq(${entityName}::get${pidFieldName?cap_first}, parentCode); + List<${entityName}> list = baseMapper.selectList(queryWrapper); + if (list == null || list.size() == 0) { + throw new JeecgBootException("该编码【" + parentCode + "】不存在,请核实!"); + } + if (list.size() > 1) { + throw new JeecgBootException("该编码【" + parentCode + "】存在多个,请核实!"); + } + pid = list.get(0).getId(); + } + return baseMapper.queryListByPid(pid, null); + } + + @Override + public List<SelectTreeModel> queryListByPid(String pid) { + if (oConvertUtils.isEmpty(pid)) { + pid = ROOT_PID_VALUE; + } + return baseMapper.queryListByPid(pid, null); + } + /** * 根据所传pid查询旧的父级节点的子节点并修改相应状态值 * @param pid @@ -149,7 +177,7 @@ public class ${entityName}ServiceImpl extends ServiceImpl<${entityName}Mapper, $ */ private ${entityName} getTreeRoot(String pidVal){ ${entityName} data = baseMapper.selectById(pidVal); - if(data != null && !"0".equals(data.get${pidFieldName?cap_first}())){ + if(data != null && !I${entityName}Service.ROOT_PID_VALUE.equals(data.get${pidFieldName?cap_first}())){ return this.getTreeRoot(data.get${pidFieldName?cap_first}()); }else{ return data; diff --git a/jeecg-boot/jeecg-boot-module-system/src/main/resources/jeecg/code-template-online/default/tree/java/${bussiPackage}/${entityPackage}/vue3/${entityName}List.vuei b/jeecg-boot/jeecg-boot-module-system/src/main/resources/jeecg/code-template-online/default/tree/java/${bussiPackage}/${entityPackage}/vue3/${entityName}List.vuei index f1bbd7a..7b1c422 100644 --- a/jeecg-boot/jeecg-boot-module-system/src/main/resources/jeecg/code-template-online/default/tree/java/${bussiPackage}/${entityPackage}/vue3/${entityName}List.vuei +++ b/jeecg-boot/jeecg-boot-module-system/src/main/resources/jeecg/code-template-online/default/tree/java/${bussiPackage}/${entityPackage}/vue3/${entityName}List.vuei @@ -1,3 +1,13 @@ +<#assign pidFieldName = ""> +<#assign hasChildrenField = ""> +<#list originalColumns as po> + <#if po.fieldDbName == tableVo.extendParams.pidField> + <#assign pidFieldName = po.fieldName> + </#if> + <#if po.fieldDbName == tableVo.extendParams.hasChildren> + <#assign hasChildrenField = po.fieldName> + </#if> +</#list> <template> <div class="p-4"> <!--引用表格--> @@ -35,8 +45,8 @@ <script lang="ts" name="${entityPackage}-${entityName?uncap_first}" setup> //ts语法 import {ref, computed, unref, toRaw, nextTick} from 'vue'; - import {BasicTable, useTable, TableAction} from '/src/components/Table'; - import {useModal} from '/src/components/Modal'; + import {BasicTable, TableAction} from '/@/components/Table'; + import {useModal} from '/@/components/Modal'; import { useListPage } from '/@/hooks/system/useListPage' import ${entityName}Modal from './components/${entityName}Modal.vue'; import {columns} from './${entityName}.data'; @@ -48,12 +58,13 @@ //注册table数据 const { prefixCls,tableContext,onExportXls,onImportXls } = useListPage({ tableProps:{ + api: list, title: '${tableVo.ftlDescription}', columns, canResize:false, actionColumn: { - width: 120, - }, + width: 240, + }, }, exportConfig: { name:"${tableVo.ftlDescription}", @@ -134,7 +145,7 @@ //编辑回调 updateTableDataRecord(values.id, values); } else { - if(!values['pid']){ + if(!values['${pidFieldName}']){ //新增根节点 reload(); }else{ @@ -164,7 +175,7 @@ let records = res.result.records const listMap = new Map(); for (let item of records) { - let pid = item['pid']; + let pid = item['${pidFieldName}']; if (unref(expandedRowKeys).includes(pid)) { let mapList = listMap.get(pid); if (mapList == null) { @@ -212,7 +223,7 @@ if (expanded) { expandedRowKeys.value.push(record.id) if (record.children.length > 0 && !!record.children[0].isLoading) { - let result = await getChildList({pid: record.id}); + let result = await getChildList({${pidFieldName}: record.id}); result=result.records?result.records:result; if (result && result.length > 0) { record.children = getDataByResult(result); @@ -234,7 +245,7 @@ async function expandTreeNode(key) { let record = findTableDataRecord(key) expandedRowKeys.value.push(key); - let result = await getChildList({pid: key}); + let result = await getChildList({${pidFieldName}: key}); if (result && result.length > 0) { record.children = getDataByResult(result); } else { @@ -261,7 +272,7 @@ }, { label: '添加下级', - onClick: handleAddSub.bind(null, {pid: record.id}), + onClick: handleAddSub.bind(null, {${pidFieldName}: record.id}), } ] } diff --git a/jeecg-boot/jeecg-boot-module-system/src/main/resources/jeecg/code-template-online/default/tree/java/${bussiPackage}/${entityPackage}/vue3/${entityName}__api.tsi b/jeecg-boot/jeecg-boot-module-system/src/main/resources/jeecg/code-template-online/default/tree/java/${bussiPackage}/${entityPackage}/vue3/${entityName}__api.tsi index df69b12..2cbeee0 100644 --- a/jeecg-boot/jeecg-boot-module-system/src/main/resources/jeecg/code-template-online/default/tree/java/${bussiPackage}/${entityPackage}/vue3/${entityName}__api.tsi +++ b/jeecg-boot/jeecg-boot-module-system/src/main/resources/jeecg/code-template-online/default/tree/java/${bussiPackage}/${entityPackage}/vue3/${entityName}__api.tsi @@ -5,7 +5,7 @@ enum Api { list = '/${entityPackage}/${entityName?uncap_first}/rootList', save='/${entityPackage}/${entityName?uncap_first}/add', edit='/${entityPackage}/${entityName?uncap_first}/edit', - delete${entityName} = '/sys/${entityName?uncap_first}/delete', + delete${entityName} = '/${entityPackage}/${entityName?uncap_first}/delete', deleteBatch = '/${entityPackage}/${entityName?uncap_first}/deleteBatch', importExcel = '/${entityPackage}/${entityName?uncap_first}/importExcel', exportXls = '/${entityPackage}/${entityName?uncap_first}/exportXls', @@ -13,6 +13,7 @@ enum Api { getChildList = '/${entityPackage}/${entityName?uncap_first}/childList', getChildListBatch = '/${entityPackage}/${entityName?uncap_first}/getChildListBatch', } + /** * 导出api * @param params diff --git a/jeecg-boot/jeecg-boot-module-system/src/main/resources/jeecg/code-template-online/default/tree/java/${bussiPackage}/${entityPackage}/vue3/${entityName}__data.tsi b/jeecg-boot/jeecg-boot-module-system/src/main/resources/jeecg/code-template-online/default/tree/java/${bussiPackage}/${entityPackage}/vue3/${entityName}__data.tsi index b9dac14..4baa604 100644 --- a/jeecg-boot/jeecg-boot-module-system/src/main/resources/jeecg/code-template-online/default/tree/java/${bussiPackage}/${entityPackage}/vue3/${entityName}__data.tsi +++ b/jeecg-boot/jeecg-boot-module-system/src/main/resources/jeecg/code-template-online/default/tree/java/${bussiPackage}/${entityPackage}/vue3/${entityName}__data.tsi @@ -8,7 +8,11 @@ export const columns: BasicColumn[] = [ <#if po.isShowList =='Y' && po.fieldName !='id'> { title: '${po.filedComment}', - align:"center", + <#if po.fieldDbName == tableVo.extendParams.textField> + align: 'left', + <#else> + align: 'center', + </#if> <#if po.sort=='Y'> sorter: true, </#if> @@ -277,13 +281,15 @@ export const formSchema: FormSchema[] = [ component: 'JTreeSelect', componentProps:{ <#if po.dictText??> - <#if po.dictText?split(',')[2]?? && po.dictText?split(',')[0]??> + <#if po.dictText?split(',')[2]?? && po.dictText?split(',')[0]??> dict:"${po.dictTable},${po.dictText?split(',')[2]},${po.dictText?split(',')[0]}", - <#elseif po.dictText?split(',')[1]??> + </#if> + <#if po.dictText?split(',')[1]??> pidField:"${po.dictText?split(',')[1]}", - <#elseif po.dictText?split(',')[3]??> + </#if> + <#if po.dictText?split(',')[3]??> hasChildField:"${po.dictText?split(',')[3]}", - </#if> + </#if> </#if> pidValue:"${po.dictField}", }, diff --git a/jeecg-boot/jeecg-boot-module-system/src/main/resources/jeecg/code-template-online/default/tree/java/${bussiPackage}/${entityPackage}/vue3/components/${entityName}Modal.vuei b/jeecg-boot/jeecg-boot-module-system/src/main/resources/jeecg/code-template-online/default/tree/java/${bussiPackage}/${entityPackage}/vue3/components/${entityName}Modal.vuei index 81e90c4..a4294d7 100644 --- a/jeecg-boot/jeecg-boot-module-system/src/main/resources/jeecg/code-template-online/default/tree/java/${bussiPackage}/${entityPackage}/vue3/components/${entityName}Modal.vuei +++ b/jeecg-boot/jeecg-boot-module-system/src/main/resources/jeecg/code-template-online/default/tree/java/${bussiPackage}/${entityPackage}/vue3/components/${entityName}Modal.vuei @@ -1,3 +1,13 @@ +<#assign pidFieldName = ""> +<#assign hasChildrenField = ""> +<#list originalColumns as po> + <#if po.fieldDbName == tableVo.extendParams.pidField> + <#assign pidFieldName = po.fieldName> + </#if> + <#if po.fieldDbName == tableVo.extendParams.hasChildren> + <#assign hasChildrenField = po.fieldName> + </#if> +</#list> <template> <BasicModal v-bind="$attrs" @register="registerModal" :title="getTitle" @ok="handleSubmit"> <BasicForm @register="registerForm"/> @@ -5,8 +15,8 @@ </template> <script lang="ts" setup> import {ref, computed, unref} from 'vue'; - import {BasicModal, useModalInner} from '/src/components/Modal'; - import {BasicForm, useForm} from '/src/components/Form'; + import {BasicModal, useModalInner} from '/@/components/Modal'; + import {BasicForm, useForm} from '/@/components/Form'; import {formSchema} from '../${entityName}.data'; import {loadTreeData, saveOrUpdateDict} from '../${entityName}.api'; // 获取emit @@ -42,13 +52,9 @@ } //父级节点树信息 treeData.value = await loadTreeData({'async': false,'pcode':''}); - updateSchema({ - field: 'pid', - componentProps: {treeData}, - }); }); //设置标题 - const getTitle = computed(() => (!unref(isUpdate) ? '新增字典' : '编辑字典')); + const getTitle = computed(() => (!unref(isUpdate) ? '新增' : '编辑')); /** * 根据pid获取展开的节点 @@ -77,7 +83,7 @@ //关闭弹窗 closeModal(); //展开的节点信息 - await getExpandKeysByPid(values['pid'],unref(treeData)) + await getExpandKeysByPid(values['${pidFieldName}'],unref(treeData)) //刷新列表(isUpdate:是否编辑;values:表单信息;expandedArr:展开的节点信息) emit('success', {isUpdate: unref(isUpdate), values:{...values},expandedArr: unref(expandedRowKeys).reverse()}); } finally { diff --git a/jeecg-boot/jeecg-boot-module-system/src/main/resources/jeecg/code-template-online/erp/onetomany/java/${bussiPackage}/${entityPackage}/controller/${entityName}Controller.javai b/jeecg-boot/jeecg-boot-module-system/src/main/resources/jeecg/code-template-online/erp/onetomany/java/${bussiPackage}/${entityPackage}/controller/${entityName}Controller.javai index 929d14d..c4a0c2c 100644 --- a/jeecg-boot/jeecg-boot-module-system/src/main/resources/jeecg/code-template-online/erp/onetomany/java/${bussiPackage}/${entityPackage}/controller/${entityName}Controller.javai +++ b/jeecg-boot/jeecg-boot-module-system/src/main/resources/jeecg/code-template-online/erp/onetomany/java/${bussiPackage}/${entityPackage}/controller/${entityName}Controller.javai @@ -251,7 +251,8 @@ public class ${entityName}Controller extends JeecgController<${entityName}, I${e // Step.3 AutoPoi 导出Excel ModelAndView mv = new ModelAndView(new JeecgEntityExcelView()); - mv.addObject(NormalExcelConstants.FILE_NAME, "${sub.ftlDescription}"); //此处设置的filename无效 ,前端会重更新设置一下 + //此处设置的filename无效,前端会重更新设置一下 + mv.addObject(NormalExcelConstants.FILE_NAME, "${sub.ftlDescription}"); mv.addObject(NormalExcelConstants.CLASS, ${sub.entityName}.class); mv.addObject(NormalExcelConstants.PARAMS, new ExportParams("${sub.ftlDescription}报表", "导出人:" + sysUser.getRealname(), "${sub.ftlDescription}")); mv.addObject(NormalExcelConstants.DATA_LIST, exportList); @@ -267,7 +268,8 @@ public class ${entityName}Controller extends JeecgController<${entityName}, I${e MultipartHttpServletRequest multipartRequest = (MultipartHttpServletRequest) request; Map<String, MultipartFile> fileMap = multipartRequest.getFileMap(); for (Map.Entry<String, MultipartFile> entity : fileMap.entrySet()) { - MultipartFile file = entity.getValue();// 获取上传文件对象 + // 获取上传文件对象 + MultipartFile file = entity.getValue(); ImportParams params = new ImportParams(); params.setTitleRows(2); params.setHeadRows(1); diff --git a/jeecg-boot/jeecg-boot-module-system/src/main/resources/jeecg/code-template-online/erp/onetomany/java/${bussiPackage}/${entityPackage}/entity/${entityName}.javai b/jeecg-boot/jeecg-boot-module-system/src/main/resources/jeecg/code-template-online/erp/onetomany/java/${bussiPackage}/${entityPackage}/entity/${entityName}.javai index f04f4c1..7bf649a 100644 --- a/jeecg-boot/jeecg-boot-module-system/src/main/resources/jeecg/code-template-online/erp/onetomany/java/${bussiPackage}/${entityPackage}/entity/${entityName}.javai +++ b/jeecg-boot/jeecg-boot-module-system/src/main/resources/jeecg/code-template-online/erp/onetomany/java/${bussiPackage}/${entityPackage}/entity/${entityName}.javai @@ -47,7 +47,7 @@ public class ${entityName} implements Serializable { <#if po.fieldName == primaryKeyField> @TableId(type = IdType.ASSIGN_ID) <#else> - <#if po.fieldDbType =='Date'> + <#if po.fieldDbType =='Date' || po.fieldDbType =='Datetime'> <#if po.classType=='date'> <#if !excel_ignore_arr?seq_contains("${po.fieldName}")> @Excel(name = "${po.filedComment}", width = 15, format = "yyyy-MM-dd") diff --git a/jeecg-boot/jeecg-boot-module-system/src/main/resources/jeecg/code-template-online/erp/onetomany/java/${bussiPackage}/${entityPackage}/entity/[1-n]Entity.javai b/jeecg-boot/jeecg-boot-module-system/src/main/resources/jeecg/code-template-online/erp/onetomany/java/${bussiPackage}/${entityPackage}/entity/[1-n]Entity.javai index 1cfdcf7..d549c98 100644 --- a/jeecg-boot/jeecg-boot-module-system/src/main/resources/jeecg/code-template-online/erp/onetomany/java/${bussiPackage}/${entityPackage}/entity/[1-n]Entity.javai +++ b/jeecg-boot/jeecg-boot-module-system/src/main/resources/jeecg/code-template-online/erp/onetomany/java/${bussiPackage}/${entityPackage}/entity/[1-n]Entity.javai @@ -34,7 +34,7 @@ public class ${subTab.entityName} implements Serializable { <#if po.fieldName == primaryKeyField> @TableId(type = IdType.ASSIGN_ID) <#else> - <#if po.fieldDbType =='Date'> + <#if po.fieldDbType =='Date' || po.fieldDbType =='Datetime'> <#if po.classType=='date'> <#if !excel_ignore_arr?seq_contains("${po.fieldName}")> @Excel(name = "${po.filedComment}", width = 15, format = "yyyy-MM-dd") diff --git a/jeecg-boot/jeecg-boot-module-system/src/main/resources/jeecg/code-template-online/erp/onetomany/java/${bussiPackage}/${entityPackage}/mapper/[1-n]Mapper.javai b/jeecg-boot/jeecg-boot-module-system/src/main/resources/jeecg/code-template-online/erp/onetomany/java/${bussiPackage}/${entityPackage}/mapper/[1-n]Mapper.javai index eccb8d6..6b6736d 100644 --- a/jeecg-boot/jeecg-boot-module-system/src/main/resources/jeecg/code-template-online/erp/onetomany/java/${bussiPackage}/${entityPackage}/mapper/[1-n]Mapper.javai +++ b/jeecg-boot/jeecg-boot-module-system/src/main/resources/jeecg/code-template-online/erp/onetomany/java/${bussiPackage}/${entityPackage}/mapper/[1-n]Mapper.javai @@ -15,8 +15,20 @@ import org.apache.ibatis.annotations.Param; */ public interface ${subTab.entityName}Mapper extends BaseMapper<${subTab.entityName}> { + /** + * 通过主表id删除子表数据 + * + * @param mainId 主表id + * @return boolean + */ public boolean deleteByMainId(@Param("mainId") String mainId); - + + /** + * 通过主表id查询子表数据 + * + * @param mainId 主表id + * @return List<${subTab.entityName}> + */ public List<${subTab.entityName}> selectByMainId(@Param("mainId") String mainId); } diff --git a/jeecg-boot/jeecg-boot-module-system/src/main/resources/jeecg/code-template-online/erp/onetomany/java/${bussiPackage}/${entityPackage}/service/I${entityName}Service.javai b/jeecg-boot/jeecg-boot-module-system/src/main/resources/jeecg/code-template-online/erp/onetomany/java/${bussiPackage}/${entityPackage}/service/I${entityName}Service.javai index 507143c..e22b54c 100644 --- a/jeecg-boot/jeecg-boot-module-system/src/main/resources/jeecg/code-template-online/erp/onetomany/java/${bussiPackage}/${entityPackage}/service/I${entityName}Service.javai +++ b/jeecg-boot/jeecg-boot-module-system/src/main/resources/jeecg/code-template-online/erp/onetomany/java/${bussiPackage}/${entityPackage}/service/I${entityName}Service.javai @@ -20,11 +20,15 @@ public interface I${entityName}Service extends IService<${entityName}> { /** * 删除一对多 + * + * @param id */ public void delMain (String id); /** * 批量删除一对多 + * + * @param idList */ public void delBatchMain (Collection<? extends Serializable> idList); diff --git a/jeecg-boot/jeecg-boot-module-system/src/main/resources/jeecg/code-template-online/erp/onetomany/java/${bussiPackage}/${entityPackage}/service/[1-n]Service.javai b/jeecg-boot/jeecg-boot-module-system/src/main/resources/jeecg/code-template-online/erp/onetomany/java/${bussiPackage}/${entityPackage}/service/[1-n]Service.javai index 0f85cb3..74ad5a7 100644 --- a/jeecg-boot/jeecg-boot-module-system/src/main/resources/jeecg/code-template-online/erp/onetomany/java/${bussiPackage}/${entityPackage}/service/[1-n]Service.javai +++ b/jeecg-boot/jeecg-boot-module-system/src/main/resources/jeecg/code-template-online/erp/onetomany/java/${bussiPackage}/${entityPackage}/service/[1-n]Service.javai @@ -14,6 +14,12 @@ import java.util.List; */ public interface I${subTab.entityName}Service extends IService<${subTab.entityName}> { + /** + * 通过主表id查询子表数据 + * + * @param mainId + * @return List<${subTab.entityName}> + */ public List<${subTab.entityName}> selectByMainId(String mainId); } </#list> diff --git a/jeecg-boot/jeecg-boot-module-system/src/main/resources/jeecg/code-template-online/erp/onetomany/java/${bussiPackage}/${entityPackage}/vue/${entityName}List.vuei b/jeecg-boot/jeecg-boot-module-system/src/main/resources/jeecg/code-template-online/erp/onetomany/java/${bussiPackage}/${entityPackage}/vue/${entityName}List.vuei index 5233401..1cf248a 100644 --- a/jeecg-boot/jeecg-boot-module-system/src/main/resources/jeecg/code-template-online/erp/onetomany/java/${bussiPackage}/${entityPackage}/vue/${entityName}List.vuei +++ b/jeecg-boot/jeecg-boot-module-system/src/main/resources/jeecg/code-template-online/erp/onetomany/java/${bussiPackage}/${entityPackage}/vue/${entityName}List.vuei @@ -193,7 +193,7 @@ <#assign sub_seq=1> <#list subTables as sub> <a-tab-pane tab="${sub.ftlDescription}" key="${sub_seq}" <#if sub_seq gt 1>forceRender</#if>> - <${sub.entityName}List :mainId="${sub.entityName?uncap_first}MainId" /> + <${sub.entityName}List :mainId="selectedMainId" /> </a-tab-pane> <#assign sub_seq=sub_seq+1> </#list> @@ -340,7 +340,7 @@ selectedMainId:'', superFieldList:[], <#list subTables as sub> - <#if sub != null> + <#if sub?? && (sub.foreignMainKeys)??> <#list sub.foreignMainKeys as key> <#assign subMainFieldMap += {"${sub.entityName?uncap_first}MainId": "${dashedToCamel(key)}"}> </#list> diff --git a/jeecg-boot/jeecg-boot-module-system/src/main/resources/jeecg/code-template-online/inner-table/onetomany/java/${bussiPackage}/${entityPackage}/controller/${entityName}Controller.javai b/jeecg-boot/jeecg-boot-module-system/src/main/resources/jeecg/code-template-online/inner-table/onetomany/java/${bussiPackage}/${entityPackage}/controller/${entityName}Controller.javai index fa9b0f3..36fb9fc 100644 --- a/jeecg-boot/jeecg-boot-module-system/src/main/resources/jeecg/code-template-online/inner-table/onetomany/java/${bussiPackage}/${entityPackage}/controller/${entityName}Controller.javai +++ b/jeecg-boot/jeecg-boot-module-system/src/main/resources/jeecg/code-template-online/inner-table/onetomany/java/${bussiPackage}/${entityPackage}/controller/${entityName}Controller.javai @@ -245,7 +245,8 @@ public class ${entityName}Controller { MultipartHttpServletRequest multipartRequest = (MultipartHttpServletRequest) request; Map<String, MultipartFile> fileMap = multipartRequest.getFileMap(); for (Map.Entry<String, MultipartFile> entity : fileMap.entrySet()) { - MultipartFile file = entity.getValue();// 获取上传文件对象 + // 获取上传文件对象 + MultipartFile file = entity.getValue(); ImportParams params = new ImportParams(); params.setTitleRows(2); params.setHeadRows(1); diff --git a/jeecg-boot/jeecg-boot-module-system/src/main/resources/jeecg/code-template-online/inner-table/onetomany/java/${bussiPackage}/${entityPackage}/entity/${entityName}.javai b/jeecg-boot/jeecg-boot-module-system/src/main/resources/jeecg/code-template-online/inner-table/onetomany/java/${bussiPackage}/${entityPackage}/entity/${entityName}.javai index d80d840..ed071ad 100644 --- a/jeecg-boot/jeecg-boot-module-system/src/main/resources/jeecg/code-template-online/inner-table/onetomany/java/${bussiPackage}/${entityPackage}/entity/${entityName}.javai +++ b/jeecg-boot/jeecg-boot-module-system/src/main/resources/jeecg/code-template-online/inner-table/onetomany/java/${bussiPackage}/${entityPackage}/entity/${entityName}.javai @@ -47,7 +47,7 @@ public class ${entityName} implements Serializable { <#if po.fieldName == primaryKeyField> @TableId(type = IdType.ASSIGN_ID) <#else> - <#if po.fieldDbType =='Date'> + <#if po.fieldDbType =='Date' || po.fieldDbType =='Datetime'> <#if po.classType=='date'> <#if !excel_ignore_arr?seq_contains("${po.fieldName}")> @Excel(name = "${po.filedComment}", width = 15, format = "yyyy-MM-dd") diff --git a/jeecg-boot/jeecg-boot-module-system/src/main/resources/jeecg/code-template-online/inner-table/onetomany/java/${bussiPackage}/${entityPackage}/entity/[1-n]Entity.javai b/jeecg-boot/jeecg-boot-module-system/src/main/resources/jeecg/code-template-online/inner-table/onetomany/java/${bussiPackage}/${entityPackage}/entity/[1-n]Entity.javai index d645a8f..30ba2dd 100644 --- a/jeecg-boot/jeecg-boot-module-system/src/main/resources/jeecg/code-template-online/inner-table/onetomany/java/${bussiPackage}/${entityPackage}/entity/[1-n]Entity.javai +++ b/jeecg-boot/jeecg-boot-module-system/src/main/resources/jeecg/code-template-online/inner-table/onetomany/java/${bussiPackage}/${entityPackage}/entity/[1-n]Entity.javai @@ -49,7 +49,7 @@ public class ${subTab.entityName} implements Serializable { <#if po.fieldName == primaryKeyField> @TableId(type = IdType.ASSIGN_ID) <#else> - <#if po.fieldDbType =='Date'> + <#if po.fieldDbType =='Date' || po.fieldDbType =='Datetime'> <#if po.classType=='date'> <#if !excel_ignore_arr?seq_contains("${po.fieldName}")> @Excel(name = "${po.filedComment}", width = 15, format = "yyyy-MM-dd") diff --git a/jeecg-boot/jeecg-boot-module-system/src/main/resources/jeecg/code-template-online/inner-table/onetomany/java/${bussiPackage}/${entityPackage}/mapper/[1-n]Mapper.javai b/jeecg-boot/jeecg-boot-module-system/src/main/resources/jeecg/code-template-online/inner-table/onetomany/java/${bussiPackage}/${entityPackage}/mapper/[1-n]Mapper.javai index ad15bfd..10b2764 100644 --- a/jeecg-boot/jeecg-boot-module-system/src/main/resources/jeecg/code-template-online/inner-table/onetomany/java/${bussiPackage}/${entityPackage}/mapper/[1-n]Mapper.javai +++ b/jeecg-boot/jeecg-boot-module-system/src/main/resources/jeecg/code-template-online/inner-table/onetomany/java/${bussiPackage}/${entityPackage}/mapper/[1-n]Mapper.javai @@ -15,8 +15,20 @@ import org.apache.ibatis.annotations.Param; */ public interface ${subTab.entityName}Mapper extends BaseMapper<${subTab.entityName}> { + /** + * 通过主表id删除子表数据 + * + * @param mainId 主表id + * @return boolean + */ public boolean deleteByMainId(@Param("mainId") String mainId); - + + /** + * 通过主表id查询子表数据 + * + * @param mainId 主表id + * @return List<${subTab.entityName}> + */ public List<${subTab.entityName}> selectByMainId(@Param("mainId") String mainId); } </#list> \ No newline at end of file diff --git a/jeecg-boot/jeecg-boot-module-system/src/main/resources/jeecg/code-template-online/inner-table/onetomany/java/${bussiPackage}/${entityPackage}/service/I${entityName}Service.javai b/jeecg-boot/jeecg-boot-module-system/src/main/resources/jeecg/code-template-online/inner-table/onetomany/java/${bussiPackage}/${entityPackage}/service/I${entityName}Service.javai index e7d9914..d80c029 100644 --- a/jeecg-boot/jeecg-boot-module-system/src/main/resources/jeecg/code-template-online/inner-table/onetomany/java/${bussiPackage}/${entityPackage}/service/I${entityName}Service.javai +++ b/jeecg-boot/jeecg-boot-module-system/src/main/resources/jeecg/code-template-online/inner-table/onetomany/java/${bussiPackage}/${entityPackage}/service/I${entityName}Service.javai @@ -19,23 +19,35 @@ public interface I${entityName}Service extends IService<${entityName}> { /** * 添加一对多 - * + * + * @param ${entityName?uncap_first} + <#list subTables as sub> + * @param ${sub.entityName?uncap_first}List + </#list> */ public void saveMain(${entityName} ${entityName?uncap_first},<#list subTables as sub>List<${sub.entityName}> ${sub.entityName?uncap_first}List<#if sub_has_next>,</#if></#list>) ; /** * 修改一对多 - * + * + * @param ${entityName?uncap_first} + <#list subTables as sub> + * @param ${sub.entityName?uncap_first}List + </#list> */ public void updateMain(${entityName} ${entityName?uncap_first},<#list subTables as sub>List<${sub.entityName}> ${sub.entityName?uncap_first}List<#if sub_has_next>,</#if></#list>); /** * 删除一对多 + * + * @param id */ public void delMain (String id); /** * 批量删除一对多 + * + * @param idList */ public void delBatchMain (Collection<? extends Serializable> idList); diff --git a/jeecg-boot/jeecg-boot-module-system/src/main/resources/jeecg/code-template-online/inner-table/onetomany/java/${bussiPackage}/${entityPackage}/service/[1-n]Service.javai b/jeecg-boot/jeecg-boot-module-system/src/main/resources/jeecg/code-template-online/inner-table/onetomany/java/${bussiPackage}/${entityPackage}/service/[1-n]Service.javai index 0f85cb3..cbc72ff 100644 --- a/jeecg-boot/jeecg-boot-module-system/src/main/resources/jeecg/code-template-online/inner-table/onetomany/java/${bussiPackage}/${entityPackage}/service/[1-n]Service.javai +++ b/jeecg-boot/jeecg-boot-module-system/src/main/resources/jeecg/code-template-online/inner-table/onetomany/java/${bussiPackage}/${entityPackage}/service/[1-n]Service.javai @@ -14,6 +14,12 @@ import java.util.List; */ public interface I${subTab.entityName}Service extends IService<${subTab.entityName}> { + /** + * 通过主表id查询子表数据 + * + * @param mainId 主表id + * @return List<${subTab.entityName}> + */ public List<${subTab.entityName}> selectByMainId(String mainId); } </#list> diff --git a/jeecg-boot/jeecg-boot-module-system/src/main/resources/jeecg/code-template-online/inner-table/onetomany/java/${bussiPackage}/${entityPackage}/vo/${entityName}Page.javai b/jeecg-boot/jeecg-boot-module-system/src/main/resources/jeecg/code-template-online/inner-table/onetomany/java/${bussiPackage}/${entityPackage}/vo/${entityName}Page.javai index b5f85f3..aa9ebe3 100644 --- a/jeecg-boot/jeecg-boot-module-system/src/main/resources/jeecg/code-template-online/inner-table/onetomany/java/${bussiPackage}/${entityPackage}/vo/${entityName}Page.javai +++ b/jeecg-boot/jeecg-boot-module-system/src/main/resources/jeecg/code-template-online/inner-table/onetomany/java/${bussiPackage}/${entityPackage}/vo/${entityName}Page.javai @@ -44,7 +44,7 @@ public class ${entityName}Page { /**${po.filedComment}*/ <#if po.fieldName == primaryKeyField> <#else> - <#if po.fieldDbType =='Date'> + <#if po.fieldDbType =='Date' || po.fieldDbType =='Datetime'> <#if po.classType=='date'> <#if !excel_ignore_arr?seq_contains("${po.fieldName}")> @Excel(name = "${po.filedComment}", width = 15, format = "yyyy-MM-dd") diff --git a/jeecg-boot/jeecg-boot-module-system/src/main/resources/jeecg/code-template-online/inner-table/onetomany/java/${bussiPackage}/${entityPackage}/vue3/components/${entityName}Modal.vuei b/jeecg-boot/jeecg-boot-module-system/src/main/resources/jeecg/code-template-online/inner-table/onetomany/java/${bussiPackage}/${entityPackage}/vue3/components/${entityName}Modal.vuei index fe662ad..4996cb5 100644 --- a/jeecg-boot/jeecg-boot-module-system/src/main/resources/jeecg/code-template-online/inner-table/onetomany/java/${bussiPackage}/${entityPackage}/vue3/components/${entityName}Modal.vuei +++ b/jeecg-boot/jeecg-boot-module-system/src/main/resources/jeecg/code-template-online/inner-table/onetomany/java/${bussiPackage}/${entityPackage}/vue3/components/${entityName}Modal.vuei @@ -4,17 +4,18 @@ <!-- 子表单区域 --> <a-tabs v-model:activeKey="activeKey" @change="handleChangeTabs"> <#list subTables as sub><#rt/> + <#assign refKey = sub.entityName?uncap_first/> <#if sub.foreignRelationType =='1'> - <a-tab-pane tab="${sub.ftlDescription}" :key="refKeys[${sub_index}]" :forceRender="true"> + <a-tab-pane tab="${sub.ftlDescription}" key="${refKey}" :forceRender="true"> <${sub.entityName}Form ref="${sub.entityName?uncap_first}Form"></${sub.entityName}Form> </a-tab-pane> <#else> - <a-tab-pane tab="${sub.ftlDescription}" :key="refKeys[${sub_index}]" :forceRender="true"> + <a-tab-pane tab="${sub.ftlDescription}" key="${refKey}" :forceRender="true"> <JVxeTable keep-source resizable - :ref="refKeys[${sub_index}]" + ref="${refKey}" :loading="${sub.entityName?uncap_first}Table.loading" :columns="${sub.entityName?uncap_first}Table.columns" :dataSource="${sub.entityName?uncap_first}Table.dataSource" diff --git a/jeecg-boot/jeecg-boot-module-system/src/main/resources/jeecg/code-template-online/jvxe/onetomany/java/${bussiPackage}/${entityPackage}/controller/${entityName}Controller.javai b/jeecg-boot/jeecg-boot-module-system/src/main/resources/jeecg/code-template-online/jvxe/onetomany/java/${bussiPackage}/${entityPackage}/controller/${entityName}Controller.javai index 09b37ab..43919c8 100644 --- a/jeecg-boot/jeecg-boot-module-system/src/main/resources/jeecg/code-template-online/jvxe/onetomany/java/${bussiPackage}/${entityPackage}/controller/${entityName}Controller.javai +++ b/jeecg-boot/jeecg-boot-module-system/src/main/resources/jeecg/code-template-online/jvxe/onetomany/java/${bussiPackage}/${entityPackage}/controller/${entityName}Controller.javai @@ -250,7 +250,8 @@ public class ${entityName}Controller { MultipartHttpServletRequest multipartRequest = (MultipartHttpServletRequest) request; Map<String, MultipartFile> fileMap = multipartRequest.getFileMap(); for (Map.Entry<String, MultipartFile> entity : fileMap.entrySet()) { - MultipartFile file = entity.getValue();// 获取上传文件对象 + // 获取上传文件对象 + MultipartFile file = entity.getValue(); ImportParams params = new ImportParams(); params.setTitleRows(2); params.setHeadRows(1); diff --git a/jeecg-boot/jeecg-boot-module-system/src/main/resources/jeecg/code-template-online/jvxe/onetomany/java/${bussiPackage}/${entityPackage}/entity/${entityName}.javai b/jeecg-boot/jeecg-boot-module-system/src/main/resources/jeecg/code-template-online/jvxe/onetomany/java/${bussiPackage}/${entityPackage}/entity/${entityName}.javai index 9bd5dfd..c861c4a 100644 --- a/jeecg-boot/jeecg-boot-module-system/src/main/resources/jeecg/code-template-online/jvxe/onetomany/java/${bussiPackage}/${entityPackage}/entity/${entityName}.javai +++ b/jeecg-boot/jeecg-boot-module-system/src/main/resources/jeecg/code-template-online/jvxe/onetomany/java/${bussiPackage}/${entityPackage}/entity/${entityName}.javai @@ -47,7 +47,7 @@ public class ${entityName} implements Serializable { <#if po.fieldName == primaryKeyField> @TableId(type = IdType.ASSIGN_ID) <#else> - <#if po.fieldDbType =='Date'> + <#if po.fieldDbType =='Date' || po.fieldDbType =='Datetime'> <#if po.classType=='date'> <#if !excel_ignore_arr?seq_contains("${po.fieldName}")> @Excel(name = "${po.filedComment}", width = 15, format = "yyyy-MM-dd") diff --git a/jeecg-boot/jeecg-boot-module-system/src/main/resources/jeecg/code-template-online/jvxe/onetomany/java/${bussiPackage}/${entityPackage}/entity/[1-n]Entity.javai b/jeecg-boot/jeecg-boot-module-system/src/main/resources/jeecg/code-template-online/jvxe/onetomany/java/${bussiPackage}/${entityPackage}/entity/[1-n]Entity.javai index c93099c..b6aabe8 100644 --- a/jeecg-boot/jeecg-boot-module-system/src/main/resources/jeecg/code-template-online/jvxe/onetomany/java/${bussiPackage}/${entityPackage}/entity/[1-n]Entity.javai +++ b/jeecg-boot/jeecg-boot-module-system/src/main/resources/jeecg/code-template-online/jvxe/onetomany/java/${bussiPackage}/${entityPackage}/entity/[1-n]Entity.javai @@ -48,7 +48,7 @@ public class ${subTab.entityName} implements Serializable { <#if po.fieldName == primaryKeyField> @TableId(type = IdType.ASSIGN_ID) <#else> - <#if po.fieldDbType =='Date'> + <#if po.fieldDbType =='Date' || po.fieldDbType =='Datetime'> <#if po.classType=='date'> <#if !excel_ignore_arr?seq_contains("${po.fieldName}")> @Excel(name = "${po.filedComment}", width = 15, format = "yyyy-MM-dd") diff --git a/jeecg-boot/jeecg-boot-module-system/src/main/resources/jeecg/code-template-online/jvxe/onetomany/java/${bussiPackage}/${entityPackage}/mapper/[1-n]Mapper.javai b/jeecg-boot/jeecg-boot-module-system/src/main/resources/jeecg/code-template-online/jvxe/onetomany/java/${bussiPackage}/${entityPackage}/mapper/[1-n]Mapper.javai index ad15bfd..10b2764 100644 --- a/jeecg-boot/jeecg-boot-module-system/src/main/resources/jeecg/code-template-online/jvxe/onetomany/java/${bussiPackage}/${entityPackage}/mapper/[1-n]Mapper.javai +++ b/jeecg-boot/jeecg-boot-module-system/src/main/resources/jeecg/code-template-online/jvxe/onetomany/java/${bussiPackage}/${entityPackage}/mapper/[1-n]Mapper.javai @@ -15,8 +15,20 @@ import org.apache.ibatis.annotations.Param; */ public interface ${subTab.entityName}Mapper extends BaseMapper<${subTab.entityName}> { + /** + * 通过主表id删除子表数据 + * + * @param mainId 主表id + * @return boolean + */ public boolean deleteByMainId(@Param("mainId") String mainId); - + + /** + * 通过主表id查询子表数据 + * + * @param mainId 主表id + * @return List<${subTab.entityName}> + */ public List<${subTab.entityName}> selectByMainId(@Param("mainId") String mainId); } </#list> \ No newline at end of file diff --git a/jeecg-boot/jeecg-boot-module-system/src/main/resources/jeecg/code-template-online/jvxe/onetomany/java/${bussiPackage}/${entityPackage}/service/I${entityName}Service.javai b/jeecg-boot/jeecg-boot-module-system/src/main/resources/jeecg/code-template-online/jvxe/onetomany/java/${bussiPackage}/${entityPackage}/service/I${entityName}Service.javai index e7d9914..43ef9dc 100644 --- a/jeecg-boot/jeecg-boot-module-system/src/main/resources/jeecg/code-template-online/jvxe/onetomany/java/${bussiPackage}/${entityPackage}/service/I${entityName}Service.javai +++ b/jeecg-boot/jeecg-boot-module-system/src/main/resources/jeecg/code-template-online/jvxe/onetomany/java/${bussiPackage}/${entityPackage}/service/I${entityName}Service.javai @@ -19,23 +19,35 @@ public interface I${entityName}Service extends IService<${entityName}> { /** * 添加一对多 - * + * + * @param ${entityName?uncap_first} + <#list subTables as sub> + * @param ${sub.entityName?uncap_first}List + </#list> */ public void saveMain(${entityName} ${entityName?uncap_first},<#list subTables as sub>List<${sub.entityName}> ${sub.entityName?uncap_first}List<#if sub_has_next>,</#if></#list>) ; /** * 修改一对多 - * + * + * @param ${entityName?uncap_first} + <#list subTables as sub> + * @param ${sub.entityName?uncap_first}List + </#list> */ public void updateMain(${entityName} ${entityName?uncap_first},<#list subTables as sub>List<${sub.entityName}> ${sub.entityName?uncap_first}List<#if sub_has_next>,</#if></#list>); /** * 删除一对多 + * + * @param id */ public void delMain (String id); /** * 批量删除一对多 + * + * @param idList */ public void delBatchMain (Collection<? extends Serializable> idList); diff --git a/jeecg-boot/jeecg-boot-module-system/src/main/resources/jeecg/code-template-online/jvxe/onetomany/java/${bussiPackage}/${entityPackage}/service/[1-n]Service.javai b/jeecg-boot/jeecg-boot-module-system/src/main/resources/jeecg/code-template-online/jvxe/onetomany/java/${bussiPackage}/${entityPackage}/service/[1-n]Service.javai index 0f85cb3..cbc72ff 100644 --- a/jeecg-boot/jeecg-boot-module-system/src/main/resources/jeecg/code-template-online/jvxe/onetomany/java/${bussiPackage}/${entityPackage}/service/[1-n]Service.javai +++ b/jeecg-boot/jeecg-boot-module-system/src/main/resources/jeecg/code-template-online/jvxe/onetomany/java/${bussiPackage}/${entityPackage}/service/[1-n]Service.javai @@ -14,6 +14,12 @@ import java.util.List; */ public interface I${subTab.entityName}Service extends IService<${subTab.entityName}> { + /** + * 通过主表id查询子表数据 + * + * @param mainId 主表id + * @return List<${subTab.entityName}> + */ public List<${subTab.entityName}> selectByMainId(String mainId); } </#list> diff --git a/jeecg-boot/jeecg-boot-module-system/src/main/resources/jeecg/code-template-online/jvxe/onetomany/java/${bussiPackage}/${entityPackage}/vo/${entityName}Page.javai b/jeecg-boot/jeecg-boot-module-system/src/main/resources/jeecg/code-template-online/jvxe/onetomany/java/${bussiPackage}/${entityPackage}/vo/${entityName}Page.javai index cee4df7..501fb9a 100644 --- a/jeecg-boot/jeecg-boot-module-system/src/main/resources/jeecg/code-template-online/jvxe/onetomany/java/${bussiPackage}/${entityPackage}/vo/${entityName}Page.javai +++ b/jeecg-boot/jeecg-boot-module-system/src/main/resources/jeecg/code-template-online/jvxe/onetomany/java/${bussiPackage}/${entityPackage}/vo/${entityName}Page.javai @@ -44,7 +44,7 @@ public class ${entityName}Page { /**${po.filedComment}*/ <#if po.fieldName == primaryKeyField> <#else> - <#if po.fieldDbType =='Date'> + <#if po.fieldDbType =='Date' || po.fieldDbType =='Datetime'> <#if po.classType=='date'> <#if !excel_ignore_arr?seq_contains("${po.fieldName}")> @Excel(name = "${po.filedComment}", width = 15, format = "yyyy-MM-dd") diff --git a/jeecg-boot/jeecg-boot-module-system/src/main/resources/jeecg/code-template-online/jvxe/onetomany/java/${bussiPackage}/${entityPackage}/vue3/components/${entityName}Modal.vuei b/jeecg-boot/jeecg-boot-module-system/src/main/resources/jeecg/code-template-online/jvxe/onetomany/java/${bussiPackage}/${entityPackage}/vue3/components/${entityName}Modal.vuei index d7b5ec1..6a2e26b 100644 --- a/jeecg-boot/jeecg-boot-module-system/src/main/resources/jeecg/code-template-online/jvxe/onetomany/java/${bussiPackage}/${entityPackage}/vue3/components/${entityName}Modal.vuei +++ b/jeecg-boot/jeecg-boot-module-system/src/main/resources/jeecg/code-template-online/jvxe/onetomany/java/${bussiPackage}/${entityPackage}/vue3/components/${entityName}Modal.vuei @@ -4,17 +4,18 @@ <!-- 子表单区域 --> <a-tabs v-model:activeKey="activeKey" @change="handleChangeTabs"> <#list subTables as sub><#rt/> + <#assign refKey = sub.entityName?uncap_first/> <#if sub.foreignRelationType =='1'> - <a-tab-pane tab="${sub.ftlDescription}" :key="refKeys[${sub_index}]" :forceRender="true"> + <a-tab-pane tab="${sub.ftlDescription}" key="${refKey}" :forceRender="true"> <${sub.entityName}Form ref="${sub.entityName?uncap_first}Form"></${sub.entityName}Form> </a-tab-pane> <#else> - <a-tab-pane tab="${sub.ftlDescription}" :key="refKeys[${sub_index}]" :forceRender="true"> + <a-tab-pane tab="${sub.ftlDescription}" key="${refKey}" :forceRender="true"> <JVxeTable keep-source resizable - :ref="refKeys[${sub_index}]" + ref="${refKey}" :loading="${sub.entityName?uncap_first}Table.loading" :columns="${sub.entityName?uncap_first}Table.columns" :dataSource="${sub.entityName?uncap_first}Table.dataSource" diff --git a/jeecg-boot/jeecg-boot-module-system/src/main/resources/jeecg/code-template-online/tab/onetomany/java/${bussiPackage}/${entityPackage}/controller/${entityName}Controller.javai b/jeecg-boot/jeecg-boot-module-system/src/main/resources/jeecg/code-template-online/tab/onetomany/java/${bussiPackage}/${entityPackage}/controller/${entityName}Controller.javai index be4e9ab..4877656 100644 --- a/jeecg-boot/jeecg-boot-module-system/src/main/resources/jeecg/code-template-online/tab/onetomany/java/${bussiPackage}/${entityPackage}/controller/${entityName}Controller.javai +++ b/jeecg-boot/jeecg-boot-module-system/src/main/resources/jeecg/code-template-online/tab/onetomany/java/${bussiPackage}/${entityPackage}/controller/${entityName}Controller.javai @@ -241,7 +241,8 @@ public class ${entityName}Controller { MultipartHttpServletRequest multipartRequest = (MultipartHttpServletRequest) request; Map<String, MultipartFile> fileMap = multipartRequest.getFileMap(); for (Map.Entry<String, MultipartFile> entity : fileMap.entrySet()) { - MultipartFile file = entity.getValue();// 获取上传文件对象 + // 获取上传文件对象 + MultipartFile file = entity.getValue(); ImportParams params = new ImportParams(); params.setTitleRows(2); params.setHeadRows(1); diff --git a/jeecg-boot/jeecg-boot-module-system/src/main/resources/jeecg/code-template-online/tab/onetomany/java/${bussiPackage}/${entityPackage}/entity/${entityName}.javai b/jeecg-boot/jeecg-boot-module-system/src/main/resources/jeecg/code-template-online/tab/onetomany/java/${bussiPackage}/${entityPackage}/entity/${entityName}.javai index 9bd5dfd..c861c4a 100644 --- a/jeecg-boot/jeecg-boot-module-system/src/main/resources/jeecg/code-template-online/tab/onetomany/java/${bussiPackage}/${entityPackage}/entity/${entityName}.javai +++ b/jeecg-boot/jeecg-boot-module-system/src/main/resources/jeecg/code-template-online/tab/onetomany/java/${bussiPackage}/${entityPackage}/entity/${entityName}.javai @@ -47,7 +47,7 @@ public class ${entityName} implements Serializable { <#if po.fieldName == primaryKeyField> @TableId(type = IdType.ASSIGN_ID) <#else> - <#if po.fieldDbType =='Date'> + <#if po.fieldDbType =='Date' || po.fieldDbType =='Datetime'> <#if po.classType=='date'> <#if !excel_ignore_arr?seq_contains("${po.fieldName}")> @Excel(name = "${po.filedComment}", width = 15, format = "yyyy-MM-dd") diff --git a/jeecg-boot/jeecg-boot-module-system/src/main/resources/jeecg/code-template-online/tab/onetomany/java/${bussiPackage}/${entityPackage}/entity/[1-n]Entity.javai b/jeecg-boot/jeecg-boot-module-system/src/main/resources/jeecg/code-template-online/tab/onetomany/java/${bussiPackage}/${entityPackage}/entity/[1-n]Entity.javai index c93099c..b6aabe8 100644 --- a/jeecg-boot/jeecg-boot-module-system/src/main/resources/jeecg/code-template-online/tab/onetomany/java/${bussiPackage}/${entityPackage}/entity/[1-n]Entity.javai +++ b/jeecg-boot/jeecg-boot-module-system/src/main/resources/jeecg/code-template-online/tab/onetomany/java/${bussiPackage}/${entityPackage}/entity/[1-n]Entity.javai @@ -48,7 +48,7 @@ public class ${subTab.entityName} implements Serializable { <#if po.fieldName == primaryKeyField> @TableId(type = IdType.ASSIGN_ID) <#else> - <#if po.fieldDbType =='Date'> + <#if po.fieldDbType =='Date' || po.fieldDbType =='Datetime'> <#if po.classType=='date'> <#if !excel_ignore_arr?seq_contains("${po.fieldName}")> @Excel(name = "${po.filedComment}", width = 15, format = "yyyy-MM-dd") diff --git a/jeecg-boot/jeecg-boot-module-system/src/main/resources/jeecg/code-template-online/tab/onetomany/java/${bussiPackage}/${entityPackage}/mapper/[1-n]Mapper.javai b/jeecg-boot/jeecg-boot-module-system/src/main/resources/jeecg/code-template-online/tab/onetomany/java/${bussiPackage}/${entityPackage}/mapper/[1-n]Mapper.javai index ad15bfd..10b2764 100644 --- a/jeecg-boot/jeecg-boot-module-system/src/main/resources/jeecg/code-template-online/tab/onetomany/java/${bussiPackage}/${entityPackage}/mapper/[1-n]Mapper.javai +++ b/jeecg-boot/jeecg-boot-module-system/src/main/resources/jeecg/code-template-online/tab/onetomany/java/${bussiPackage}/${entityPackage}/mapper/[1-n]Mapper.javai @@ -15,8 +15,20 @@ import org.apache.ibatis.annotations.Param; */ public interface ${subTab.entityName}Mapper extends BaseMapper<${subTab.entityName}> { + /** + * 通过主表id删除子表数据 + * + * @param mainId 主表id + * @return boolean + */ public boolean deleteByMainId(@Param("mainId") String mainId); - + + /** + * 通过主表id查询子表数据 + * + * @param mainId 主表id + * @return List<${subTab.entityName}> + */ public List<${subTab.entityName}> selectByMainId(@Param("mainId") String mainId); } </#list> \ No newline at end of file diff --git a/jeecg-boot/jeecg-boot-module-system/src/main/resources/jeecg/code-template-online/tab/onetomany/java/${bussiPackage}/${entityPackage}/service/I${entityName}Service.javai b/jeecg-boot/jeecg-boot-module-system/src/main/resources/jeecg/code-template-online/tab/onetomany/java/${bussiPackage}/${entityPackage}/service/I${entityName}Service.javai index e7d9914..d80c029 100644 --- a/jeecg-boot/jeecg-boot-module-system/src/main/resources/jeecg/code-template-online/tab/onetomany/java/${bussiPackage}/${entityPackage}/service/I${entityName}Service.javai +++ b/jeecg-boot/jeecg-boot-module-system/src/main/resources/jeecg/code-template-online/tab/onetomany/java/${bussiPackage}/${entityPackage}/service/I${entityName}Service.javai @@ -19,23 +19,35 @@ public interface I${entityName}Service extends IService<${entityName}> { /** * 添加一对多 - * + * + * @param ${entityName?uncap_first} + <#list subTables as sub> + * @param ${sub.entityName?uncap_first}List + </#list> */ public void saveMain(${entityName} ${entityName?uncap_first},<#list subTables as sub>List<${sub.entityName}> ${sub.entityName?uncap_first}List<#if sub_has_next>,</#if></#list>) ; /** * 修改一对多 - * + * + * @param ${entityName?uncap_first} + <#list subTables as sub> + * @param ${sub.entityName?uncap_first}List + </#list> */ public void updateMain(${entityName} ${entityName?uncap_first},<#list subTables as sub>List<${sub.entityName}> ${sub.entityName?uncap_first}List<#if sub_has_next>,</#if></#list>); /** * 删除一对多 + * + * @param id */ public void delMain (String id); /** * 批量删除一对多 + * + * @param idList */ public void delBatchMain (Collection<? extends Serializable> idList); diff --git a/jeecg-boot/jeecg-boot-module-system/src/main/resources/jeecg/code-template-online/tab/onetomany/java/${bussiPackage}/${entityPackage}/service/[1-n]Service.javai b/jeecg-boot/jeecg-boot-module-system/src/main/resources/jeecg/code-template-online/tab/onetomany/java/${bussiPackage}/${entityPackage}/service/[1-n]Service.javai index 0f85cb3..cbc72ff 100644 --- a/jeecg-boot/jeecg-boot-module-system/src/main/resources/jeecg/code-template-online/tab/onetomany/java/${bussiPackage}/${entityPackage}/service/[1-n]Service.javai +++ b/jeecg-boot/jeecg-boot-module-system/src/main/resources/jeecg/code-template-online/tab/onetomany/java/${bussiPackage}/${entityPackage}/service/[1-n]Service.javai @@ -14,6 +14,12 @@ import java.util.List; */ public interface I${subTab.entityName}Service extends IService<${subTab.entityName}> { + /** + * 通过主表id查询子表数据 + * + * @param mainId 主表id + * @return List<${subTab.entityName}> + */ public List<${subTab.entityName}> selectByMainId(String mainId); } </#list> diff --git a/jeecg-boot/jeecg-boot-module-system/src/main/resources/jeecg/code-template-online/tab/onetomany/java/${bussiPackage}/${entityPackage}/vo/${entityName}Page.javai b/jeecg-boot/jeecg-boot-module-system/src/main/resources/jeecg/code-template-online/tab/onetomany/java/${bussiPackage}/${entityPackage}/vo/${entityName}Page.javai index cee4df7..501fb9a 100644 --- a/jeecg-boot/jeecg-boot-module-system/src/main/resources/jeecg/code-template-online/tab/onetomany/java/${bussiPackage}/${entityPackage}/vo/${entityName}Page.javai +++ b/jeecg-boot/jeecg-boot-module-system/src/main/resources/jeecg/code-template-online/tab/onetomany/java/${bussiPackage}/${entityPackage}/vo/${entityName}Page.javai @@ -44,7 +44,7 @@ public class ${entityName}Page { /**${po.filedComment}*/ <#if po.fieldName == primaryKeyField> <#else> - <#if po.fieldDbType =='Date'> + <#if po.fieldDbType =='Date' || po.fieldDbType =='Datetime'> <#if po.classType=='date'> <#if !excel_ignore_arr?seq_contains("${po.fieldName}")> @Excel(name = "${po.filedComment}", width = 15, format = "yyyy-MM-dd") diff --git a/jeecg-boot/jeecg-boot-module-system/src/main/resources/jeecg/code-template-online/tab/onetomany/java/${bussiPackage}/${entityPackage}/vue3/components/${entityName}Modal.vuei b/jeecg-boot/jeecg-boot-module-system/src/main/resources/jeecg/code-template-online/tab/onetomany/java/${bussiPackage}/${entityPackage}/vue3/components/${entityName}Modal.vuei index 8e6821d..aa5fe59 100644 --- a/jeecg-boot/jeecg-boot-module-system/src/main/resources/jeecg/code-template-online/tab/onetomany/java/${bussiPackage}/${entityPackage}/vue3/components/${entityName}Modal.vuei +++ b/jeecg-boot/jeecg-boot-module-system/src/main/resources/jeecg/code-template-online/tab/onetomany/java/${bussiPackage}/${entityPackage}/vue3/components/${entityName}Modal.vuei @@ -8,17 +8,18 @@ </a-tab-pane> <!--子表单区域 --> <#list subTables as sub><#rt/> + <#assign refKey = sub.entityName?uncap_first/> <#if sub.foreignRelationType =='1'> - <a-tab-pane tab="${sub.ftlDescription}" :key="refKeys[${sub_index+1}]" :forceRender="true"> + <a-tab-pane tab="${sub.ftlDescription}" key="${refKey}" :forceRender="true"> <${sub.entityName}Form ref="${sub.entityName?uncap_first}Form"></${sub.entityName}Form> </a-tab-pane> <#else> - <a-tab-pane tab="${sub.ftlDescription}" :key="refKeys[${sub_index+1}]" :forceRender="true"> + <a-tab-pane tab="${sub.ftlDescription}" key="${refKey}" :forceRender="true"> <JVxeTable keep-source resizable - :ref="refKeys[${sub_index+1}]" + ref="${refKey}" :loading="${sub.entityName?uncap_first}Table.loading" :columns="${sub.entityName?uncap_first}Table.columns" :dataSource="${sub.entityName?uncap_first}Table.dataSource" diff --git a/jeecg-boot/jeecg-boot-module-system/src/main/resources/jeecg/code-template/onetomany/java/${bussiPackage}/${entityPackage}/vue3/modules/${entityName}Modal.vuei b/jeecg-boot/jeecg-boot-module-system/src/main/resources/jeecg/code-template/onetomany/java/${bussiPackage}/${entityPackage}/vue3/modules/${entityName}Modal.vuei index cf1b561..a46c30e 100644 --- a/jeecg-boot/jeecg-boot-module-system/src/main/resources/jeecg/code-template/onetomany/java/${bussiPackage}/${entityPackage}/vue3/modules/${entityName}Modal.vuei +++ b/jeecg-boot/jeecg-boot-module-system/src/main/resources/jeecg/code-template/onetomany/java/${bussiPackage}/${entityPackage}/vue3/modules/${entityName}Modal.vuei @@ -4,11 +4,12 @@ <!-- 子表单区域 --> <a-tabs v-model:activeKey="activeKey" @change="handleChangeTabs"> <#list subTables as sub><#rt/> - <a-tab-pane tab="${sub.ftlDescription}" :key="refKeys[${sub_index}]" :forceRender="true"> + <#assign refKey = sub.entityName?uncap_first/> + <a-tab-pane tab="${sub.ftlDescription}" key="${refKey}" :forceRender="true"> <JVxeTable keep-source resizable - :ref="refKeys[${sub_index}]" + ref="${refKey}" :loading="${sub.entityName?uncap_first}Table.loading" :columns="${sub.entityName?uncap_first}Table.columns" :dataSource="${sub.entityName?uncap_first}Table.dataSource" -- libgit2 0.22.2