This commit is contained in:
20932067@zju.edu.cn 2021-04-10 22:03:41 +08:00
parent 35063a87df
commit ff4156d965
5 changed files with 26 additions and 30 deletions

View File

@ -38,7 +38,6 @@ public class FileUtils extends org.apache.commons.io.FileUtils {
os.write(b, 0, length);
}
} catch (IOException e) {
System.out.println(e);
throw e;
} finally {
if (os != null) {

View File

@ -21,13 +21,6 @@ public class Config {
private static String profile;
public void setProfile(String profile){
Config.profile = profile;
}
public static String getProfile() {
return profile;
}

View File

@ -167,11 +167,9 @@ public class GenController extends GenBaseController {
@GetMapping("/download/{tableName}")
public void download(HttpServletResponse response, @PathVariable("tableName") String tableName) throws IOException {
byte[] data = genTableService.downloadCode(tableName);
genCode(response, data);
}
/**
* 生成代码自定义路径
*/
@ -217,6 +215,7 @@ public class GenController extends GenBaseController {
/**
* 将bytes流写入到本地
*
* @param bytes
*/
public boolean compress(byte[] bytes) {

View File

@ -559,6 +559,8 @@ public class GenTableServiceImpl implements GenTableService {
} else if (GenStringUtils.isEmpty(genTable.getSubTableFkName())) {
throw new GenCustomException("子表关联的外键名不能为空");
}
} else if (GenConstants.TPL_ASS.equals(genTable.getTplCategory())) {
// todo 规则校验
}
}
}

View File

@ -101,7 +101,7 @@ public class QueryServiceImpl implements QueryService {
try {
int uqrenewal = uniQueryDao.updateUniQuery(uniQuery);
if (uqrenewal > 0) {
if (uniQuery.getUniCons() != null) {
if (uniQuery.getUniCons() != null && uniQuery.getUniCons().size() > 0) {
queryDao.deleteUniCon(uniQuery.getId());
Integer ucrenewal = queryDao.insertUniCon(uniQuery.getUniCons());
if (ucrenewal == 0) {
@ -123,16 +123,19 @@ public class QueryServiceImpl implements QueryService {
try {
StringBuilder sql = new StringBuilder(uniQuery.getUqSql().toLowerCase());
List<UniCon> uniConList = uniQuery.getUniCons();
if (sql.toString().contains("insert") || sql.toString().contains("delete ") || sql.toString().contains("update ") || sql.toString().contains("drop ") || sql.toString().contains("database ") || sql.toString().contains("create ") || sql.toString().contains("view ") || sql.toString().contains("alter ")) {
return new GenServerResult<>(false, "sql语句含有insert,delete,update,drop,database,view,alter等特殊字符!");
if (sql.toString().contains("insert") || sql.toString().contains("delete ") || sql.toString().contains("update ") ||
sql.toString().contains("drop ") || sql.toString().contains("database ") || sql.toString().contains("create ") ||
sql.toString().contains("view ") || sql.toString().contains("alter ")|| sql.toString().contains("gen_")) {
return new GenServerResult<>(false, "sql语句含有insert,delete,update,drop,database,view,alter,gen_等特殊字符!");
}
if (uniConList.size() > 0) {
sql.append(" where 1 = 1");
for (UniCon uniCon : uniConList) {
if(!uniCon.getUcMock().equals("")){
sql.append(conversionPreview(uniCon));
}
}
}
List<Map<String, Object>> dataMap = queryDao.UniQuery(sql.toString());
return new GenServerResult<>(true, dataMap);
} catch (RuntimeException e) {