From e4bd5c35f7ced8854b1caa6defa342d35d337b5e Mon Sep 17 00:00:00 2001
From: 杜洪波 <1074825718@qq.com>
Date: 星期二, 04 十一月 2025 17:57:33 +0800
Subject: [PATCH] 图表配置优化
---
src/main/java/com/product/server/report/controller/ReportDatasourceController.java | 141 ++++++++--------------------------------------
1 files changed, 26 insertions(+), 115 deletions(-)
diff --git a/src/main/java/com/product/server/report/controller/ReportDatasourceController.java b/src/main/java/com/product/server/report/controller/ReportDatasourceController.java
index 02395f1..b5b0961 100644
--- a/src/main/java/com/product/server/report/controller/ReportDatasourceController.java
+++ b/src/main/java/com/product/server/report/controller/ReportDatasourceController.java
@@ -26,15 +26,17 @@
import com.product.server.report.service.idel.IReportDatasourceService;
import com.product.util.config.SystemParamSet;
-
+/**
+ * 閰嶇疆鎶ヨ〃鏁版嵁婧�
+ *
+ */
@RestController
@RequestMapping("/api/report-datasource")
public class ReportDatasourceController extends AbstractBaseController{
-
+
@Autowired
ReportDatasourceService reportDatasourceService;
-
-
+
/**
* 鎶ヨ〃鏁版嵁婧愬垪琛�
* @param response
@@ -46,22 +48,8 @@
public String listDatasource(HttpServletResponse response,HttpServletRequest request) {
try {
//鑾峰彇鍙傛暟
- FieldSetEntity fse=null;
- Object bean=request.getAttribute(CoreConst.API_POST_REQUEST_DATA);
- if(bean != null){
- RequestParameterEntity reqp=(RequestParameterEntity)bean;
- fse = reqp.getFormData();
- }
- //鍒ゆ柇鍙傛暟鏄惁涓虹┖
- if(bean == null || fse == null) {
- return this.error(SystemCode.SYSTEM_FORM_NODATA.getValue(), SystemCode.SYSTEM_FORM_NODATA.getText());
- }
- //鍒ゆ柇琛ㄥ悕鏄惁姝e父
- if (!CmnConst.PRODUCT_SYS_REPORT_DATASOURCE_CONFIG.equals(fse.getTableName())) {
- return this.error(SystemCode.SYSTEM_TABLE_NODATA.getValue(), SystemCode.SYSTEM_TABLE_NODATA.getText());
- }
- DataTableEntity dt=reportDatasourceService.listDatasource(fse);
- return OK_List(dt);
+ FieldSetEntity fse = BaseUtil.getFieldSetEntity(request, CmnConst.PRODUCT_SYS_REPORT_DATASOURCE_CONFIG);
+ return OK_List(reportDatasourceService.listDatasource(fse));
} catch (BaseException e) {
e.printStackTrace();
return this.error(e.getCode(),e.getMessage());
@@ -70,7 +58,7 @@
return this.error(ReportCode.REPORT_DATASOURCE_ERROR.getValue(), ReportCode.REPORT_DATASOURCE_ERROR.getText()+e.getMessage());
}
}
-
+
/**
* 鎶ヨ〃鏁版嵁婧愯鎯�
* @param response
@@ -82,26 +70,12 @@
public String findDatasource(HttpServletResponse response,HttpServletRequest request) {
try {
//鑾峰彇鍙傛暟
- FieldSetEntity fse=null;
- Object bean=request.getAttribute(CoreConst.API_POST_REQUEST_DATA);
- if(bean != null){
- RequestParameterEntity reqp=(RequestParameterEntity)bean;
- fse = reqp.getFormData();
- }
- //鍒ゆ柇鍙傛暟鏄惁涓虹┖
- if(bean == null || fse == null) {
- return this.error(SystemCode.SYSTEM_FORM_NODATA.getValue(), SystemCode.SYSTEM_FORM_NODATA.getText());
- }
- //鍒ゆ柇琛ㄥ悕鏄惁姝e父
- if (!CmnConst.PRODUCT_SYS_REPORT_DATASOURCE_CONFIG.equals(fse.getTableName())) {
- return this.error(SystemCode.SYSTEM_TABLE_NODATA.getValue(), SystemCode.SYSTEM_TABLE_NODATA.getText());
- }
+ FieldSetEntity fse = BaseUtil.getFieldSetEntity(request, CmnConst.PRODUCT_SYS_REPORT_DATASOURCE_CONFIG);
//鍒ゆ柇uuid鏄惁涓虹┖
if (StringUtils.isEmpty(fse.getUUID())) {
return this.error(SystemCode.SYSTEM_FORM_COUNT.getValue(), SystemCode.SYSTEM_FORM_COUNT.getText());
}
- FieldSetEntity dt=reportDatasourceService.findDatasource(fse.getUUID());
- return OK_List(dt);
+ return OK_List(reportDatasourceService.findDatasource(fse.getUUID()));
} catch (BaseException e) {
e.printStackTrace();
return this.error(e.getCode(),e.getMessage());
@@ -110,7 +84,7 @@
return this.error(ReportCode.REPORT_DATASOURCE_ERROR.getValue(), ReportCode.REPORT_DATASOURCE_ERROR.getText()+e.getMessage());
}
}
-
+
/**
* 鏁版嵁婧�-淇濆瓨
* @param response
@@ -122,20 +96,7 @@
public String updateDatasource(HttpServletRequest request) {
try {
//鑾峰彇鍙傛暟
- FieldSetEntity fse=null;
- Object bean=request.getAttribute(CoreConst.API_POST_REQUEST_DATA);
- if(bean != null){
- RequestParameterEntity reqp=(RequestParameterEntity)bean;
- fse = reqp.getFormData();
- }
- //鍒ゆ柇鍙傛暟鏄惁涓虹┖
- if(bean == null || fse == null) {
- return this.error(SystemCode.SYSTEM_FORM_NODATA.getValue(), SystemCode.SYSTEM_FORM_NODATA.getText());
- }
- //鍒ゆ柇琛ㄥ悕鏄惁姝e父
- if (!CmnConst.PRODUCT_SYS_REPORT_DATASOURCE_CONFIG.equals(fse.getTableName())) {
- return this.error(SystemCode.SYSTEM_TABLE_NODATA.getValue(), SystemCode.SYSTEM_TABLE_NODATA.getText());
- }
+ FieldSetEntity fse = BaseUtil.getFieldSetEntity(request, CmnConst.PRODUCT_SYS_REPORT_DATASOURCE_CONFIG);
IReportDatasourceService service=(IReportDatasourceService)getProxyInstance(reportDatasourceService);
String uuid = service.saveDatasource(fse);
return OK_Add(uuid);
@@ -159,20 +120,7 @@
public String copyDatasource(HttpServletRequest request) {
try {
//鑾峰彇鍙傛暟
- FieldSetEntity fse = null;
- Object bean = request.getAttribute(CoreConst.API_POST_REQUEST_DATA);
- if (bean != null) {
- RequestParameterEntity reqp = (RequestParameterEntity) bean;
- fse = reqp.getFormData();
- }
- //鍒ゆ柇鍙傛暟鏄惁涓虹┖
- if (bean == null || fse == null) {
- return this.error(SystemCode.SYSTEM_FORM_NODATA.getValue(), SystemCode.SYSTEM_FORM_NODATA.getText());
- }
- //鍒ゆ柇琛ㄥ悕鏄惁姝e父
- if (!CmnConst.PRODUCT_SYS_REPORT_DATASOURCE_CONFIG.equals(fse.getTableName())) {
- return this.error(SystemCode.SYSTEM_TABLE_NODATA.getValue(), SystemCode.SYSTEM_TABLE_NODATA.getText());
- }
+ FieldSetEntity fse = BaseUtil.getFieldSetEntity(request, CmnConst.PRODUCT_SYS_REPORT_DATASOURCE_CONFIG);
return OK_List(reportDatasourceService.copyDatasource(fse));
} catch (BaseException e) {
e.printStackTrace();
@@ -182,7 +130,7 @@
return this.error(ReportCode.REPORT_DATASOURCE_COPY_FAIL.getValue(), ReportCode.REPORT_DATASOURCE_COPY_FAIL.getText() + e.getMessage());
}
}
-
+
/**
* 鎶ヨ〃鏁版嵁婧愬垹闄�
* @param response
@@ -194,20 +142,7 @@
public String deleteDatasource(HttpServletResponse response,HttpServletRequest request) {
try {
//鑾峰彇鍙傛暟
- FieldSetEntity fse=null;
- Object bean=request.getAttribute(CoreConst.API_POST_REQUEST_DATA);
- if(bean != null){
- RequestParameterEntity reqp=(RequestParameterEntity)bean;
- fse = reqp.getFormData();
- }
- //鍒ゆ柇鍙傛暟鏄惁涓虹┖
- if(bean == null || fse == null) {
- return this.error(SystemCode.SYSTEM_FORM_NODATA.getValue(), SystemCode.SYSTEM_FORM_NODATA.getText());
- }
- //鍒ゆ柇琛ㄥ悕鏄惁姝e父
- if (!CmnConst.PRODUCT_SYS_REPORT_DATASOURCE_CONFIG.equals(fse.getTableName())) {
- return this.error(SystemCode.SYSTEM_TABLE_NODATA.getValue(), SystemCode.SYSTEM_TABLE_NODATA.getText());
- }
+ FieldSetEntity fse = BaseUtil.getFieldSetEntity(request, CmnConst.PRODUCT_SYS_REPORT_DATASOURCE_CONFIG);
//鍒ゆ柇uuid鏄惁涓虹┖
if (StringUtils.isEmpty(fse.getUUID())) {
return this.error(SystemCode.SYSTEM_FORM_COUNT.getValue(), SystemCode.SYSTEM_FORM_COUNT.getText());
@@ -216,9 +151,8 @@
boolean succ=service.deleteDatasource(fse.getUUID());
if (succ) {
return OK();
- }else {
- return this.error(SystemCode.SYTEM_REPORT_DATASOURCE_DELETE_ERROR.getValue(), SystemCode.SYTEM_REPORT_DATASOURCE_DELETE_ERROR.getText());
}
+ return this.error(SystemCode.SYTEM_REPORT_DATASOURCE_DELETE_ERROR.getValue(), SystemCode.SYTEM_REPORT_DATASOURCE_DELETE_ERROR.getText());
} catch (BaseException e) {
e.printStackTrace();
return this.error(e.getCode(),e.getMessage());
@@ -227,7 +161,7 @@
return this.error(ReportCode.REPORT_DATASOURCE_ERROR.getValue(), ReportCode.REPORT_DATASOURCE_ERROR.getText()+e.getMessage());
}
}
-
+
/**
* 鎶ヨ〃sql瑙f瀽涓庨獙璇�
* @param response
@@ -239,16 +173,7 @@
public String sqlVerify(HttpServletResponse response,HttpServletRequest request) {
try {
//鑾峰彇鍙傛暟
- FieldSetEntity fse=null;
- Object bean=request.getAttribute(CoreConst.API_POST_REQUEST_DATA);
- if(bean != null){
- RequestParameterEntity reqp=(RequestParameterEntity)bean;
- fse = reqp.getFormData();
- }
- //鍒ゆ柇鍙傛暟鏄惁涓虹┖
- if(bean == null || fse == null) {
- return this.error(SystemCode.SYSTEM_FORM_NODATA.getValue(), SystemCode.SYSTEM_FORM_NODATA.getText());
- }
+ FieldSetEntity fse = BaseUtil.getFieldSetEntity(request);
//鍒ゆ柇uuid鏄惁涓虹┖
if (StringUtils.isEmpty(fse.getString(CmnConst.SQL_TEXT))) {
return this.error(SystemCode.SYSTEM_FORM_COUNT.getValue(), SystemCode.SYSTEM_FORM_COUNT.getText());
@@ -257,13 +182,13 @@
return OK_List(dt);
} catch (BaseException e) {
e.printStackTrace();
- return this.error(e.getCode());
+ return this.error(e);
} catch (Exception e) {
e.printStackTrace();
- return this.error("", ReportCode.REPORT_DATASOURCE_ERROR.getText()+e.getMessage());
+ return this.error(ReportCode.REPORT_DATASOURCE_ERROR.getValue(), ReportCode.REPORT_DATASOURCE_ERROR.getText()+e.getMessage());
}
}
-
+
/**
* 鑾峰彇绯荤粺鍙傛暟
* @param response
@@ -323,7 +248,7 @@
return this.error("", e.getMessage());
}
}
-
+
/**
* 鎶ヨ〃鏁版嵁婧愯鎯�
* @param response
@@ -335,26 +260,12 @@
public String getDataReouceOfField(HttpServletResponse response,HttpServletRequest request) {
try {
//鑾峰彇鍙傛暟
- FieldSetEntity fse=null;
- Object bean=request.getAttribute(CoreConst.API_POST_REQUEST_DATA);
- if(bean != null){
- RequestParameterEntity reqp=(RequestParameterEntity)bean;
- fse = reqp.getFormData();
- }
- //鍒ゆ柇鍙傛暟鏄惁涓虹┖
- if(bean == null || fse == null) {
- return this.error(SystemCode.SYSTEM_FORM_NODATA.getValue(), SystemCode.SYSTEM_FORM_NODATA.getText());
- }
- //鍒ゆ柇琛ㄥ悕鏄惁姝e父
- if (!CmnConst.PRODUCT_SYS_REPORT_DATASOURCE_CONFIG_FIELD.equals(fse.getTableName())) {
- return this.error(SystemCode.SYSTEM_TABLE_NODATA.getValue(), SystemCode.SYSTEM_TABLE_NODATA.getText());
- }
+ FieldSetEntity fse = BaseUtil.getFieldSetEntity(request, CmnConst.PRODUCT_SYS_REPORT_DATASOURCE_CONFIG_FIELD);
//鍒ゆ柇uuid鏄惁涓虹┖
if (StringUtils.isEmpty(fse.getUUID())) {
return this.error(SystemCode.SYSTEM_FORM_COUNT.getValue(), SystemCode.SYSTEM_FORM_COUNT.getText());
}
- DataTableEntity dt=reportDatasourceService.getDataReouceOfField(fse.getUUID());
- return OK_List(dt);
+ return OK_List(reportDatasourceService.getDataReouceOfField(fse.getUUID()));
} catch (BaseException e) {
e.printStackTrace();
return this.error(e.getCode(),e.getMessage());
@@ -363,7 +274,7 @@
return this.error(ReportCode.REPORT_DATASOURCE_ERROR.getValue(), ReportCode.REPORT_DATASOURCE_ERROR.getText()+e.getMessage());
}
}
-
+
/**
* 鎶ヨ〃鏁版嵁婧愯鎯�
* @param response
--
Gitblit v1.9.2