DataConnectorMapper.java 5.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134
  1. package com.database1.dao;
  2. import com.model.po.*;
  3. import org.apache.ibatis.annotations.*;
  4. import org.springframework.stereotype.Repository;
  5. import java.util.List;
  6. @Mapper
  7. @Repository
  8. public interface DataConnectorMapper {
  9. @Select("select d.column_name as columnName, d.DATA_TYPE as columnType, b.comments as remarks from " +
  10. "(select column_name,DATA_TYPE from user_tab_cols where Table_Name = #{tableName}) d," +
  11. "(select * from user_col_comments where Table_Name = #{tableName}) b" +
  12. " where d.column_name = b.column_name order by columnName")
  13. List<ColumnData> getColumn(@Param("tableName") String tableName);
  14. @Select("<script>" +
  15. "select * from bi_data_connectors where" + "1=1" +
  16. "<if test=\"id != null\"> and id = #{id} </if>" +
  17. "<if test=\"dataName != null\"> and data_name = #{dataName} </if>" +
  18. "<if test=\"dataTag != null\"> and data_tag = #{dataTag} </if>" +
  19. "<if test=\"configuration != null\"> and configuration = #{configuration} </if>" +
  20. "<if test=\"columnConfig != null\"> and columns_config = #{columnConfig} </if>" +
  21. "<if test=\"usedNumber != null\"> and used_number = #{usedNumber} </if>" +
  22. "<if test=\"createBy != null\">and create_by = #{createBy}</if>" +
  23. "</script>")
  24. List<DataConnector> getAllData(DataConnector dataConnector);
  25. /*
  26. 查询单个数据源
  27. */
  28. @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," +
  29. "CREATE_BY as createBy, USED_NUMBER as userNumber, CREATE_DATE as createDate,DB_CONFIG as dbConfig, " +
  30. "CON_TYPE as type from bi_data_connectors where id = #{id}")
  31. DataConnector getOneData(int id);
  32. /*
  33. 查询数据源列表
  34. */
  35. @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," +
  36. " used_number as usedNumber, db_config as dbConfig from bi_data_connectors")
  37. List<DataConnectorList> getDataConnectorList();
  38. /*
  39. 插入数据源配置
  40. */
  41. @Insert("INSERT INTO bi_data_connectors(data_name,data_note,data_tag,con_type,LOAD_OBJECT,DB_CONFIG,columns_config,used_number,create_by,create_date, table_name) " +
  42. "VALUES (#{dataName}, #{note}, #{dataTag}, #{type}, #{loadObject}, #{dbConfig},#{columnConfig}, #{usedNumber},#{createBy}, to_date(#{createDate},'YYYY-MM-DD hh24:mi:ss'), #{tableName})")
  43. void insertDataConnector(DataConnector dataConnector);
  44. /*
  45. 更新数据源配置
  46. */
  47. @Update("<script>" +
  48. "UPDATE bi_data_connectors set " +
  49. "data_name = #{dataName}" +
  50. "<if test=\"dataTag != null\"> , data_tag = #{dataTag} </if>" +
  51. "<if test=\"loadObject != null\"> , LOAD_OBJECT = #{loadObject} </if>" +
  52. "<if test=\"columnConfig != null\"> , columns_config = #{columnConfig} </if>" +
  53. "<if test=\"dbConfig != null\"> , DB_CONFIG = #{dbConfig} </if>" +
  54. "<if test=\"usedNumber != null\"> , used_number = #{usedNumber} </if>" +
  55. "<if test=\"createBy != null\"> , create_by = #{createBy} </if>" +
  56. "<if test=\"type != null\"> , con_TYPE = #{type} </if>" +
  57. "<if test=\"note != null\"> , DATA_NOTE = #{note} </if>" +
  58. "<if test=\"tableName != null\"> , table_name = #{tableName} </if>" +
  59. "where id = #{dataId}" +
  60. "</script>")
  61. void updateData(DataConnector dataConnector);
  62. /*
  63. 删除数据源
  64. */
  65. @Delete("<script>" +
  66. "delete from bi_data_connectors where id in " +
  67. "("+
  68. "<foreach collection=\"list\" index=\"index\" item=\"item\" separator=\",\">" +
  69. "#{item, jdbcType = NUMERIC}"+
  70. "</foreach>" +
  71. ")"+
  72. "</script>")
  73. void deleteData(List<Integer> idList);
  74. /*
  75. 保存数据库连接
  76. */
  77. @Insert("insert into BI_DATABASES(ADDRASS, CREATE_DATE, DATABASE_TYPE, DATA_NAME, bases_NAME, PASS_WORD, PORT, USER_NAME, note)" +
  78. "values(#{addrass}, to_date(#{createDate},'YYYY-MM-DD hh24:mi:ss'), #{databaseType}, #{dataName}, #{name}, #{passWord}, #{port}, #{userName}, #{note})")
  79. void inputDataBases(Databases databases);
  80. /*
  81. 查询单个数据库连接ID
  82. */
  83. @Select("select id from BI_DATABASES where id= #{id}")
  84. int getBasesById(int id);
  85. /*
  86. 查询数据库配置列表
  87. */
  88. @Select("select id, bases_name as name, note, addrass, data_name as dataName, DATABASE_TYPE as databaseType," +
  89. " PASS_WORD as passWord, USER_NAME as userName, PORT, CREATE_DATE as createDate from bi_databases")
  90. List<Databases> getDatabasesList();
  91. /*
  92. 修改数据库配置列表
  93. */
  94. @Update("<script>"+
  95. "UPDATE BI_DATABASES set " +
  96. "BASES_NAME = #{name}" +
  97. "<if test=\"addrass != null\"> , ADDRASS = #{addrass} </if>" +
  98. "<if test=\"port != null\"> , PORT = #{port} </if>" +
  99. "<if test=\"databaseType != null\"> , DATABASE_TYPE = #{databaseType} </if>" +
  100. "<if test=\"dataName != null\"> , DATA_NAME = #{dataName} </if>" +
  101. "<if test=\"userName != null\"> , USER_NAME = #{userName} </if>" +
  102. "<if test=\"passWord != null\"> , PASS_WORD = #{passWord} </if>" +
  103. "<if test=\"note != null\"> , NOTE = #{note} </if>" +
  104. "where id = #{id}" +
  105. "</script>")
  106. void updatabases(Databases databases);
  107. /*
  108. 删除数据库配置
  109. */
  110. @Delete("<script>" +
  111. "delete from bi_databases where id in " +
  112. "("+
  113. "<foreach collection=\"list\" index=\"index\" item=\"item\" separator=\",\">" +
  114. "#{item, jdbcType = NUMERIC}"+
  115. "</foreach>" +
  116. ")"+
  117. "</script>")
  118. void deleteDatabases(List<Integer> idList);
  119. }