mirror of https://github.com/elunez/eladmin
优化badsmell:包括空指针以及多次使用变量的提取
parent
7d68d58bbd
commit
4a3a564298
|
@ -59,6 +59,7 @@ public class GeneratorServiceImpl implements GeneratorService {
|
||||||
|
|
||||||
private final ColumnInfoRepository columnInfoRepository;
|
private final ColumnInfoRepository columnInfoRepository;
|
||||||
|
|
||||||
|
private final String CONFIG_MESSAGE = "请先配置生成器";
|
||||||
@Override
|
@Override
|
||||||
public Object getTables() {
|
public Object getTables() {
|
||||||
// 使用预编译防止sql注入
|
// 使用预编译防止sql注入
|
||||||
|
@ -169,7 +170,7 @@ public class GeneratorServiceImpl implements GeneratorService {
|
||||||
@Override
|
@Override
|
||||||
public void generator(GenConfig genConfig, List<ColumnInfo> columns) {
|
public void generator(GenConfig genConfig, List<ColumnInfo> columns) {
|
||||||
if (genConfig.getId() == null) {
|
if (genConfig.getId() == null) {
|
||||||
throw new BadRequestException("请先配置生成器");
|
throw new BadRequestException(CONFIG_MESSAGE);
|
||||||
}
|
}
|
||||||
try {
|
try {
|
||||||
GenUtil.generatorCode(columns, genConfig);
|
GenUtil.generatorCode(columns, genConfig);
|
||||||
|
@ -182,7 +183,7 @@ public class GeneratorServiceImpl implements GeneratorService {
|
||||||
@Override
|
@Override
|
||||||
public ResponseEntity<Object> preview(GenConfig genConfig, List<ColumnInfo> columns) {
|
public ResponseEntity<Object> preview(GenConfig genConfig, List<ColumnInfo> columns) {
|
||||||
if (genConfig.getId() == null) {
|
if (genConfig.getId() == null) {
|
||||||
throw new BadRequestException("请先配置生成器");
|
throw new BadRequestException(CONFIG_MESSAGE);
|
||||||
}
|
}
|
||||||
List<Map<String, Object>> genList = GenUtil.preview(columns, genConfig);
|
List<Map<String, Object>> genList = GenUtil.preview(columns, genConfig);
|
||||||
return new ResponseEntity<>(genList, HttpStatus.OK);
|
return new ResponseEntity<>(genList, HttpStatus.OK);
|
||||||
|
@ -191,7 +192,7 @@ public class GeneratorServiceImpl implements GeneratorService {
|
||||||
@Override
|
@Override
|
||||||
public void download(GenConfig genConfig, List<ColumnInfo> columns, HttpServletRequest request, HttpServletResponse response) {
|
public void download(GenConfig genConfig, List<ColumnInfo> columns, HttpServletRequest request, HttpServletResponse response) {
|
||||||
if (genConfig.getId() == null) {
|
if (genConfig.getId() == null) {
|
||||||
throw new BadRequestException("请先配置生成器");
|
throw new BadRequestException(CONFIG_MESSAGE);
|
||||||
}
|
}
|
||||||
try {
|
try {
|
||||||
File file = new File(GenUtil.download(columns, genConfig));
|
File file = new File(GenUtil.download(columns, genConfig));
|
||||||
|
|
|
@ -114,7 +114,7 @@ public class MenuServiceImpl implements MenuService {
|
||||||
throw new EntityExistException(Menu.class,"componentName",resources.getComponentName());
|
throw new EntityExistException(Menu.class,"componentName",resources.getComponentName());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if(resources.getPid().equals(0L)){
|
if (Long.valueOf(0L).equals(resources.getPid())) {
|
||||||
resources.setPid(null);
|
resources.setPid(null);
|
||||||
}
|
}
|
||||||
if(resources.getIFrame()){
|
if(resources.getIFrame()){
|
||||||
|
|
Loading…
Reference in New Issue