Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix bug: Error #705 when switching database source to mysql #706

Open
wants to merge 4 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -18,15 +18,15 @@
*/
@Getter
@Setter
@TableName("CHART")
@TableName("chart")
public class ChartDO implements Serializable {

private static final long serialVersionUID = 1L;

/**
* 主键
*/
@TableId(value = "ID", type = IdType.AUTO)
@TableId(value = "id", type = IdType.AUTO)
private Long id;

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,15 +18,15 @@
*/
@Getter
@Setter
@TableName("DASHBOARD_CHART_RELATION")
@TableName("dashboard_chart_relation")
public class DashboardChartRelationDO implements Serializable {

private static final long serialVersionUID = 1L;

/**
* 主键
*/
@TableId(value = "ID", type = IdType.AUTO)
@TableId(value = "id", type = IdType.AUTO)
private Long id;

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,15 +18,15 @@
*/
@Getter
@Setter
@TableName("DASHBOARD")
@TableName("dashboard")
public class DashboardDO implements Serializable {

private static final long serialVersionUID = 1L;

/**
* 主键
*/
@TableId(value = "ID", type = IdType.AUTO)
@TableId(value = "id", type = IdType.AUTO)
private Long id;

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,15 +18,15 @@
*/
@Getter
@Setter
@TableName("DATA_SOURCE_ACCESS")
@TableName("data_source_access")
public class DataSourceAccessDO implements Serializable {

private static final long serialVersionUID = 1L;

/**
* 主键
*/
@TableId(value = "ID", type = IdType.AUTO)
@TableId(value = "id", type = IdType.AUTO)
private Long id;

/**
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package ai.chat2db.server.domain.repository.entity;

import com.baomidou.mybatisplus.annotation.IdType;
import com.baomidou.mybatisplus.annotation.TableField;
import com.baomidou.mybatisplus.annotation.TableId;
import com.baomidou.mybatisplus.annotation.TableName;
import java.io.Serializable;
Expand All @@ -18,15 +19,15 @@
*/
@Getter
@Setter
@TableName("DATA_SOURCE")
@TableName("data_source")
public class DataSourceDO implements Serializable {

private static final long serialVersionUID = 1L;

/**
* 主键
*/
@TableId(value = "ID", type = IdType.AUTO)
@TableId(value = "id", type = IdType.AUTO)
private Long id;

/**
Expand Down Expand Up @@ -92,6 +93,7 @@ public class DataSourceDO implements Serializable {
/**
* ssl配置信息json
*/
@TableField(value = "`ssl`")
private String ssl;

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,15 +18,15 @@
*/
@Getter
@Setter
@TableName("DBHUB_USER")
@TableName("dbhub_user")
public class DbhubUserDO implements Serializable {

private static final long serialVersionUID = 1L;

/**
* 主键
*/
@TableId(value = "ID", type = IdType.AUTO)
@TableId(value = "id", type = IdType.AUTO)
private Long id;

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,15 +18,15 @@
*/
@Getter
@Setter
@TableName("ENVIRONMENT")
@TableName("environment")
public class EnvironmentDO implements Serializable {

private static final long serialVersionUID = 1L;

/**
* 主键
*/
@TableId(value = "ID", type = IdType.AUTO)
@TableId(value = "id", type = IdType.AUTO)
private Long id;

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,15 +11,15 @@

@Getter
@Setter
@TableName("JDBC_DRIVER")
@TableName("jdbc_driver")
public class JdbcDriverDO implements Serializable {

private static final long serialVersionUID = 1L;

/**
* 主键
*/
@TableId(value = "ID", type = IdType.AUTO)
@TableId(value = "id", type = IdType.AUTO)
private Long id;

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,15 +19,15 @@
*/
@Getter
@Setter
@TableName("OPERATION_LOG")
@TableName("operation_log")
public class OperationLogDO implements Serializable {

private static final long serialVersionUID = 1L;

/**
* 主键
*/
@TableId(value = "ID", type = IdType.AUTO)
@TableId(value = "id", type = IdType.AUTO)
private Long id;

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,15 +18,15 @@
*/
@Getter
@Setter
@TableName("OPERATION_SAVED")
@TableName("operation_saved")
public class OperationSavedDO implements Serializable {

private static final long serialVersionUID = 1L;

/**
* 主键
*/
@TableId(value = "ID", type = IdType.AUTO)
@TableId(value = "id", type = IdType.AUTO)
private Long id;

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,15 +11,15 @@

@Getter
@Setter
@TableName("PIN_TABLE")
@TableName("pin_table")
public class PinTableDO implements Serializable {

private static final long serialVersionUID = 1L;

/**
* 主键
*/
@TableId(value = "ID", type = IdType.AUTO)
@TableId(value = "id", type = IdType.AUTO)
private Long id;

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,15 +16,15 @@
*/
@Getter
@Setter
@TableName("SYSTEM_CONFIG")
@TableName("system_config")
public class SystemConfigDO implements Serializable {

private static final long serialVersionUID = 1L;

/**
* 主键
*/
@TableId(value = "ID", type = IdType.AUTO)
@TableId(value = "id", type = IdType.AUTO)
private Long id;

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,15 +19,15 @@
*/
@Getter
@Setter
@TableName("TABLE_CACHE")
@TableName("table_cache")
public class TableCacheDO implements Serializable {

private static final long serialVersionUID = 1L;

/**
* 主键
*/
@TableId(value = "ID", type = IdType.AUTO)
@TableId(value = "id", type = IdType.AUTO)
private Long id;

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,15 +19,15 @@
*/
@Getter
@Setter
@TableName("TABLE_CACHE_VERSION")
@TableName("table_cache_version")
public class TableCacheVersionDO implements Serializable {

private static final long serialVersionUID = 1L;

/**
* 主键
*/
@TableId(value = "ID", type = IdType.AUTO)
@TableId(value = "id", type = IdType.AUTO)
private Long id;

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,15 +17,15 @@
*/
@Getter
@Setter
@TableName("TABLE_VECTOR_MAPPING")
@TableName("table_vector_mapping")
public class TableVectorMappingDO implements Serializable {

private static final long serialVersionUID = 1L;

/**
* 主键
*/
@TableId(value = "ID", type = IdType.AUTO)
@TableId(value = "id", type = IdType.AUTO)
private Long id;

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,15 +18,15 @@
*/
@Getter
@Setter
@TableName("TEAM")
@TableName("team")
public class TeamDO implements Serializable {

private static final long serialVersionUID = 1L;

/**
* 主键
*/
@TableId(value = "ID", type = IdType.AUTO)
@TableId(value = "id", type = IdType.AUTO)
private Long id;

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,15 +19,15 @@
*/
@Getter
@Setter
@TableName("TEAM_USER")
@TableName("team_user")
public class TeamUserDO implements Serializable {

private static final long serialVersionUID = 1L;

/**
* 主键
*/
@TableId(value = "ID", type = IdType.AUTO)
@TableId(value = "id", type = IdType.AUTO)
private Long id;

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,46 +3,46 @@
<mapper namespace="ai.chat2db.server.domain.repository.mapper.DataSourceAccessCustomMapper">
<select id="comprehensivePageQuery" resultType="ai.chat2db.server.domain.repository.entity.DataSourceAccessDO">
select dsa.*
from DATA_SOURCE_ACCESS dsa
from data_source_access dsa
<if test="userOrTeamSearchKey != '' and userOrTeamSearchKey != null ">
left join TEAM t on t.id =dsa.ACCESS_OBJECT_ID and dsa.ACCESS_OBJECT_TYPE = 'TEAM'
left join DBHUB_USER du on du.ID=dsa.ACCESS_OBJECT_ID and dsa.ACCESS_OBJECT_TYPE = 'USER'
left join team t on t.id =dsa.access_object_id and dsa.access_object_type = 'TEAM'
left join DBHUB_USER du on du.id=dsa.access_object_id and dsa.access_object_type = 'USER'
</if>
<if test="dataSourceSearchKey != '' and dataSourceSearchKey != null ">
left join DATA_SOURCE ds on ds.id =dsa.DATA_SOURCE_ID
left join data_source ds on ds.id =dsa.data_source_id
</if>
<where>
<if test="dataSourceId != null ">
and dsa.DATA_SOURCE_ID = #{dataSourceId}
and dsa.data_source_id = #{dataSourceId}
</if>
<if test="accessObjectId != null ">
and dsa.ACCESS_OBJECT_ID = #{accessObjectId}
and dsa.access_object_id = #{accessObjectId}
</if>
<if test="accessObjectType != null ">
and dsa.ACCESS_OBJECT_TYPE = #{accessObjectType}
and dsa.access_object_type = #{accessObjectType}
</if>
<if test="userOrTeamSearchKey != '' and userOrTeamSearchKey != null ">
and (t.CODE like concat('%',#{userOrTeamSearchKey},'%') or t.NAME like
and (t.code like concat('%',#{userOrTeamSearchKey},'%') or t.name like
concat('%',#{userOrTeamSearchKey},'%') or
du.USER_NAME like concat('%',#{userOrTeamSearchKey},'%') or du.NICK_NAME like
du.user_name like concat('%',#{userOrTeamSearchKey},'%') or du.nick_name like
concat('%',#{userOrTeamSearchKey},'%') or
du.EMAIL like concat('%',#{userOrTeamSearchKey},'%'))
du.email like concat('%',#{userOrTeamSearchKey},'%'))
</if>
<if test="dataSourceSearchKey != '' and dataSourceSearchKey != null ">
and (ds.ALIAS like concat('%',#{dataSourceSearchKey},'%') or ds.URL like
and (ds.alias like concat('%',#{dataSourceSearchKey},'%') or ds.url like
concat('%',#{dataSourceSearchKey},'%'))
</if>
</where>
</select>

<select id="checkTeamPermission" resultType="ai.chat2db.server.domain.repository.entity.DataSourceAccessDO">
select dsa.*
from DATA_SOURCE_ACCESS dsa
left join TEAM t on t.id =dsa.ACCESS_OBJECT_ID and dsa.ACCESS_OBJECT_TYPE = 'TEAM' and t.status='VALID'
left join TEAM_USER tu on tu.TEAM_ID =t.ID
from data_source_access dsa
left join team t on t.id =dsa.access_object_id and dsa.access_object_type = 'TEAM' and t.status='VALID'
left join team_user tu on tu.team_id =t.id
<where>
dsa.DATA_SOURCE_ID = #{dataSourceId}
and tu.USER_ID = #{userId}
dsa.data_source_id = #{dataSourceId}
and tu.user_id = #{userId}
limit 1
</where>
</select>
Expand Down
Loading