kgdxpr 6 months ago
commit 42464bd03b

@ -1,15 +1,12 @@
package com.dsideal.base.YunXiao.Controller; package com.dsideal.base.YunXiao.Controller;
import com.dsideal.base.Interceptor.IsLoginInterface; import com.dsideal.base.Interceptor.IsLoginInterface;
import com.dsideal.base.Interceptor.IsNumericInterface;
import com.dsideal.base.Util.CommonUtil; import com.dsideal.base.Util.CommonUtil;
import com.dsideal.base.Util.SqlInjectionUtils;
import com.dsideal.base.YunXiao.Model.YunXiaoModel; import com.dsideal.base.YunXiao.Model.YunXiaoModel;
import com.jfinal.aop.Before; import com.jfinal.aop.Before;
import com.jfinal.core.Controller; import com.jfinal.core.Controller;
import com.jfinal.ext.interceptor.GET; import com.jfinal.ext.interceptor.GET;
import com.jfinal.ext.interceptor.POST; import com.jfinal.ext.interceptor.POST;
import com.jfinal.kit.StrKit;
import com.jfinal.plugin.activerecord.Page; import com.jfinal.plugin.activerecord.Page;
import com.jfinal.plugin.activerecord.Record; import com.jfinal.plugin.activerecord.Record;
import io.github.yedaxia.apidocs.ApiDoc; import io.github.yedaxia.apidocs.ApiDoc;
@ -22,40 +19,29 @@ public class YunXiaoController extends Controller {
YunXiaoModel ym = new YunXiaoModel(); YunXiaoModel ym = new YunXiaoModel();
/** /**
* *
*/ */
// http://10.10.21.20:9000/dsBase/yx/getDataSet @Before(GET.class)
@Before({GET.class})
@IsLoginInterface({}) @IsLoginInterface({})
public void getDataSet() { public void getDatasetTree() {
List<Record> list = ym.getDataSet(); List<Record> list = ym.getDatasetTree();
renderJson(CommonUtil.renderJsonForLayUI(list)); renderJson(CommonUtil.renderJsonForLayUI(list));
} }
/** /**
* *
* * @param datasetId id
* @param id id * @param page
* @param pageNumber * @param limit
* @param keyword
* @param pageSize
*/ */
@Before(GET.class) @Before(GET.class)
@IsLoginInterface({}) @IsLoginInterface({})
@IsNumericInterface({"id"}) public void getDataSetContent(long datasetId, int page, int limit) {
public void getDataSetContent(int id, String keyword, int pageNumber, int pageSize) { Page<Record> p = ym.getDataSetContent(datasetId, page, limit);
if (StrKit.isBlank(keyword)) keyword = ""; renderJson(CommonUtil.renderJsonForLayUI(p));
if (pageNumber == 0) pageNumber = 1;
if (pageSize == 0) pageSize = 20;
if (SqlInjectionUtils.hasSqlInjectionRisk(keyword)) {
renderJson("输入的查询关键字存在SQL注入攻击无法执行");
return;
}
Page<Record> pageList = ym.getDataSetContent(id, keyword, pageNumber, pageSize);
renderJson(CommonUtil.renderJsonForLayUI(pageList));
} }
/** /**
* *
* *

@ -226,14 +226,14 @@ public class YunXiaoModel {
/** /**
* *
* *
* @param id id
* @return * @return
*/ */
public Page<Record> getDataSetContent(int id, String keyword, int pageNumber, int pageSize) { public Page<Record> getDataSetContent(long datasetId, int pageNumber, int pageSize) {
Record record = Db.findById("t_dp_yx_dataset", "id", id); String sql = "select * from t_dp_yx_dataset where dataset_group_id=?";
Record record = Db.findFirst(sql, datasetId);
String tableName = record.getStr("table_name"); String tableName = record.getStr("table_name");
Page<Record> p = Db.paginate(pageNumber, pageSize, Page<Record> p = Db.paginate(pageNumber, pageSize,
"SELECT *", "from " + DB_NAME + ".`" + tableName + "` where `行政区划` like '%" + keyword + "%'"); "SELECT *", "from " + DB_NAME + ".`" + tableName);
return p; return p;
} }
@ -256,4 +256,14 @@ public class YunXiaoModel {
if (parent_id == null) return null; if (parent_id == null) return null;
return getAreaById(parent_id).getStr("area_name"); return getAreaById(parent_id).getStr("area_name");
} }
/**
*
*
* @return
*/
public List<Record> getDatasetTree() {
SqlPara sqlPara = Db.getSqlPara("YunXiao.datasetTree");
return Db.find(sqlPara);
}
} }

@ -0,0 +1,16 @@
#namespace("YunXiao")
#sql("datasetTree")
WITH RECURSIVE tree_cte AS (
SELECT *
FROM dataease.core_dataset_group
WHERE id = 1072161072829566976 -- 上线
UNION ALL
SELECT c.*
FROM dataease.core_dataset_group c
INNER JOIN tree_cte t ON c.pid = t.id
)
SELECT t1.id ,t1.name ,t1.pid,t1.node_type,t2.name as parent_name FROM tree_cte as t1
inner join dataease.core_dataset_group as t2
on t1.pid=t2.id
#end
#end
Loading…
Cancel
Save