Commit c24882e5 by wqc

通用查询——自定义sql完成

parent f9598eed
......@@ -7,6 +7,7 @@ import com.alibaba.druid.pool.DruidPooledConnection;
import com.alibaba.druid.spring.boot.autoconfigure.DruidDataSourceBuilder;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.zq.common.exception.BusinessException;
import com.zq.common.vo.ResultVo;
......@@ -16,6 +17,7 @@ import com.zq.dataoperation.entity.CommonQuerySetting;
import com.zq.dataoperation.entity.QueryDb;
import com.zq.dataoperation.utils.ConnectionUtil;
import com.zq.spiderflow.dao.MetaDataMappingDao;
import com.zq.spiderflow.entity.MetaData;
import com.zq.spiderflow.entity.MetaDataMapping;
import org.springframework.stereotype.Service;
......@@ -145,9 +147,7 @@ public class CommonQueryService extends ServiceImpl<CommonQuerySettingDao, Commo
JSONObject jsonObject = JSONUtil.parseObj(body);
String querySql = jsonObject.get("querySql").toString();
Long id = Long.valueOf(jsonObject.get("id").toString());
LambdaQueryWrapper<MetaDataMapping> wrapper = new LambdaQueryWrapper<>();
wrapper.eq(MetaDataMapping::getMetadataId, id);
List<MetaDataMapping> list = metaDataMappingDao.selectList(wrapper);
List<MetaDataMapping> list = metaDataMappingDao.selectByCateId(id);
ResultSet resultSet = null;
String tableSqlname = null;
Long queryDbId = null;
......
......@@ -14,4 +14,6 @@ public interface MetaDataMappingDao extends BaseMapper<MetaDataMapping> {
List<MetaDataMapping> selectRepeat(String tableSqlname);
List<MetaDataMapping> getSqlName();
List<MetaDataMapping> selectByCateId(Long id);
}
......@@ -99,7 +99,8 @@ public class MetaDataService extends ServiceImpl<MetaDataDao, MetaData> {
}
BeanUtil.copyProperties(parent, metaDataCategory);
metaDataCategory.setCategoryType(1);
metaDataCategory.setCategoryName(file.getName());
String fileName = file.getOriginalFilename().substring(0, file.getOriginalFilename().lastIndexOf("."));
metaDataCategory.setCategoryName(fileName);
metaDataCategoryService.save(metaDataCategory);
List<List<Object>> readList = reader.read(1);
for (List<Object> objectList : readList) {
......
......@@ -32,4 +32,15 @@
HAVING
COUNT( table_sqlname ) > 1)
</select>
<select id="selectByCateId" resultType="com.zq.spiderflow.entity.MetaDataMapping">
SELECT
DISTINCT
t.table_sqlname,
t.query_db_id
FROM
meta_data_mapping t
LEFT JOIN meta_data m ON t.metadata_id = m.id
LEFT JOIN meta_data_category y ON m.category_id = y.id
WHERE y.id=#{id}
</select>
</mapper>
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment