Browse Source

提交开源任务材料

master
LAPTOP-SB56SG4Q\86185 3 years ago
parent
commit
adba2cc075
  1. 5
      README.md
  2. BIN
      lib/finekit-10.0.jar
  3. 21
      plugin.xml
  4. 188
      src/main/java/com/fr/plugin/third/party/jsdjdcg/Utils.java
  5. 66
      src/main/java/com/fr/plugin/third/party/jsdjdcg/config/CustomDataConfig.java
  6. 26
      src/main/java/com/fr/plugin/third/party/jsdjdcg/config/DataConfigInitializeMonitor.java
  7. 196
      src/main/java/com/fr/plugin/third/party/jsdjdcg/data/CustomHttpDataModel.java
  8. 18
      src/main/java/com/fr/plugin/third/party/jsdjdcg/data/CustomHttpTableData.java
  9. 50
      src/main/java/com/fr/plugin/third/party/jsdjdcg/data/CustomHttpTableDataDefine.java
  10. 76
      src/main/java/com/fr/plugin/third/party/jsdjdcg/data/CustomHttpTableDataPane.java
  11. 44
      src/main/java/com/fr/plugin/third/party/jsdjdcg/data/CustomUniversalServerTableDataProvider.java
  12. 67
      src/main/java/com/fr/plugin/third/party/jsdjdcg/data/DatasetData.java
  13. 292
      src/main/resources/com/fr/plugin/third/party/jsdjdcg/web/tabledata.js

5
README.md

@ -1,3 +1,6 @@
# open-JSD-9326
JSD-9326 分页REST用户数据集
JSD-9326 分页REST用户数据集\
免责说明:该源码为第三方爱好者提供,不保证源码和方案的可靠性,也不提供任何形式的源码教学指导和协助!\
仅作为开发者学习参考使用!禁止用于任何商业用途!\
为保护开发者隐私,开发者信息已隐去!若原开发者希望公开自己的信息,可联系hugh处理。

BIN
lib/finekit-10.0.jar

Binary file not shown.

21
plugin.xml

@ -0,0 +1,21 @@
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<plugin>
<id>com.fr.plugin.third.party.jsdjdcg</id>
<name><![CDATA[用户信息数据集]]></name>
<active>yes</active>
<version>0.1</version>
<env-version>10.0</env-version>
<jartime>2019-01-01</jartime>
<vendor>fr.open</vendor>
<description><![CDATA[]]></description>
<change-notes><![CDATA[]]></change-notes>
<extra-decision>
<UniversalServerTableDataProvider class="com.fr.plugin.third.party.jsdjdcg.data.CustomUniversalServerTableDataProvider"/>
</extra-decision>
<extra-designer>
<ServerTableDataDefineProvider class="com.fr.plugin.third.party.jsdjdcg.data.CustomHttpTableDataDefine"/>
<TableDataDefineProvider class="com.fr.plugin.third.party.jsdjdcg.data.CustomHttpTableDataDefine"/>
</extra-designer>
<function-recorder class="com.fr.plugin.third.party.jsdjdcg.config.DataConfigInitializeMonitor"/>
<lifecycle-monitor class="com.fr.plugin.third.party.jsdjdcg.config.DataConfigInitializeMonitor"/>
</plugin>

188
src/main/java/com/fr/plugin/third/party/jsdjdcg/Utils.java

@ -0,0 +1,188 @@
package com.fr.plugin.third.party.jsdjdcg;
import com.fanruan.api.log.LogKit;
import com.fanruan.api.util.StringKit;
import com.fr.third.org.apache.http.HttpEntity;
import com.fr.third.org.apache.http.HttpStatus;
import com.fr.third.org.apache.http.client.config.RequestConfig;
import com.fr.third.org.apache.http.client.methods.CloseableHttpResponse;
import com.fr.third.org.apache.http.client.methods.HttpGet;
import com.fr.third.org.apache.http.client.methods.HttpPost;
import com.fr.third.org.apache.http.conn.ssl.NoopHostnameVerifier;
import com.fr.third.org.apache.http.conn.ssl.SSLConnectionSocketFactory;
import com.fr.third.org.apache.http.entity.StringEntity;
import com.fr.third.org.apache.http.impl.client.CloseableHttpClient;
import com.fr.third.org.apache.http.impl.client.HttpClients;
import com.fr.third.org.apache.http.ssl.SSLContextBuilder;
import com.fr.third.org.apache.http.ssl.TrustStrategy;
import com.fr.third.org.apache.http.util.EntityUtils;
import javax.net.ssl.HostnameVerifier;
import javax.net.ssl.SSLContext;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;
import java.security.cert.CertificateException;
import java.security.cert.X509Certificate;
import java.util.UUID;
public class Utils {
public static String DEFAULT_USER_AGENT = "Mozilla/5.0 (Windows NT 6.1; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/83.0.4103.61 Safari/537.36";
public static RequestConfig REQUEST_CONFIG = RequestConfig.custom()
.setConnectionRequestTimeout(30000)
.setSocketTimeout(30000) // 服务端相应超时
.setConnectTimeout(30000) // 建立socket链接超时时间
.build();
public static CloseableHttpClient createSSLClientDefault() {
try {
SSLContext sslContext = new SSLContextBuilder().loadTrustMaterial(null, new TrustStrategy() {
@Override
public boolean isTrusted(X509Certificate[] chain, String authType) throws CertificateException {
return true;
}
}).build();
HostnameVerifier hostnameVerifier = NoopHostnameVerifier.INSTANCE;
SSLConnectionSocketFactory sslsf = new SSLConnectionSocketFactory(sslContext, hostnameVerifier);
return HttpClients.custom().setSSLSocketFactory(sslsf).build();
} catch (Exception e) {
LogKit.error(e.getMessage(), e);
}
return HttpClients.createDefault();
}
public static synchronized CloseableHttpClient createHttpClient(String url) {
CloseableHttpClient httpClient = null;
if (StringKit.isEmpty(url)) {
httpClient = HttpClients.createDefault();
return httpClient;
}
if (url.startsWith("https://")) {
httpClient = createSSLClientDefault();
return httpClient;
}
httpClient = HttpClients.createDefault();
return httpClient;
}
public static synchronized String createHttpGetContent(CloseableHttpClient httpClient, String url, String basicAuth) throws IOException {
if ((httpClient == null) || (StringKit.isEmpty(url))) {
return "";
}
HttpGet httpGet = new HttpGet(url);
httpGet.addHeader("User-Agent", Utils.DEFAULT_USER_AGENT);
if (StringKit.isNotEmpty(basicAuth)) {
httpGet.addHeader("Authorization", basicAuth);
}
httpGet.setConfig(Utils.REQUEST_CONFIG);
CloseableHttpResponse response = httpClient.execute(httpGet);
int statusCode = response.getStatusLine().getStatusCode();
if (statusCode != HttpStatus.SC_OK) {
response.close();
LogKit.info("http请求出错,http status:" + statusCode);
return "";
}
HttpEntity httpEntity = response.getEntity();
if (httpEntity == null) {
response.close();
LogKit.info("http请求出错,http响应内容为空");
return "";
}
String responseContent = EntityUtils.toString(httpEntity, "UTF-8");
response.close();
if (StringKit.isEmpty(responseContent)) {
LogKit.info("http请求出错,http响应内容为空1");
return "";
}
return responseContent;
}
public static synchronized String createHttpPostContent(CloseableHttpClient httpClient, String url, String bodyContent, String basicAuth,String contentType) throws IOException {
if ((httpClient == null) || (StringKit.isEmpty(url))) {
return "";
}
HttpPost httpPost = new HttpPost(url);
httpPost.addHeader("User-Agent", Utils.DEFAULT_USER_AGENT);
httpPost.setConfig(Utils.REQUEST_CONFIG);
if (StringKit.isNotEmpty(basicAuth)) {
httpPost.addHeader("Authorization", basicAuth);
}
if (StringKit.isNotEmpty(contentType)) {
httpPost.addHeader("Content-Type", contentType);
}
StringEntity bodyEntity = new StringEntity(bodyContent, "UTF-8");
httpPost.setEntity(bodyEntity);
CloseableHttpResponse response = httpClient.execute(httpPost);
int statusCode = response.getStatusLine().getStatusCode();
if (statusCode != HttpStatus.SC_OK) {
response.close();
LogKit.info("http请求出错,http status:" + statusCode);
return "";
}
HttpEntity httpEntity = response.getEntity();
if (httpEntity == null) {
response.close();
LogKit.info("http请求出错,http响应内容为空");
return "";
}
String responseContent = EntityUtils.toString(httpEntity, "UTF-8");
response.close();
if (StringKit.isEmpty(responseContent)) {
LogKit.info("http请求出错,http响应内容为空1");
return "";
}
return responseContent;
}
/**
* 获取完整请求链接
*
* @param req 请求
* @return
*/
public static String getFullRequestUrl(HttpServletRequest req) {
if (req == null) {
return "";
}
String url = req.getRequestURL().toString();
String queryUrl = req.getQueryString();
if ((queryUrl == null) || "null".equalsIgnoreCase(queryUrl)) {
queryUrl = "";
} else {
queryUrl = "?" + queryUrl;
}
String fullUrl = url + queryUrl;
return fullUrl;
}
/**
* 重定向
*
* @param res
* @param url
*/
public static void sendRedirect(HttpServletResponse res, String url) {
if ((res == null) || (StringKit.isEmpty(url))) {
return;
}
res.setStatus(HttpServletResponse.SC_MOVED_TEMPORARILY);
res.setHeader("Location", url);
}
public static synchronized String getUuid() {
String uuid = UUID.randomUUID().toString().replace("-", "");
return uuid;
}
}

66
src/main/java/com/fr/plugin/third/party/jsdjdcg/config/CustomDataConfig.java

@ -0,0 +1,66 @@
package com.fr.plugin.third.party.jsdjdcg.config;
import com.fr.config.*;
import com.fr.config.holder.Conf;
import com.fr.config.holder.factory.Holders;
/**
* 配置数据保存
*/
@Visualization(category = "用户信息数据集配置")
public class CustomDataConfig extends DefaultConfiguration {
public String getNameSpace() {
return this.getClass().getName();
}
private static volatile CustomDataConfig config = null;
public static CustomDataConfig getInstance() {
if (config == null) {
config = ConfigContext.getConfigInstance(CustomDataConfig.class);
}
return config;
}
@Identifier(value = "dataSyncUrl", name = "数据地址", description = "", status = Status.SHOW)
private Conf<String> dataSyncUrl = Holders.simple("");
@Identifier(value = "dataUsername", name = "数据用户名", description = "", status = Status.HIDE)
private Conf<String> dataUsername = Holders.simple("");
@Identifier(value = "dataPassword", name = "数据密码", description = "", status = Status.HIDE)
private Conf<String> dataPassword = Holders.simple("");
public String getDataSyncUrl() {
return dataSyncUrl.get();
}
public void setDataSyncUrl(String dataSyncUrl) {
this.dataSyncUrl.set(dataSyncUrl);
}
public String getDataUsername() {
return dataUsername.get();
}
public void setDataUsername(String dataUsername) {
this.dataUsername.set(dataUsername);
}
public String getDataPassword() {
return dataPassword.get();
}
public void setDataPassword(String dataPassword) {
this.dataPassword.set(dataPassword);
}
@Override
public Object clone() throws CloneNotSupportedException {
CustomDataConfig cloned = (CustomDataConfig) super.clone();
cloned.dataSyncUrl = (Conf<String>) dataSyncUrl.clone();
cloned.dataUsername = (Conf<String>) dataUsername.clone();
cloned.dataPassword = (Conf<String>) dataPassword.clone();
return cloned;
}
}

26
src/main/java/com/fr/plugin/third/party/jsdjdcg/config/DataConfigInitializeMonitor.java

@ -0,0 +1,26 @@
package com.fr.plugin.third.party.jsdjdcg.config;
import com.fr.intelli.record.Focus;
import com.fr.intelli.record.Original;
import com.fr.plugin.context.PluginContext;
import com.fr.plugin.observer.inner.AbstractPluginLifecycleMonitor;
import com.fr.record.analyzer.EnableMetrics;
import com.fr.stable.fun.Authorize;
/**
* 配置信息初始化
*/
@EnableMetrics
@Authorize(callSignKey = "com.fr.plugin.third.party.jsdjdcg")
public class DataConfigInitializeMonitor extends AbstractPluginLifecycleMonitor {
@Override
@Focus(id = "com.fr.plugin.third.party.jsdjdcg", text = "plugin-jsdjdcg", source = Original.PLUGIN)
public void afterRun(PluginContext pluginContext) {
CustomDataConfig.getInstance();
}
@Override
public void beforeStop(PluginContext pluginContext) {
}
}

196
src/main/java/com/fr/plugin/third/party/jsdjdcg/data/CustomHttpDataModel.java

@ -0,0 +1,196 @@
package com.fr.plugin.third.party.jsdjdcg.data;
import com.fanruan.api.log.LogKit;
import com.fanruan.api.util.StringKit;
import com.fr.base.TableData;
import com.fr.data.AbstractDataModel;
import com.fr.general.data.TableDataException;
import com.fr.json.JSONArray;
import com.fr.json.JSONObject;
import com.fr.plugin.context.PluginContexts;
import com.fr.plugin.third.party.jsdjdcg.Utils;
import com.fr.plugin.third.party.jsdjdcg.config.CustomDataConfig;
import com.fr.third.org.apache.http.impl.client.CloseableHttpClient;
import com.fr.utils.Base64;
import java.util.ArrayList;
import java.util.List;
public class CustomHttpDataModel extends AbstractDataModel {
private static String[] COLUMN_NAMES = {"loginName", "userName", "userPwd", "orgId", "orgName", "parentId", "userJob"};
private int rowCount = TableData.RESULT_ALL;
private DatasetData datas = new DatasetData();
public CustomHttpDataModel(int count) {
this.rowCount = count;
if (this.rowCount == 0) {
return;
}
queryData();
}
@Override
public int getColumnCount() throws TableDataException {
return COLUMN_NAMES.length;
}
@Override
public String getColumnName(int i) throws TableDataException {
return COLUMN_NAMES[i];
}
@Override
public boolean hasRow(int rowIndex) throws TableDataException {
int count = getRowCount();
return rowIndex < count;
}
@Override
public int getRowCount() throws TableDataException {
if (this.datas == null) {
return 0;
}
List<List<Object>> values = this.datas.getValues();
if (values == null) {
return 0;
}
int count = values.size();
return count;
}
@Override
public Object getValueAt(int rowIndex, int columnIndex) throws TableDataException {
if (this.datas == null) {
return "";
}
List<List<Object>> values = this.datas.getValues();
if ((values == null) || (values.size() <= rowIndex)) {
return "";
}
List<Object> rowValues = values.get(rowIndex);
if ((rowValues == null) || (rowValues.size() <= columnIndex)) {
return "";
}
return rowValues.get(columnIndex);
}
@Override
public void release() throws Exception {
this.datas = null;
}
/**
* 查询数据
*/
private void queryData() {
try {
createDatas();
} catch (Exception e) {
LogKit.error("用户信息数据集获取信息,请求出错," + e.getMessage() + "," + e.getCause(), e);
}
}
private void createDatas() throws Exception {
String userSyncUrl = CustomDataConfig.getInstance().getDataSyncUrl();
//String userSyncUsername = CustomDataConfig.getInstance().getDataUsername();
///String userSyncPassword = CustomDataConfig.getInstance().getDataPassword();
if (StringKit.isEmpty(userSyncUrl)) {
return;
}
CloseableHttpClient httpClient = Utils.createHttpClient(userSyncUrl);
//String authValue = userSyncUsername + ":" + userSyncPassword;
//String auth = "Basic " + Base64.getEncoder().encodeToString(authValue.getBytes("utf-8"));
String content = "";
LogKit.info("用户信息数据集,请求数据..");
//添加认证
if (!PluginContexts.currentContext().isAvailable()) {
LogKit.error("用户信息数据集插件试用过期, 请购买许可证");
return;
}
String bodyContent = "{\n" +
" \"pageIndex\":\"0\",\n" +
" \"pageSize\":\"2000\"\n" +
"}";
int count = 0, count1 = 0;
int index = 0;
do {
bodyContent = getBodyContent(index);
content = Utils.createHttpPostContent(httpClient, userSyncUrl, bodyContent, "", "application/json");
if (StringKit.isEmpty(content)) {
break;
}
LogKit.info("用户信息数据集" + index + ",json内容:\n" + content);
index++;
count = this.getRowCount();
addDatas(content);
count1 = this.getRowCount();
}
while (count1 > count);
httpClient.close();
}
private String getBodyContent(int index) {
String bodyContent = "{\n" +
" \"pageIndex\":\"" + index + "\",\n" +
" \"pageSize\":\"2000\"\n" +
"}";
return bodyContent;
}
private void addDatas(String content) throws TableDataException {
if (StringKit.isEmpty(content)) {
return;
}
JSONObject resJson = new JSONObject(content);
String status = resJson.getString("status");
if (!StringKit.equals("000000", status)) {
return;
}
JSONObject resultJson = resJson.getJSONObject("result");
if (resultJson == null) {
return;
}
JSONArray dataJsons = resultJson.getJSONArray("data");
if ((dataJsons == null) || (dataJsons.size() <= 0)) {
return;
}
String loginName = "", userName = "", userPwd = "", orgId = "", orgName = "", parentId = "", userJob = "";
JSONObject dataJson;
int tempCount = 0;
for (int i = 0, max = dataJsons.size() - 1; i <= max; i++) {
if ((this.rowCount >= 1) && (tempCount >= this.rowCount)) {
return;
}
dataJson = dataJsons.getJSONObject(i);
loginName = dataJson.getString("loginName", "");
userName = dataJson.getString("userName", "");
userPwd = dataJson.getString("userPwd", "");
orgId = dataJson.getString("orgId", "");
orgName = dataJson.getString("orgName", "");
parentId = dataJson.getString("parentId", "");
userJob = dataJson.getString("userJob", "");
addRowDatas(loginName, userName, userPwd, orgId, orgName, parentId, userJob);
tempCount++;
}
}
//"loginName", "userName", "userPwd", "orgId", "orgName", "parentId", "userJob"
private void addRowDatas(String loginName, String userName, String userPwd, String orgId, String orgName, String parentId, String userJob) {
List<Object> rowDatas = new ArrayList<>();
rowDatas.add(loginName);
rowDatas.add(userName);
rowDatas.add(userPwd);
rowDatas.add(orgId);
rowDatas.add(orgName);
rowDatas.add(parentId);
rowDatas.add(userJob);
List<List<Object>> values = this.datas.getValues();
values.add(rowDatas);
}
}

18
src/main/java/com/fr/plugin/third/party/jsdjdcg/data/CustomHttpTableData.java

@ -0,0 +1,18 @@
package com.fr.plugin.third.party.jsdjdcg.data;
import com.fr.base.TableData;
import com.fr.data.AbstractParameterTableData;
import com.fr.general.data.DataModel;
import com.fr.script.Calculator;
public class CustomHttpTableData extends AbstractParameterTableData {
@Override
public DataModel createDataModel(Calculator calculator) {
return createDataModel(calculator, TableData.RESULT_ALL);
}
@Override
public DataModel createDataModel(Calculator calculator, int rowCount) {
return new CustomHttpDataModel(rowCount);
}
}

50
src/main/java/com/fr/plugin/third/party/jsdjdcg/data/CustomHttpTableDataDefine.java

@ -0,0 +1,50 @@
package com.fr.plugin.third.party.jsdjdcg.data;
import com.fr.base.TableData;
import com.fr.design.data.tabledata.tabledatapane.AbstractTableDataPane;
import com.fr.design.fun.ServerTableDataDefineProvider;
import com.fr.design.fun.impl.AbstractTableDataDefineProvider;
import com.fr.design.i18n.Toolkit;
public class CustomHttpTableDataDefine extends AbstractTableDataDefineProvider implements ServerTableDataDefineProvider {
@Override
public int currentAPILevel() {
return CURRENT_LEVEL;
}
@Override
public Class<? extends TableData> classForTableData() {
return CustomHttpTableData.class;
}
@Override
public Class<? extends TableData> classForInitTableData() {
return CustomHttpTableData.class;
}
@Override
public Class<? extends AbstractTableDataPane> appearanceForTableData() {
return CustomHttpTableDataPane.class;
}
@Override
public String nameForTableData() {
return Toolkit.i18nText("用户信息数据集");
}
@Override
public String prefixForTableData() {
return "user_data";
}
@Override
public String iconPathForTableData() {
return "";
}
}

76
src/main/java/com/fr/plugin/third/party/jsdjdcg/data/CustomHttpTableDataPane.java

@ -0,0 +1,76 @@
package com.fr.plugin.third.party.jsdjdcg.data;
import com.fanruan.api.design.DesignKit;
import com.fanruan.api.design.ui.component.UIButton;
import com.fr.design.data.datapane.preview.PreviewTablePane;
import com.fr.design.data.tabledata.tabledatapane.AbstractTableDataPane;
import com.fr.general.IOUtils;
import javax.swing.*;
import java.awt.*;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
public class CustomHttpTableDataPane extends AbstractTableDataPane<CustomHttpTableData> {
public CustomHttpTableDataPane() {
super();
createContent();
}
@Override
public void populateBean(CustomHttpTableData ob) {
if (ob == null) {
return;
}
}
@Override
public CustomHttpTableData updateBean() {
CustomHttpTableData tableData = new CustomHttpTableData();
return tableData;
}
@Override
protected String title4PopupWindow() {
return DesignKit.i18nText("用户信息数据集");
}
private void createContent() {
setLayout(new BorderLayout());
JPanel contentPane = new JPanel();
contentPane.setLayout(new BorderLayout());
add(contentPane, BorderLayout.CENTER);
JPanel connectionPanel = new JPanel(new FlowLayout(FlowLayout.LEFT, 10, 5));
UIButton previewButton = createIconButton("Fine-Design_Basic_Preview", "/com/fr/design/images/m_file/preview.png");
previewButton.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e) {
PreviewTablePane.previewTableData(updateBean());
}
});
connectionPanel.add(previewButton);
contentPane.add(connectionPanel, BorderLayout.NORTH);
}
/**
* 获取图标按钮
*
* @param toolTip 提示信息,国际化key
* @param iconPath 图标路径
* @return
*/
public static UIButton createIconButton(String toolTip, String iconPath) {
UIButton iconButton = new UIButton(IOUtils.readIcon(iconPath));
iconButton.setToolTipText(DesignKit.i18nText(toolTip));
return iconButton;
}
}

44
src/main/java/com/fr/plugin/third/party/jsdjdcg/data/CustomUniversalServerTableDataProvider.java

@ -0,0 +1,44 @@
package com.fr.plugin.third.party.jsdjdcg.data;
import com.fr.decision.fun.impl.AbstractUniversalServerTableDataProvider;
import com.fr.json.JSONObject;
import com.fr.web.struct.Atom;
import com.fr.web.struct.Component;
import com.fr.web.struct.browser.RequestClient;
import com.fr.web.struct.category.ParserType;
import com.fr.web.struct.category.ScriptPath;
public class CustomUniversalServerTableDataProvider extends AbstractUniversalServerTableDataProvider<CustomHttpTableData> {
@Override
public Class classForTableData() {
return CustomHttpTableData.class;
}
@Override
public String nameForTableData() {
return "custom_user_data";
}
@Override
public JSONObject serialize(CustomHttpTableData data) {
//bean.setParameters(parameterBeans);
//return JSONObject.mapFrom(bean);
return new JSONObject();
}
@Override
public CustomHttpTableData deserialize(CustomHttpTableData data, JSONObject config ) {
CustomHttpTableData dataSet = new CustomHttpTableData();
return dataSet;
}
@Override
public Atom client() {
return new Component(){
@Override
public ScriptPath script(RequestClient client ) {
return ScriptPath.build("com/fr/plugin/third/party/jsdjdcg/web/tabledata.js", ParserType.DYNAMIC);
}
};
}
}

67
src/main/java/com/fr/plugin/third/party/jsdjdcg/data/DatasetData.java

@ -0,0 +1,67 @@
package com.fr.plugin.third.party.jsdjdcg.data;
import java.util.ArrayList;
import java.util.List;
/**
* 数据集数据
*/
public class DatasetData {
private String name;
private List<String> columns;
private List<List<Object>> values;
public DatasetData() {
columns = new ArrayList<String>();
values = new ArrayList<List<Object>>();
}
/**
* 获取表名
* @return 表名
*/
public String getName() {
return this.name;
}
/**
* 设置表名
* @param name 表名
*/
public void setName(String name) {
this.name = name;
}
/**
* 获取列名
* @return 列名
*/
public List<String> getColumns() {
return this.columns;
}
/**
* 设置列名
* @param columns 列名
*/
public void setColumns(List<String> columns) {
this.columns = columns;
}
/**
* 获取表数据
* @return 表数据
*/
public List<List<Object>> getValues() {
return this.values;
}
/**
* 设置表数据
* @param values
*/
public void setValues(List<List<Object>> values) {
this.values = values;
}
}

292
src/main/resources/com/fr/plugin/third/party/jsdjdcg/web/tabledata.js

@ -0,0 +1,292 @@
!(function () {
var Model = BI.inherit(Fix.Model, {
_init: function () {
this.service = BI.Services.getService("dec.service.data.set");
},
context: ["dataSetName", "ableSave"],
state: function () {
var val = this.options.value.datasetData || {};
return {
config: val.config || "",
parameters: val.parameters || []
};
},
childContext: ["previewAble", "previewedDataSet"],
watch: {
previewAble: function (v) {
this.setAbleSave(v);
}
},
computed: {
paramHeader: function () {
//定义参数列表表头
var map = BI.map(BI.Constants.getConstant("dec.constants.data.set.sql.header"), function (i, v) {
return BI.extend({
textAlign: "left",
height: 30,
hgap: 10
}, v);
});
map.push({
textAlign: "left",
height: 30,
hgap: 10,
text: ""
});
return [map];
},
paramItems: function () {
var self = this;
return BI.map(this.model.parameters, function (i, param) {
return [{
type: "bi.text_editor",
value: param.name,
textAlign: "left",
height: 30,
lgap: 10,
listeners: [{
eventName: BI.TextEditor.EVENT_CHANGE,
action: function () {
self.setParamName(i, this.getValue());
}
}]
}, {
type: "bi.icon_text_value_combo",
cls: "field-type-change",
height: 30,
items: BI.Constants.getConstant("dec.constants.data.set.sql.field"),
value: param.type,
listeners: [{
eventName: BI.IconTextValueCombo.EVENT_CHANGE,
action: function () {
self.setParamType(i, this.getValue()[0]);
}
}]
}, self.service.createParameterValueItem(param, function (val) {
self.setParamValue(i, val);
}), {
type: "bi.icon_button",
cls: "default-delete-font",
height: 30,
lgap: 10,
title: BI.i18nText("Dec-Basic_Delete"),
handler: function () {
self.deleteParameter(i);
}
}];
});
},
previewAble: function () {
return true;
},
previewedDataSet: function () {
return {
datasetType: DecCst.DataSet.Type.CUSTOM_USER_DATA,
datasetName: this.model.dataSetName,
datasetData: {
parameters:[]
}
};
}
},
actions: {
initPage: function (cb) {
var self = this;
cb();
},
setConfig: function (v) {
this.model.config = v;
},
refreshParam: function () {
var self = this;
Dec.Utils.getDataSetParameters(this.model.previewedDataSet, function (res) {
self.model.parameters = self.service.getParameters(res.data, self.model.parameters);
});
},
addParamter: function (v) {
this.model.parameters.push(v);
},
deleteParameter: function (index) {
this.model.parameters.splice(index, 1);
},
setParamName: function (index, name) {
this.model.parameters[index].name = name;
},
setParamType: function (index, type) {
if (this.model.parameters[index].type !== type) {
this.model.parameters[index].type = type;
this.model.parameters[index].value = this.service.getDefaultValueByType(type);
this.model.parameters.splice(0, 0);
}
},
setParamValue: function (index, val) {
this.model.parameters[index].value = val;
},
setAbleSave: function (v) {
this.model.ableSave = v;
}
}
});
BI.model("dec.model.data.set.type.demo.data", Model);
var DemoData = BI.inherit(BI.Widget, {
props: {
baseCls: "dec-data-set-sql",
$testId: "dec-data-set-sql",
value: {
datasetData: {}
}
},
_store: function () {
return BI.Models.getModel("dec.model.data.set.type.demo.data", this.options);
},
watch: {
config: function (v) {
this.configEditor.setValue(v);
},
"config || parameters.**": function () {
this.previewPane.resetPreview();
},
parameters: function () {
this.paramSettingPane.populate(this.model.paramItems, this.model.paramHeader);
}
},
beforeInit: function (cb) {
this.store.initPage(cb);
},
mounted: function () {
// 在render方法里的子组件被渲染到页面之后的钩子函数
this.previewPane.resetPreview();
this.store.setAbleSave(true);
},
render: function () {
var self = this;
return {
type: "bi.htape",
items: [
//左侧的配置界面
/*{
el: {
type: "bi.vtape",
items: [
{
height: 24,
type: "bi.label",
cls: "dec-font-weight-bold",
text: "Config",
title: "Config",
textAlign: "left",
},
{
height: 220,
type: "bi.textarea_editor",
cls: "bi-border",
value: this.model.config,
ref: function (_ref) {
self.configEditor = _ref;
},
listeners: [{
eventName: BI.FormulaEditor.EVENT_CHANGE,
action: function () {
self.store.setConfig(this.getValue());
}
}]
},
//下面是参数面板
{
type: "bi.left_right_vertical_adapt",
height: 24,
items: {
left: [{
type: "bi.label",
cls: "dec-font-weight-bold",
text: BI.i18nText("Dec-Basic_Parameter_Setting")
}],
right: [{
type: "bi.icon_button",
cls: "add-keyword-font",
level: "ignore",
lgap: 10,
handler: function () {
self.store.addParamter({
type: "String",
name: "",
value: ""
});
}
}, {
type: "bi.icon_button",
cls: "refresh-font",
lgap: 10,
level: "ignore",
handler: function () {
self.store.refreshParam();
}
}]
}
}, {
type: "bi.components.style_table",
cls: "param-table",
width: 420,
columnSize: [130, 120, 120, ""],
items: this.model.paramItems,
header: this.model.paramHeader,
ref: function () {
self.paramSettingPane = this;
}
}
],
lgap: 10,
vgap: 15
},
width: 410,
lgap: 10,
vgap: 15
},*/
//右侧的预览界面
{
el: {
type: "bi.absolute",
cls: "bi-sortable-holder",
items: [{
el: {
type: "dec.data.set.preview",
listeners: [{
eventName: "EVENT_CHANGE",
action: function () {
//self.store.refreshParam();
self.previewPane.previewData();
}
}],
ref: function (_ref) {
self.previewPane = _ref;
}
}, top: 10, right: 10, bottom: 10, left: 10
}]
},
hgap: 10,
vgap: 15
}
]
};
},
getValue: function () {
return {
config: this.model.config,
parameters: this.model.parameters
};
}
});
BI.shortcut("dec.data.set.type.custom.data", DemoData);
$.extend(DecCst.DataSet.Type, {CUSTOM_USER_DATA: "custom_user_data"});
BI.config("dec.provider.data.set", function (provider) {
provider.registerDataSetType({
value: DecCst.DataSet.Type.CUSTOM_USER_DATA,
text: "用户信息数据集",
cardType: "dec.data.set.type.custom.data",
iconCls: "user-font"
});
});
})();
Loading…
Cancel
Save