【fix sonar】CodeGenerateOneToMany文件

This commit is contained in:
梁琦涛
2023-04-03 11:04:52 +08:00
parent 46f0f8b784
commit 43ef42ab9d
@@ -1,14 +1,5 @@
package com.jero.codegenerate.generate.impl;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.Iterator;
import java.util.List;
import java.util.Map;
import com.jero.codegenerate.properties.CodeConfigProperties;
import lombok.extern.slf4j.Slf4j;
import org.apache.commons.lang.StringUtils;
import com.jero.codegenerate.database.DbReadTableUtil;
import com.jero.codegenerate.generate.IGenerate;
import com.jero.codegenerate.generate.config.CreateFileConfig;
@@ -17,6 +8,16 @@ import com.jero.codegenerate.generate.pojo.ColumnVo;
import com.jero.codegenerate.generate.pojo.onetomany.MainTableVo;
import com.jero.codegenerate.generate.pojo.onetomany.SubTableVo;
import com.jero.codegenerate.generate.util.NonceUtils;
import com.jero.codegenerate.properties.CodeConfigProperties;
import lombok.extern.slf4j.Slf4j;
import org.apache.commons.lang.StringUtils;
import java.io.IOException;
import java.sql.SQLException;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
@Slf4j
public class CodeGenerateOneToMany extends BaseCodeGenerate implements IGenerate {
@@ -45,7 +46,7 @@ public class CodeGenerateOneToMany extends BaseCodeGenerate implements IGenerate
* @return java.util.Map<java.lang.String,java.lang.Object>
*/
@Override
public Map<String, Object> getCodeGenerateConfig() throws Exception {
public Map<String, Object> getCodeGenerateConfig() throws SQLException, ClassNotFoundException {
HashMap<String,Object> hashMap = new HashMap<>();
// 包名
hashMap.put("bussiPackage", com.jero.codegenerate.properties.CodeConfigProperties.packageName);
@@ -94,8 +95,8 @@ public class CodeGenerateOneToMany extends BaseCodeGenerate implements IGenerate
setSubTableVo();
// put从表集合
hashMap.put("subTables", this.subTables);
} catch (Exception e) {
throw e;
} catch (SQLException | ClassNotFoundException throwAbles) {
throw throwAbles;
}
long serialVersionUID = NonceUtils.getSecureRandomLong() + NonceUtils.getCurrentTimeMillis();
@@ -104,7 +105,7 @@ public class CodeGenerateOneToMany extends BaseCodeGenerate implements IGenerate
return hashMap;
}
private void setSubTableVo() throws Exception {
private void setSubTableVo() throws SQLException, ClassNotFoundException {
for (SubTableVo subTableVo : this.subTables) {
// 从表(局部变量)
List<ColumnVo> originalColumns;
@@ -135,7 +136,7 @@ public class CodeGenerateOneToMany extends BaseCodeGenerate implements IGenerate
}
@Override
public List<String> generateCodeFile(String stylePath) throws Exception {
public List<String> generateCodeFile(String stylePath) throws SQLException, ClassNotFoundException, IOException {
String projectPath = com.jero.codegenerate.properties.CodeConfigProperties.projectPath;
Map<String, Object> configMap = this.getCodeGenerateConfig();
String templateUrl = com.jero.codegenerate.properties.CodeConfigProperties.templateUrl;
@@ -152,7 +153,7 @@ public class CodeGenerateOneToMany extends BaseCodeGenerate implements IGenerate
}
@Override
public List<String> generateCodeFile(String projectPath, String templatePath, String stylePath) throws Exception {
public List<String> generateCodeFile(String projectPath, String templatePath, String stylePath) throws SQLException, IOException, ClassNotFoundException {
if (projectPath != null && !"".equals(projectPath)) {
com.jero.codegenerate.properties.CodeConfigProperties.setProjectPath(projectPath);
}