Browse Source

超级用户查看数据调整

chenw 6 years ago
parent
commit
7750fe910b

+ 22 - 0
bi-server/src/main/java/com/usoftchina/bi/server/dao/dashboard/DashboardsMapper.java

@@ -91,6 +91,17 @@ public interface DashboardsMapper {
     @ResultMap("DashBoardsResultMap")
     List<Dashboards> getListDashboards(@Param("userId") int userId, TestPage testPage);
 
+    /*
+    查询看板列表
+     */
+    @Select("select id, bd_note as bdNote, bd_name as bdName, CONFIGURATION as bdConfiguration, CREATE_BY as createBy, create_id as createId, CREATE_DATE as createDate, BD_THUMBNAIL as thumbnail, filters, demo, bd_code,bd_menuId  " +
+            "from BI_DASHBOARDS where id in " +
+            " (select bo_da_id from bi_DASHBOARDS_object " +
+            "where (bo_type = '0' and bo_ob_id in (select br_user_group from bi_user_rel_groups)) " +
+            " or (BO_TYPE='1'))")
+    @ResultMap("DashBoardsResultMap")
+    List<Dashboards> getListDashboardsWithoutLimit(TestPage testPage);
+
     /*
     查询看板
      */
@@ -117,6 +128,17 @@ public interface DashboardsMapper {
     })
     Dashboards getDashboards(@Param("userId") int userId, @Param("id") int id);
 
+    /*
+   查询看板
+    */
+    @Select("select id, bd_note as bdNote, bd_name as bdName, CONFIGURATION as bdConfiguration, CREATE_BY as createBy, create_id as createId, CREATE_DATE as createDate, BD_THUMBNAIL as thumbnail, relation_columns as relationColumns, filters, demo, bd_code,bd_menuId " +
+            " from BI_DASHBOARDS where (id in " +
+            " (select bo_da_id from bi_DASHBOARDS_object " +
+            " where (bo_type = '0' and bo_ob_id in (select br_user_group from bi_user_rel_groups))" +
+            " or (BO_TYPE='1'))) and id = #{id}")
+    @ResultMap("DashBoardsResultMap")
+    Dashboards getDashboardsWithoutLimit(@Param("id") int id);
+
     @Select("SELECT id, bd_note as bdNote, bd_name as bdName, CONFIGURATION as bdConfiguration, CREATE_BY as createBy, create_id as createId, CREATE_DATE as createDate, BD_THUMBNAIL as thumbnail, relation_columns as relationColumns, filters, demo, bd_code,bd_menuId FROM BI_DASHBOARDS WHERE BD_CODE = #{code}")
     @ResultMap("DashBoardsResultMap")
     Dashboards getDashboardByCode(String code);

+ 11 - 4
bi-server/src/main/java/com/usoftchina/bi/server/service/chart/ChartsUtilService.java

@@ -1,5 +1,7 @@
 package com.usoftchina.bi.server.service.chart;
 
+import com.usoftchina.bi.core.base.BaseContextHolder;
+import com.usoftchina.bi.core.base.RoleConstant;
 import com.usoftchina.bi.core.utils.GetTokenDataUtil;
 import com.usoftchina.bi.server.dao.chart.ChartsConfigMapper;
 import com.usoftchina.bi.server.dao.dataSource.DataConnectorMapper;
@@ -32,6 +34,7 @@ public class ChartsUtilService {
     public String getSqlStr(String token, int id, int dashId) {
         Map<String, String> resultMap = GetTokenDataUtil.getTokenData(token);
         int userId = Integer.parseInt(resultMap.get("id"));
+        String role = resultMap.get("role");
         int createID;
         int baseId;
         try {
@@ -42,7 +45,7 @@ public class ChartsUtilService {
         }
         String tableName = chartsConfigMapper.getTableName(id);
         if (dashId == 0) {
-            if (userId == createID) {
+            if (userId == createID || RoleConstant.SUPER_ADMIN.getRole().equals(role)) {
                 //如果数据源创建人ID跟用户ID一样,获得数据源全部权限
                 if (tableName == null || "".equals(tableName)) {
                     return "";
@@ -62,7 +65,7 @@ public class ChartsUtilService {
     public String columnNameUtil(int userId, int baseId, String tableName, boolean isOrder, int id, int createBId){
         //用户不是创建人
         List<String> strList = new ArrayList<>();
-
+        String role = BaseContextHolder.getRole();
         if (isOrder){
             int baseCreateId;
             if (id != 0) {
@@ -70,13 +73,17 @@ public class ChartsUtilService {
             }else {
                 baseCreateId = createBId;
             }
-            if (baseCreateId == userId ){
+            if (baseCreateId == userId || RoleConstant.SUPER_ADMIN.getRole().equals(role)){
                 return "(" + tableName +")";
             }else {
                 strList = strategysBdMapper.getSqlStr(userId, baseId);
             }
         }else {
-            strList = strategysChartMapper.getSqlStr(userId, id);
+            if (RoleConstant.SUPER_ADMIN.getRole().equals(role)) {
+                return "(" + tableName +")";
+            }else {
+                strList = strategysChartMapper.getSqlStr(userId, id);
+            }
         }
 
         if (strList.size() == 0){

+ 17 - 7
bi-server/src/main/java/com/usoftchina/bi/server/service/dashboard/DashboardsService.java

@@ -3,7 +3,7 @@ package com.usoftchina.bi.server.service.dashboard;
 import com.alibaba.fastjson.JSON;
 import com.alibaba.fastjson.JSONArray;
 import com.alibaba.fastjson.JSONObject;
-import com.usoftchina.bi.core.base.BaseContextHolder;
+import com.usoftchina.bi.core.base.*;
 import com.usoftchina.bi.core.exception.MyException;
 import com.usoftchina.bi.core.utils.EncryUtil;
 import com.usoftchina.bi.server.dao.chart.ChartsConfigMapper;
@@ -15,9 +15,6 @@ import com.usoftchina.bi.server.model.bo.DashOrder;
 import com.usoftchina.bi.server.model.bo.ShareReqBO;
 import com.usoftchina.bi.server.model.po.ChartConfig;
 import com.usoftchina.bi.server.model.po.Dashboards;
-import com.usoftchina.bi.core.base.RepCode;
-import com.usoftchina.bi.core.base.RepEntity;
-import com.usoftchina.bi.core.base.TestPage;
 import com.usoftchina.bi.server.model.vo.configVo.ChangeOrderInfo;
 import com.usoftchina.bi.server.model.vo.configVo.DashboardsInfo;
 import com.usoftchina.bi.server.model.vo.dataVo.DashboardCopyInfo;
@@ -186,7 +183,13 @@ public class DashboardsService {
      */
     public RepEntity getListDashboards(String token, TestPage testPage) {
         int id = BaseContextHolder.getUserId();
-        List<Dashboards> getListDashboards = dashboardsMapper.getListDashboards(id, testPage.enablePaging());
+        String role = BaseContextHolder.getRole();
+        List<Dashboards> getListDashboards = new ArrayList<>();
+        if (RoleConstant.SUPER_ADMIN.getRole().equals(role)) {
+            getListDashboards = dashboardsMapper.getListDashboardsWithoutLimit(testPage.enablePaging());
+        }else {
+            getListDashboards = dashboardsMapper.getListDashboards(id, testPage.enablePaging());
+        }
         PageInfo<Dashboards> pageInfo = new PageInfo<>(getListDashboards);
         return new RepEntity(RepCode.success, pageInfo);
     }
@@ -196,7 +199,13 @@ public class DashboardsService {
      */
     public RepEntity getDashboards(String token, int id) {
         int userId = BaseContextHolder.getUserId();
-        Dashboards dashboards = dashboardsMapper.getDashboards(userId, id);
+        String role = BaseContextHolder.getRole();
+        Dashboards dashboards = new Dashboards();
+        if (RoleConstant.SUPER_ADMIN.getRole().equals(role)) {
+            dashboards = dashboardsMapper.getDashboardsWithoutLimit(id);
+        }else {
+            dashboards = dashboardsMapper.getDashboards(userId, id);
+        }
         if (dashboards == null){
             return new RepEntity(RepCode.DashboardNonExistent);
         }
@@ -286,8 +295,9 @@ public class DashboardsService {
      */
     public RepEntity changeDashOrder(String token, ChangeOrderInfo changeOrderInfo) {
         int userId = BaseContextHolder.getUserId();
+        String role = BaseContextHolder.getRole();
         int createId = dashboardsMapper.getCreateIdById(changeOrderInfo.getId());
-        if (userId != createId) {
+        if (userId != createId && !RoleConstant.SUPER_ADMIN.getRole().equals(role)) {
             return new RepEntity(RepCode.NoAuthority);
         }
         String name = userMapper.getName(changeOrderInfo.getUserId());