调整代码静态化

This commit is contained in:
wenc000 2020-04-26 12:50:10 +08:00
parent 7a3b10ee58
commit ed2989c375
11 changed files with 131 additions and 31 deletions

View File

@ -200,6 +200,7 @@ public class DynamicConfigTableServiceImpl extends AbstractService implements ID
|| StringUtils.equals(FieldTypeEnum.LEFT_JOIN.getValue(), dynamicConfigFormDTO.getFieldType()) || StringUtils.equals(FieldTypeEnum.LEFT_JOIN.getValue(), dynamicConfigFormDTO.getFieldType())
|| StringUtils.equals(FieldTypeEnum.RIGHT_JOIN.getValue(), dynamicConfigFormDTO.getFieldType())) { || StringUtils.equals(FieldTypeEnum.RIGHT_JOIN.getValue(), dynamicConfigFormDTO.getFieldType())) {
field.put("joinTable", dynamicConfigFormDTO.getJoinTable()); field.put("joinTable", dynamicConfigFormDTO.getJoinTable());
field.put("firstUpperJoinTable", WStringUtil.firstToUpper(dynamicConfigFormDTO.getJoinTable()));
field.put("lowerJoinTable", dynamicConfigFormDTO.getJoinTable().toLowerCase()); field.put("lowerJoinTable", dynamicConfigFormDTO.getJoinTable().toLowerCase());
field.put("underLineJoinTable", WStringUtil.lowerUpper2UnderLine(dynamicConfigFormDTO.getJoinTable())); field.put("underLineJoinTable", WStringUtil.lowerUpper2UnderLine(dynamicConfigFormDTO.getJoinTable()));
field.put("joinTableField", dynamicConfigFormDTO.getJoinTableField()); field.put("joinTableField", dynamicConfigFormDTO.getJoinTableField());

View File

@ -10,6 +10,7 @@ import com.cm.common.pojo.ListPage;
import com.cm.common.pojo.dtos.CurrentUserIdInfoDTO; import com.cm.common.pojo.dtos.CurrentUserIdInfoDTO;
import com.cm.common.result.ErrorResult; import com.cm.common.result.ErrorResult;
import com.cm.common.result.SuccessResult; import com.cm.common.result.SuccessResult;
import com.cm.common.result.SuccessResultData;
import com.cm.common.result.SuccessResultList; import com.cm.common.result.SuccessResultList;
import ${basePackage}.pojo.dtos.${lowerTableName}.${firstUpperTableName}DTO; import ${basePackage}.pojo.dtos.${lowerTableName}.${firstUpperTableName}DTO;
import ${basePackage}.pojo.vos.${lowerTableName}.${firstUpperTableName}VO; import ${basePackage}.pojo.vos.${lowerTableName}.${firstUpperTableName}VO;
@ -102,6 +103,14 @@ public class ${firstUpperTableName}Controller extends AbstractController {
return ${firstLowerTableName}Service.listPage${firstUpperTableName}(page); return ${firstLowerTableName}Service.listPage${firstUpperTableName}(page);
} }
@ApiOperation(value = "${tableExplain}统计", notes = "${tableExplain}统计接口")
@ApiResponses({@ApiResponse(code = 400, message = "请求失败", response = ErrorResult.class)})
@GetMapping("count${lowerTableName}")
SuccessResultData<Integer> count${firstUpperTableName}() throws SearchException {
Map<String, Object> params = requestParams();
return ${firstLowerTableName}Service.count${firstUpperTableName}(params);
}
@ApiOperation(value = "当前用户id信息", notes = "当前用户id信息接口") @ApiOperation(value = "当前用户id信息", notes = "当前用户id信息接口")
@ApiResponses({@ApiResponse(code = 400, message = "请求失败", response = ErrorResult.class)}) @ApiResponses({@ApiResponse(code = 400, message = "请求失败", response = ErrorResult.class)})
@GetMapping("getcurrentuseridinfo") @GetMapping("getcurrentuseridinfo")

View File

@ -8,6 +8,7 @@ import com.cm.common.exception.SearchException;
import com.cm.common.pojo.ListPage; import com.cm.common.pojo.ListPage;
import com.cm.common.result.ErrorResult; import com.cm.common.result.ErrorResult;
import com.cm.common.result.SuccessResult; import com.cm.common.result.SuccessResult;
import com.cm.common.result.SuccessResultData;
import com.cm.common.result.SuccessResultList; import com.cm.common.result.SuccessResultList;
import ${basePackage}.pojo.dtos.${lowerTableName}.${firstUpperTableName}DTO; import ${basePackage}.pojo.dtos.${lowerTableName}.${firstUpperTableName}DTO;
import ${basePackage}.pojo.vos.${lowerTableName}.${firstUpperTableName}VO; import ${basePackage}.pojo.vos.${lowerTableName}.${firstUpperTableName}VO;
@ -108,4 +109,12 @@ public class ${firstUpperTableName}AppController extends AbstractController {
return ${firstLowerTableName}Service.listPage${firstUpperTableName}(page); return ${firstLowerTableName}Service.listPage${firstUpperTableName}(page);
} }
@ApiOperation(value = "${tableExplain}统计", notes = "${tableExplain}统计接口")
@ApiResponses({@ApiResponse(code = 400, message = "请求失败", response = ErrorResult.class)})
@GetMapping("count${lowerTableName}")
SuccessResultData<Integer> count${firstUpperTableName}() throws SearchException {
Map<String, Object> params = requestParams();
return ${firstLowerTableName}Service.count${firstUpperTableName}(params);
}
} }

View File

@ -8,6 +8,7 @@ import com.cm.common.exception.SearchException;
import com.cm.common.pojo.ListPage; import com.cm.common.pojo.ListPage;
import com.cm.common.result.ErrorResult; import com.cm.common.result.ErrorResult;
import com.cm.common.result.SuccessResult; import com.cm.common.result.SuccessResult;
import com.cm.common.result.SuccessResultData;
import com.cm.common.result.SuccessResultList; import com.cm.common.result.SuccessResultList;
import ${basePackage}.pojo.dtos.${lowerTableName}.${firstUpperTableName}DTO; import ${basePackage}.pojo.dtos.${lowerTableName}.${firstUpperTableName}DTO;
import ${basePackage}.pojo.vos.${lowerTableName}.${firstUpperTableName}VO; import ${basePackage}.pojo.vos.${lowerTableName}.${firstUpperTableName}VO;
@ -108,4 +109,12 @@ public class ${firstUpperTableName}ResourceController extends AbstractController
return ${firstLowerTableName}Service.listPage${firstUpperTableName}(page); return ${firstLowerTableName}Service.listPage${firstUpperTableName}(page);
} }
@ApiOperation(value = "${tableExplain}统计", notes = "${tableExplain}统计接口")
@ApiResponses({@ApiResponse(code = 400, message = "请求失败", response = ErrorResult.class)})
@GetMapping("count${lowerTableName}")
SuccessResultData<Integer> count${firstUpperTableName}() throws SearchException {
Map<String, Object> params = requestParams();
return ${firstLowerTableName}Service.count${firstUpperTableName}(params);
}
} }

View File

@ -37,6 +37,14 @@ public interface I${firstUpperTableName}Dao {
*/ */
void remove${firstUpperTableName}(Map<String, Object> params) throws RemoveException; void remove${firstUpperTableName}(Map<String, Object> params) throws RemoveException;
/**
* 删除${tableExplain}(物理)
*
* @param params
* @throws RemoveException
*/
void delete${firstUpperTableName}(Map<String, Object> params) throws RemoveException;
/** /**
* 修改${tableExplain} * 修改${tableExplain}
* *
@ -62,5 +70,14 @@ public interface I${firstUpperTableName}Dao {
* @throws SearchException * @throws SearchException
*/ */
List<${firstUpperTableName}DTO> list${firstUpperTableName}(Map<String, Object> params) throws SearchException; List<${firstUpperTableName}DTO> list${firstUpperTableName}(Map<String, Object> params) throws SearchException;
} /**
* ${tableExplain}统计
*
* @param params
* @return
* @throws SearchException
*/
Integer count${firstUpperTableName}(Map<String, Object> params) throws SearchException;
}

View File

@ -15,7 +15,7 @@
<#if field.fieldType == "innerJoin" || field.fieldType == "leftJoin" || field.fieldType == "rightJoin"> <#if field.fieldType == "innerJoin" || field.fieldType == "leftJoin" || field.fieldType == "rightJoin">
<#list field.listJoinTableField! as joinTableField> <#list field.listJoinTableField! as joinTableField>
<#if joinTableField.listShow == 1> <#if joinTableField.listShow == 1>
<result column="${joinTableField.underLineFieldName}_join_by_${field.underLineFieldName}" property="${joinTableField.fieldName}JoinBy${field.firstUpperFieldName}"/> <result column="${field.underLineJoinTable}_${joinTableField.underLineFieldName}" property="${field.joinTable}${joinTableField.firstUpperFieldName}"/>
</#if> </#if>
</#list> </#list>
</#if> </#if>
@ -63,6 +63,17 @@
</foreach> </foreach>
</update> </update>
<!-- 删除${tableExplain}(物理) -->
<update id="delete${firstUpperTableName}" parameterType="map">
DELETE FROM
${tablePrefix}${underLineTableName}
WHERE
${underLineTableName}_id IN
<foreach collection="${firstLowerTableName}Ids" index="index" open="(" separator="," close=")">
${r"#{"}${firstLowerTableName}${r"Ids[${index}]}"}
</foreach>
</update>
<!-- 修改${tableExplain} --> <!-- 修改${tableExplain} -->
<update id="update${firstUpperTableName}" parameterType="map"> <update id="update${firstUpperTableName}" parameterType="map">
UPDATE UPDATE
@ -112,7 +123,7 @@
t1.${field.underLineFieldName}, t1.${field.underLineFieldName},
<#-- 字典 start --> <#-- 字典 start -->
<#if field.fieldType == "radio" || field.fieldType == "checkbox" || field.fieldType == "select"> <#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,
</#if> </#if>
<#-- 字典 end --> <#-- 字典 end -->
</#if> </#if>
@ -120,7 +131,7 @@
<#if field.fieldType == "innerJoin" || field.fieldType == "leftJoin" || field.fieldType == "rightJoin"> <#if field.fieldType == "innerJoin" || field.fieldType == "leftJoin" || field.fieldType == "rightJoin">
<#list field.listJoinTableField! as joinTableField> <#list field.listJoinTableField! as joinTableField>
<#if joinTableField.listShow == 1> <#if joinTableField.listShow == 1>
jt${field.joinTableIndex}.${joinTableField.underLineFieldName} ${joinTableField.underLineFieldName}_join_by_${field.underLineFieldName}, jt${field.joinTableIndex}.${joinTableField.underLineFieldName} ${field.underLineJoinTable}_${joinTableField.underLineFieldName},
</#if> </#if>
</#list> </#list>
</#if> </#if>
@ -135,7 +146,7 @@
LEFT JOIN LEFT JOIN
data_dictionary dt${field.dictionaryIndex} data_dictionary dt${field.dictionaryIndex}
ON ON
FIND_IN_SET(dt${field.dictionaryIndex}.dictionary_id, t1.${field.underLineFieldName}) dt${field.dictionaryIndex}.dictionary_id = t1.${field.underLineFieldName}
AND AND
dt${field.dictionaryIndex}.is_delete = 0 dt${field.dictionaryIndex}.is_delete = 0
</#if> </#if>
@ -161,6 +172,11 @@
t1.is_delete = 0 t1.is_delete = 0
<if test="keywords != null and keywords != ''"> <if test="keywords != null and keywords != ''">
<!-- 这里添加检索关键字 --> <!-- 这里添加检索关键字 -->
AND (
t1.id LIKE CONCAT('%', #{keywords}, '%')
OR
t1.${underLineTableName}_id LIKE CONCAT('%', #{keywords}, '%')
)
</if> </if>
<if test="startTime != null and startTime != ''"> <if test="startTime != null and startTime != ''">
AND AND
@ -177,22 +193,16 @@
${r"#{"}${firstLowerTableName}${r"Ids[${index}]}"} ${r"#{"}${firstLowerTableName}${r"Ids[${index}]}"}
</foreach> </foreach>
</if> </if>
GROUP BY </select>
<#list fieldList! as field>
<#if field.listShow == 1> <!-- ${tableExplain}统计 -->
t1.${field.underLineFieldName}, <select id="count${firstUpperTableName}" parameterType="map" resultMap="Integer">
</#if> SELECT
<#-- 联表 start --> COUNT(*)
<#if field.fieldType == "innerJoin" || field.fieldType == "leftJoin" || field.fieldType == "rightJoin"> FROM
<#list field.listJoinTableField! as joinTableField> ${tablePrefix}${underLineTableName} t1
<#if joinTableField.listShow == 1> WHERE
jt${field.joinTableIndex}.${joinTableField.underLineFieldName}, t1.is_delete = 0
</#if>
</#list>
</#if>
<#-- 联表 end -->
</#list>
t1.${underLineTableName}_id
</select> </select>
</mapper> </mapper>

View File

@ -33,8 +33,8 @@ public class ${firstUpperTableName}DTO {
private String ${field.fieldName}; private String ${field.fieldName};
<#list field.listJoinTableField! as joinTableField> <#list field.listJoinTableField! as joinTableField>
<#if joinTableField.listShow == 1> <#if joinTableField.listShow == 1>
@ApiModelProperty(name = "${joinTableField.fieldName}JoinBy${field.firstUpperFieldName}", value = "${field.fieldExplain}的${joinTableField.fieldExplain}") @ApiModelProperty(name = "${field.joinTable}${joinTableField.firstUpperFieldName}", value = "${joinTableField.fieldExplain}")
private String ${joinTableField.fieldName}JoinBy${field.firstUpperFieldName}; private String ${field.joinTable}${joinTableField.firstUpperFieldName};
</#if> </#if>
</#list> </#list>
<#else> <#else>
@ -97,12 +97,12 @@ public class ${firstUpperTableName}DTO {
<#list field.listJoinTableField! as joinTableField> <#list field.listJoinTableField! as joinTableField>
<#if joinTableField.listShow == 1> <#if joinTableField.listShow == 1>
public String get${joinTableField.firstUpperFieldName}JoinBy${field.firstUpperFieldName}() { public String get${field.firstUpperJoinTable}${joinTableField.firstUpperFieldName}() {
return ${joinTableField.fieldName}JoinBy${field.firstUpperFieldName} == null ? "" : ${joinTableField.fieldName}JoinBy${field.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}) { public void set${field.firstUpperJoinTable}${joinTableField.firstUpperFieldName}(String ${field.joinTable}${joinTableField.firstUpperFieldName}) {
this.${joinTableField.fieldName}JoinBy${field.firstUpperFieldName} = ${joinTableField.fieldName}JoinBy${field.firstUpperFieldName}; this.${field.joinTable}${joinTableField.firstUpperFieldName} = ${field.joinTable}${joinTableField.firstUpperFieldName};
} }
</#if> </#if>

View File

@ -145,7 +145,7 @@
<#if field.fieldType == "innerJoin" || field.fieldType == "leftJoin" || field.fieldType == "rightJoin"> <#if field.fieldType == "innerJoin" || field.fieldType == "leftJoin" || field.fieldType == "rightJoin">
<#list field.listJoinTableField! as joinTableField> <#list field.listJoinTableField! as joinTableField>
<#if joinTableField.listShow == 1> <#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) { templet: function(row) {
var rowData = row[this.field]; var rowData = row[this.field];
if(typeof(rowData) === 'undefined' || rowData == null || rowData == '') { if(typeof(rowData) === 'undefined' || rowData == null || rowData == '') {

View File

@ -50,6 +50,14 @@ public interface I${firstUpperTableName}Service {
*/ */
SuccessResult remove${firstUpperTableName}(String ids) throws RemoveException; SuccessResult remove${firstUpperTableName}(String ids) throws RemoveException;
/**
* 删除${tableExplain}(物理删除)
*
* @param ids
* @throws RemoveException
*/
void delete${firstUpperTableName}(String ids) throws RemoveException;
/** /**
* 删除${tableExplain}(APP) * 删除${tableExplain}(APP)
* *
@ -108,4 +116,22 @@ public interface I${firstUpperTableName}Service {
*/ */
SuccessResultList<List<${firstUpperTableName}DTO>> listPage${firstUpperTableName}(ListPage page) throws SearchException; SuccessResultList<List<${firstUpperTableName}DTO>> listPage${firstUpperTableName}(ListPage page) throws SearchException;
} /**
* ${tableExplain}统计
*
* @param params
* @return
* @throws SearchException
*/
Integer countNumber${firstUpperTableName}(Map<String, Object> params) throws SearchException;
/**
* ${tableExplain}统计
*
* @param params
* @return
* @throws SearchException
*/
SuccessResultData<Integer> count${firstUpperTableName}(Map<String, Object> params) throws SearchException;
}

View File

@ -5,6 +5,7 @@ import com.cm.common.exception.SaveException;
import com.cm.common.exception.SearchException; import com.cm.common.exception.SearchException;
import com.cm.common.pojo.ListPage; import com.cm.common.pojo.ListPage;
import com.cm.common.result.SuccessResult; import com.cm.common.result.SuccessResult;
import com.cm.common.result.SuccessResultData;
import com.cm.common.result.SuccessResultList; import com.cm.common.result.SuccessResultList;
import com.cm.common.utils.HashMapUtil; import com.cm.common.utils.HashMapUtil;
import com.cm.common.utils.UUIDUtil; import com.cm.common.utils.UUIDUtil;
@ -92,6 +93,13 @@ public class ${firstUpperTableName}ServiceImpl extends BaseService implements I$
${firstLowerTableName}Dao.remove${firstUpperTableName}(params); ${firstLowerTableName}Dao.remove${firstUpperTableName}(params);
} }
@Override
public void delete${firstUpperTableName}(String ids) throws RemoveException {
Map<String, Object> params = getHashMap(3);
params.put("${firstLowerTableName}Ids", Arrays.asList(ids.split("_")));
${firstLowerTableName}Dao.delete${firstUpperTableName}(params);
}
@Override @Override
public SuccessResult update${firstUpperTableName}(String ${firstLowerTableName}Id, ${firstUpperTableName}VO ${firstLowerTableName}VO) throws Exception { public SuccessResult update${firstUpperTableName}(String ${firstLowerTableName}Id, ${firstUpperTableName}VO ${firstLowerTableName}VO) throws Exception {
update${firstUpperTableName}Info(null, ${firstLowerTableName}Id, ${firstLowerTableName}VO); 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()); return new SuccessResultList<>(${firstLowerTableName}DTOs, pageInfo.getPageNum(), pageInfo.getTotal());
} }
} @Override
Integer countNumber${firstUpperTableName}(Map<String, Object> params) throws SearchException {
Integer count = ${firstLowerTableName}Dao.count${firstUpperTableName}(params);
return count == null ? 0 : count;
}
@Override
SuccessResultData<Integer> count${firstUpperTableName}(Map<String, Object> params) throws SearchException {
return new SuccessResultData<>(countNumber${firstUpperTableName}(params));
}
}