heqinwei преди 7 години
родител
ревизия
996af3e683
променени са 39 файла, в които са добавени 708 реда и са изтрити 210 реда
  1. 1 0
      src/main/java/com/Application.java
  2. 7 8
      src/main/java/com/controller/ChartsConfigController.java
  3. 10 4
      src/main/java/com/controller/DataBasesController.java
  4. 16 5
      src/main/java/com/controller/DataConnectorController.java
  5. 10 8
      src/main/java/com/controller/ShowChartsController.java
  6. 10 0
      src/main/java/com/controller/UserController.java
  7. 87 5
      src/main/java/com/dao/ChartsConfigMapper.java
  8. 34 24
      src/main/java/com/dao/DataConnectorMapper.java
  9. 22 18
      src/main/java/com/dao/ShowChartsMapper.java
  10. 8 11
      src/main/java/com/dao/StrategysBdMapper.java
  11. 9 0
      src/main/java/com/dao/StrategysChartMapper.java
  12. 9 2
      src/main/java/com/dao/UserMapper.java
  13. 9 0
      src/main/java/com/model/po/ChartConfig.java
  14. 18 0
      src/main/java/com/model/po/ChartConfigList.java
  15. 9 0
      src/main/java/com/model/po/DataConnector.java
  16. 9 0
      src/main/java/com/model/po/DataConnectorList.java
  17. 15 0
      src/main/java/com/model/po/User.java
  18. 2 1
      src/main/java/com/model/pojo/RepCode.java
  19. 9 0
      src/main/java/com/model/vo/configVo/ChartConfigInfo.java
  20. 0 1
      src/main/java/com/model/vo/configVo/HistogramConfigInfo.java
  21. 35 15
      src/main/java/com/server/ChartsConfigService.java
  22. 93 0
      src/main/java/com/server/ChartsUtilService.java
  23. 7 7
      src/main/java/com/server/ColumnScreenService.java
  24. 4 10
      src/main/java/com/server/DataBasesService.java
  25. 24 14
      src/main/java/com/server/DataConnectorService.java
  26. 16 15
      src/main/java/com/server/ShowHistogramService.java
  27. 7 7
      src/main/java/com/server/ShowIndividualService.java
  28. 10 9
      src/main/java/com/server/ShowLineService.java
  29. 11 10
      src/main/java/com/server/ShowPieService.java
  30. 6 6
      src/main/java/com/server/ShowPopulationService.java
  31. 13 12
      src/main/java/com/server/ShowScatterService.java
  32. 14 14
      src/main/java/com/server/TimeConverterUtil.java
  33. 18 2
      src/main/java/com/server/UserService.java
  34. 39 0
      src/main/java/com/util/GetTokenData.java
  35. 21 0
      src/main/java/com/util/GlobalException.java
  36. 3 2
      src/main/java/com/util/JwtTokenUtil.java
  37. 11 0
      src/main/java/com/util/RoleInterceptor/Auth.java
  38. 24 0
      src/main/java/com/util/RoleInterceptor/ConfigAdapter.java
  39. 58 0
      src/main/java/com/util/RoleInterceptor/SecurityInterceptor.java

+ 1 - 0
src/main/java/com/Application.java

@@ -8,6 +8,7 @@ import org.springframework.context.ApplicationContext;
 import org.springframework.context.annotation.Import;
 
 @SpringBootApplication
+//@ComponentScan(basePackages={"com.util"})
 @Import({DynamicDataSourceRegister.class})
 public class Application {
     public static void main(String[] args) {

+ 7 - 8
src/main/java/com/controller/ChartsConfigController.java

@@ -7,7 +7,6 @@ import com.model.vo.configVo.ChartConfigInfo;
 import com.model.vo.configVo.GroupInfo;
 import com.server.ChartsConfigService;
 import org.springframework.beans.factory.annotation.Autowired;
-import org.springframework.transaction.annotation.Transactional;
 import org.springframework.web.bind.annotation.RequestBody;
 import org.springframework.web.bind.annotation.RequestHeader;
 import org.springframework.web.bind.annotation.RequestMapping;
@@ -16,7 +15,6 @@ import org.springframework.web.bind.annotation.RestController;
 import java.util.List;
 
 @RestController
-@Transactional
 public class ChartsConfigController {
     @Autowired
     ChartsConfigService chartsConfigService;
@@ -24,10 +22,10 @@ public class ChartsConfigController {
    /*
    添加
     */
-   @CheckToken
+    @CheckToken
     @RequestMapping("/inputCharts")
     public RepEntity inputCharts(@RequestHeader String token,@RequestBody ChartConfigInfo body){
-        return chartsConfigService.setChartsConfig(body);
+        return chartsConfigService.setChartsConfig(body, token);
     }
 
     /*
@@ -36,15 +34,16 @@ public class ChartsConfigController {
     @CheckToken
     @RequestMapping("/updateCharts")
     public RepEntity updateCharts(@RequestHeader String token,@RequestBody ChartConfigInfo body){
-        return chartsConfigService.updateChartsConfig(body);
+        return chartsConfigService.updateChartsConfig(body, token);
     }
 
     /*
     移交图表
      */
+    @CheckToken
     @RequestMapping("/changeChartOrder")
-    public RepEntity changeChartOrder(@RequestBody ChangeOrderInfo body){
-        return chartsConfigService.changeChartOrder(body);
+    public RepEntity changeChartOrder(@RequestHeader String token, @RequestBody ChangeOrderInfo body){
+        return chartsConfigService.changeChartOrder(body, token);
     }
 
     /*
@@ -71,7 +70,7 @@ public class ChartsConfigController {
     @CheckToken
     @RequestMapping("/getListCharts")
     public RepEntity getListCharts(@RequestHeader String token){
-        return chartsConfigService.getListCharts();
+        return chartsConfigService.getListCharts(token);
     }
 
     /*

+ 10 - 4
src/main/java/com/controller/DataBasesController.java

@@ -1,11 +1,11 @@
 package com.controller;
 
-import com.model.bo.Pages;
 import com.model.po.Databases;
 import com.model.pojo.RepEntity;
 import com.model.vo.configVo.DatabasesInfo;
 import com.server.DataBasesService;
 import com.server.ImplementSqlService;
+import com.util.RoleInterceptor.Auth;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.web.bind.annotation.RequestBody;
 import org.springframework.web.bind.annotation.RequestHeader;
@@ -15,6 +15,7 @@ import org.springframework.web.bind.annotation.RestController;
 import java.util.List;
 
 @RestController
+@RequestMapping("/DataBase")
 public class DataBasesController {
     @Autowired
     DataBasesService dataBasesService;
@@ -25,6 +26,7 @@ public class DataBasesController {
    保存数据库配置
    */
     @CheckToken
+    @Auth(user = "admin")
     @RequestMapping("/inputDatabases")
     public RepEntity inputDatabases(@RequestHeader String token, @RequestBody DatabasesInfo body){
         return dataBasesService.inputDatabases(body);
@@ -34,15 +36,17 @@ public class DataBasesController {
     查看数据库配置列表
      */
     @CheckToken
+    @Auth(user = "admin")
     @RequestMapping("/getDatabases")
-    public RepEntity getDatabases(@RequestHeader String token,@RequestBody Pages body){
-        return dataBasesService.getListDatabases(body);
+    public RepEntity getDatabases(@RequestHeader String token){
+        return dataBasesService.getListDatabases();
     }
 
     /*
     删除数据库配置
      */
     @CheckToken
+    @Auth(user = "admin")
     @RequestMapping("/delDatabases")
     public RepEntity delDatabases(@RequestHeader String token,@RequestBody List<Integer> body){
         return dataBasesService.delDatabases(body);
@@ -52,6 +56,7 @@ public class DataBasesController {
     更新数据库配置
      */
     @CheckToken
+    @Auth(user = "admin")
     @RequestMapping("/updatabases")
     public RepEntity updatabases(@RequestHeader String token,@RequestBody DatabasesInfo databasesInfo){
         return dataBasesService.updatabases(databasesInfo);
@@ -69,7 +74,7 @@ public class DataBasesController {
     /*
     通过图表Id查看列数据
      */
-//    @CheckToken
+    @CheckToken
     @RequestMapping("/getColumnByChartId")
     public RepEntity getColumnByChartId(@RequestHeader String token,@RequestBody int body){
         return dataBasesService.getColumnByChartId(body);
@@ -80,6 +85,7 @@ public class DataBasesController {
     测试数据库连接
      */
     @CheckToken
+    @Auth(user = "admin")
     @RequestMapping("/testConnect")
     public RepEntity testConnect(@RequestHeader String token,@RequestBody Databases body){
         return implementSqlService.connectTest(body);

+ 16 - 5
src/main/java/com/controller/DataConnectorController.java

@@ -8,7 +8,7 @@ import com.model.vo.configVo.DataConnectorInfo;
 import com.model.vo.configVo.GroupInfo;
 import com.server.DataConnectorService;
 import com.server.ImplementSqlService;
-import com.util.BasesSource.TargetDataSource;
+import com.util.RoleInterceptor.Auth;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.web.bind.annotation.RequestBody;
 import org.springframework.web.bind.annotation.RequestHeader;
@@ -18,6 +18,7 @@ import org.springframework.web.bind.annotation.RestController;
 import java.util.List;
 
 @RestController
+@RequestMapping("/Connector")
 public class DataConnectorController {
     @Autowired
     DataConnectorService dataConnectorService;
@@ -29,6 +30,7 @@ public class DataConnectorController {
     保存数据源配置
      */
     @CheckToken
+    @Auth(user = "admin")
     @RequestMapping("/inputDataConnector")
     public RepEntity inputDataConnector(@RequestHeader String token, @RequestBody DataConnectorInfo body) {
         System.out.println("-----------");
@@ -42,13 +44,14 @@ public class DataConnectorController {
     @CheckToken
     @RequestMapping("/getListDataConnector")
     public RepEntity getListDataConnector(@RequestHeader String token){
-        return dataConnectorService.getListConnector();
+        return dataConnectorService.getListConnector(token);
     }
 
     /*
     查看单个数据源配置
      */
     @CheckToken
+    @Auth(user = "admin")
     @RequestMapping("/getDataConnector")
     public RepEntity getDataConnector(@RequestHeader String token,@RequestBody int body){
         return dataConnectorService.getConnector(body);
@@ -58,6 +61,7 @@ public class DataConnectorController {
     更新数据源配置
      */
     @CheckToken
+    @Auth(user = "admin")
     @RequestMapping("/updateData")
     public RepEntity updateData(@RequestHeader String token,@RequestBody DataConnectorInfo body){
         return dataConnectorService.updateData(body);
@@ -66,14 +70,16 @@ public class DataConnectorController {
     /*
     转交数据源
      */
+    @CheckToken
     @RequestMapping("/changeDbOrder")
-    public RepEntity changeDbOrder(@RequestBody ChangeOrderInfo body){
-        return dataConnectorService.changeOrder(body);
+    public RepEntity changeDbOrder(@RequestHeader String token,@RequestBody ChangeOrderInfo body){
+        return dataConnectorService.changeOrder(body, token);
     }
 
     /*
     更新数据源配置的分组
      */
+    @Auth(user = "admin")
     @CheckToken
     @RequestMapping("/updateConnectConfigGroup")
     public RepEntity updateConConfigGroup(@RequestHeader String token,@RequestBody GroupUpdateId body){
@@ -84,6 +90,7 @@ public class DataConnectorController {
     /*
     删除配置
      */
+    @Auth(user = "admin")
     @CheckToken
     @RequestMapping("/delDataConnector")
     public RepEntity delDataConnector(@RequestHeader String token,@RequestBody List<Integer> body){
@@ -95,7 +102,7 @@ public class DataConnectorController {
     */
     @CheckToken
     @RequestMapping("/implementSql")
-    @TargetDataSource
+    @Auth(user = "admin")
     public RepEntity implementSql(@RequestHeader String token,@RequestBody ToSql body){
         return implementSqlService.implementSql(body);
     }
@@ -105,6 +112,7 @@ public class DataConnectorController {
      */
     @CheckToken
     @RequestMapping("/setConnectorGroup")
+    @Auth(user = "admin")
     public RepEntity setConnectorGroup(@RequestHeader String token,@RequestBody GroupInfo body){
         return dataConnectorService.setDataConnectorGroup(body);
     }
@@ -113,6 +121,7 @@ public class DataConnectorController {
     更新数据源分组
      */
     @CheckToken
+    @Auth(user = "admin")
     @RequestMapping("/updataDataConnectorGroup")
     public RepEntity updataDataConnectorGroup(@RequestHeader String token,@RequestBody GroupInfo body){
         return dataConnectorService.updataDataConnectorGroup(body);
@@ -122,6 +131,7 @@ public class DataConnectorController {
     批量更新数据源分组
      */
     @CheckToken
+    @Auth(user = "admin")
     @RequestMapping("/updataConnectorGroup")
     public RepEntity updataConnectorGroup(@RequestHeader String token,@RequestBody List<GroupInfo> body){
         return dataConnectorService.updataConnectorGroups(body);
@@ -130,6 +140,7 @@ public class DataConnectorController {
     /*
     删除数据源分组
      */
+    @Auth(user = "admin")
     @CheckToken
     @RequestMapping("/delDataConnectorGroup")
     public RepEntity delDataConnectorGroup(@RequestHeader String token,@RequestBody List<Integer> body){

+ 10 - 8
src/main/java/com/controller/ShowChartsController.java

@@ -3,6 +3,7 @@ package com.controller;
 import com.model.pojo.RepEntity;
 import com.model.vo.configVo.*;
 import com.server.*;
+import com.util.RoleInterceptor.Auth;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.web.bind.annotation.RequestBody;
 import org.springframework.web.bind.annotation.RequestHeader;
@@ -32,9 +33,10 @@ public class ShowChartsController {
     展示柱状图
      */
     @CheckToken
+    @Auth(user = "admin")
     @RequestMapping("/showHistogram")
     public RepEntity showHistogram(@RequestHeader String token,@RequestBody HistogramConfigInfo body){
-        return showHistogramService.showHistogram(body);
+        return showHistogramService.showHistogram(body, token);
     }
 
     /*
@@ -43,7 +45,7 @@ public class ShowChartsController {
     @CheckToken
     @RequestMapping("/showPie")
     public RepEntity showPie(@RequestHeader String token,@RequestBody PieConfigInfo body){
-        return showPieService.showPie(body);
+        return showPieService.showPie(body, token);
     }
 
     /*
@@ -52,7 +54,7 @@ public class ShowChartsController {
     @CheckToken
     @RequestMapping("/showLine")
     public RepEntity showLine(@RequestHeader String token,@RequestBody LineConfigInfo body){
-        return showLineService.showLine(body);
+        return showLineService.showLine(body, token);
     }
 
     /*
@@ -61,7 +63,7 @@ public class ShowChartsController {
     @CheckToken
     @RequestMapping("/showScatter")
     public RepEntity showScatter(@RequestHeader String token,@RequestBody ScatterConfigInfo body){
-        return showScatterService.showScatter(body);
+        return showScatterService.showScatter(body, token);
     }
 
     /*
@@ -70,7 +72,7 @@ public class ShowChartsController {
     @CheckToken
     @RequestMapping("/showIndividual")
     public RepEntity showIndividual(@RequestHeader String token,@RequestBody IndividualConfigInfo body){
-        return showIndividualService.showIndividual(body);
+        return showIndividualService.showIndividual(body, token);
     }
 
     /*
@@ -79,7 +81,7 @@ public class ShowChartsController {
     @CheckToken
     @RequestMapping("/showPopulation")
     public RepEntity showPopulation(@RequestHeader String token,@RequestBody PopulationInfo body) throws SQLException {
-        return showPopulationService.showPopulation(body);
+        return showPopulationService.showPopulation(body, token);
     }
 
     /*
@@ -88,7 +90,7 @@ public class ShowChartsController {
     @CheckToken
     @RequestMapping("/showScreenData")
     public RepEntity showScreenData(@RequestHeader String token,@RequestBody ColumnScreenInfo body){
-        return columnScreenService.getScreenData(body);
+        return columnScreenService.getScreenData(body, token);
     }
 
     /*
@@ -96,6 +98,6 @@ public class ShowChartsController {
      */
     @RequestMapping("/getScreenByBaseId")
     public RepEntity getScreenByBaseId(@RequestHeader String token,@RequestBody ColumnScreenInfo body){
-        return columnScreenService.getScreenByBaseId(body);
+        return columnScreenService.getScreenByBaseId(body, token);
     }
 }

+ 10 - 0
src/main/java/com/controller/UserController.java

@@ -5,6 +5,7 @@ import com.model.vo.configVo.LoginInfo;
 import com.model.vo.configVo.UserGroupInfo;
 import com.model.vo.configVo.UserGroupSetInfo;
 import com.server.UserService;
+import com.util.RoleInterceptor.Auth;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.web.bind.annotation.RequestBody;
 import org.springframework.web.bind.annotation.RequestMapping;
@@ -13,6 +14,7 @@ import org.springframework.web.bind.annotation.RestController;
 import java.util.List;
 
 @RestController
+//@RequestMapping("/User")
 public class UserController {
     @Autowired
     UserService userService;
@@ -28,6 +30,7 @@ public class UserController {
     /*
     查询用户列表
      */
+    @Auth(user = "admin")
     @RequestMapping("/getUserList")
     public RepEntity getUserList(){
         return userService.getUserList();
@@ -44,6 +47,7 @@ public class UserController {
     /*
     创建用户组
      */
+    @Auth(user = "admin")
     @RequestMapping("/createUserGroup")
     public RepEntity createUserGroup(@RequestBody UserGroupInfo body){
         return userService.createUserGroup(body);
@@ -52,6 +56,7 @@ public class UserController {
     /*
     更新用户组
      */
+    @Auth(user = "admin")
     @RequestMapping("/updateUserGroup")
     public RepEntity updateUserGroup(@RequestBody UserGroupInfo body){
         return userService.updateUserGroup(body);
@@ -60,6 +65,7 @@ public class UserController {
     /*
     查询用户组列表
      */
+    @Auth(user = "admin")
     @RequestMapping("/getUserGroupList")
     public RepEntity getUserGroupList(){
         return userService.getUserGroup();
@@ -68,6 +74,7 @@ public class UserController {
     /*
     删除用户组
      */
+    @Auth(user = "admin")
     @RequestMapping("/delUserGroup")
     public RepEntity delUserGroup(@RequestBody List<Integer> body){
         return userService.delUserGroup(body);
@@ -76,6 +83,7 @@ public class UserController {
     /*
     用户组添加用户
      */
+    @Auth(user = "admin")
     @RequestMapping("/setUserInto")
     public RepEntity setUserInto(@RequestBody UserGroupSetInfo body){
         return userService.setUserInto(body);
@@ -84,6 +92,7 @@ public class UserController {
     /*
     查询用户组下的用户
      */
+    @Auth(user = "admin")
     @RequestMapping("/getUserInGroup")
     public RepEntity getUserInGroup(@RequestBody int body){
         return userService.getUserInGroup(body);
@@ -92,6 +101,7 @@ public class UserController {
     /*
     删除用户组下的用户
      */
+    @Auth(user = "admin")
     @RequestMapping("/delUserInGroup")
     public RepEntity delUserInGroup(@RequestBody UserGroupSetInfo body){
         return userService.delUserInGroup(body);

+ 87 - 5
src/main/java/com/dao/ChartsConfigMapper.java

@@ -12,9 +12,10 @@ import java.util.List;
 @Repository
 public interface ChartsConfigMapper {
 
-    @Insert("insert into bi_charts(id,CHART_NAME,CHART_TYPE,BD_DATA_ID,CHART_CONFIG,GROUP_BY,ACCESS_AUTHORITY,UPDATE_AUTHORITY,BC_CHARTS_GROUP,CHART_DESCRIBES,BC_CHART_STYLE,create_by,create_date, bc_charts_option) " +
+    @Insert("insert into bi_charts(id,CHART_NAME,CHART_TYPE,BD_DATA_ID,CHART_CONFIG,GROUP_BY,ACCESS_AUTHORITY,UPDATE_AUTHORITY,BC_CHARTS_GROUP,CHART_DESCRIBES,BC_CHART_STYLE," +
+            "create_by,create_date, bc_charts_option, create_Id) " +
             "VALUES (#{chartId},#{chartName},#{chartType}, #{dataId}, #{chartConfig}, #{groupBy}, #{accessAuthority}, #{updateAuthority}, #{chartsGroup}," +
-            "#{describes},#{style}, #{createBy},to_date(to_char(sysdate,'yyyy-mm-dd hh24:mi:ss'),'YYYY-MM-DD hh24:mi:ss'),  #{chartOption})" )
+            "#{describes},#{style}, #{createBy},to_date(to_char(sysdate,'yyyy-mm-dd hh24:mi:ss'),'YYYY-MM-DD hh24:mi:ss'),  #{chartOption}, #{createId})" )
 //    @Options(useGeneratedKeys=false, keyProperty = "chartId",keyColumn = "id")
     @SelectKey(before=true,keyProperty="chartId",resultType=Integer.class,statement="SELECT charts_squence.nextval from dual",keyColumn = "id")
     void insertCharts(ChartConfig chartConfig);
@@ -32,13 +33,69 @@ public interface ChartsConfigMapper {
     @Select("select id as chartId, chart_name as chartName, chart_type as chartType, create_by as createBy, create_date as createDate, bc_charts_group as chartsGroup" +
             ",bc_filters as filters, BD_DATA_ID as dataId, bc_table_name as tableName, CHART_CONFIG as chartConfig, GROUP_BY as groupBy, bc_charts_option as chartOption, " +
             "ACCESS_AUTHORITY as accessAuthority, UPDATE_AUTHORITY as updateAuthority, CHART_DESCRIBES as describes, BC_CHART_STYLE as style, BC_FILTERS as filters " +
-            " from bi_charts where id = #{id}")
+            ",create_id as createId from bi_charts where id = #{id}")
     ChartConfig getOneChart(int id);
 
+    /*
+    查看图表列表
+     */
     @Select("select id as chartId, chart_name as chartName, chart_type as chartType, create_by as createBy, create_date as createDate" +
             ",bc_filters as filters, CHART_DESCRIBES as describes, bc_charts_group as chartsGroup, bc_charts_option as chartOption from bi_charts")
     List<ChartConfigList> getListCharts();
 
+    /*
+    权限查看图表列表
+     */
+    @Select("  select case " +
+            "    when bc.CREATE_ID = #{id} and bc.BD_DATA_ID in (select id from bi_data_connectors where create_id=#{id}) then '1'" +
+            "    when bc.CREATE_ID = #{id} and bc.BD_DATA_ID not in (select id from bi_data_connectors where create_id=#{id}) and (" +
+            "      select count(1) from BI_DB_STRATEGYS bs1 " +
+            "        where bs1.IS_OPEN='1' and bs1.BS_ID in (" +
+            "          select bo1.BO_ST_ID from bi_db_object bo1 " +
+            "            where bo1.BO_TYPE = '0' and bo1.BO_OB_ID in ( select BR_USER_GROUP from BI_USER_REL_GROUPS where BR_USER_ID=#{id} ) " +
+            "            or bo1.bo_type = '1' and bo1.bo_ob_id = #{id}" +
+            "        )" +
+            "    ) > 0 then '1'" +
+            "    when bc.CREATE_ID = #{id} and bc.BD_DATA_ID not in (select id from bi_data_connectors where create_id=#{id}) and (" +
+            "      select count(1) from BI_DB_STRATEGYS bs2 " +
+            "        where bs2.IS_OPEN='1' and bs2.BS_ID in (" +
+            "          select bo2.BO_ST_ID from bi_db_object bo2 " +
+            "            where bo2.BO_TYPE = '0' and bo2.BO_OB_ID in ( select BR_USER_GROUP from BI_USER_REL_GROUPS where BR_USER_ID=#{id} ) " +
+            "            or bo2.bo_type = '1' and bo2.bo_ob_id = #{id}" +
+            "        )" +
+            "    ) = 0 then '0' " +
+            "    when bc.CREATE_ID != #{id} and bc.BD_DATA_ID in (select bdc1.id " +
+            " from bi_data_connectors bdc1 where bdc1.create_id=bc.CREATE_ID) then '1'" +
+            "    when bc.CREATE_ID != #{id} and bc.BD_DATA_ID in (select bdc2.id " +
+            "" +
+            " from bi_data_connectors bdc2 where bdc2.create_id=bc.CREATE_ID) and (" +
+            "      select count(1) from BI_DB_STRATEGYS bs2" +
+            "        where bs2.IS_OPEN='1' and bs2.BS_ID in (" +
+            "          select bo2.BO_ST_ID from bi_db_object bo2 " +
+            "            where bo2.BO_TYPE = '0' and bo2.BO_OB_ID in ( select BR_USER_GROUP from BI_USER_REL_GROUPS where BR_USER_ID=bc.CREATE_ID ) " +
+            "            or bo2.bo_type = '1' and bo2.bo_ob_id = bc.CREATE_ID" +
+            "        )" +
+            "    ) > 0 then '1'" +
+            "    when bc.CREATE_ID != #{id} and bc.BD_DATA_ID not in (select bdc3.id " +
+            " from bi_data_connectors bdc3 where bdc3.create_id=bc.CREATE_ID) and (" +
+            "      select count(1) from BI_DB_STRATEGYS bs2" +
+            "        where bs2.IS_OPEN='1' and bs2.BS_ID in (" +
+            "          select bo2.BO_ST_ID from bi_db_object bo2 " +
+            "            where bo2.BO_TYPE = '0' and bo2.BO_OB_ID in ( select BR_USER_GROUP from BI_USER_REL_GROUPS where BR_USER_ID=bc.CREATE_ID ) " +
+            "            or bo2.bo_type = '1' and bo2.bo_ob_id = bc.CREATE_ID" +
+            "        )" +
+            "    ) = 0 then '0'" +
+            "    else null end authority, id as chartId, chart_name as chartName, chart_type as chartType, bc.create_by as createBy, bc.create_date as createDate" +
+            "            ,bc_filters as filters, CHART_DESCRIBES as describes, bc_charts_group as chartsGroup, bc_charts_option as chartOption, create_id as createId from bi_charts bc where create_id = #{id} or ( create_id !=#{id} and id in (" +
+            "      select bc_chart_id from bi_chart_strategys where BC_ID in (" +
+            "        select BO_ST_ID from BI_CHART_OBJECT where (BO_TYPE='1' and BO_OB_ID = #{id})" +
+            "        or (" +
+            "          BO_TYPE='0' and BO_OB_ID in ( select BR_USER_GROUP from BI_USER_REL_GROUPS where BR_USER_ID=#{id} )" +
+            "        )" +
+            "      )" +
+            "    ))")
+    List<ChartConfigList> getListByUser(int id);
+
     /*
     通过Id查找表名
     */
@@ -89,8 +146,8 @@ public interface ChartsConfigMapper {
     /*
     移交图表
      */
-    @Update("update bi_charts set create_by = #{userId} where id = #{baseId}")
-    void changeChartOrder(@Param("userId") String userId, @Param("baseId") int baseId);
+    @Update("update bi_charts set create_by = #{name}, create_id = #{createId} where id = #{baseId}")
+    void changeChartOrder(@Param("name") String name, @Param("createId") int userId, @Param("baseId") int baseId);
 
     /*
     更新图表分组
@@ -169,5 +226,30 @@ public interface ChartsConfigMapper {
     @Select("select chart_name from bi_charts where BC_CHARTS_GROUP = #{id}")
     List<String> getChartName(int id);
 
+    /*
+    查询图表创建人ID
+     */
+    @Select("select create_id from bi_charts where id = #{id}")
+    int getCreateId(@Param("id") int id);
+
+    /*
+    通过图表id查询数据源创建人ID
+     */
+    @Select("select bd.create_id from bi_charts bc,bi_data_connectors bd where bc.bd_data_id = bd.id and bc.id = #{id}")
+    int getCreateIdBychart(int id);
+
+    /*
+    通过图表查询数据源ID
+     */
+    @Select("select bd_data_id from bi_charts where id = #{id}")
+    int getBaseIdByChart(int id);
+
+    /*
+    通过用户Id查询数据源ID
+     */
+    @Select("select bs_db_id from bi_db_strategys where bs_id in (select bo_st_id from " +
+            "bi_db_object where (bo_ob_id = #{id} and bo_type = '1') or (bo_ob_id = '1' and bo_type = '0' and bo_ob_id in" +
+            "(select br_user_group from bi_user_rel_groups where br_user_id= #{id}))) and is_open = '1'")
+    int getBaseIdByUser(int id);
 
 }

+ 34 - 24
src/main/java/com/dao/DataConnectorMapper.java

@@ -14,44 +14,47 @@ import java.util.List;
 @Repository
 public interface DataConnectorMapper {
 
-//    @Select("select d.column_name as columnName, d.DATA_TYPE as columnType, b.comments as remarks from " +
-//            "(select column_name,DATA_TYPE from user_tab_cols where Table_Name = #{tableName}) d," +
-//            "(select * from user_col_comments where Table_Name = #{tableName}) b" +
-//            " where d.column_name = b.column_name order by columnName")
-//    List<ColumnScreenInfo> getColumn(@Param("tableName") String tableName);
-
-//    @Select("<script>" +
-//            "select * from bi_data_connectors where" + "1=1" +
-//            "<if test=\"id != null\"> and id = #{id} </if>" +
-//            "<if test=\"dataName != null\"> and data_name = #{dataName} </if>" +
-//            "<if test=\"dataTag != null\"> and data_tag = #{dataTag} </if>" +
-//            "<if test=\"configuration != null\"> and configuration = #{configuration} </if>" +
-//            "<if test=\"columnConfig != null\"> and columns_config = #{columnConfig} </if>"  +
-//            "<if test=\"usedNumber != null\"> and used_number = #{usedNumber} </if>" +
-//            "<if test=\"createBy != null\">and create_by = #{createBy}</if>" +
-//            "</script>")
-//    List<DataConnector> getAllData(DataConnector dataConnector);
+    /*
+    查询数据源创建人ID
+     */
+    @Select("select c.create_id from bi_data_connectors c,bi_charts cs where cs.id = #{id} and cs.bd_data_id = c.id")
+    int getCreateId(int id);
+
+    /*
+    查询数据源ID
+     */
+    @Select("select c.id from bi_data_connectors c,bi_charts cs where cs.id = #{id} and cs.bd_data_id = c.id")
+    int getBaseId(int id);
 
     /*
     查询单个数据源
      */
     @Select("select ID as dataId, DATA_NAME as dataName, DATA_NOTE as note, DATA_TAG as dataTag, COLUMNS_CONFIG as columnConfig, LOAD_OBJECT as loadObject," +
-            "CREATE_BY as createBy, USED_NUMBER as userNumber, CREATE_DATE as createDate,DB_CONFIG as dbConfig, BD_group as connectorGroup," +
+            "CREATE_BY as createBy, create_id as createId, USED_NUMBER as userNumber, CREATE_DATE as createDate,DB_CONFIG as dbConfig, BD_group as connectorGroup," +
             "CON_TYPE as type from bi_data_connectors where id = #{id}")
     DataConnector getOneData(int id);
 
     /*
-    查询数据源列表
+    查询自己创建的,权限分配的数据源列表,已经启用
      */
-    @Select("select id as dataId, con_type as type, data_name as dataName, data_tag as dataTag, data_note as note, create_by as createBy, create_date as createDate," +
-            " used_number as usedNumber, db_config as dbConfig ,BD_group as connectorGroup from bi_data_connectors")
-    List<DataConnectorList> getDataConnectorList();
+    @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 from bi_data_connectors bc where CREATE_ID = #{id} or ( id in ( select distinct bs_db_id from BI_DB_STRATEGYS where bs_id in (" +
+            "  select bo_st_id from bi_db_object  where " +
+            "  (BO_TYPE='1' and bo_ob_id = #{id} ) or " +
+            "  ( bo_type='0' and bo_ob_id in " +
+            "  ( select br_user_group from bi_user_rel_groups where br_user_id = #{id} ) " +
+            "   )" +
+            "))) and is_open = '1'")
+    List<DataConnectorList> getDataConnectorList(int id);
+
 
     /*
     转交数据源
      */
-    @Update("updata bi_data_connectors set create_by = #{userId} where id = #{baseId}")
-    void updataOrder(@Param("userId") String userId, @Param("baseId") int baseId);
+    @Update("update bi_data_connectors set create_by = #{name}, create_id = #{createId} where id = #{baseId}")
+    void updataOrder(@Param("name") String name, @Param("createId") int userId, @Param("baseId") int baseId);
 
     /*
     插入数据源配置
@@ -231,4 +234,11 @@ public interface DataConnectorMapper {
     @Select("select chart_name from bi_charts where bd_data_ID = #{id}")
     List<String> getChartsName(int id);
 
+    /*
+    查询数据源创建人ID
+     */
+    @Select("select create_id from bi_data_connectors where id = #{id}")
+    int getCreateIdById(@Param("id") int id);
+
+
 }

+ 22 - 18
src/main/java/com/dao/ShowChartsMapper.java

@@ -19,15 +19,16 @@ public interface ShowChartsMapper {
 
 
     //x轴数据
-    @Select("select ${dataType}(${yAxisName}) from ${tableName} where ${xColumn} = #{xdata}")
+    @Select("select ${dataType}(${yAxisName}) from ${tableName} where ${xColumn} = #{xdata} ${screen}")
     String getValues(@Param("yAxisName") String yAxisName, @Param("xColumn") String xColumn,
                      @Param("tableName") String tableName, @Param("dataType") String dataType,
-                     @Param("xdata") String xdata);
+                     @Param("xdata") String xdata, @Param("screen") String screen);
 
     //x轴为空时的数据
-    @Select("select ${dataType}(${yAxisName}) from ${tableName} where ${xColumn} is null")
+    @Select("select ${dataType}(${yAxisName}) from ${tableName} where ${xColumn} is null ${screen}")
     String getValuesIsNull(@Param("yAxisName") String yAxisName, @Param("xColumn") String xColumn,
-                     @Param("tableName") String tableName, @Param("dataType") String dataType);
+                     @Param("tableName") String tableName, @Param("dataType") String dataType,
+                           @Param("screen") String screen);
 
 
 
@@ -42,10 +43,11 @@ public interface ShowChartsMapper {
 //                                @Param("xColumn") String xColumn, @Param("xColumnIndex") String xColumnIndex);
 
     //查询分组的值
-    @Select("select ${dataType}(${yAxisName}) from ${tableName} where ${groupsColumn} and ${xColumn}")
+    @Select("select ${dataType}(${yAxisName}) from ${tableName} where ${groupsColumn} and ${xColumn} ${screen}")
     String getGroupsValue(@Param("dataType") String dataType, @Param("yAxisName") String yAxisName, @Param("tableName") String tableName,
                           @Param("groupsColumn") String groupsColumn,
-                          @Param("xColumn") String xColumn);
+                          @Param("xColumn") String xColumn,
+                          @Param("screen") String screen);
 
 
     //时间类型的X轴
@@ -59,21 +61,22 @@ public interface ShowChartsMapper {
     List<String> getTimeYear(@Param("xAxisName") String xAxisName, @Param("tableName") String tableName, @Param("screen") String screen);
     
     //无分组时间类型值
-    @Select("select ${dataType}(${yAxisName}) from ${tableName} where (to_char(${xAxisName},${timeType})) = #{xColumnIndex}")
-    String getTimeValue (@Param("dataType") String dataType, @Param("yAxisName") String yAxisName, @Param("tableName") String tableName,
-                         @Param("xAxisName") String xAxisName, @Param("timeType") String timeType, @Param("xColumnIndex") String xColumnIndex
-                         );
+    @Select("select ${dataType}(${yAxisName}) from ${tableName} where (to_char(${xAxisName},${timeType})) = #{xColumnIndex} ${screen}")
+    String getTimeValue (@Param("dataType") String dataType, @Param("yAxisName") String yAxisName,
+                         @Param("tableName") String tableName, @Param("xAxisName") String xAxisName,
+                         @Param("timeType") String timeType, @Param("xColumnIndex") String xColumnIndex,
+                         @Param("screen") String screen);
 
     //无分组半年时间值
-    @Select("select ${dataType}(${yAxisName}) from ${tableName} where TO_CHAR(${xAxisName},'YYYY-MM') between #{firstIndex} and #{afterIndex} ")
+    @Select("select ${dataType}(${yAxisName}) from ${tableName} where TO_CHAR(${xAxisName},'YYYY-MM') between #{firstIndex} and #{afterIndex} ${screen}")
     String getTimeValueYear(@Param("dataType") String dataType, @Param("yAxisName") String yAxisName, @Param("tableName") String tableName,
                             @Param("xAxisName") String xAxisName, @Param("firstIndex") String firstIndex,
-                            @Param("afterIndex") String afterIndex);
+                            @Param("afterIndex") String afterIndex, @Param("screen") String screen);
 
     //时间为空时间值
-    @Select("select ${dataType}(${yAxisName}) from ${tableName} where ${xAxisName} is null")
+    @Select("select ${dataType}(${yAxisName}) from ${tableName} where ${xAxisName} is null ${screen}")
     String getTimeIsNull(@Param("dataType") String dataType, @Param("yAxisName") String yAxisName, @Param("tableName") String tableName,
-                         @Param("xAxisName") String xAxisName);
+                         @Param("xAxisName") String xAxisName, @Param("screen") String screen);
 
 
     //查询时间类型分组的值
@@ -84,19 +87,20 @@ public interface ShowChartsMapper {
                            );
 
     //有分组时时间类型为空值
-    @Select("select ${dataType}(${yAxisName}) from ${tableName} where ${groupsColumn} is null and TO_CHAR(${xColumn},${timeType})=#{xColumnIndex} ")
+    @Select("select ${dataType}(${yAxisName}) from ${tableName} where ${groupsColumn} is null and TO_CHAR(${xColumn},${timeType})=#{xColumnIndex} ${screen}")
     String getGroupsValueTimeIsNull(@Param("dataType") String dataType, @Param("yAxisName") String yAxisName, @Param("tableName") String tableName,
                               @Param("groupsColumn") String groupsColumn, @Param("groupsIndex") String groupsIndex,
-                              @Param("xColumn") String xColumn, @Param("timeType") String timeType, @Param("xColumnIndex") String xColumnIndex
+                              @Param("xColumn") String xColumn, @Param("timeType") String timeType,
+                                    @Param("xColumnIndex") String xColumnIndex, @Param("screen") String screen
     );
 
 
     //查询分组的值(时间类型半年)
     //分组半年时间值
-    @Select("select ${dataType}(${yAxisName}) from ${tableName} where TO_CHAR(${xAxisName},'YYYY-MM') between #{firstIndex} and #{afterIndex} and ${groupsColumn}=#{groupsIndex} ")
+    @Select("select ${dataType}(${yAxisName}) from ${tableName} where TO_CHAR(${xAxisName},'YYYY-MM') between #{firstIndex} and #{afterIndex} and ${groupsColumn}=#{groupsIndex} ${screen}")
     String getTimeValueHalfYear(@Param("dataType") String dataType, @Param("yAxisName") String yAxisName, @Param("tableName") String tableName,
                             @Param("xAxisName") String xAxisName, @Param("firstIndex") String firstIndex, @Param("afterIndex") String afterIndex,
-                                @Param("groupsColumn") String groupsColumn, @Param("groupsIndex") String groupsIndex);
+                                @Param("groupsColumn") String groupsColumn, @Param("groupsIndex") String groupsIndex, @Param("screen") String screen);
 
 
     /*

+ 8 - 11
src/main/java/com/dao/StrategysBdMapper.java

@@ -97,15 +97,12 @@ public interface StrategysBdMapper {
     @Delete("delete from bi_db_object where bo_st_id = #{stId}")
     void delObject(int stId);
 
-//    /*
-//    查询用户ID
-//     */
-//    @Select("select bu_id from bi_users where bu_name = #{name}")
-//    int getUserOrGroupId(String name);
-//
-//    /*
-//    修改修改对象
-//     */
-//    @Update("update bi_db_object set bo_type = #{type}, bo_ob_id = #{obId} where bo_type = '0' and bo_st_id = #{stId} and bo_ob_id = #{id}")
-//    void updateObject(ObjectInfo addObjectInfo, int id);
+    /*
+    查询在某个数据源下的所有策略
+     */
+    @Select("select bs_rule from bi_db_strategys where bs_id in " +
+            "(select bo_st_id from bi_db_object " +
+            "where (bo_type = '0' and bo_ob_id in (select br_user_group from bi_user_rel_groups where br_user_id= #{userId})) " +
+            " or (BO_TYPE='1' and bo_ob_id = #{userId} )) and bs_db_id = #{baseId} ")
+    List<String> getSqlStr(@Param("userId") int userId, @Param("baseId") int baseId);
 }

+ 9 - 0
src/main/java/com/dao/StrategysChartMapper.java

@@ -96,4 +96,13 @@ public interface StrategysChartMapper {
      */
     @Delete("delete from bi_chart_object where bo_st_id = #{stId}")
     void delObject(int stId);
+
+    /*
+    查询在某个数据源下的所有策略
+     */
+    @Select("select bc_rule from bi_chart_strategys where bc_id in " +
+            "(select bo_st_id from bi_chart_object " +
+            "where (bo_type = '0' and bo_ob_id in (select br_user_group from bi_user_rel_groups where br_user_id= #{userId})) " +
+            " or (BO_TYPE='1' and bo_ob_id = #{userId} )) and bc_chart_id = #{baseId} ")
+    List<String> getSqlStr(@Param("userId") int userId, @Param("baseId") int baseId);
 }

+ 9 - 2
src/main/java/com/dao/UserMapper.java

@@ -20,6 +20,12 @@ public interface UserMapper {
             "from bi_users where user_name = #{userName}")
     User getLogin(String userName);
 
+    /*
+    通过ID获取名称
+     */
+    @Select("select bu_name from bi_users where bu_id = #{id}")
+    String getName(int id);
+
     /*
     获取用户列表
      */
@@ -31,8 +37,9 @@ public interface UserMapper {
     /*
     匹配用户20个
      */
-    @Select("select * from bi_users where bu_name like ${value} and rownum<21")
-    List<String> getNameList(String value);
+    @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 ${value} and rownum<21")
+    List<User> getNameList(String value);
 
     /*
     更新token

+ 9 - 0
src/main/java/com/model/po/ChartConfig.java

@@ -12,6 +12,7 @@ public class ChartConfig {
     private String Subsections;    //分段
     private String chartConfig;
     private String createBy;
+    private int createId;
     private String accessAuthority;   //访问权限
     private String updateAuthority;    //修改权限
     private String describes;           //描述
@@ -22,6 +23,14 @@ public class ChartConfig {
     private String chartOption;      //列表缩略图数据
 
 
+    public int getCreateId() {
+        return createId;
+    }
+
+    public void setCreateId(int createId) {
+        this.createId = createId;
+    }
+
     public int getChartsGroup() {
         return chartsGroup;
     }

+ 18 - 0
src/main/java/com/model/po/ChartConfigList.java

@@ -9,6 +9,24 @@ public class ChartConfigList {
     private String createBy;
     private String createDate;
     private String chartOption;
+    private String authority;
+    private int createId;
+
+    public int getCreateId() {
+        return createId;
+    }
+
+    public void setCreateId(int createId) {
+        this.createId = createId;
+    }
+
+    public String getAuthority() {
+        return authority;
+    }
+
+    public void setAuthority(String authority) {
+        this.authority = authority;
+    }
 
     public int getChartsGroup() {
         return chartsGroup;

+ 9 - 0
src/main/java/com/model/po/DataConnector.java

@@ -16,6 +16,7 @@ public class DataConnector {
     private int usedNumber;
     private String type;
     private String createBy;
+    private int createId;
     private String createDate;
     private String updateDate;
 
@@ -131,6 +132,14 @@ public class DataConnector {
         this.type = type;
     }
 
+    public int getCreateId() {
+        return createId;
+    }
+
+    public void setCreateId(int createId) {
+        this.createId = createId;
+    }
+
     @Override
     public String toString() {
         return "DataConnector{" +

+ 9 - 0
src/main/java/com/model/po/DataConnectorList.java

@@ -10,8 +10,17 @@ public class DataConnectorList {
     private int connectorGroup;
     private int usedNumber;
     private String createBy;
+    private int createId;
     private String createDate;
 
+    public int getCreateId() {
+        return createId;
+    }
+
+    public void setCreateId(int createId) {
+        this.createId = createId;
+    }
+
     public int getConnectorGroup() {
         return connectorGroup;
     }

+ 15 - 0
src/main/java/com/model/po/User.java

@@ -84,4 +84,19 @@ public class User {
     public void setUpdateDate(Date updateDate) {
         this.updateDate = updateDate;
     }
+
+    @Override
+    public String toString() {
+        return "User{" +
+                "id=" + id +
+                ", name='" + name + '\'' +
+                ", userName='" + userName + '\'' +
+                ", passWord='" + passWord + '\'' +
+                ", department='" + department + '\'' +
+                ", post='" + post + '\'' +
+                ", role='" + role + '\'' +
+                ", createDate=" + createDate +
+                ", updateDate=" + updateDate +
+                '}';
+    }
 }

+ 2 - 1
src/main/java/com/model/pojo/RepCode.java

@@ -12,7 +12,8 @@ public enum  RepCode {
     hasConUsing(-150, "分组正在被数据源使用"),
     hasChartUsing(-160, "分组正在被图表使用"),
     ChartsNameNull(-170, "表不存在"),
-    NoUser(-180, "用户名或密码错误");
+    NoUser(-180, "用户名或密码错误"),
+    NoAuthority(-503, "无此权限");
 
     private int code;
     private String msg;

+ 9 - 0
src/main/java/com/model/vo/configVo/ChartConfigInfo.java

@@ -16,6 +16,7 @@ public class ChartConfigInfo {
     private List<Column> subsections;    //分段
     private String chartConfig;
     private String createBy;
+    private int createId;
     private List<String> accessAuthority;   //访问权限
     private List<String> updateAuthority;    //修改权限
     private String describes;           //描述
@@ -23,6 +24,14 @@ public class ChartConfigInfo {
     private String filters;          //筛选
     private String chartOption;      //列表缩略图数据
 
+    public int getCreateId() {
+        return createId;
+    }
+
+    public void setCreateId(int createId) {
+        this.createId = createId;
+    }
+
     public int getChartsGroup() {
         return chartsGroup;
     }

+ 0 - 1
src/main/java/com/model/vo/configVo/HistogramConfigInfo.java

@@ -8,7 +8,6 @@ import java.util.List;
 
 public class HistogramConfigInfo {
     private int id;
-//    private String tableName;
     private Column xAxis;
     private Column yAxis;
     private List<String> groups;

+ 35 - 15
src/main/java/com/server/ChartsConfigService.java

@@ -1,15 +1,18 @@
 package com.server;
 
 import com.dao.ChartsConfigMapper;
+import com.dao.UserMapper;
 import com.fasterxml.jackson.core.JsonProcessingException;
 import com.fasterxml.jackson.databind.ObjectMapper;
 import com.model.bo.GroupUpdateId;
 import com.model.po.ChartConfig;
+import com.model.po.ChartConfigList;
 import com.model.pojo.RepCode;
 import com.model.pojo.RepEntity;
 import com.model.vo.configVo.ChangeOrderInfo;
 import com.model.vo.configVo.ChartConfigInfo;
 import com.model.vo.configVo.GroupInfo;
+import com.util.GetTokenData;
 import com.util.TimeUtil;
 import org.springframework.beans.BeanUtils;
 import org.springframework.beans.factory.annotation.Autowired;
@@ -17,6 +20,7 @@ import org.springframework.stereotype.Service;
 
 import java.util.Iterator;
 import java.util.List;
+import java.util.Map;
 
 @Service
 public class ChartsConfigService {
@@ -29,19 +33,22 @@ public class ChartsConfigService {
     ObjectMapper objectmapper;
     @Autowired
     StrategysService strategysService;
-
+    @Autowired
+    GetTokenData getTokenData;
+    @Autowired
+    UserMapper userMapper;
 
     /*
     保存表设置
      */
-    public RepEntity setChartsConfig(ChartConfigInfo chartConfigInfo){
-
+    public RepEntity setChartsConfig(ChartConfigInfo chartConfigInfo, String token){
+        Map<String, String> resMap = getTokenData.getTokenData(token);
+        int userId = Integer.parseInt(resMap.get("id"));
+        String userName = resMap.get("name");
         ChartConfig chartConfig = new ChartConfig();
         BeanUtils.copyProperties(chartConfigInfo, chartConfig);
 
         String groupBy = null;
-//        String subsections = null;
-//        String chartsConfig = null;
         String accessAuthority = null;
         String updateAuthority = null;
         String style = null;
@@ -76,6 +83,8 @@ public class ChartsConfigService {
         chartConfig.setUpdateAuthority(updateAuthority);
         chartConfig.setStyle(style);
         chartConfig.setCreateDate(timeUtil.SystemTime());
+        chartConfig.setCreateId(userId);
+        chartConfig.setCreateBy(userName);
 
         if (chartConfig.getChartsGroup() == 0){
             chartConfig.setChartsGroup(-1);
@@ -94,9 +103,13 @@ public class ChartsConfigService {
     /*
     更新表设置
      */
-    public RepEntity updateChartsConfig(ChartConfigInfo chartConfigInfo){
-
-
+    public RepEntity updateChartsConfig(ChartConfigInfo chartConfigInfo, String token){
+        Map<String, String> resMap = getTokenData.getTokenData(token);
+        int userId = Integer.parseInt(resMap.get("id"));
+        int createID = chartsConfigMapper.getCreateId(chartConfigInfo.getChartId());
+        if (userId != createID){
+            return new RepEntity(RepCode.NoAuthority);
+        }
         ChartConfig chartConfig = new ChartConfig();
         BeanUtils.copyProperties(chartConfigInfo, chartConfig);
 
@@ -153,10 +166,15 @@ public class ChartsConfigService {
     /*
     移交图表
      */
-    public RepEntity changeChartOrder(ChangeOrderInfo changeOrderInfo){
-        String userId = String.valueOf(changeOrderInfo.getUserId());
-        int baseId = changeOrderInfo.getId();
-        chartsConfigMapper.changeChartOrder(userId, baseId);
+    public RepEntity changeChartOrder(ChangeOrderInfo changeOrderInfo, String token){
+        Map<String, String> resMap = getTokenData.getTokenData(token);
+        int userId = Integer.parseInt(resMap.get("id"));
+        String name = userMapper.getName(changeOrderInfo.getUserId());
+        int createId = chartsConfigMapper.getCreateId(changeOrderInfo.getId());
+        if (createId != userId){
+            return new RepEntity(RepCode.NoAuthority);
+        }
+        chartsConfigMapper.changeChartOrder(name, changeOrderInfo.getUserId(), changeOrderInfo.getId());
         return new RepEntity(RepCode.success);
     }
 
@@ -181,9 +199,11 @@ public class ChartsConfigService {
     /*
     查询图表列表
      */
-    public RepEntity getListCharts(){
-
-        return new RepEntity(RepCode.success, chartsConfigMapper.getListCharts());
+    public RepEntity getListCharts(String token){
+        Map<String, String> resMap = getTokenData.getTokenData(token);
+        int id = Integer.parseInt(resMap.get("id"));
+        List<ChartConfigList> chartsList = chartsConfigMapper.getListByUser(id);
+        return new RepEntity(RepCode.success, chartsList);
     }
 
     /*

+ 93 - 0
src/main/java/com/server/ChartsUtilService.java

@@ -0,0 +1,93 @@
+package com.server;
+
+import com.dao.ChartsConfigMapper;
+import com.dao.DataConnectorMapper;
+import com.dao.StrategysBdMapper;
+import com.dao.StrategysChartMapper;
+import com.util.GetTokenData;
+import org.apache.ibatis.binding.BindingException;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.stereotype.Component;
+
+import java.util.ArrayList;
+import java.util.Iterator;
+import java.util.List;
+import java.util.Map;
+
+@Component
+public class ChartsUtilService {
+    @Autowired
+    GetTokenData getTokenData;
+    @Autowired
+    DataConnectorMapper dataConnectorMapper;
+    @Autowired
+    ChartsConfigMapper chartsConfigMapper;
+    @Autowired
+    StrategysBdMapper strategysBdMapper;
+    @Autowired
+    StrategysChartMapper strategysChartMapper;
+
+    public String getSqlStr(String token, int id) {
+        Map<String, String> resultMap = getTokenData.getTokenData(token);
+        int userId = Integer.parseInt(resultMap.get("id"));
+        int createID;
+        int baseId;
+        try {
+            createID = chartsConfigMapper.getCreateId(id);
+            baseId = dataConnectorMapper.getBaseId(id);
+        }catch (BindingException exception){
+            throw new BindingException();
+        }
+        String tableName = chartsConfigMapper.getTableName(id);
+        System.out.println("table:"+tableName);
+        System.out.println("userId:" + userId + ", createID:" + createID + "");
+        if (userId == createID) {
+            //如果数据源创建人ID跟用户ID一样,获得数据源全部权限
+            if (tableName == null || "".equals(tableName)) {
+                return "";
+            } else {
+                return columnNameUtil(userId, baseId, tableName, true, id);
+            }
+        } else {
+            String sql = columnNameUtil(userId, baseId, tableName, true, id);
+            return columnNameUtil(userId, baseId, sql, false, id);
+        }
+    }
+
+    public String columnNameUtil(int userId, int baseId, String tableName, boolean isOrder, int id){
+        //用户不是创建人
+        List<String> strList = new ArrayList<>();
+
+        if (isOrder){
+            int baseCreateId = chartsConfigMapper.getCreateIdBychart(id);
+            if (baseCreateId == userId){
+                return "(" + tableName +")";
+            }else {
+                strList = strategysBdMapper.getSqlStr(userId, baseId);
+            }
+        }else {
+            strList = strategysChartMapper.getSqlStr(userId, baseId);
+        }
+
+        if (strList.size() == 0){
+            return "";
+        }
+        String sqlStr = "";
+        Iterator isList = strList.iterator();
+        while (isList.hasNext()){
+            String str = (String) isList.next();
+            System.out.println("str111:" + str);
+            StringBuilder sb = new StringBuilder(str);
+            sqlStr = sqlStr + String.valueOf(sb .replace(1, 5, "( ")) + ") or";
+        }
+        System.out.println("sqlStr:" + sqlStr);
+        StringBuilder sb = new StringBuilder(sqlStr);
+        sqlStr = "(select * from " + "(" + tableName +")" + " where " + sb.replace(sb.length()-2,sb.length(), "") + ")";
+        System.out.println("sql:" + sqlStr);
+        return sqlStr;
+    }
+
+    /*
+    判断图表是否有权限
+     */
+}

+ 7 - 7
src/main/java/com/server/ColumnScreenService.java

@@ -20,15 +20,15 @@ public class ColumnScreenService {
     GetChartsDataUtilService getChartsDataUtilService;
     @Autowired
     ChartsConfigMapper chartsConfigMapper;
+    @Autowired
+    ChartsUtilService chartsUtilService;
 
-    public RepEntity getScreenData(ColumnScreenInfo columnScreenInfo){
+    public RepEntity getScreenData(ColumnScreenInfo columnScreenInfo, String token){
         //取表名
         int id = columnScreenInfo.getId();
-        String tableName = chartsConfigMapper.getTableName(id);
-        if (tableName == null || "".equals(tableName)){
-            return new RepEntity(RepCode.nullTableName);
-        }else {
-            tableName = "(" + tableName +")";
+        String tableName = chartsUtilService.getSqlStr(token, id);
+        if ("".equals(tableName)){
+            return new RepEntity(RepCode.NoAuthority);
         }
 
         List<Object> data = new ArrayList<>();
@@ -58,7 +58,7 @@ public class ColumnScreenService {
     /*
     通过数据源ID获取列的值
      */
-    public RepEntity getScreenByBaseId(ColumnScreenInfo columnScreenInfo){
+    public RepEntity getScreenByBaseId(ColumnScreenInfo columnScreenInfo, String token){
         //取表名
         int connectId = columnScreenInfo.getId();
         String tableName = chartsConfigMapper.getTableNameByBase(connectId);

+ 4 - 10
src/main/java/com/server/DataBasesService.java

@@ -3,7 +3,6 @@ package com.server;
 import com.dao.DataConnectorMapper;
 import com.fasterxml.jackson.databind.ObjectMapper;
 import com.fasterxml.jackson.databind.type.CollectionType;
-import com.model.bo.Pages;
 import com.model.po.ColumnToShow;
 import com.model.po.DataConnector;
 import com.model.po.Databases;
@@ -15,6 +14,7 @@ import com.util.BasesSource.DynamicDataSource;
 import com.util.BasesSource.DynamicDataSourceContextHolder;
 import com.util.BasesSource.DynamicDataSourceRegister;
 import com.util.ContextUtil;
+import com.util.GetTokenData;
 import com.util.TimeUtil;
 import org.springframework.beans.BeanUtils;
 import org.springframework.beans.factory.annotation.Autowired;
@@ -35,6 +35,8 @@ public class DataBasesService {
     private DynamicDataSourceRegister dataSourceRegister;
     @Autowired
     GetChartsDataUtilService getChartsDataUtilService;
+    @Autowired
+    GetTokenData getTokenData;
     /*
    保存数据库连接
     */
@@ -64,15 +66,7 @@ public class DataBasesService {
     /*
    查看数据库配置列表
     */
-    public RepEntity getListDatabases(Pages pages){
-        if (pages == null || "".equals(pages)){
-            int pageNum = pages.getPageNum();
-            int pageSize = pages.getPageSize();
-
-            //使用分页插件,核心代码就这一行
-//            PageHelper.startPage(pageNum, pageSize);
-        }
-
+    public RepEntity getListDatabases(){
         List<Databases> databasesList = dataConnectorMapper.getDatabasesList();
         List<Databases> databases = new ArrayList<>();
         Iterator isList = databasesList.iterator();

+ 24 - 14
src/main/java/com/server/DataConnectorService.java

@@ -1,6 +1,7 @@
 package com.server;
 
 import com.dao.DataConnectorMapper;
+import com.dao.UserMapper;
 import com.fasterxml.jackson.core.JsonProcessingException;
 import com.fasterxml.jackson.databind.ObjectMapper;
 import com.model.bo.DatabaseConfig;
@@ -14,6 +15,7 @@ import com.model.vo.configVo.ChangeOrderInfo;
 import com.model.vo.configVo.ColumnRenameInfo;
 import com.model.vo.configVo.DataConnectorInfo;
 import com.model.vo.configVo.GroupInfo;
+import com.util.GetTokenData;
 import com.util.ScreenUtil;
 import com.util.SqlMatch;
 import com.util.TimeUtil;
@@ -24,6 +26,7 @@ import org.springframework.stereotype.Service;
 import java.util.ArrayList;
 import java.util.Iterator;
 import java.util.List;
+import java.util.Map;
 
 @Service
 public class DataConnectorService {
@@ -44,6 +47,10 @@ public class DataConnectorService {
     ScreenUtil screenUtil;
     @Autowired
     StrategysService strategysService;
+    @Autowired
+    GetTokenData getTokenData;
+    @Autowired
+    UserMapper userMapper;
 
     /*
     保存数据源
@@ -107,20 +114,18 @@ public class DataConnectorService {
     }
 
     //查看数据源列表
-    public RepEntity getListConnector(){
-//        if (pages == null || "".equals(pages)){
-//            int pageNum = pages.getPageNum();
-//            int pageSize = pages.getPageSize();
-
-            //使用分页插件,核心代码就这一行
-//            PageHelper.startPage(pageNum, pageSize);
-//        }
-
-        List<DataConnectorList> listConnector = dataConnectorMapper.getDataConnectorList();
+    public RepEntity getListConnector(String token){
+        Map<String, String> resultMap = getTokenData.getTokenData(token);
+        String id = resultMap.get("id");
+        System.out.println("id:" + id);
+        List<DataConnectorList> listConnector = dataConnectorMapper.getDataConnectorList(Integer.parseInt(id));
+//        listConnector.addAll(dataConnectorMapper.getDataConnectorUList(Integer.parseInt(id)));
+//        listConnector.addAll(dataConnectorMapper.getDataConnectorUgList(Integer.parseInt(id)));
         List<DataConnectorList> listConnectors = new ArrayList<>();
         Iterator isList = listConnector.iterator();
         while (isList.hasNext()){
             DataConnectorList dataConnectorList = (DataConnectorList) isList.next();
+            System.out.println("ddddd:"+dataConnectorList);
             BaseConfig baseConfig = new BaseConfig();
             String dbConfig = dataConnectorList.getDbConfig();
             try {
@@ -227,10 +232,15 @@ public class DataConnectorService {
     /*
     转交数据源
      */
-    public RepEntity changeOrder(ChangeOrderInfo changeOrderInfo){
-        String userId = String.valueOf(changeOrderInfo.getUserId());
-        int baseId = changeOrderInfo.getId();
-        dataConnectorMapper.updataOrder(userId, baseId);
+    public RepEntity changeOrder(ChangeOrderInfo changeOrderInfo, String token){
+        Map<String, String> resMap = getTokenData.getTokenData(token);
+        int userId = Integer.parseInt(resMap.get("id"));
+        String name = userMapper.getName(changeOrderInfo.getUserId());
+        int createId = dataConnectorMapper.getCreateIdById(changeOrderInfo.getId());
+        if (createId != userId){
+            return new RepEntity(RepCode.NoAuthority);
+        }
+        dataConnectorMapper.updataOrder(name, changeOrderInfo.getUserId(), changeOrderInfo.getId());
         return new RepEntity(RepCode.success);
     }
 

+ 16 - 15
src/main/java/com/server/ShowHistogramService.java

@@ -36,11 +36,13 @@ public class ShowHistogramService {
     GetChartsDataUtilService getChartsDataUtilService;
     @Autowired
     ScreenUtil screenUtil;
+    @Autowired
+    ChartsUtilService chartsUtilService;
 
     /*
     柱状图数据展示
      */
-    public RepEntity showHistogram(HistogramConfigInfo histogramConfigInfo){
+    public RepEntity showHistogram(HistogramConfigInfo histogramConfigInfo, String token){
         ChartsDataInfo chartsDataInfo = new ChartsDataInfo();
         if (histogramConfigInfo == null || "".equals(histogramConfigInfo)){
             return new RepEntity(RepCode.Null);
@@ -48,11 +50,9 @@ public class ShowHistogramService {
 
         //取表名
         int id = histogramConfigInfo.getId();
-        String tableName = chartsConfigMapper.getTableName(id);
-        if (tableName == null || "".equals(tableName)){
-            return new RepEntity(RepCode.nullTableName);
-        }else {
-            tableName = "(" + tableName +")";
+        String tableName = chartsUtilService.getSqlStr(token, id);
+        if ("".equals(tableName)){
+            return new RepEntity(RepCode.NoAuthority);
         }
 
         int baseId = getChartsDataUtilService.getBaseId(id);
@@ -93,6 +93,7 @@ public class ShowHistogramService {
             ScreenStr scr = new ScreenStr();
             String screen = "";               //正常筛选条件
             String screenToColumn = "";       //跟目标列相同的筛选条件
+            String screenStr = "";
             if ("".equals(screens) || screens == null || screens.size() == 0){
                 screen = "";
             }else {
@@ -107,19 +108,19 @@ public class ShowHistogramService {
                     System.out.println("screen:" + screen);
                 }else {
                     StringBuilder sb1 = new StringBuilder(screen);
-                    screen = String.valueOf(sb1 .replace(1, 5, "where "));
+                    screenStr = String.valueOf(sb1 .replace(1, 5, "where "));
                 }
             }
 
             //X轴
             //判断是否为日期类型
             if ("time".equals(xColumnType)){
-                xAxisData = timeConverterUtil.timeConverter(xColumn, tableName, xAxisType, screen);
+                xAxisData = timeConverterUtil.timeConverter(xColumn, tableName, xAxisType, screenStr);
                 System.out.println("xA:" + xAxisData);
                 xData = timeConverterUtil.toRespons(xAxisData,xAxisType );
                 System.out.println("data:"+xAxisData);
             }else {
-                xAxisData = showChartsMapper.getXAxis(xColumn, tableName, screen);
+                xAxisData = showChartsMapper.getXAxis(xColumn, tableName, screenStr);
 
             }
             if ("".equals(xAxisData) || xAxisData == null || xAxisData.size() == 0){
@@ -138,12 +139,12 @@ public class ShowHistogramService {
                 double valueOne = 0;
                 String valueOnes = null;
                 if ("time".equals(xColumnType)){
-                    valueOnes = timeConverterUtil.getTimeValueConverter(yColumn, xColumn, tableName, yAxisType, xAxisType, xdata);
+                    valueOnes = timeConverterUtil.getTimeValueConverter(yColumn, xColumn, tableName, yAxisType, xAxisType, xdata, screen);
                 }else {
                     if (xdata == null || "".equals(xdata)){
-                        valueOnes = showChartsMapper.getValuesIsNull(yColumn, xColumn, tableName, yAxisType);
+                        valueOnes = showChartsMapper.getValuesIsNull(yColumn, xColumn, tableName, yAxisType, screen);
                     }else {
-                        valueOnes = showChartsMapper.getValues(yColumn, xColumn, tableName, yAxisType, xdata);
+                        valueOnes = showChartsMapper.getValues(yColumn, xColumn, tableName, yAxisType, xdata, screen);
                     }
                 }
                 if (valueOnes == null || "".equals(valueOnes)){
@@ -168,7 +169,7 @@ public class ShowHistogramService {
                 //便利分组
                 while (itGroup.hasNext()){
                     String groupByName = (String) itGroup.next(); //每个分组的组名
-                    List<String> groupsData = showChartsMapper.getGroups(groupByName,tableName, screen); //查询每个分组系列
+                    List<String> groupsData = showChartsMapper.getGroups(groupByName,tableName, screenStr); //查询每个分组系列
                     System.out.println("groupdata:"+ groupsData.toString());
                     Iterator itGroupsData = groupsData.iterator();
 
@@ -192,7 +193,7 @@ public class ShowHistogramService {
                             String groupsValueOnes = null;
                             if ("time".equals(xColumnType)){
                                 groupsValueOnes = timeConverterUtil.getGroupTimeConverter(yAxisType, yColumn, tableName, groupByName, xAxisType,
-                                        groupsName, xColumn, xAxisDataOne);
+                                        groupsName, xColumn, xAxisDataOne, screen);
                             }else {
                                 String xColumnKey = "";
                                 if (xAxisDataOne == null || "".equals(xAxisDataOne)){
@@ -208,7 +209,7 @@ public class ShowHistogramService {
                                 }else {
                                     groupByKey = groupByName + " = '" +groupsName +"'";
                                 }
-                                groupsValueOnes = showChartsMapper.getGroupsValue(yAxisType, yColumn, tableName, groupByKey, xColumnKey);
+                                groupsValueOnes = showChartsMapper.getGroupsValue(yAxisType, yColumn, tableName, groupByKey, xColumnKey, screen);
                             }
                             if ("".equals(groupsValueOnes) || groupsValueOnes == null){
                                 groupsValueOne = 0;

+ 7 - 7
src/main/java/com/server/ShowIndividualService.java

@@ -29,8 +29,10 @@ public class ShowIndividualService {
     ShowChartsMapper showChartsMapper;
     @Autowired
     ScreenUtil screenUtil;
+    @Autowired
+    ChartsUtilService chartsUtilService;
 
-    public RepEntity showIndividual(IndividualConfigInfo individualConfigInfo){
+    public RepEntity showIndividual(IndividualConfigInfo individualConfigInfo, String token){
         if (individualConfigInfo == null || "".equals(individualConfigInfo)){
             return new RepEntity(RepCode.Null);
         }
@@ -38,12 +40,10 @@ public class ShowIndividualService {
         List<LinkedHashMap<String, Object>> targetValue = new ArrayList<>();
         //取表名
         int id = individualConfigInfo.getId();
-        String tableName = chartsConfigMapper.getTableName(id);
-        if (tableName == null || "".equals(tableName)){
-            return new RepEntity(RepCode.nullTableName);
-        }else {
-            tableName = "(" + tableName +")";
-        }
+        String tableName = chartsUtilService.getSqlStr(token, id);
+        if ("".equals(tableName)){
+            return new RepEntity(RepCode.NoAuthority);
+    }
 
         int baseId = getChartsDataUtilService.getBaseId(id);
         System.out.println("切换数据库"+String.valueOf(baseId));

+ 10 - 9
src/main/java/com/server/ShowLineService.java

@@ -34,21 +34,21 @@ public class ShowLineService {
     GetChartsDataUtilService getChartsDataUtilService;
     @Autowired
     ScreenUtil screenUtil;
+    @Autowired
+    ChartsUtilService chartsUtilService;
 
     /*
     Line数据展示
      */
-    public RepEntity showLine(LineConfigInfo lineConfigInfo){
+    public RepEntity showLine(LineConfigInfo lineConfigInfo, String token){
         ChartsDataInfo chartsDataInfo = new ChartsDataInfo();
         if (lineConfigInfo == null || "".equals(lineConfigInfo)){
             return new RepEntity(RepCode.Null);
         }
         int id = lineConfigInfo.getId();
-        String tableName = chartsConfigMapper.getTableName(id);
-        if (tableName == null || "".equals(tableName)){
-            return new RepEntity(RepCode.nullTableName);
-        }else {
-            tableName = "(" + tableName +")";
+        String tableName = chartsUtilService.getSqlStr(token, id);
+        if ("".equals(tableName)){
+            return new RepEntity(RepCode.NoAuthority);
         }
 
         int baseId = getChartsDataUtilService.getBaseId(id);
@@ -88,6 +88,7 @@ public class ShowLineService {
             ScreenStr scr = new ScreenStr();
             String screen = "";
             String screenToColumn = "";
+            String screenStr = "";
             if ("".equals(screens) || screens == null || screens.size() == 0){
                 screen = "";
             }else {
@@ -101,7 +102,7 @@ public class ShowLineService {
                     System.out.println("screen:" + screen);
                 }else {
                     StringBuilder sb1 = new StringBuilder(screen);
-                    screen = String.valueOf(sb1 .replace(1, 5, "where "));
+                    screenStr = String.valueOf(sb1 .replace(1, 5, "where "));
                 }
             }
 
@@ -124,7 +125,7 @@ public class ShowLineService {
             double valueOne = 0;
             String valueOnes = null;
 //                System.out.println("Y:"+ yColumn + "........x:" + xColumn + "........yAxistype:" + yAxisType + "...xtpye:+"+yAxisType+ "   xdata:"+xdata);
-                valueOnes = timeConverterUtil.getTimeValueConverter(yColumn, xColumn, tableName, yAxisType, xAxisType, xdata);
+                valueOnes = timeConverterUtil.getTimeValueConverter(yColumn, xColumn, tableName, yAxisType, xAxisType, xdata, screen);
 //                System.out.println("value:"+valueOnes);
             if (valueOnes == null || "".equals(valueOnes)){
                 valueOne = 0;
@@ -171,7 +172,7 @@ public class ShowLineService {
                         double groupsValueOne = 0;
                         String groupsValueOnes = null;
                         groupsValueOnes = timeConverterUtil.getGroupTimeConverter(yAxisType, yColumn, tableName, groupByName, xAxisType,
-                                    groupsName, xColumn, xAxisDataOne);
+                                    groupsName, xColumn, xAxisDataOne, screen);
                         if ("".equals(groupsValueOnes) || groupsValueOnes == null){
                             groupsValueOne = 0;
                         }else{

+ 11 - 10
src/main/java/com/server/ShowPieService.java

@@ -34,21 +34,21 @@ public class ShowPieService {
     ScreenUtil screenUtil;
     @Autowired
     GetChartsDataUtilService getChartsDataUtilService;
+    @Autowired
+    ChartsUtilService chartsUtilService;
 
     /*
     Pie数据展示
      */
-    public RepEntity showPie(PieConfigInfo pieConfigInfo){
+    public RepEntity showPie(PieConfigInfo pieConfigInfo, String token){
         ChartsDataInfo<PieSeries> chartsDataInfo = new ChartsDataInfo();
         if (pieConfigInfo == null || "".equals(pieConfigInfo)){
             return new RepEntity(RepCode.Null);
         }
         int id = pieConfigInfo.getId();
-        String tableName = chartsConfigMapper.getTableName(id);
-        if (tableName == null || "".equals(tableName)){
-            return new RepEntity(RepCode.nullTableName);
-        }else {
-            tableName = "(" + tableName +")";
+        String tableName = chartsUtilService.getSqlStr(token, id);
+        if ("".equals(tableName)){
+            return new RepEntity(RepCode.NoAuthority);
         }
 
         int baseId = getChartsDataUtilService.getBaseId(id);
@@ -87,6 +87,7 @@ public class ShowPieService {
         ScreenStr scr = new ScreenStr();
         String screen = "";
         String screenToColumn = "";
+        String screenStr = "";
         if ("".equals(screens) || screens == null || screens.size() == 0){
             screen = "";
         }else {
@@ -101,7 +102,7 @@ public class ShowPieService {
                 System.out.println("screen:" + screen);
             }else {
                 StringBuilder sb1 = new StringBuilder(screen);
-                screen = String.valueOf(sb1 .replace(1, 5, "where "));
+                screenStr = String.valueOf(sb1 .replace(1, 5, "where "));
             }
         }
 
@@ -135,12 +136,12 @@ public class ShowPieService {
             String valueOnes = null;
             PieSeriesMap pieSeriesMap = new PieSeriesMap();
             if ("time".equals(xColumnType)){
-                valueOnes = timeConverterUtil.getTimeValueConverter(yColumn, xColumn, tableName, yAxisType, xAxisType, xdata);
+                valueOnes = timeConverterUtil.getTimeValueConverter(yColumn, xColumn, tableName, yAxisType, xAxisType, xdata, screen);
             }else {
                 if (xdata == null || "".equals(xdata)){
-                    valueOnes = showChartsMapper.getValuesIsNull(yColumn, xColumn, tableName, yAxisType);
+                    valueOnes = showChartsMapper.getValuesIsNull(yColumn, xColumn, tableName, yAxisType, screen);
                 }else {
-                    valueOnes = showChartsMapper.getValues(yColumn, xColumn, tableName, yAxisType, xdata);
+                    valueOnes = showChartsMapper.getValues(yColumn, xColumn, tableName, yAxisType, xdata, screen);
                 }
             }
             if (valueOnes == null || "".equals(valueOnes)){

+ 6 - 6
src/main/java/com/server/ShowPopulationService.java

@@ -25,18 +25,18 @@ public class ShowPopulationService {
     GetChartsDataUtilService getChartsDataUtilService;
     @Autowired
     ScreenUtil screenUtil;
+    @Autowired
+    ChartsUtilService chartsUtilService;
 
-    public RepEntity showPopulation(PopulationInfo populationInfo) throws SQLException {
+    public RepEntity showPopulation(PopulationInfo populationInfo, String token) throws SQLException {
         if (populationInfo == null || "".equals(populationInfo)){
             return new RepEntity(RepCode.Null);
         }
         //取表名
         int id = populationInfo.getId();
-        String tableName = chartsConfigMapper.getTableName(id);
-        if (tableName == null || "".equals(tableName)){
-            return new RepEntity(RepCode.nullTableName);
-        }else {
-            tableName = "(" + tableName +")";
+        String tableName = chartsUtilService.getSqlStr(token, id);
+        if ("".equals(tableName)){
+            return new RepEntity(RepCode.NoAuthority);
         }
 
         int baseId = getChartsDataUtilService.getBaseId(id);

+ 13 - 12
src/main/java/com/server/ShowScatterService.java

@@ -34,21 +34,21 @@ public class ShowScatterService {
     GetChartsDataUtilService getChartsDataUtilService;
     @Autowired
     ScreenUtil screenUtil;
+    @Autowired
+    ChartsUtilService chartsUtilService;
 
     /*
     Line数据展示
      */
-    public RepEntity showScatter(ScatterConfigInfo scatterConfigInfo){
+    public RepEntity showScatter(ScatterConfigInfo scatterConfigInfo, String token){
         ChartsDataInfo chartsDataInfo = new ChartsDataInfo();
         if (scatterConfigInfo == null || "".equals(scatterConfigInfo)){
             return new RepEntity(RepCode.Null);
         }
         int id = scatterConfigInfo.getId();
-        String tableName = chartsConfigMapper.getTableName(id);
-        if (tableName == null || "".equals(tableName)){
-            return new RepEntity(RepCode.nullTableName);
-        }else {
-            tableName = "(" + tableName +")";
+        String tableName = chartsUtilService.getSqlStr(token, id);
+        if ("".equals(tableName)){
+            return new RepEntity(RepCode.NoAuthority);
         }
 
         int baseId = getChartsDataUtilService.getBaseId(id);
@@ -89,6 +89,7 @@ public class ShowScatterService {
             ScreenStr scr = new ScreenStr();
             String screen = "";
             String screenToColumn = "";
+            String screenStr = "";
             if ("".equals(screens) || screens == null || screens.size() == 0){
                 screen = "";
             }else {
@@ -102,7 +103,7 @@ public class ShowScatterService {
                     System.out.println("screen:" + screen);
                 }else {
                     StringBuilder sb1 = new StringBuilder(screen);
-                    screen = String.valueOf(sb1 .replace(1, 5, "where "));
+                    screenStr = String.valueOf(sb1 .replace(1, 5, "where "));
                 }
             }
 
@@ -128,12 +129,12 @@ public class ShowScatterService {
             double valueOne = 0;
             String valueOnes = null;
             if ("time".equals(xColumnType)){
-                valueOnes = timeConverterUtil.getTimeValueConverter(yColumn, xColumn, tableName, yAxisType, xAxisType, xdata);
+                valueOnes = timeConverterUtil.getTimeValueConverter(yColumn, xColumn, tableName, yAxisType, xAxisType, xdata, screen);
             }else {
                 if (xdata == null || "".equals(xdata)){
-                    valueOnes = showChartsMapper.getValuesIsNull(yColumn, xColumn, tableName, yAxisType);
+                    valueOnes = showChartsMapper.getValuesIsNull(yColumn, xColumn, tableName, yAxisType, screen);
                 }else {
-                    valueOnes = showChartsMapper.getValues(yColumn, xColumn, tableName, yAxisType, xdata);
+                    valueOnes = showChartsMapper.getValues(yColumn, xColumn, tableName, yAxisType, xdata ,screen);
                 }
             }
             if (valueOnes == null || "".equals(valueOnes)){
@@ -182,7 +183,7 @@ public class ShowScatterService {
                         String groupsValueOnes = null;
                         if ("time".equals(xColumnType)){
                             groupsValueOnes = timeConverterUtil.getGroupTimeConverter(yAxisType, yColumn, tableName, groupByName, xAxisType,
-                                    groupsName, xColumn, xAxisDataOne);
+                                    groupsName, xColumn, xAxisDataOne,screen);
                         }else {
                             String xColumnKey = "";
                             if (xAxisDataOne == null || "".equals(xAxisDataOne)){
@@ -198,7 +199,7 @@ public class ShowScatterService {
                             }else {
                                 groupByKey = groupByName + " = '" +groupsName +"'";
                             }
-                            groupsValueOnes = showChartsMapper.getGroupsValue(yAxisType, yColumn, tableName, groupByKey, xColumnKey);
+                            groupsValueOnes = showChartsMapper.getGroupsValue(yAxisType, yColumn, tableName, groupByKey, xColumnKey ,screen);
                         }
                         if ("".equals(groupsValueOnes) || groupsValueOnes == null){
                             groupsValueOne = 0;

+ 14 - 14
src/main/java/com/server/TimeConverterUtil.java

@@ -69,41 +69,41 @@ public class TimeConverterUtil {
     }
 
     //无分组时间值
-    public String getTimeValueConverter(String yColumn, String xColumn, String tableName, String dataType, String timeType, String xdata){
+    public String getTimeValueConverter(String yColumn, String xColumn, String tableName, String dataType, String timeType, String xdata, String screen){
 
         String timeGroup = "'YYYY-MM-DD'";
         String value = null;
         //判断时间类型
         if (xdata == null || "".equals(xdata)){
-            value = showChartsMapper.getTimeIsNull(dataType, yColumn, tableName, xColumn);
+            value = showChartsMapper.getTimeIsNull(dataType, yColumn, tableName, xColumn, screen);
         }else {
             if ("halfYear".equals(timeType)) {
                 String[] str = xdata.split("-");
                 if ("H1".equals(str[1])) {
                     String firstIndex = str[0] + "-01";
                     String afterIndex = str[0] + "-06";
-                    value = showChartsMapper.getTimeValueYear(dataType, yColumn, tableName, xColumn, firstIndex, afterIndex);
+                    value = showChartsMapper.getTimeValueYear(dataType, yColumn, tableName, xColumn, firstIndex, afterIndex, screen);
                 } else {
                     String firstIndex = str[0] + "-07";
                     String afterIndex = str[0] + "-12";
-                    value = showChartsMapper.getTimeValueYear(dataType, yColumn, tableName, xColumn, firstIndex, afterIndex);
+                    value = showChartsMapper.getTimeValueYear(dataType, yColumn, tableName, xColumn, firstIndex, afterIndex, screen);
                 }
             } else if ("year".equals(timeType)) {
                 timeGroup = "'YYYY'";
-                value = showChartsMapper.getTimeValue(dataType, yColumn, tableName, xColumn, timeGroup, xdata);
+                value = showChartsMapper.getTimeValue(dataType, yColumn, tableName, xColumn, timeGroup, xdata, screen);
             } else if ("month".equals(timeType)) {
                 timeGroup = "'YYYY-MM'";
-                value = showChartsMapper.getTimeValue(dataType, yColumn, tableName, xColumn, timeGroup, xdata);
+                value = showChartsMapper.getTimeValue(dataType, yColumn, tableName, xColumn, timeGroup, xdata, screen);
             } else if ("day".equals(timeType) || "".equals(timeType)) {
-                value = showChartsMapper.getTimeValue(dataType, yColumn, tableName, xColumn, timeGroup, xdata);
+                value = showChartsMapper.getTimeValue(dataType, yColumn, tableName, xColumn, timeGroup, xdata, screen);
             } else if ("quarter".equals(timeType)) {
                 timeGroup = "'YYYY-Q'";
-                value = showChartsMapper.getTimeValue(dataType, yColumn, tableName, xColumn, timeGroup, xdata);
+                value = showChartsMapper.getTimeValue(dataType, yColumn, tableName, xColumn, timeGroup, xdata, screen);
             } else if ("week".equals(timeType)) {
                 timeGroup = "'YYYY-WW'";
-                value = showChartsMapper.getTimeValue(dataType, yColumn, tableName, xColumn, timeGroup, xdata);
+                value = showChartsMapper.getTimeValue(dataType, yColumn, tableName, xColumn, timeGroup, xdata, screen);
             } else {
-                value = showChartsMapper.getTimeValue(dataType, yColumn, tableName, xColumn, timeGroup, xdata);
+                value = showChartsMapper.getTimeValue(dataType, yColumn, tableName, xColumn, timeGroup, xdata, screen);
             }
         }
         return value;
@@ -111,12 +111,12 @@ public class TimeConverterUtil {
 
     //有分组时间类型值处理
     public String getGroupTimeConverter(String dataType, String yColumn, String tableName, String groupByName, String timeType,
-                                        String groupsName, String xColumn, String xAxisDataOne){
+                                        String groupsName, String xColumn, String xAxisDataOne, String screen){
         String timeGroup = "'YYYY-MM-DD'";
         String value = null;
         if(groupsName == null || "".equals(groupsName)){
             value = showChartsMapper.getGroupsValueTimeIsNull(dataType, yColumn, tableName, groupByName, groupsName, xColumn,
-                    timeGroup, xAxisDataOne);
+                    timeGroup, xAxisDataOne, screen);
         }else {
             if ("year".equals(timeType)) {
                 timeGroup = "'YYYY'";
@@ -142,11 +142,11 @@ public class TimeConverterUtil {
                 if ("上半年".equals(str[1])) {
                     String firstIndex = str[0] + "-01";
                     String afterIndex = str[0] + "-06";
-                    value = showChartsMapper.getTimeValueHalfYear(dataType, yColumn, tableName, xColumn, firstIndex, afterIndex, groupByName, groupsName);
+                    value = showChartsMapper.getTimeValueHalfYear(dataType, yColumn, tableName, xColumn, firstIndex, afterIndex, groupByName, groupsName, screen);
                 } else {
                     String firstIndex = str[0] + "-07";
                     String afterIndex = str[0] + "-12";
-                    value = showChartsMapper.getTimeValueHalfYear(dataType, yColumn, tableName, xColumn, firstIndex, afterIndex, groupByName, groupsName);
+                    value = showChartsMapper.getTimeValueHalfYear(dataType, yColumn, tableName, xColumn, firstIndex, afterIndex, groupByName, groupsName, screen);
                 }
             } else {
                 value = showChartsMapper.getGroupsValueTime(dataType, yColumn, tableName, groupByName, groupsName, xColumn,

+ 18 - 2
src/main/java/com/server/UserService.java

@@ -1,6 +1,7 @@
 package com.server;
 
 import com.dao.UserMapper;
+import com.fasterxml.jackson.databind.ObjectMapper;
 import com.model.po.TokenData;
 import com.model.po.User;
 import com.model.po.UserGroup;
@@ -14,6 +15,7 @@ import org.springframework.beans.BeanUtils;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.stereotype.Service;
 
+import java.io.IOException;
 import java.util.List;
 
 @Service
@@ -22,6 +24,8 @@ public class UserService {
     JwtTokenUtil jwtTokenUtil;
     @Autowired
     UserMapper userMapper;
+    @Autowired
+    ObjectMapper objectMapper;
 
     public RepEntity login(LoginInfo loginInfo){
         String userName = loginInfo.getUserName();
@@ -53,8 +57,20 @@ public class UserService {
     /*
     查询匹配用户
      */
-    public RepEntity getNameList(String value){
-        List<String> userName = userMapper.getNameList(value);
+    public RepEntity getNameList(String str){
+        String value = null;
+        String v = null;
+        try {
+            v = objectMapper.readValue(str, String.class);
+        } catch (IOException e) {
+            e.printStackTrace();
+        }
+
+        value = "like '%" + v + "%'";
+        System.out.println("value:" + value);
+
+        List<User> userName = userMapper.getNameList(value);
+        System.out.println("userName:" + userName);
         return new RepEntity(RepCode.success, userName);
     }
 

+ 39 - 0
src/main/java/com/util/GetTokenData.java

@@ -0,0 +1,39 @@
+package com.util;
+
+import com.auth0.jwt.JWT;
+import com.auth0.jwt.JWTVerifier;
+import com.auth0.jwt.algorithms.Algorithm;
+import com.auth0.jwt.interfaces.Claim;
+import com.auth0.jwt.interfaces.DecodedJWT;
+import com.google.common.collect.Maps;
+import org.springframework.stereotype.Component;
+
+import java.io.UnsupportedEncodingException;
+import java.util.Map;
+
+@Component
+public class GetTokenData {
+    //公共密钥
+    public static String SECRET = "YouRuanKeJiBi";
+    public Map<String, String> getTokenData(String token){
+        DecodedJWT jwt = null;
+
+        JWTVerifier verifier = null;
+        try {
+            verifier = JWT.require(Algorithm.HMAC256(SECRET)).build();
+        } catch (UnsupportedEncodingException e) {
+            e.printStackTrace();
+        }
+
+        try {
+            jwt = verifier.verify(token);
+        } catch (Exception e) {
+            throw new RuntimeException("登录凭证已过期,请重新登录");
+        }
+        Map<String, Claim> claimMap = jwt.getClaims();
+        Map<String, String> resultMap = Maps.newHashMap();
+        claimMap.forEach((k,v) -> resultMap.put(k, v.asString()));
+        System.out.println("re:"+resultMap);
+        return resultMap;
+    }
+}

+ 21 - 0
src/main/java/com/util/GlobalException.java

@@ -1,9 +1,11 @@
 //package com.util;
 //
+//import org.apache.ibatis.binding.BindingException;
 //import org.springframework.web.bind.annotation.ControllerAdvice;
 //import org.springframework.web.bind.annotation.ExceptionHandler;
 //import org.springframework.web.bind.annotation.ResponseBody;
 //
+//import javax.management.OperationsException;
 //import java.util.HashMap;
 //import java.util.Map;
 //
@@ -18,4 +20,23 @@
 //        return result;
 //    }
 //
+//    @ExceptionHandler(OperationsException.class)
+//    @ResponseBody
+//    public Map<String, Object> operationsException(){
+//        Map<String, Object> result = new HashMap<String, Object>();
+//        result.put("code" , "-503");
+//        result.put("msg" , "权限不足");
+//        return result;
+//    }
+//
+//
+//    @ExceptionHandler(BindingException.class)
+//    @ResponseBody
+//    public Map<String, Object> BindingException(){
+//        Map<String, Object> result = new HashMap<String, Object>();
+//        result.put("code" , "-504");
+//        result.put("msg" , "数据为空");
+//        return result;
+//    }
+//
 //}

+ 3 - 2
src/main/java/com/util/JwtTokenUtil.java

@@ -14,6 +14,7 @@ import org.aspectj.lang.annotation.Pointcut;
 import org.springframework.core.annotation.Order;
 import org.springframework.stereotype.Component;
 
+import javax.management.OperationsException;
 import java.io.UnsupportedEncodingException;
 import java.util.Calendar;
 import java.util.Date;
@@ -56,7 +57,7 @@ public class JwtTokenUtil {
         try {
             token = JWT.create()
                     .withHeader(map)
-                    .withClaim("id", user.getId())
+                    .withClaim("id", String.valueOf(user.getId()))
                     .withClaim("name", user.getName())
                     .withClaim("department", user.getDepartment())
                     .withClaim("post", user.getPost())
@@ -89,7 +90,7 @@ public class JwtTokenUtil {
         try {
             jwt = verifier.verify(token);
         } catch (Exception e) {
-            throw new RuntimeException("登录凭证已过期,请重新登录");
+            throw new OperationsException("登录凭证已过期,请重新登录");
         }
         return jwt.getClaims();
     }

+ 11 - 0
src/main/java/com/util/RoleInterceptor/Auth.java

@@ -0,0 +1,11 @@
+package com.util.RoleInterceptor;
+
+import java.lang.annotation.*;
+
+@Inherited
+@Target({ElementType.TYPE, ElementType.METHOD})
+@Retention(RetentionPolicy.RUNTIME)
+@Documented
+public @interface  Auth {
+    String user() default "";
+}

+ 24 - 0
src/main/java/com/util/RoleInterceptor/ConfigAdapter.java

@@ -0,0 +1,24 @@
+package com.util.RoleInterceptor;
+
+import org.springframework.context.annotation.Bean;
+import org.springframework.context.annotation.Configuration;
+import org.springframework.web.servlet.config.annotation.InterceptorRegistry;
+import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;
+
+@Configuration
+public class ConfigAdapter implements WebMvcConfigurer {
+
+    @Bean
+    SecurityInterceptor securityInterceptor() {
+        return new SecurityInterceptor();
+    }
+    @Override
+    public void addInterceptors(InterceptorRegistry registry) {
+        registry.addInterceptor(securityInterceptor())
+                .addPathPatterns("/DataBase/*").excludePathPatterns("/DataBase/getColumnData")
+        .addPathPatterns("/getUserList")
+        .addPathPatterns("/Connector/*").excludePathPatterns("/Connector/getListDataConnector")
+        .excludePathPatterns("/Connector/getConnectorGroup");
+        System.out.println("进入拦截器");
+    }
+}

+ 58 - 0
src/main/java/com/util/RoleInterceptor/SecurityInterceptor.java

@@ -0,0 +1,58 @@
+package com.util.RoleInterceptor;
+
+import com.fasterxml.jackson.databind.ObjectMapper;
+import com.util.GetTokenData;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.stereotype.Component;
+import org.springframework.web.method.HandlerMethod;
+import org.springframework.web.servlet.HandlerInterceptor;
+import org.springframework.web.servlet.ModelAndView;
+
+import javax.management.OperationsException;
+import javax.servlet.http.HttpServletRequest;
+import javax.servlet.http.HttpServletResponse;
+import java.util.Map;
+
+@Component
+public class SecurityInterceptor implements HandlerInterceptor {
+    @Autowired
+    GetTokenData getTokenData;
+    @Autowired
+    ObjectMapper objectMapper;
+    @Override
+    public boolean preHandle(HttpServletRequest request, HttpServletResponse response, Object handler) throws Exception {
+        System.out.println("preHandle");
+        if (!handler.getClass().isAssignableFrom(HandlerMethod.class)) {
+            System.out.println("cat cast handler to HandlerMethod.class");
+            return true;
+        }
+        // 获取注解
+        Auth auth = ((HandlerMethod) handler).getMethod().getAnnotation(Auth.class);
+        if (auth == null) {
+            System.out.println("cant find @Auth in this uri:" + request.getRequestURI());
+            return true;
+        }
+        // 从参数中取出用户身份并验证
+        String admin = auth.user();
+        System.out.println("auth:"+admin);
+        String token = request.getHeader("token");
+        Map<String, String> resultMap = getTokenData.getTokenData(token);
+
+        System.out.println("user:" + resultMap.get("role"));
+        if (!admin.equals(resultMap.get("role"))) {
+            System.out.println("permission denied");
+            throw new OperationsException("权限不足");
+        }
+        return true;
+    }
+
+    @Override
+    public void postHandle(HttpServletRequest httpServletRequest, HttpServletResponse httpServletResponse, Object o, ModelAndView modelAndView) throws Exception {
+        System.out.println("2");
+    }
+
+    @Override
+    public void afterCompletion(HttpServletRequest httpServletRequest, HttpServletResponse httpServletResponse, Object o, Exception e) throws Exception {
+        System.out.println("3");
+    }
+}