杜洪波
6 天以前 e4bd5c35f7ced8854b1caa6defa342d35d337b5e
src/main/java/com/product/server/report/controller/ReportDatasourceController.java
@@ -26,14 +26,16 @@
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;
   /**
    *    报表数据源列表
@@ -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());
         }
         //判断表名是否正常
         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());
@@ -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());
         }
         //判断表名是否正常
         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());
@@ -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());
         }
         //判断表名是否正常
         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());
         }
         //判断表名是否正常
         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();
@@ -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());
         }
         //判断表名是否正常
         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());
@@ -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());
@@ -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());
         }
         //判断表名是否正常
         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());