package com.dao; import com.model.po.DataConnector; import com.model.po.DataConnectorList; import com.model.po.Databases; import com.model.vo.configVo.GroupInfo; import org.apache.ibatis.annotations.*; import org.springframework.stereotype.Repository; import java.util.List; @Mapper @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 getColumn(@Param("tableName") String tableName); // @Select("") // List getAllData(DataConnector dataConnector); /* 查询单个数据源 */ @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," + "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 getDataConnectorList(); /* 插入数据源配置 */ @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) " + "VALUES (#{dataId},#{dataName}, #{note}, #{dataTag}, #{type}, #{loadObject}, #{dbConfig},#{columnConfig}, #{usedNumber},#{createBy}, to_date(#{createDate},'YYYY-MM-DD hh24:mi:ss'), #{tableName}, #{connectorGroup})") @SelectKey(before=true,keyProperty="dataId",resultType=int.class,statement="SELECT BI_DASHBOARDS_squence.nextval from dual",keyColumn = "id") void insertDataConnector(DataConnector dataConnector); /* 更新数据源配置 */ @Update("") void updateData(DataConnector dataConnector); /* 更新数据源配置的分组 */ @Update("update bi_data_connectors set BD_GROUP = #{connectGroup} where id = #{dataId}") void updateConfigGroup(@Param("dataId") int dataId, @Param("connectGroup") int connectGroup); /* 删除数据源 */ @Delete("") void deleteData(List idList); /* 保存数据库连接 */ @Insert("insert into BI_DATABASES(id,ADDRASS, CREATE_DATE, DATABASE_TYPE, DATA_NAME, bases_NAME, PASS_WORD, PORT, USER_NAME, note)" + "values(#{id},#{addrass}, to_date(#{createDate},'YYYY-MM-DD hh24:mi:ss'), #{databaseType}, #{dataName}, #{name}, #{passWord}, #{port}, #{userName}, #{note})") @SelectKey(before=true,keyProperty="id",resultType=int.class,statement="SELECT bi_databases_squence.nextval from dual",keyColumn = "id") void inputDataBases(Databases databases); /* 查询单个数据库连接ID */ @Select("select pass_word from BI_DATABASES where id= #{id}") String getBasesById(int id); /* 查询数据库配置列表 */ @Select("select id, bases_name as name, note, addrass, data_name as dataName, DATABASE_TYPE as databaseType," + " PASS_WORD as passWord, USER_NAME as userName, PORT, CREATE_DATE as createDate from bi_databases") List getDatabasesList(); /* 修改数据库配置列表 */ @Update("") void updatabases(Databases databases); /* 删除数据库配置 */ @Delete("") void deleteDatabases(List idList); /* 查询数据源列数据 */ @Select("select columns_Config as columnConfig from bi_data_connectors " + " where id =#{id}") DataConnector getColumnData(int id); /* 创建数据源分组 */ @Insert("insert into bi_base_group_by(bb_id, bb_group_name, bb_index, bb_father_id, create_by, create_date)" + "values(#{id}, #{groupName}, #{groupIndex}, #{fatherId}, #{createBy}, to_date(to_char(sysdate,'yyyy-mm-dd hh24:mi:ss'),'YYYY-MM-DD hh24:mi:ss'))") @SelectKey(before=true,keyProperty="id",resultType=int.class,statement="SELECT bi_base_group_by_squence.nextval from dual",keyColumn = "bb_id") void setConnectorGroup(GroupInfo group); /* 更新数据源分组 */ @Update("") void updataConnectorGroup(GroupInfo groupInfo); /* 删除分组 */ @Delete("") void delConnectorGroup(List isList); /* 查询分组是否有子分组 */ @Select("select BB_GROUP_NAME from bi_base_group_by where bb_father_id = #{id}") List getFatherId(int id); /* 查询是否有数据源正在使用 */ @Select("select data_name from bi_data_connectors where bd_group = #{id}") List getConName(int id); /* 查询分组 */ @Select("select bb_id as id, bb_group_name as groupName, bb_index as groupIndex, bb_father_id as fatherId, create_by as createBy," + "create_date as createDate from bi_base_group_by") List getConnectorGroup(); /* 查询数据源是否关联图表 */ @Select("select chart_name from bi_charts where bd_data_ID = #{id}") List getChartsName(int id); }