DataConnectorMapper.java 9.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212
  1. package com.dao;
  2. import com.model.po.DataConnector;
  3. import com.model.po.DataConnectorList;
  4. import com.model.po.Databases;
  5. import com.model.vo.configVo.GroupInfo;
  6. import org.apache.ibatis.annotations.*;
  7. import org.springframework.stereotype.Repository;
  8. import java.util.List;
  9. @Mapper
  10. @Repository
  11. public interface DataConnectorMapper {
  12. // @Select("select d.column_name as columnName, d.DATA_TYPE as columnType, b.comments as remarks from " +
  13. // "(select column_name,DATA_TYPE from user_tab_cols where Table_Name = #{tableName}) d," +
  14. // "(select * from user_col_comments where Table_Name = #{tableName}) b" +
  15. // " where d.column_name = b.column_name order by columnName")
  16. // List<ColumnScreenInfo> getColumn(@Param("tableName") String tableName);
  17. // @Select("<script>" +
  18. // "select * from bi_data_connectors where" + "1=1" +
  19. // "<if test=\"id != null\"> and id = #{id} </if>" +
  20. // "<if test=\"dataName != null\"> and data_name = #{dataName} </if>" +
  21. // "<if test=\"dataTag != null\"> and data_tag = #{dataTag} </if>" +
  22. // "<if test=\"configuration != null\"> and configuration = #{configuration} </if>" +
  23. // "<if test=\"columnConfig != null\"> and columns_config = #{columnConfig} </if>" +
  24. // "<if test=\"usedNumber != null\"> and used_number = #{usedNumber} </if>" +
  25. // "<if test=\"createBy != null\">and create_by = #{createBy}</if>" +
  26. // "</script>")
  27. // List<DataConnector> getAllData(DataConnector dataConnector);
  28. /*
  29. 查询单个数据源
  30. */
  31. @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," +
  32. "CREATE_BY as createBy, USED_NUMBER as userNumber, CREATE_DATE as createDate,DB_CONFIG as dbConfig, BD_group as connectorGroup," +
  33. "CON_TYPE as type from bi_data_connectors where id = #{id}")
  34. DataConnector getOneData(int id);
  35. /*
  36. 查询数据源列表
  37. */
  38. @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," +
  39. " used_number as usedNumber, db_config as dbConfig ,BD_group as connectorGroup from bi_data_connectors")
  40. List<DataConnectorList> getDataConnectorList();
  41. /*
  42. 插入数据源配置
  43. */
  44. @Insert("INSERT INTO bi_data_connectors(id,data_name,data_note,data_tag,con_type,LOAD_OBJECT,DB_CONFIG,columns_config,used_number,create_by,create_date, table_name, BD_GROUP) " +
  45. "VALUES (#{dataId},#{dataName}, #{note}, #{dataTag}, #{type}, #{loadObject}, #{dbConfig},#{columnConfig}, #{usedNumber},#{createBy}, to_date(#{createDate},'YYYY-MM-DD hh24:mi:ss'), #{tableName}, #{connectorGroup})")
  46. @SelectKey(before=true,keyProperty="dataId",resultType=int.class,statement="SELECT BI_DASHBOARDS_squence.nextval from dual",keyColumn = "id")
  47. void insertDataConnector(DataConnector dataConnector);
  48. /*
  49. 更新数据源配置
  50. */
  51. @Update("<script>" +
  52. "UPDATE bi_data_connectors set " +
  53. "data_name = #{dataName}" +
  54. "<if test=\"dataTag != null\"> , data_tag = #{dataTag} </if>" +
  55. "<if test=\"loadObject != null\"> , LOAD_OBJECT = #{loadObject} </if>" +
  56. "<if test=\"columnConfig != null\"> , columns_config = #{columnConfig} </if>" +
  57. "<if test=\"dbConfig != null\"> , DB_CONFIG = #{dbConfig} </if>" +
  58. "<if test=\"usedNumber != null\"> , used_number = #{usedNumber} </if>" +
  59. "<if test=\"createBy != null\"> , create_by = #{createBy} </if>" +
  60. "<if test=\"type != null\"> , con_TYPE = #{type} </if>" +
  61. "<if test=\"note != null\"> , DATA_NOTE = #{note} </if>" +
  62. "<if test=\"tableName != null\"> , table_name = #{tableName} </if>" +
  63. "<if test=\"connectorGroup != null\"> , BD_GROUP = #{connectorGroup} </if>"+
  64. "where id = #{dataId}" +
  65. "</script>")
  66. void updateData(DataConnector dataConnector);
  67. /*
  68. 更新数据源配置的分组
  69. */
  70. @Update("update bi_data_connectors set BD_GROUP = #{connectGroup} where id = #{dataId}")
  71. void updateConfigGroup(@Param("dataId") int dataId, @Param("connectGroup") int connectGroup);
  72. /*
  73. 删除数据源
  74. */
  75. @Delete("<script>" +
  76. "delete from bi_data_connectors where id in " +
  77. "("+
  78. "<foreach collection=\"list\" index=\"index\" item=\"item\" separator=\",\">" +
  79. "#{item, jdbcType = NUMERIC}"+
  80. "</foreach>" +
  81. ")"+
  82. "</script>")
  83. void deleteData(List<Integer> idList);
  84. /*
  85. 保存数据库连接
  86. */
  87. @Insert("insert into BI_DATABASES(id,ADDRASS, CREATE_DATE, DATABASE_TYPE, DATA_NAME, bases_NAME, PASS_WORD, PORT, USER_NAME, note)" +
  88. "values(#{id},#{addrass}, to_date(#{createDate},'YYYY-MM-DD hh24:mi:ss'), #{databaseType}, #{dataName}, #{name}, #{passWord}, #{port}, #{userName}, #{note})")
  89. @SelectKey(before=true,keyProperty="id",resultType=int.class,statement="SELECT bi_databases_squence.nextval from dual",keyColumn = "id")
  90. void inputDataBases(Databases databases);
  91. /*
  92. 查询单个数据库连接ID
  93. */
  94. @Select("select pass_word from BI_DATABASES where id= #{id}")
  95. String getBasesById(int id);
  96. /*
  97. 查询数据库配置列表
  98. */
  99. @Select("select id, bases_name as name, note, addrass, data_name as dataName, DATABASE_TYPE as databaseType," +
  100. " PASS_WORD as passWord, USER_NAME as userName, PORT, CREATE_DATE as createDate from bi_databases")
  101. List<Databases> getDatabasesList();
  102. /*
  103. 修改数据库配置列表
  104. */
  105. @Update("<script>"+
  106. "UPDATE BI_DATABASES set " +
  107. "BASES_NAME = #{name}" +
  108. "<if test=\"addrass != null\"> , ADDRASS = #{addrass} </if>" +
  109. "<if test=\"port != null\"> , PORT = #{port} </if>" +
  110. "<if test=\"databaseType != null\"> , DATABASE_TYPE = #{databaseType} </if>" +
  111. "<if test=\"dataName != null\"> , DATA_NAME = #{dataName} </if>" +
  112. "<if test=\"userName != null\"> , USER_NAME = #{userName} </if>" +
  113. "<if test=\"passWord != null\"> , PASS_WORD = #{passWord} </if>" +
  114. "<if test=\"note != null\"> , NOTE = #{note} </if>" +
  115. "where id = #{id}" +
  116. "</script>")
  117. void updatabases(Databases databases);
  118. /*
  119. 删除数据库配置
  120. */
  121. @Delete("<script>" +
  122. "delete from bi_databases where id in " +
  123. "("+
  124. "<foreach collection=\"list\" index=\"index\" item=\"item\" separator=\",\">" +
  125. "#{item, jdbcType = NUMERIC}"+
  126. "</foreach>" +
  127. ")"+
  128. "</script>")
  129. void deleteDatabases(List<Integer> idList);
  130. /*
  131. 查询数据源列数据
  132. */
  133. @Select("select columns_Config as columnConfig from bi_data_connectors " +
  134. " where id =#{id}")
  135. DataConnector getColumnData(int id);
  136. /*
  137. 创建数据源分组
  138. */
  139. @Insert("insert into bi_base_group_by(bb_id, bb_group_name, bb_index, bb_father_id, create_by, create_date)" +
  140. "values(#{id}, #{groupName}, #{groupIndex}, #{fatherId}, #{createBy}, to_date(to_char(sysdate,'yyyy-mm-dd hh24:mi:ss'),'YYYY-MM-DD hh24:mi:ss'))")
  141. @SelectKey(before=true,keyProperty="id",resultType=int.class,statement="SELECT bi_base_group_by_squence.nextval from dual",keyColumn = "bb_id")
  142. void setConnectorGroup(GroupInfo group);
  143. /*
  144. 更新数据源分组
  145. */
  146. @Update("<script>"+
  147. "UPDATE bi_base_group_by set "+
  148. "bb_group_name = #{groupName}" +
  149. "<if test=\"groupIndex != null\"> , bb_index = #{groupIndex} </if>" +
  150. "<if test=\"fatherId != null\"> , bb_father_id = #{fatherId} </if>" +
  151. "<if test=\"createBy != null\"> , create_by = #{createBy} ,</if>" +
  152. "updata_date = to_date(to_char(sysdate,'yyyy-mm-dd hh24:mi:ss'),'YYYY-MM-DD hh24:mi:ss') "+
  153. " where bb_id = #{id}" +
  154. "</script>")
  155. void updataConnectorGroup(GroupInfo groupInfo);
  156. /*
  157. 删除分组
  158. */
  159. @Delete("<script>" +
  160. "delete from bi_base_group_by where bb_id in" +
  161. "(" +
  162. "<foreach collection=\"list\" index=\"index\" item=\"item\" separator=\",\">" +
  163. "#{item, jdbcType = NUMERIC}" +
  164. " </foreach>" +
  165. ")" +
  166. "</script>")
  167. void delConnectorGroup(List<Integer> isList);
  168. /*
  169. 查询分组是否有子分组
  170. */
  171. @Select("select BB_GROUP_NAME from bi_base_group_by where bb_father_id = #{id}")
  172. List<String> getFatherId(int id);
  173. /*
  174. 查询是否有数据源正在使用
  175. */
  176. @Select("select data_name from bi_data_connectors where bd_group = #{id}")
  177. List<String> getConName(int id);
  178. /*
  179. 查询分组
  180. */
  181. @Select("select bb_id as id, bb_group_name as groupName, bb_index as groupIndex, bb_father_id as fatherId, create_by as createBy," +
  182. "create_date as createDate from bi_base_group_by")
  183. List<GroupInfo> getConnectorGroup();
  184. /*
  185. 查询数据源是否关联图表
  186. */
  187. @Select("select chart_name from bi_charts where bd_data_ID = #{id}")
  188. List<String> getChartsName(int id);
  189. }