You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

75 lines
2.4 KiB

This file contains ambiguous Unicode characters!

This file contains ambiguous Unicode characters that may be confused with others in your current locale. If your use case is intentional and legitimate, you can safely ignore this warning. Use the Escape button to highlight these characters.

package com.dsideal.base.YunXiao.Controller;
import com.dsideal.base.Interceptor.IsLoginInterface;
import com.dsideal.base.Interceptor.IsNumericInterface;
import com.dsideal.base.Util.CommonUtil;
import com.dsideal.base.Util.SqlInjectionUtils;
import com.dsideal.base.YunXiao.Model.YunXiaoModel;
import com.jfinal.aop.Before;
import com.jfinal.core.Controller;
import com.jfinal.ext.interceptor.GET;
import com.jfinal.ext.interceptor.POST;
import com.jfinal.kit.StrKit;
import com.jfinal.plugin.activerecord.Page;
import com.jfinal.plugin.activerecord.Record;
import io.github.yedaxia.apidocs.ApiDoc;
import java.util.List;
@ApiDoc
public class YunXiaoController extends Controller {
YunXiaoModel ym = new YunXiaoModel();
/**
* 可以维护的数据集名称
*/
// http://10.10.21.20:9000/dsBase/yx/getDataSet
@Before({GET.class})
@IsLoginInterface({})
public void getDataSet() {
List<Record> list = ym.getDataSet();
renderJson(CommonUtil.renderJsonForLayUI(list));
}
/**
* 获取数据集下的数据表
*
* @param id 数据集id
* @param pageNumber 第几页
* @param keyword 关键字
* @param pageSize 每页多少条数据
*/
@Before(GET.class)
@IsLoginInterface({})
@IsNumericInterface({"id"})
public void getDataSetContent(int id, String keyword, int pageNumber, int pageSize) {
if (StrKit.isBlank(keyword)) keyword = "";
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));
}
/**
* 保存数据集下的数据表
*
* @param dataset_id 数据集id
* @param id 数据集下的数据表的id
* @param field 字段名
* @param value 值
*/
@Before(POST.class)
@IsLoginInterface({})
public void saveDataSet(int dataset_id, int id, String field, String value) {
ym.saveDataSet(dataset_id, id, field, value);
renderJson(CommonUtil.returnMessageJson(true, "保存成功"));
}
}