diff --git a/cloud-common-plugin-dynamic/src/main/java/com/cm/common/plugin/service/dynamic/config/impl/DynamicConfigTableServiceImpl.java b/cloud-common-plugin-dynamic/src/main/java/com/cm/common/plugin/service/dynamic/config/impl/DynamicConfigTableServiceImpl.java index ed076b4..c3f0b98 100644 --- a/cloud-common-plugin-dynamic/src/main/java/com/cm/common/plugin/service/dynamic/config/impl/DynamicConfigTableServiceImpl.java +++ b/cloud-common-plugin-dynamic/src/main/java/com/cm/common/plugin/service/dynamic/config/impl/DynamicConfigTableServiceImpl.java @@ -200,6 +200,7 @@ public class DynamicConfigTableServiceImpl extends AbstractService implements ID || StringUtils.equals(FieldTypeEnum.LEFT_JOIN.getValue(), dynamicConfigFormDTO.getFieldType()) || StringUtils.equals(FieldTypeEnum.RIGHT_JOIN.getValue(), dynamicConfigFormDTO.getFieldType())) { field.put("joinTable", dynamicConfigFormDTO.getJoinTable()); + field.put("firstUpperJoinTable", WStringUtil.firstToUpper(dynamicConfigFormDTO.getJoinTable())); field.put("lowerJoinTable", dynamicConfigFormDTO.getJoinTable().toLowerCase()); field.put("underLineJoinTable", WStringUtil.lowerUpper2UnderLine(dynamicConfigFormDTO.getJoinTable())); field.put("joinTableField", dynamicConfigFormDTO.getJoinTableField()); diff --git a/cloud-common-plugin-dynamic/src/main/resources/assets.zip b/cloud-common-plugin-dynamic/src/main/resources/assets.zip index 2b1da15..f074426 100644 Binary files a/cloud-common-plugin-dynamic/src/main/resources/assets.zip and b/cloud-common-plugin-dynamic/src/main/resources/assets.zip differ diff --git a/cloud-common-plugin-dynamic/src/main/resources/templates/codetemplate/default/controller/apis/ApiController.ftl b/cloud-common-plugin-dynamic/src/main/resources/templates/codetemplate/default/controller/apis/ApiController.ftl index 88179f9..149cac0 100644 --- a/cloud-common-plugin-dynamic/src/main/resources/templates/codetemplate/default/controller/apis/ApiController.ftl +++ b/cloud-common-plugin-dynamic/src/main/resources/templates/codetemplate/default/controller/apis/ApiController.ftl @@ -10,6 +10,7 @@ import com.cm.common.pojo.ListPage; import com.cm.common.pojo.dtos.CurrentUserIdInfoDTO; import com.cm.common.result.ErrorResult; import com.cm.common.result.SuccessResult; +import com.cm.common.result.SuccessResultData; import com.cm.common.result.SuccessResultList; import ${basePackage}.pojo.dtos.${lowerTableName}.${firstUpperTableName}DTO; import ${basePackage}.pojo.vos.${lowerTableName}.${firstUpperTableName}VO; @@ -102,6 +103,14 @@ public class ${firstUpperTableName}Controller extends AbstractController { return ${firstLowerTableName}Service.listPage${firstUpperTableName}(page); } + @ApiOperation(value = "${tableExplain}统计", notes = "${tableExplain}统计接口") + @ApiResponses({@ApiResponse(code = 400, message = "请求失败", response = ErrorResult.class)}) + @GetMapping("count${lowerTableName}") + SuccessResultData count${firstUpperTableName}() throws SearchException { + Map params = requestParams(); + return ${firstLowerTableName}Service.count${firstUpperTableName}(params); + } + @ApiOperation(value = "当前用户id信息", notes = "当前用户id信息接口") @ApiResponses({@ApiResponse(code = 400, message = "请求失败", response = ErrorResult.class)}) @GetMapping("getcurrentuseridinfo") diff --git a/cloud-common-plugin-dynamic/src/main/resources/templates/codetemplate/default/controller/app/apis/AppController.ftl b/cloud-common-plugin-dynamic/src/main/resources/templates/codetemplate/default/controller/app/apis/AppController.ftl index 2c552bf..0ed873f 100644 --- a/cloud-common-plugin-dynamic/src/main/resources/templates/codetemplate/default/controller/app/apis/AppController.ftl +++ b/cloud-common-plugin-dynamic/src/main/resources/templates/codetemplate/default/controller/app/apis/AppController.ftl @@ -8,6 +8,7 @@ import com.cm.common.exception.SearchException; import com.cm.common.pojo.ListPage; import com.cm.common.result.ErrorResult; import com.cm.common.result.SuccessResult; +import com.cm.common.result.SuccessResultData; import com.cm.common.result.SuccessResultList; import ${basePackage}.pojo.dtos.${lowerTableName}.${firstUpperTableName}DTO; import ${basePackage}.pojo.vos.${lowerTableName}.${firstUpperTableName}VO; @@ -108,4 +109,12 @@ public class ${firstUpperTableName}AppController extends AbstractController { return ${firstLowerTableName}Service.listPage${firstUpperTableName}(page); } + @ApiOperation(value = "${tableExplain}统计", notes = "${tableExplain}统计接口") + @ApiResponses({@ApiResponse(code = 400, message = "请求失败", response = ErrorResult.class)}) + @GetMapping("count${lowerTableName}") + SuccessResultData count${firstUpperTableName}() throws SearchException { + Map params = requestParams(); + return ${firstLowerTableName}Service.count${firstUpperTableName}(params); + } + } \ No newline at end of file diff --git a/cloud-common-plugin-dynamic/src/main/resources/templates/codetemplate/default/controller/resources/ResourceController.ftl b/cloud-common-plugin-dynamic/src/main/resources/templates/codetemplate/default/controller/resources/ResourceController.ftl index 48dc348..4ca1a16 100644 --- a/cloud-common-plugin-dynamic/src/main/resources/templates/codetemplate/default/controller/resources/ResourceController.ftl +++ b/cloud-common-plugin-dynamic/src/main/resources/templates/codetemplate/default/controller/resources/ResourceController.ftl @@ -8,6 +8,7 @@ import com.cm.common.exception.SearchException; import com.cm.common.pojo.ListPage; import com.cm.common.result.ErrorResult; import com.cm.common.result.SuccessResult; +import com.cm.common.result.SuccessResultData; import com.cm.common.result.SuccessResultList; import ${basePackage}.pojo.dtos.${lowerTableName}.${firstUpperTableName}DTO; import ${basePackage}.pojo.vos.${lowerTableName}.${firstUpperTableName}VO; @@ -108,4 +109,12 @@ public class ${firstUpperTableName}ResourceController extends AbstractController return ${firstLowerTableName}Service.listPage${firstUpperTableName}(page); } + @ApiOperation(value = "${tableExplain}统计", notes = "${tableExplain}统计接口") + @ApiResponses({@ApiResponse(code = 400, message = "请求失败", response = ErrorResult.class)}) + @GetMapping("count${lowerTableName}") + SuccessResultData count${firstUpperTableName}() throws SearchException { + Map params = requestParams(); + return ${firstLowerTableName}Service.count${firstUpperTableName}(params); + } + } \ No newline at end of file diff --git a/cloud-common-plugin-dynamic/src/main/resources/templates/codetemplate/default/dao/IDao.ftl b/cloud-common-plugin-dynamic/src/main/resources/templates/codetemplate/default/dao/IDao.ftl index afb6505..0983734 100644 --- a/cloud-common-plugin-dynamic/src/main/resources/templates/codetemplate/default/dao/IDao.ftl +++ b/cloud-common-plugin-dynamic/src/main/resources/templates/codetemplate/default/dao/IDao.ftl @@ -37,6 +37,14 @@ public interface I${firstUpperTableName}Dao { */ void remove${firstUpperTableName}(Map params) throws RemoveException; + /** + * 删除${tableExplain}(物理) + * + * @param params + * @throws RemoveException + */ + void delete${firstUpperTableName}(Map params) throws RemoveException; + /** * 修改${tableExplain} * @@ -62,5 +70,14 @@ public interface I${firstUpperTableName}Dao { * @throws SearchException */ List<${firstUpperTableName}DTO> list${firstUpperTableName}(Map params) throws SearchException; - -} + + /** + * ${tableExplain}统计 + * + * @param params + * @return + * @throws SearchException + */ + Integer count${firstUpperTableName}(Map params) throws SearchException; + +} \ No newline at end of file diff --git a/cloud-common-plugin-dynamic/src/main/resources/templates/codetemplate/default/mapper/mapper.ftl b/cloud-common-plugin-dynamic/src/main/resources/templates/codetemplate/default/mapper/mapper.ftl index 8227f5d..f85e6cf 100644 --- a/cloud-common-plugin-dynamic/src/main/resources/templates/codetemplate/default/mapper/mapper.ftl +++ b/cloud-common-plugin-dynamic/src/main/resources/templates/codetemplate/default/mapper/mapper.ftl @@ -15,7 +15,7 @@ <#if field.fieldType == "innerJoin" || field.fieldType == "leftJoin" || field.fieldType == "rightJoin"> <#list field.listJoinTableField! as joinTableField> <#if joinTableField.listShow == 1> - + @@ -63,6 +63,17 @@ + + + DELETE FROM + ${tablePrefix}${underLineTableName} + WHERE + ${underLineTableName}_id IN + + ${r"#{"}${firstLowerTableName}${r"Ids[${index}]}"} + + + UPDATE @@ -112,7 +123,7 @@ t1.${field.underLineFieldName}, <#-- 字典 start --> <#if field.fieldType == "radio" || field.fieldType == "checkbox" || field.fieldType == "select"> - GROUP_CONCAT(DISTINCT dt${field.dictionaryIndex}.dictionary_name) ${field.underLineFieldName}_dictionary_name, + dt${field.dictionaryIndex}.dictionary_name ${field.underLineFieldName}_dictionary_name, <#-- 字典 end --> @@ -120,7 +131,7 @@ <#if field.fieldType == "innerJoin" || field.fieldType == "leftJoin" || field.fieldType == "rightJoin"> <#list field.listJoinTableField! as joinTableField> <#if joinTableField.listShow == 1> - jt${field.joinTableIndex}.${joinTableField.underLineFieldName} ${joinTableField.underLineFieldName}_join_by_${field.underLineFieldName}, + jt${field.joinTableIndex}.${joinTableField.underLineFieldName} ${field.underLineJoinTable}_${joinTableField.underLineFieldName}, @@ -135,7 +146,7 @@ LEFT JOIN data_dictionary dt${field.dictionaryIndex} ON - FIND_IN_SET(dt${field.dictionaryIndex}.dictionary_id, t1.${field.underLineFieldName}) + dt${field.dictionaryIndex}.dictionary_id = t1.${field.underLineFieldName} AND dt${field.dictionaryIndex}.is_delete = 0 @@ -161,6 +172,11 @@ t1.is_delete = 0 + AND ( + t1.id LIKE CONCAT('%', #{keywords}, '%') + OR + t1.${underLineTableName}_id LIKE CONCAT('%', #{keywords}, '%') + ) AND @@ -177,22 +193,16 @@ ${r"#{"}${firstLowerTableName}${r"Ids[${index}]}"} - GROUP BY - <#list fieldList! as field> - <#if field.listShow == 1> - t1.${field.underLineFieldName}, - - <#-- 联表 start --> - <#if field.fieldType == "innerJoin" || field.fieldType == "leftJoin" || field.fieldType == "rightJoin"> - <#list field.listJoinTableField! as joinTableField> - <#if joinTableField.listShow == 1> - jt${field.joinTableIndex}.${joinTableField.underLineFieldName}, - - - - <#-- 联表 end --> - - t1.${underLineTableName}_id + + + + \ No newline at end of file diff --git a/cloud-common-plugin-dynamic/src/main/resources/templates/codetemplate/default/pojo/dto.ftl b/cloud-common-plugin-dynamic/src/main/resources/templates/codetemplate/default/pojo/dto.ftl index d7d5245..57be7a6 100644 --- a/cloud-common-plugin-dynamic/src/main/resources/templates/codetemplate/default/pojo/dto.ftl +++ b/cloud-common-plugin-dynamic/src/main/resources/templates/codetemplate/default/pojo/dto.ftl @@ -33,8 +33,8 @@ public class ${firstUpperTableName}DTO { private String ${field.fieldName}; <#list field.listJoinTableField! as joinTableField> <#if joinTableField.listShow == 1> - @ApiModelProperty(name = "${joinTableField.fieldName}JoinBy${field.firstUpperFieldName}", value = "${field.fieldExplain}的${joinTableField.fieldExplain}") - private String ${joinTableField.fieldName}JoinBy${field.firstUpperFieldName}; + @ApiModelProperty(name = "${field.joinTable}${joinTableField.firstUpperFieldName}", value = "${joinTableField.fieldExplain}") + private String ${field.joinTable}${joinTableField.firstUpperFieldName}; <#else> @@ -97,12 +97,12 @@ public class ${firstUpperTableName}DTO { <#list field.listJoinTableField! as joinTableField> <#if joinTableField.listShow == 1> - public String get${joinTableField.firstUpperFieldName}JoinBy${field.firstUpperFieldName}() { - return ${joinTableField.fieldName}JoinBy${field.firstUpperFieldName} == null ? "" : ${joinTableField.fieldName}JoinBy${field.firstUpperFieldName}; + public String get${field.firstUpperJoinTable}${joinTableField.firstUpperFieldName}() { + return ${field.joinTable}${joinTableField.firstUpperFieldName} == null ? "" : ${field.joinTable}${joinTableField.firstUpperFieldName}; } - public void set${joinTableField.firstUpperFieldName}JoinBy${field.firstUpperFieldName}(String ${joinTableField.fieldName}JoinBy${field.firstUpperFieldName}) { - this.${joinTableField.fieldName}JoinBy${field.firstUpperFieldName} = ${joinTableField.fieldName}JoinBy${field.firstUpperFieldName}; + public void set${field.firstUpperJoinTable}${joinTableField.firstUpperFieldName}(String ${field.joinTable}${joinTableField.firstUpperFieldName}) { + this.${field.joinTable}${joinTableField.firstUpperFieldName} = ${field.joinTable}${joinTableField.firstUpperFieldName}; } diff --git a/cloud-common-plugin-dynamic/src/main/resources/templates/codetemplate/default/route/list.ftl b/cloud-common-plugin-dynamic/src/main/resources/templates/codetemplate/default/route/list.ftl index 0447b25..5211a5b 100644 --- a/cloud-common-plugin-dynamic/src/main/resources/templates/codetemplate/default/route/list.ftl +++ b/cloud-common-plugin-dynamic/src/main/resources/templates/codetemplate/default/route/list.ftl @@ -145,7 +145,7 @@ <#if field.fieldType == "innerJoin" || field.fieldType == "leftJoin" || field.fieldType == "rightJoin"> <#list field.listJoinTableField! as joinTableField> <#if joinTableField.listShow == 1> - {field: '${joinTableField.fieldName}JoinBy${field.firstUpperFieldName}', width: ${joinTableField.fieldWidth}, title: '${field.fieldExplain}的${joinTableField.fieldExplain}', align:'center', + {field: '${field.joinTable}${joinTableField.firstUpperFieldName}', width: ${joinTableField.fieldWidth}, title: '${joinTableField.fieldExplain}', align:'center', templet: function(row) { var rowData = row[this.field]; if(typeof(rowData) === 'undefined' || rowData == null || rowData == '') { diff --git a/cloud-common-plugin-dynamic/src/main/resources/templates/codetemplate/default/service/IService.ftl b/cloud-common-plugin-dynamic/src/main/resources/templates/codetemplate/default/service/IService.ftl index 81bb13c..926d7ff 100644 --- a/cloud-common-plugin-dynamic/src/main/resources/templates/codetemplate/default/service/IService.ftl +++ b/cloud-common-plugin-dynamic/src/main/resources/templates/codetemplate/default/service/IService.ftl @@ -50,6 +50,14 @@ public interface I${firstUpperTableName}Service { */ SuccessResult remove${firstUpperTableName}(String ids) throws RemoveException; + /** + * 删除${tableExplain}(物理删除) + * + * @param ids + * @throws RemoveException + */ + void delete${firstUpperTableName}(String ids) throws RemoveException; + /** * 删除${tableExplain}(APP) * @@ -108,4 +116,22 @@ public interface I${firstUpperTableName}Service { */ SuccessResultList> listPage${firstUpperTableName}(ListPage page) throws SearchException; -} + /** + * ${tableExplain}统计 + * + * @param params + * @return + * @throws SearchException + */ + Integer countNumber${firstUpperTableName}(Map params) throws SearchException; + + /** + * ${tableExplain}统计 + * + * @param params + * @return + * @throws SearchException + */ + SuccessResultData count${firstUpperTableName}(Map params) throws SearchException; + +} \ No newline at end of file diff --git a/cloud-common-plugin-dynamic/src/main/resources/templates/codetemplate/default/service/ServiceImpl.ftl b/cloud-common-plugin-dynamic/src/main/resources/templates/codetemplate/default/service/ServiceImpl.ftl index 154ee5b..31bb997 100644 --- a/cloud-common-plugin-dynamic/src/main/resources/templates/codetemplate/default/service/ServiceImpl.ftl +++ b/cloud-common-plugin-dynamic/src/main/resources/templates/codetemplate/default/service/ServiceImpl.ftl @@ -5,6 +5,7 @@ import com.cm.common.exception.SaveException; import com.cm.common.exception.SearchException; import com.cm.common.pojo.ListPage; import com.cm.common.result.SuccessResult; +import com.cm.common.result.SuccessResultData; import com.cm.common.result.SuccessResultList; import com.cm.common.utils.HashMapUtil; import com.cm.common.utils.UUIDUtil; @@ -92,6 +93,13 @@ public class ${firstUpperTableName}ServiceImpl extends BaseService implements I$ ${firstLowerTableName}Dao.remove${firstUpperTableName}(params); } + @Override + public void delete${firstUpperTableName}(String ids) throws RemoveException { + Map params = getHashMap(3); + params.put("${firstLowerTableName}Ids", Arrays.asList(ids.split("_"))); + ${firstLowerTableName}Dao.delete${firstUpperTableName}(params); + } + @Override public SuccessResult update${firstUpperTableName}(String ${firstLowerTableName}Id, ${firstUpperTableName}VO ${firstLowerTableName}VO) throws Exception { update${firstUpperTableName}Info(null, ${firstLowerTableName}Id, ${firstLowerTableName}VO); @@ -142,4 +150,15 @@ public class ${firstUpperTableName}ServiceImpl extends BaseService implements I$ return new SuccessResultList<>(${firstLowerTableName}DTOs, pageInfo.getPageNum(), pageInfo.getTotal()); } -} + @Override + Integer countNumber${firstUpperTableName}(Map params) throws SearchException { + Integer count = ${firstLowerTableName}Dao.count${firstUpperTableName}(params); + return count == null ? 0 : count; + } + + @Override + SuccessResultData count${firstUpperTableName}(Map params) throws SearchException { + return new SuccessResultData<>(countNumber${firstUpperTableName}(params)); + } + +} \ No newline at end of file