Browse Source

Merge remote-tracking branch 'origin/feature-refactor' into feature-refactor

hy 6 years ago
parent
commit
7b1a2dc22e
20 changed files with 167 additions and 62 deletions
  1. 5 0
      bi-auth/src/main/java/com/usoftchina/bi/auth/interceptor/SecurityInterceptor.java
  2. 9 0
      bi-core/src/main/java/com/usoftchina/bi/core/base/BaseContextHolder.java
  3. 33 0
      bi-core/src/main/java/com/usoftchina/bi/core/base/RoleConstant.java
  4. 0 1
      bi-server/src/main/java/com/usoftchina/bi/server/Application.java
  5. 1 0
      bi-server/src/main/java/com/usoftchina/bi/server/aspect/JwtTokenAspect.java
  6. 2 2
      bi-server/src/main/java/com/usoftchina/bi/server/controller/dashboard/DashboardsController.java
  7. 2 2
      bi-server/src/main/java/com/usoftchina/bi/server/controller/dataSource/DataBasesController.java
  8. 3 0
      bi-server/src/main/java/com/usoftchina/bi/server/dao/chart/ChartsConfigMapper.java
  9. 33 3
      bi-server/src/main/java/com/usoftchina/bi/server/dao/dashboard/DashBoardMenuMapper.java
  10. 13 0
      bi-server/src/main/java/com/usoftchina/bi/server/dao/dataSource/DataConnectorMapper.java
  11. 3 3
      bi-server/src/main/java/com/usoftchina/bi/server/dao/user/UserMapper.java
  12. 7 12
      bi-server/src/main/java/com/usoftchina/bi/server/service/chart/ChartsConfigService.java
  13. 20 7
      bi-server/src/main/java/com/usoftchina/bi/server/service/dashboard/DashBoardMenuService.java
  14. 12 12
      bi-server/src/main/java/com/usoftchina/bi/server/service/dashboard/DashboardsService.java
  15. 6 6
      bi-server/src/main/java/com/usoftchina/bi/server/service/dataSource/DataBasesService.java
  16. 16 12
      bi-server/src/main/java/com/usoftchina/bi/server/service/dataSource/DataConnectorService.java
  17. 0 0
      bi-server/src/main/resources/static/index.250ed1fb.js
  18. 0 0
      bi-server/src/main/resources/static/index.89cfd43f.js
  19. 0 0
      bi-server/src/main/resources/static/index.965ee983.css
  20. 2 2
      bi-server/src/main/resources/static/index.html

+ 5 - 0
bi-auth/src/main/java/com/usoftchina/bi/auth/interceptor/SecurityInterceptor.java

@@ -4,6 +4,7 @@ import com.fasterxml.jackson.databind.ObjectMapper;
 import com.usoftchina.bi.auth.annotation.Auth;
 import com.usoftchina.bi.core.base.RepCode;
 import com.usoftchina.bi.core.base.RepEntity;
+import com.usoftchina.bi.core.base.RoleConstant;
 import com.usoftchina.bi.core.utils.GetTokenDataUtil;
 import com.usoftchina.bi.core.utils.JsonUtils;
 import org.slf4j.Logger;
@@ -47,6 +48,10 @@ public class SecurityInterceptor implements HandlerInterceptor {
         String token = request.getHeader("token");
         Map<String, String> resultMap = GetTokenDataUtil.getTokenData(token);
         logger.info("authRole={},userRole={}", admin, resultMap.get("role"));
+        //超级管理员跳过认证
+        if (RoleConstant.SUPER_ADMIN.getRole().equals(resultMap.get("role"))) {
+            return true;
+        }
         if (!admin.equals(resultMap.get("role"))) {
             returnErrorMessage(request, response, RepCode.NoAuthority);
             return false;

+ 9 - 0
bi-core/src/main/java/com/usoftchina/bi/core/base/BaseContextHolder.java

@@ -47,4 +47,13 @@ public class BaseContextHolder {
     public static void setUserName(String userName) {
         set("userName", userName);
     }
+
+    public static String getRole(){
+        Object value = get("role");
+        return String.valueOf(value);
+    }
+
+    public static void setRole(String role){
+        set("role", role);
+    }
 }

+ 33 - 0
bi-core/src/main/java/com/usoftchina/bi/core/base/RoleConstant.java

@@ -0,0 +1,33 @@
+package com.usoftchina.bi.core.base;
+
+/**
+ * 角色枚举类
+ * @Author chenwei
+ * @Date 2019-05-15
+ */
+public enum RoleConstant {
+
+    /**
+     * 超级管理员
+     */
+    SUPER_ADMIN("superAdmin"),
+    /**
+     * 管理员
+     */
+    ADMIN("admin"),
+    /**
+     * 普通用户
+     */
+    NORMAL("normal");
+
+    String role;
+
+    RoleConstant(String role) {
+        this.role = role;
+    }
+
+    public String getRole() {
+        return role;
+    }
+
+}

+ 0 - 1
bi-server/src/main/java/com/usoftchina/bi/server/Application.java

@@ -14,7 +14,6 @@ import springfox.documentation.swagger2.annotations.EnableSwagger2;
 @SpringBootApplication
 @EnableSwagger2
 @Import({DynamicDataSourceRegister.class})
-@EnableCaching
 @EnableScheduling
 @ComponentScan("com.usoftchina.bi")
 public class Application {

+ 1 - 0
bi-server/src/main/java/com/usoftchina/bi/server/aspect/JwtTokenAspect.java

@@ -94,6 +94,7 @@ public class JwtTokenAspect {
         }
         BaseContextHolder.setUserId(Integer.valueOf(jwt.getClaim("id").asString()));
         BaseContextHolder.setUserName(jwt.getClaim("name").asString());
+        BaseContextHolder.setRole(jwt.getClaim("role").asString());
         return jwt.getClaims();
     }
 }

+ 2 - 2
bi-server/src/main/java/com/usoftchina/bi/server/controller/dashboard/DashboardsController.java

@@ -34,7 +34,7 @@ public class DashboardsController {
      */
     @ApiOperation(value = "保存看板", notes = "保存看板", response = RepEntity.class)
     @CheckToken
-    @Log(module = "看板", name = "#body.bdName", token = "#token")
+    @Log(module = "报表", name = "#body.bdName", token = "#token")
     @PostMapping("/inputDashboards")
     public RepEntity saveDashboards(@RequestHeader String token, @RequestBody DashboardsInfo body){
         return dashboardsService.setDashboards(token, body);
@@ -45,7 +45,7 @@ public class DashboardsController {
      */
     @ApiOperation(value = "更新看板", notes = "更新看板", response = RepEntity.class)
     @CheckToken
-    @Log(module = "看板", name = "#body.bdName", token = "#token")
+    @Log(module = "报表", name = "#body.bdName", token = "#token")
     @PostMapping("/updateDashboards")
     public RepEntity updateDashboards(@RequestHeader String token,@RequestBody DashboardsInfo body){
         return dashboardsService.updateDashboards(token, body);

+ 2 - 2
bi-server/src/main/java/com/usoftchina/bi/server/controller/dataSource/DataBasesController.java

@@ -29,7 +29,7 @@ public class DataBasesController {
     @ApiOperation(value = "保存数据库配置", notes = "保存数据库配置", response = RepEntity.class)
     @CheckToken
     @Auth(user = "admin")
-    @Log(module = "数据接", name = "#body.name", token = "#token")
+    @Log(module = "数据接", name = "#body.name", token = "#token")
     @PostMapping("/inputDatabases")
     public RepEntity saveDatabases(@RequestHeader String token, @RequestBody DatabasesInfo body){
         return dataBasesService.inputDatabases(body);
@@ -63,7 +63,7 @@ public class DataBasesController {
     @ApiOperation(value = "更新数据库配置", notes = "更新数据库配置", response = RepEntity.class)
     @CheckToken
     @Auth(user = "admin")
-    @Log(module = "数据接", name = "#databasesInfo.name", token = "#token")
+    @Log(module = "数据接", name = "#databasesInfo.name", token = "#token")
     @PostMapping("/updatabases")
     public RepEntity updateDatabases(@RequestHeader String token,@RequestBody DatabasesInfo databasesInfo){
         return dataBasesService.updatabases(databasesInfo);

+ 3 - 0
bi-server/src/main/java/com/usoftchina/bi/server/dao/chart/ChartsConfigMapper.java

@@ -103,6 +103,9 @@ public interface ChartsConfigMapper {
             "    ))")
     List<ChartConfigList> getListByUser(@Param("id") int id, TestPage testPage);
 
+    @Select("")
+    List<ChartConfigList> getListWithoutLimit(@Param("id") int id, TestPage testPage);
+
     /*
     通过Id查找表名
     */

+ 33 - 3
bi-server/src/main/java/com/usoftchina/bi/server/dao/dashboard/DashBoardMenuMapper.java

@@ -13,11 +13,31 @@ import java.util.List;
 @Repository
 public interface DashBoardMenuMapper {
 
+    /**
+     * 普通用户/管理员查看
+     * @param userId
+     * @param id
+     * @return
+     */
     @Select("SELECT BDM_ID id,BDM_NAME name,'menu' type,BDM_PARENTID parentId FROM BI_DASHBOARDS_MENU WHERE BDM_PARENTID = #{id, jdbcType=INTEGER} "
-            + "UNION ALL "
-            + "SELECT ID id,BD_NAME name,'dashboard' type,BD_MENUID parentId FROM BI_DASHBOARDS WHERE BD_MENUID = #{id, jdbcType=INTEGER} AND CREATE_ID = #{userId,jdbcType=INTEGER}")
+            + " UNION "
+            + " SELECT ID id,BD_NAME name,'dashboard' type,BD_MENUID parentId FROM BI_DASHBOARDS WHERE BD_MENUID = #{id, jdbcType=INTEGER} AND CREATE_ID = #{userId,jdbcType=INTEGER} "
+            + " UNION "
+            + " SELECT ID id,BD_NAME name,'dashboard' type,BD_MENUID parentId FROM BI_POWER_USERS INNER JOIN BI_DASHBOARDS ON ID = BPU_DASHBOARDID WHERE BPU_USERID = #{userId,jdbcType=INTEGER} "
+            + " UNION "
+            + " SELECT ID id,BD_NAME name,'dashboard' type,BD_MENUID parentId FROM BI_POWER_USERS INNER JOIN BI_DASHBOARDS ON ID = BPU_DASHBOARDID WHERE BPU_USERGROUPID IN (SELECT BR_USER_GROUP FROM BI_USER_REL_GROUPS WHERE BR_USER_ID = #{userId,jdbcType=INTEGER}) ")
     List<DashboardMenuRespDTO> getMenuById(@Param("userId") int userId, @Param("id") int id);
 
+    /**
+     * 超级用户查看
+     * @param id
+     * @return
+     */
+    @Select("SELECT BDM_ID id,BDM_NAME name,'menu' type,BDM_PARENTID parentId FROM BI_DASHBOARDS_MENU WHERE BDM_PARENTID = #{id, jdbcType=INTEGER} "
+            + " UNION "
+            + " SELECT ID id,BD_NAME name,'dashboard' type,BD_MENUID parentId FROM BI_DASHBOARDS WHERE BD_MENUID = #{id, jdbcType=INTEGER} ")
+    List<DashboardMenuRespDTO> getMenuWithNoLimit(int id);
+
     /**
      * 保存
      * @param dashBoardMenuInfo
@@ -71,7 +91,7 @@ public interface DashBoardMenuMapper {
     void updateDashBoardMenu(DashBoardUpdateMenuInfo dashBoardUpdateMenuInfo);
 
     /**
-     * 获取目录下的所有看板
+     * 普通用户/管理员 获取目录下的所有看板
      * @param userId
      * @param menuId
      * @return
@@ -82,4 +102,14 @@ public interface DashBoardMenuMapper {
             + "AND CREATE_ID = #{userId,jdbcType=INTEGER}")
     List<Dashboards> getDashBoardByMenuId(@Param("userId") int userId, @Param("menuId") int menuId);
 
+    /**
+     * 超级用户 获取目录下的所有看板
+     * @param menuId
+     * @return
+     */
+    @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 as bdCode,BD_MENUID as menuId  FROM BI_DASHBOARDS WHERE BD_MENUID = #{menuId,jdbcType=INTEGER} ")
+    List<Dashboards> getDashBoardByMenuIdWithoutLimit(@Param("menuId") int menuId);
+
 }

+ 13 - 0
bi-server/src/main/java/com/usoftchina/bi/server/dao/dataSource/DataConnectorMapper.java

@@ -94,6 +94,19 @@ public interface DataConnectorMapper {
     List<DataConnectorList> getDataConnectorList(@Param("id") int id, TestPage testPage);
 
 
+    /**
+     * 查询已经启用的数据源列表
+     * @param id
+     * @param testPage
+     * @return
+     */
+    @Select("select id as dataId, con_type as type, data_name as dataName, data_tag as dataTag, data_note as note, " +
+            "bc.create_by as createBy, bc.create_date as createDate," +
+            "used_number as usedNumber, db_config as dbConfig ,BD_group as connectorGroup, " +
+            "create_id as createId, demo from bi_data_connectors bc where is_open = '1' ORDER BY dataId DESC")
+    @ResultMap("DataConnectorListResultMap")
+    List<DataConnectorList> getDataConnectorListWithoutLimit(@Param("id") int id, TestPage testPage);
+
     /*
     转交数据源
      */

+ 3 - 3
bi-server/src/main/java/com/usoftchina/bi/server/dao/user/UserMapper.java

@@ -112,7 +112,7 @@ public interface UserMapper {
      */
     @Select("SELECT BU_ID as id, BU_NAME as name, BU_DEPARTMENT as department, BU_POST as post, BU_ROLE as role," +
             " USER_NAME as userName, PASS_WORD as passWord, BU_PHONE as phone, BU_CLASS as state " +
-            "FROM BI_USERS WHERE USER_NAME = #{userName} OR BU_PHONE = #{userName}")
+            "FROM BI_USERS WHERE (USER_NAME = #{userName} OR BU_PHONE = #{userName}) and rownum = 1")
     User getLogin(String userName);
 
     /*
@@ -132,7 +132,7 @@ public interface UserMapper {
      */
     @Select("select BU_ID as id, BU_NAME as name, BU_DEPARTMENT as department, BU_POST as post, BU_ROLE as role," +
             "user_name as userName, pass_word as passWord, create_date as createDate " +
-            "from bi_users WHERE BU_CLASS <> '离职'")
+            "from bi_users WHERE BU_CLASS <> '离职' AND BU_ROLE <> 'superAdmin'")
     List<User> getUserList();
 
     @Select("select BU_ID as id, BU_NAME as name, BU_DEPARTMENT as department, BU_POST as post, BU_ROLE as role," +
@@ -144,7 +144,7 @@ public interface UserMapper {
     匹配用户20个
      */
     @Select("select BU_ID as id, BU_NAME as name, BU_DEPARTMENT as department, BU_POST as post, BU_ROLE as role " +
-            "from bi_users where bu_name ${condition} AND BU_CLASS <> '离职' and rownum < #{count, jdbcType=INTEGER}")
+            "from bi_users where bu_name ${condition} AND BU_CLASS <> '离职' AND BU_ROLE <> 'superAdmin' and rownum < #{count, jdbcType=INTEGER}")
     List<User> getNameList(@Param("condition") String condition, @Param("count") Long count);
 
     /*

+ 7 - 12
bi-server/src/main/java/com/usoftchina/bi/server/service/chart/ChartsConfigService.java

@@ -1,9 +1,6 @@
 package com.usoftchina.bi.server.service.chart;
 
-import com.usoftchina.bi.core.base.BaseContextHolder;
-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.core.base.*;
 import com.usoftchina.bi.core.exception.MyException;
 import com.usoftchina.bi.core.utils.GetTokenDataUtil;
 import com.usoftchina.bi.server.dao.chart.ChartsConfigMapper;
@@ -47,9 +44,8 @@ public class ChartsConfigService {
     保存表设置
      */
     public RepEntity setChartsConfig(ChartConfigInfo chartConfigInfo, String token){
-        Map<String, String> resMap = GetTokenDataUtil.getTokenData(token);
-        int userId = Integer.parseInt(resMap.get("id"));
-        String userName = resMap.get("name");
+        int userId = BaseContextHolder.getUserId();
+        String userName = BaseContextHolder.getUserName();
         ChartConfig chartConfig = new ChartConfig();
         BeanUtils.copyProperties(chartConfigInfo, chartConfig);
 
@@ -104,11 +100,10 @@ public class ChartsConfigService {
     更新表设置
      */
     public RepEntity updateChartsConfig(ChartConfigInfo chartConfigInfo, String token){
-        Map<String, String> resMap = GetTokenDataUtil.getTokenData(token);
-        int userId = Integer.parseInt(resMap.get("id"));
-        String userName = resMap.get("name");
+        int userId = BaseContextHolder.getUserId();
+        String userName = BaseContextHolder.getUserName();
         int createID = chartsConfigMapper.getCreateId(chartConfigInfo.getChartId());
-        if (userId != createID){
+        if (userId != createID && !RoleConstant.ADMIN.getRole().equals(BaseContextHolder.getRole())){
             return new RepEntity(RepCode.NoAuthority);
         }
         ChartConfig chartConfig = new ChartConfig();
@@ -165,7 +160,7 @@ public class ChartsConfigService {
         int userId = BaseContextHolder.getUserId();
         String username = BaseContextHolder.getUserName();
         int createId = chartsConfigMapper.getCreateId(changeOrderInfo.getId());
-        if (createId != userId){
+        if (createId != userId && !RoleConstant.SUPER_ADMIN.getRole().equals(BaseContextHolder.getRole())){
             return new RepEntity(RepCode.NoAuthority);
         }
         chartsConfigMapper.changeChartOrder(username, changeOrderInfo.getUserId(), changeOrderInfo.getId());

+ 20 - 7
bi-server/src/main/java/com/usoftchina/bi/server/service/dashboard/DashBoardMenuService.java

@@ -1,7 +1,9 @@
 package com.usoftchina.bi.server.service.dashboard;
 
+import com.usoftchina.bi.core.base.BaseContextHolder;
 import com.usoftchina.bi.core.base.RepCode;
 import com.usoftchina.bi.core.base.RepEntity;
+import com.usoftchina.bi.core.base.RoleConstant;
 import com.usoftchina.bi.core.exception.MyException;
 import com.usoftchina.bi.core.utils.GetTokenDataUtil;
 import com.usoftchina.bi.server.dao.dashboard.DashBoardMenuMapper;
@@ -13,6 +15,7 @@ import org.springframework.stereotype.Service;
 import org.springframework.util.Assert;
 import org.springframework.util.CollectionUtils;
 
+import java.util.ArrayList;
 import java.util.List;
 
 /**
@@ -26,16 +29,21 @@ public class DashBoardMenuService {
     private DashBoardMenuMapper dashBoardMenuMapper;
 
     public List<DashboardMenuRespDTO> list(String token){
-        int userId = Integer.parseInt(GetTokenDataUtil.getTokenData(token).get("id"));
-        return getData(userId, 0);
+        String role = BaseContextHolder.getRole();
+        return getData(BaseContextHolder.getUserId(), 0, role);
     }
 
-    private List<DashboardMenuRespDTO> getData(int userId, int id){
-        List<DashboardMenuRespDTO> dashboardMenuRespDTOList = dashBoardMenuMapper.getMenuById(userId, id);
+    private List<DashboardMenuRespDTO> getData(int userId, int id, String role){
+        List<DashboardMenuRespDTO> dashboardMenuRespDTOList = new ArrayList<>();
+        if (!RoleConstant.SUPER_ADMIN.getRole().equals(role)) {
+            dashboardMenuRespDTOList = dashBoardMenuMapper.getMenuById(userId, id);
+        }else {
+            dashboardMenuRespDTOList = dashBoardMenuMapper.getMenuWithNoLimit(id);
+        }
         if (!CollectionUtils.isEmpty(dashboardMenuRespDTOList)) {
             for (DashboardMenuRespDTO dashboardMenuRespDTO : dashboardMenuRespDTOList) {
                 if ("menu".equals(dashboardMenuRespDTO.getType())) {
-                    dashboardMenuRespDTO.setChildren(getData(userId, dashboardMenuRespDTO.getId()));
+                    dashboardMenuRespDTO.setChildren(getData(userId, dashboardMenuRespDTO.getId(), role));
                 }
             }
         }
@@ -65,8 +73,13 @@ public class DashBoardMenuService {
     }
 
     public RepEntity getDashBoardByMenuId(String token, int menuId){
-        int userId = Integer.parseInt(GetTokenDataUtil.getTokenData(token).get("id"));
-        return new RepEntity(RepCode.success, dashBoardMenuMapper.getDashBoardByMenuId(userId, menuId));
+        int userId = BaseContextHolder.getUserId();
+        String role = BaseContextHolder.getRole();
+        if (!RoleConstant.SUPER_ADMIN.getRole().equals(role)) {
+            return new RepEntity(RepCode.success, dashBoardMenuMapper.getDashBoardByMenuId(userId, menuId));
+        }else {
+            return new RepEntity(RepCode.success, dashBoardMenuMapper.getDashBoardByMenuIdWithoutLimit(menuId));
+        }
     }
 
 }

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

@@ -58,7 +58,7 @@ public class DashboardsService {
     private static final Logger LOGGER = LoggerFactory.getLogger(DashboardsService.class);
 
     /*
-    保存看板
+    保存报表
      */
     public RepEntity setDashboards(String token, DashboardsInfo dashboardsInfo) {
         //校验报表编号是否已存在
@@ -85,7 +85,7 @@ public class DashboardsService {
     }
 
     /*
-    更新看板
+    更新报表
      */
     public RepEntity updateDashboards(String token, DashboardsInfo dashboardsInfo) {
         //校验报表编号是否已存在
@@ -161,7 +161,7 @@ public class DashboardsService {
     }
 
     /*
-    删除看板
+    删除报表
      */
     public RepEntity delDashboards(String token, Integer id) {
         int userId = BaseContextHolder.getUserId();
@@ -175,14 +175,14 @@ public class DashboardsService {
             name = dashboards.getBdName();
         }
         dashboardsMapper.delDashboards(id);
-        //删除看板-图表关联关系
+        //删除报表-图表关联关系
         dashboardsMapper.deleteDashboardChartRelation(id);
-        messageLogService.delete("看板", name, BaseContextHolder.getUserName(), null);
+        messageLogService.delete("报表", name, BaseContextHolder.getUserName(), null);
         return new RepEntity(RepCode.success);
     }
 
     /*
-    查看看板
+    查看报表
      */
     public RepEntity getListDashboards(String token, TestPage testPage) {
         int id = BaseContextHolder.getUserId();
@@ -192,7 +192,7 @@ public class DashboardsService {
     }
 
     /*
-    查看单个看板
+    查看单个报表
      */
     public RepEntity getDashboards(String token, int id) {
         int userId = BaseContextHolder.getUserId();
@@ -204,7 +204,7 @@ public class DashboardsService {
     }
 
     /**
-     * 通过code查看单个看板
+     * 通过code查看单个报表
      * @param code
      * @return
      */
@@ -262,7 +262,7 @@ public class DashboardsService {
     }
 
     /**
-     * 通过分享链接获取看板信息
+     * 通过分享链接获取报表信息
      * @param data
      * @return
      */
@@ -282,7 +282,7 @@ public class DashboardsService {
     }
 
     /*
-    转交看板
+    转交报表
      */
     public RepEntity changeDashOrder(String token, ChangeOrderInfo changeOrderInfo) {
         int userId = BaseContextHolder.getUserId();
@@ -296,7 +296,7 @@ public class DashboardsService {
     }
 
     /*
-    查看看板分发对象
+    查看报表分发对象
      */
     public RepEntity getDashOrder(String token, int dashId) {
         int userId = BaseContextHolder.getUserId();
@@ -324,7 +324,7 @@ public class DashboardsService {
     }
 
     /**
-     * 复制看板
+     * 复制报表
      * @param dashboardCopyInfo
      * @return
      */

+ 6 - 6
bi-server/src/main/java/com/usoftchina/bi/server/service/dataSource/DataBasesService.java

@@ -48,7 +48,7 @@ public class DataBasesService {
 
     private static final Logger LOGGER = LoggerFactory.getLogger(DataBasesService.class);
     /*
-   保存数据库
+   保存数据库
     */
     public RepEntity inputDatabases(DatabasesInfo databasesInfo){
         if (databasesInfo == null || "".equals(databasesInfo)){
@@ -56,9 +56,9 @@ public class DataBasesService {
         }
         Databases databases = new Databases();
         BeanUtils.copyProperties(databasesInfo, databases);
-        //校验此数据接是否已存在
+        //校验此数据接是否已存在
         validExists(databases);
-        //校验此接是否可用
+        //校验此接是否可用
         implementSqlService.connectTest(databases);
 
         String note = databases.getNote();
@@ -76,7 +76,7 @@ public class DataBasesService {
     }
 
     /**
-     * 校验此数据接是否已存在
+     * 校验此数据接是否已存在
      * @param databases
      */
     private void validExists(Databases databases){
@@ -117,7 +117,7 @@ public class DataBasesService {
         }
         String databaseName = dataConnectorMapper.getDatabases(id.intValue()).getName();
         dataConnectorMapper.deleteDatabases(id);
-        messageLogService.delete("数据接", databaseName, username, null);
+        messageLogService.delete("数据接", databaseName, username, null);
         return new RepEntity(RepCode.success);
     }
 
@@ -130,7 +130,7 @@ public class DataBasesService {
         if (databases.getPassWord() == null || "".equals(databases.getPassWord())){
             databases.setPassWord(null);
         }
-        //校验此接是否可用
+        //校验此接是否可用
         implementSqlService.connectTest(databases);
         //更新
         dataConnectorMapper.updatabases(databases);

+ 16 - 12
bi-server/src/main/java/com/usoftchina/bi/server/service/dataSource/DataConnectorService.java

@@ -1,6 +1,6 @@
 package com.usoftchina.bi.server.service.dataSource;
 
-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.GetTokenDataUtil;
 import com.usoftchina.bi.server.dao.chart.ChartsConfigMapper;
@@ -15,9 +15,6 @@ import com.usoftchina.bi.server.model.bo.GroupUpdateId;
 import com.usoftchina.bi.server.model.po.BaseConfig;
 import com.usoftchina.bi.server.model.po.DataConnector;
 import com.usoftchina.bi.server.model.po.DataConnectorList;
-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.po.MessageLog;
 import com.usoftchina.bi.server.model.vo.configVo.*;
 import com.usoftchina.bi.server.model.vo.dataVo.ColumnValuesInfo;
@@ -129,9 +126,14 @@ public class DataConnectorService {
      */
 //    @Cacheable(value = "dataConnector", key = "#testPage.pageNum")
     public RepEntity getListConnector(String token, TestPage testPage) {
-        Map<String, String> resultMap = GetTokenDataUtil.getTokenData(token);
-        String id = resultMap.get("id");
-        List<DataConnectorList> listConnector = dataConnectorMapper.getDataConnectorList(Integer.parseInt(id), testPage.enablePaging());
+        int id = BaseContextHolder.getUserId();
+        String role = BaseContextHolder.getRole();
+        List<DataConnectorList> listConnector = new ArrayList<>();
+        if (RoleConstant.SUPER_ADMIN.getRole().equals(role)) {
+            listConnector = dataConnectorMapper.getDataConnectorListWithoutLimit(id, testPage.enablePaging());
+        }else {
+            listConnector = dataConnectorMapper.getDataConnectorList(id, testPage.enablePaging());
+        }
         List<DataConnectorList> listConnectors = new ArrayList<>();
         Iterator isList = listConnector.iterator();
         while (isList.hasNext()) {
@@ -208,9 +210,10 @@ public class DataConnectorService {
      */
     public RepEntity changeOrder(ChangeOrderInfo changeOrderInfo) {
         int userId = BaseContextHolder.getUserId();
+        String role = BaseContextHolder.getRole();
         String name = BaseContextHolder.getUserName();
         int createId = dataConnectorMapper.getCreateIdById(changeOrderInfo.getId());
-        if (createId != userId) {
+        if (createId != userId && !RoleConstant.SUPER_ADMIN.getRole().equals(role)) {
             return new RepEntity(RepCode.NoAuthority);
         }
         dataConnectorMapper.updataOrder(name, changeOrderInfo.getUserId(), changeOrderInfo.getId());
@@ -309,8 +312,7 @@ public class DataConnectorService {
      */
     public RepEntity updataDataConnectorGroup(String token, GroupInfo groupInfo) {
         dataConnectorMapper.updataConnectorGroup(groupInfo);
-        Map<String, String> resMap = GetTokenDataUtil.getTokenData(token);
-        String username = resMap.get("name");
+        String username = BaseContextHolder.getUserName();
         messageLogService.update("数据源分组", groupInfo.getGroupName(), username, "更新分组");
         return new RepEntity(RepCode.success);
     }
@@ -366,14 +368,16 @@ public class DataConnectorService {
         int baseId = getChartsDataUtilService.getBaseIdByConnect(dataId);
         logger.info("切换数据库:{}", baseId);
 
-        Map<String, String> resultMap = GetTokenDataUtil.getTokenData(token);
-        int id = Integer.parseInt(resultMap.get("id"));
+        int id = BaseContextHolder.getUserId();
         int createId = dataConnectorMapper.getCreateIdById(dataId);
         ColumnValuesInfo columnValuesInfo = new ColumnValuesInfo();
         ColumnConfigAndSql columnConfigAndSql = chartsConfigMapper.getConfigAndSql(dataId);
         String sql = columnConfigAndSql.getSql();
         String columnConfig = columnConfigAndSql.getColumnConfig();
         columnValuesInfo.setColumnConfig(columnConfig);
+        if (RoleConstant.SUPER_ADMIN.getRole().equals(BaseContextHolder.getRole())) {
+            id = createId;
+        }
         String sqls = chartsUtilService.columnNameUtil(id, dataId, sql, true, 0, createId);
 
         try {

File diff suppressed because it is too large
+ 0 - 0
bi-server/src/main/resources/static/index.250ed1fb.js


File diff suppressed because it is too large
+ 0 - 0
bi-server/src/main/resources/static/index.89cfd43f.js


File diff suppressed because it is too large
+ 0 - 0
bi-server/src/main/resources/static/index.965ee983.css


+ 2 - 2
bi-server/src/main/resources/static/index.html

@@ -4,8 +4,8 @@
   <meta charset="UTF-8">
   <meta name="viewport" content="width=device-width, initial-scale=1">
   <title>BI 商业智能平台</title>
-<link rel="shortcut icon" href="favicon.png"><link href="index.e374b23a.css" rel="stylesheet"></head>
+<link rel="shortcut icon" href="favicon.png"><link href="index.965ee983.css" rel="stylesheet"></head>
 <body>
   <div id="root"></div>
-<script type="text/javascript" src="index.89cfd43f.js"></script></body>
+<script type="text/javascript" src="index.250ed1fb.js"></script></body>
 </html>

Some files were not shown because too many files changed in this diff