Ver código fonte

Merge branch 'master' of http://git.homecommunity.cn/supervip/MicroCommunity

java110 4 anos atrás
pai
commit
ea2e93ccd7

+ 2 - 2
java110-db/src/main/java/com/java110/db/dao/impl/QueryServiceDAOImpl.java

@@ -64,8 +64,8 @@ public class QueryServiceDAOImpl extends BaseServiceDao implements IQueryService
             //精髓的地方就在这里,类ResultSet有getMetaData()会返回数据的列和对应的值的信息,然后我们将列名和对应的值作为map的键值存入map对象之中...
             ResultSetMetaData rsmd = rs.getMetaData();
             if (columns != null) {
-                for (int i = 1; i < rsmd.getColumnCount(); ++i) {
-                    columns.add(rsmd.getColumnLabel(i));
+                for (int i = 0; i < rsmd.getColumnCount(); i++) {
+                    columns.add(rsmd.getColumnLabel(i+1));
                 }
             }
             while (rs.next()) {

+ 3 - 2
java110-db/src/main/resources/mapper/report/ReportCustomComponentRelV1ServiceDaoImplMapper.xml

@@ -28,7 +28,7 @@
             and t.rel_id= #{relId}
         </if>
         <if test="componentType !=null and componentType != ''">
-            and t.component_type= #{componentType}
+            and cc.component_type= #{componentType}
         </if>
         <if test="componentId !=null and componentId != ''">
             and t.component_id= #{componentId}
@@ -76,12 +76,13 @@
     <select id="queryReportCustomComponentRelsCount" parameterType="Map" resultType="Map">
         select count(1) count
         from report_custom_component_rel t
+        left join report_custom_component cc on t.component_id = cc.component_id and cc.status_cd = '0'
         where 1 =1
         <if test="relId !=null and relId != ''">
             and t.rel_id= #{relId}
         </if>
         <if test="componentType !=null and componentType != ''">
-            and t.component_type= #{componentType}
+            and cc.component_type= #{componentType}
         </if>
         <if test="componentId !=null and componentId != ''">
             and t.component_id= #{componentId}

+ 5 - 0
service-report/src/main/java/com/java110/report/cmd/reportCustomComponent/ListReportCustomComponentCmd.java

@@ -23,7 +23,9 @@ import com.java110.core.event.cmd.CmdEvent;
 import com.java110.dto.reportCustomComponent.ReportCustomComponentDto;
 import com.java110.intf.report.IReportCustomComponentV1InnerServiceSMO;
 import com.java110.utils.exception.CmdException;
+import com.java110.utils.util.Base64Convert;
 import com.java110.utils.util.BeanConvertUtil;
+import com.java110.utils.util.StringUtil;
 import com.java110.vo.ResultVo;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
@@ -68,6 +70,7 @@ public class ListReportCustomComponentCmd extends AbstractServiceCmdListener {
 
         if (count > 0) {
             reportCustomComponentDtos = reportCustomComponentV1InnerServiceSMOImpl.queryReportCustomComponents(reportCustomComponentDto);
+
         } else {
             reportCustomComponentDtos = new ArrayList<>();
         }
@@ -78,4 +81,6 @@ public class ListReportCustomComponentCmd extends AbstractServiceCmdListener {
 
         cmdDataFlowContext.setResponseEntity(responseEntity);
     }
+
+
 }

+ 1 - 1
service-report/src/main/java/com/java110/report/cmd/reportCustomComponent/ListReportCustomComponentDataCmd.java

@@ -101,7 +101,7 @@ public class ListReportCustomComponentDataCmd extends AbstractServiceCmdListener
             }
             reqJsonCount.put("count", "1");
             JSONObject data = queryServiceSMOImpl.execQuerySql(reqJsonCount, sql);
-            total = data.getJSONArray("data").getJSONObject(0).getIntValue("total");
+            total = data.getJSONArray("td").getJSONObject(0).getIntValue("total");
         }
         reqJson.put("count", "0");
         int page = reqJson.getInteger("page");

+ 13 - 0
service-report/src/main/java/com/java110/report/cmd/reportCustomComponent/SaveReportCustomComponentCmd.java

@@ -26,7 +26,9 @@ import com.java110.intf.report.IReportCustomComponentV1InnerServiceSMO;
 import com.java110.po.reportCustomComponent.ReportCustomComponentPo;
 import com.java110.utils.exception.CmdException;
 import com.java110.utils.util.Assert;
+import com.java110.utils.util.Base64Convert;
 import com.java110.utils.util.BeanConvertUtil;
+import com.java110.utils.util.StringUtil;
 import com.java110.vo.ResultVo;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
@@ -67,6 +69,17 @@ public class SaveReportCustomComponentCmd extends AbstractServiceCmdListener {
         ReportCustomComponentPo reportCustomComponentPo = BeanConvertUtil.covertBean(reqJson, ReportCustomComponentPo.class);
         reportCustomComponentPo.setComponentId(GenerateCodeFactory.getGeneratorId(CODE_PREFIX_ID));
         reportCustomComponentPo.setComponentGroup("C");
+        try {
+            if (!StringUtil.isEmpty(reportCustomComponentPo.getComponentSql())) {
+                reportCustomComponentPo.setComponentSql(Base64Convert.byteToBase64(reportCustomComponentPo.getComponentSql().getBytes("UTF-8")));
+            }
+            if (!StringUtil.isEmpty(reportCustomComponentPo.getJavaScript())) {
+                reportCustomComponentPo.setJavaScript(Base64Convert.byteToBase64(reportCustomComponentPo.getJavaScript().getBytes("UTF-8")));
+            }
+        } catch (Exception e) {
+            logger.error("编码失败", e);
+        }
+
         int flag = reportCustomComponentV1InnerServiceSMOImpl.saveReportCustomComponent(reportCustomComponentPo);
 
         if (flag < 1) {

+ 12 - 0
service-report/src/main/java/com/java110/report/cmd/reportCustomComponent/UpdateReportCustomComponentCmd.java

@@ -25,7 +25,9 @@ import com.java110.intf.report.IReportCustomComponentV1InnerServiceSMO;
 import com.java110.po.reportCustomComponent.ReportCustomComponentPo;
 import com.java110.utils.exception.CmdException;
 import com.java110.utils.util.Assert;
+import com.java110.utils.util.Base64Convert;
 import com.java110.utils.util.BeanConvertUtil;
+import com.java110.utils.util.StringUtil;
 import com.java110.vo.ResultVo;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
@@ -63,6 +65,16 @@ public class UpdateReportCustomComponentCmd extends AbstractServiceCmdListener {
     public void doCmd(CmdEvent event, ICmdDataFlowContext cmdDataFlowContext, JSONObject reqJson) throws CmdException {
 
         ReportCustomComponentPo reportCustomComponentPo = BeanConvertUtil.covertBean(reqJson, ReportCustomComponentPo.class);
+        try {
+            if (!StringUtil.isEmpty(reportCustomComponentPo.getComponentSql())) {
+                reportCustomComponentPo.setComponentSql(Base64Convert.byteToBase64(reportCustomComponentPo.getComponentSql().getBytes("UTF-8")));
+            }
+            if (!StringUtil.isEmpty(reportCustomComponentPo.getJavaScript())) {
+                reportCustomComponentPo.setJavaScript(Base64Convert.byteToBase64(reportCustomComponentPo.getJavaScript().getBytes("UTF-8")));
+            }
+        } catch (Exception e) {
+            logger.error("编码失败", e);
+        }
         int flag = reportCustomComponentV1InnerServiceSMOImpl.updateReportCustomComponent(reportCustomComponentPo);
 
         if (flag < 1) {

+ 35 - 17
service-report/src/main/java/com/java110/report/smo/impl/ReportCustomComponentV1InnerServiceSMOImpl.java

@@ -16,19 +16,19 @@
 package com.java110.report.smo.impl;
 
 
-import com.java110.report.dao.IReportCustomComponentV1ServiceDao;
-import com.java110.intf.report.IReportCustomComponentV1InnerServiceSMO;
+import com.java110.core.base.smo.BaseServiceSMO;
+import com.java110.dto.PageDto;
 import com.java110.dto.reportCustomComponent.ReportCustomComponentDto;
+import com.java110.intf.report.IReportCustomComponentV1InnerServiceSMO;
 import com.java110.po.reportCustomComponent.ReportCustomComponentPo;
+import com.java110.report.dao.IReportCustomComponentV1ServiceDao;
+import com.java110.utils.util.Base64Convert;
 import com.java110.utils.util.BeanConvertUtil;
-import com.java110.core.base.smo.BaseServiceSMO;
-import com.java110.dto.user.UserDto;
-import com.java110.dto.PageDto;
+import com.java110.utils.util.StringUtil;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.web.bind.annotation.RequestBody;
 import org.springframework.web.bind.annotation.RestController;
 
-import java.util.ArrayList;
 import java.util.List;
 
 /**
@@ -47,26 +47,26 @@ public class ReportCustomComponentV1InnerServiceSMOImpl extends BaseServiceSMO i
 
 
     @Override
-    public int saveReportCustomComponent(@RequestBody  ReportCustomComponentPo reportCustomComponentPo) {
+    public int saveReportCustomComponent(@RequestBody ReportCustomComponentPo reportCustomComponentPo) {
         int saveFlag = reportCustomComponentV1ServiceDaoImpl.saveReportCustomComponentInfo(BeanConvertUtil.beanCovertMap(reportCustomComponentPo));
         return saveFlag;
     }
 
-     @Override
-    public int updateReportCustomComponent(@RequestBody  ReportCustomComponentPo reportCustomComponentPo) {
+    @Override
+    public int updateReportCustomComponent(@RequestBody ReportCustomComponentPo reportCustomComponentPo) {
         int saveFlag = reportCustomComponentV1ServiceDaoImpl.updateReportCustomComponentInfo(BeanConvertUtil.beanCovertMap(reportCustomComponentPo));
         return saveFlag;
     }
 
-     @Override
-    public int deleteReportCustomComponent(@RequestBody  ReportCustomComponentPo reportCustomComponentPo) {
-       reportCustomComponentPo.setStatusCd("1");
-       int saveFlag = reportCustomComponentV1ServiceDaoImpl.updateReportCustomComponentInfo(BeanConvertUtil.beanCovertMap(reportCustomComponentPo));
-       return saveFlag;
+    @Override
+    public int deleteReportCustomComponent(@RequestBody ReportCustomComponentPo reportCustomComponentPo) {
+        reportCustomComponentPo.setStatusCd("1");
+        int saveFlag = reportCustomComponentV1ServiceDaoImpl.updateReportCustomComponentInfo(BeanConvertUtil.beanCovertMap(reportCustomComponentPo));
+        return saveFlag;
     }
 
     @Override
-    public List<ReportCustomComponentDto> queryReportCustomComponents(@RequestBody  ReportCustomComponentDto reportCustomComponentDto) {
+    public List<ReportCustomComponentDto> queryReportCustomComponents(@RequestBody ReportCustomComponentDto reportCustomComponentDto) {
 
         //校验是否传了 分页信息
 
@@ -77,13 +77,31 @@ public class ReportCustomComponentV1InnerServiceSMOImpl extends BaseServiceSMO i
         }
 
         List<ReportCustomComponentDto> reportCustomComponents = BeanConvertUtil.covertBeanList(reportCustomComponentV1ServiceDaoImpl.getReportCustomComponentInfo(BeanConvertUtil.beanCovertMap(reportCustomComponentDto)), ReportCustomComponentDto.class);
-
+        desCode(reportCustomComponents);
         return reportCustomComponents;
     }
 
 
     @Override
     public int queryReportCustomComponentsCount(@RequestBody ReportCustomComponentDto reportCustomComponentDto) {
-        return reportCustomComponentV1ServiceDaoImpl.queryReportCustomComponentsCount(BeanConvertUtil.beanCovertMap(reportCustomComponentDto));    }
+        return reportCustomComponentV1ServiceDaoImpl.queryReportCustomComponentsCount(BeanConvertUtil.beanCovertMap(reportCustomComponentDto));
+    }
+
+    private void desCode(List<ReportCustomComponentDto> reportCustomComponentDtos) {
+        if (reportCustomComponentDtos == null || reportCustomComponentDtos.size() < 1) {
+            return;
+        }
+        for (ReportCustomComponentDto reportCustomComponentDto : reportCustomComponentDtos) {
+            try {
+                if (!StringUtil.isEmpty(reportCustomComponentDto.getComponentSql())) {
+                    reportCustomComponentDto.setComponentSql(new String(Base64Convert.base64ToByte(reportCustomComponentDto.getComponentSql()), "UTF-8"));
+                }
+                if (!StringUtil.isEmpty(reportCustomComponentDto.getJavaScript())) {
+                    reportCustomComponentDto.setJavaScript(new String(Base64Convert.base64ToByte(reportCustomComponentDto.getJavaScript()), "UTF-8"));
+                }
+            } catch (Exception e) {
+            }
+        }
+    }
 
 }