|
@@ -3,8 +3,12 @@ package com.ruoyi.system.service.impl;
|
|
import com.alibaba.fastjson2.JSON;
|
|
import com.alibaba.fastjson2.JSON;
|
|
import com.alibaba.fastjson2.JSONObject;
|
|
import com.alibaba.fastjson2.JSONObject;
|
|
import com.ruoyi.common.utils.CollectionUtil;
|
|
import com.ruoyi.common.utils.CollectionUtil;
|
|
|
|
+import com.ruoyi.system.entity.CommonEntity;
|
|
|
|
+import com.ruoyi.system.entity.TableSql;
|
|
import com.ruoyi.system.mapper.CommonMapper;
|
|
import com.ruoyi.system.mapper.CommonMapper;
|
|
import com.ruoyi.system.service.ICommonService;
|
|
import com.ruoyi.system.service.ICommonService;
|
|
|
|
+import com.ruoyi.system.service.ITableSqlService;
|
|
|
|
+import org.springframework.beans.factory.annotation.Autowired;
|
|
import org.springframework.stereotype.Service;
|
|
import org.springframework.stereotype.Service;
|
|
import org.springframework.util.CollectionUtils;
|
|
import org.springframework.util.CollectionUtils;
|
|
|
|
|
|
@@ -17,44 +21,62 @@ public class CommonServiceImpl implements ICommonService {
|
|
|
|
|
|
@Resource
|
|
@Resource
|
|
private CommonMapper commonMapper;
|
|
private CommonMapper commonMapper;
|
|
|
|
+ @Resource
|
|
|
|
+ private ITableSqlService iTableSqlService;
|
|
|
|
|
|
@Override
|
|
@Override
|
|
- public List<Map<String, Object>> selectList(Map<String,Object> map) {
|
|
|
|
- String tableName = (String)map.get("tableName");
|
|
|
|
- Map<String,Object> conditions = JSONObject.parseObject(JSON.toJSONString(map.get("condition")));
|
|
|
|
- return commonMapper.selectList(tableName,conditions);
|
|
|
|
|
|
+ public List<CommonEntity> selectList(Map<String, Object> map) {
|
|
|
|
+ String tableName = (String) map.get("tableName");
|
|
|
|
+ Map<String, Object> conditions = JSONObject.parseObject(JSON.toJSONString(map.get("condition")));
|
|
|
|
+ return commonMapper.selectList(tableName, conditions);
|
|
}
|
|
}
|
|
|
|
|
|
@Override
|
|
@Override
|
|
public int batchInsert(Map<String, Object> map) {
|
|
public int batchInsert(Map<String, Object> map) {
|
|
- String tableName = (String)map.get("tableName");
|
|
|
|
|
|
+ String tableName = (String) map.get("tableName");
|
|
List<Object> list = (List<Object>) map.get("field");
|
|
List<Object> list = (List<Object>) map.get("field");
|
|
List<Map<String, Object>> mapList = new ArrayList<>();
|
|
List<Map<String, Object>> mapList = new ArrayList<>();
|
|
for (Object obj : list) {
|
|
for (Object obj : list) {
|
|
- Map<String,Object> map1 = JSONObject.parseObject(JSON.toJSONString(obj));
|
|
|
|
|
|
+ Map<String, Object> map1 = JSONObject.parseObject(JSON.toJSONString(obj));
|
|
mapList.add(map1);
|
|
mapList.add(map1);
|
|
}
|
|
}
|
|
Set<String> fieldNames = new LinkedHashSet<>();
|
|
Set<String> fieldNames = new LinkedHashSet<>();
|
|
- mapList.stream().forEach(map1 ->{
|
|
|
|
- map1.forEach((key,value)->{
|
|
|
|
|
|
+ mapList.stream().forEach(map1 -> {
|
|
|
|
+ map1.forEach((key, value) -> {
|
|
fieldNames.add(key);
|
|
fieldNames.add(key);
|
|
});
|
|
});
|
|
});
|
|
});
|
|
- return commonMapper.batchInsert(fieldNames,tableName,mapList);
|
|
|
|
|
|
+ return commonMapper.batchInsert(fieldNames, tableName, mapList);
|
|
}
|
|
}
|
|
|
|
|
|
@Override
|
|
@Override
|
|
public int edit(Map<String, Object> map) {
|
|
public int edit(Map<String, Object> map) {
|
|
- String tableName = (String)map.get("tableName");
|
|
|
|
- Map<String,Object> conditions = JSONObject.parseObject(JSON.toJSONString(map.get("condition")));
|
|
|
|
- Map<String,Object> fields = JSONObject.parseObject(JSON.toJSONString(map.get("field")));
|
|
|
|
- return commonMapper.edit(fields,tableName,conditions);
|
|
|
|
|
|
+ String tableName = (String) map.get("tableName");
|
|
|
|
+ Map<String, Object> conditions = JSONObject.parseObject(JSON.toJSONString(map.get("condition")));
|
|
|
|
+ Map<String, Object> fields = JSONObject.parseObject(JSON.toJSONString(map.get("field")));
|
|
|
|
+ return commonMapper.edit(fields, tableName, conditions);
|
|
}
|
|
}
|
|
|
|
|
|
@Override
|
|
@Override
|
|
public int batchDelete(Map<String, Object> map) {
|
|
public int batchDelete(Map<String, Object> map) {
|
|
- String tableName = (String)map.get("tableName");
|
|
|
|
- Map<String,Object> conditions = JSONObject.parseObject(JSON.toJSONString(map.get("condition")));
|
|
|
|
- return commonMapper.batchDelete(tableName,conditions);
|
|
|
|
|
|
+ String tableName = (String) map.get("tableName");
|
|
|
|
+ Map<String, Object> conditions = JSONObject.parseObject(JSON.toJSONString(map.get("condition")));
|
|
|
|
+ return commonMapper.batchDelete(tableName, conditions);
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ @Override
|
|
|
|
+ public List<Map<String, Object>> queryTableList(Map<String, Object> map) {
|
|
|
|
+ // 根据sqlkey查询得到当前表单对应的sql
|
|
|
|
+ TableSql tableSql = iTableSqlService.selectTableSqlByTSqlKey(map.get("SQLKEY").toString());
|
|
|
|
+ Map<String, Object> conditions = JSONObject.parseObject(JSON.toJSONString(map.get("condition")));
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+ StringBuilder endSQL = new StringBuilder();
|
|
|
|
+ endSQL.append("" + tableSql.getTableSql() + "where 1=1");
|
|
|
|
+
|
|
|
|
+ conditions.forEach((key, val) -> {
|
|
|
|
+ endSQL.append(" and " + tableSql.getTableAlias() + " " + key + " = " + val);
|
|
|
|
+ });
|
|
|
|
+ return null;
|
|
}
|
|
}
|
|
}
|
|
}
|