|
@@ -110,40 +110,40 @@ public class CommonServiceImpl implements ICommonService {
|
|
|
|
|
|
|
|
|
public List<CommonEntity> queryGroupTableList(CommonEntity commonEntity, TableSql tableSql) {
|
|
|
- //前端传递过来的参数
|
|
|
- Map<String, Object> queryMap = commonEntity.getQueryMap();
|
|
|
- //是否存在
|
|
|
- AtomicReference<Boolean> isExist= new AtomicReference<>(true);
|
|
|
- //循环前端传过来的参数 跳过 sqlkey
|
|
|
- AtomicReference<String> replaceSql= new AtomicReference<>(tableSql.getTableCondition());
|
|
|
- queryMap.forEach((k,v)->{
|
|
|
- if(!k.equals("sqlkey")){ //查询第一个表的数据是不会进行任何替换的
|
|
|
- int isExistIndex = tableSql.getTableCondition().indexOf(k);
|
|
|
- replaceSql.set(tableSql.getTableCondition().replace(k, v.toString()));
|
|
|
- if(isExistIndex<0){
|
|
|
- isExist.set(false);
|
|
|
- }
|
|
|
- }
|
|
|
- });
|
|
|
- //证明条件不对应不能让他进行查询
|
|
|
- if(!isExist.get()){
|
|
|
- List<CommonEntity> commonEntityList = new ArrayList<>();
|
|
|
- CommonEntity common = new CommonEntity();
|
|
|
- HashMap<String, Object> hashMap=new HashMap();
|
|
|
- hashMap.put("err","查询条件不匹配查询失败");
|
|
|
- common.setResultMap(hashMap);
|
|
|
- commonEntityList.add(common);
|
|
|
- return commonEntityList;
|
|
|
- }
|
|
|
- Map<String, Object> conditions = JSONObject.parseObject(JSON.toJSONString(commonEntity.getQueryMap()));
|
|
|
+ //前端传递过来的参数
|
|
|
+ Map<String, Object> queryMap = commonEntity.getQueryMap();
|
|
|
+ //是否存在
|
|
|
+ AtomicReference<Boolean> isExist = new AtomicReference<>(true);
|
|
|
+ //循环前端传过来的参数 跳过 sqlkey
|
|
|
+ AtomicReference<String> replaceSql = new AtomicReference<>(tableSql.getTableCondition());
|
|
|
+ queryMap.forEach((k, v) -> {
|
|
|
+ if (!k.equals("sqlkey")) { //查询第一个表的数据是不会进行任何替换的
|
|
|
+ int isExistIndex = tableSql.getTableCondition().indexOf(k);
|
|
|
+ replaceSql.set(tableSql.getTableCondition().replace(k, v.toString()));
|
|
|
+ if (isExistIndex < 0) {
|
|
|
+ isExist.set(false);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ });
|
|
|
+ //证明条件不对应不能让他进行查询
|
|
|
+ if (!isExist.get()) {
|
|
|
+ List<CommonEntity> commonEntityList = new ArrayList<>();
|
|
|
+ CommonEntity common = new CommonEntity();
|
|
|
+ HashMap<String, Object> hashMap = new HashMap();
|
|
|
+ hashMap.put("err", "查询条件不匹配查询失败");
|
|
|
+ common.setResultMap(hashMap);
|
|
|
+ commonEntityList.add(common);
|
|
|
+ return commonEntityList;
|
|
|
+ }
|
|
|
+ Map<String, Object> conditions = JSONObject.parseObject(JSON.toJSONString(commonEntity.getQueryMap()));
|
|
|
|
|
|
- //正常的查询
|
|
|
- String queryCriteriaValue =
|
|
|
- conditions.containsKey("queryCriteriaValue") == true
|
|
|
- ? conditions.get("queryCriteriaValue").toString() : "";
|
|
|
- String endSQL = replaceSql.get().replace("#{val}", queryCriteriaValue);
|
|
|
- String sqlString=tableSql.getTableSql() + " where " + endSQL;
|
|
|
- return commonMapper.queryTableList(sqlString);
|
|
|
+ //正常的查询
|
|
|
+ String queryCriteriaValue =
|
|
|
+ conditions.containsKey("queryCriteriaValue") == true
|
|
|
+ ? conditions.get("queryCriteriaValue").toString() : "";
|
|
|
+ String endSQL = replaceSql.get().replace("#{val}", queryCriteriaValue);
|
|
|
+ String sqlString = tableSql.getTableSql() + " where " + endSQL;
|
|
|
+ return commonMapper.queryTableList(sqlString);
|
|
|
}
|
|
|
|
|
|
|
|
@@ -286,7 +286,14 @@ public class CommonServiceImpl implements ICommonService {
|
|
|
public CommonEntity getInfoById(CommonEntity commonEntity) {
|
|
|
String tableName = (String) commonEntity.getBasicMap().get("tableName");
|
|
|
Map<String, Object> conditions = JSONObject.parseObject(JSON.toJSONString(commonEntity.getConditionMap()));
|
|
|
- return commonMapper.getInfoById(tableName,conditions);
|
|
|
+ CommonEntity common = new CommonEntity();
|
|
|
+ Map<String, Object> retMap = commonMapper.getInfoById(tableName, conditions).getResultMap();
|
|
|
+ Map<String, Object> retMap1 = new HashMap<>();
|
|
|
+ retMap.keySet().forEach(item -> {
|
|
|
+ retMap1.put(toUnderScoreCase(item), retMap.get(item));
|
|
|
+ });
|
|
|
+ common.setResultMap(retMap1);
|
|
|
+ return common;
|
|
|
}
|
|
|
|
|
|
public static String extractSubstring(String input, String identifier) {
|