fix(video): Mapper 移除多数据库方言分支(仅保留 MySQL)

WVP 原支持 MySQL / H2 / KingBase / PostgreSQL,使用 databaseId 属性
区分 SQL 方言,但本项目 MyBatis 未配置 databaseIdProvider,运行时
databaseId 为 null 导致 "Could not find a statement annotation that
correspond a current database" 启动失败。

改动:
- CommonGBChannelMapper.queryListInCircle / queryListInPolygon:
  仅保留 queryListInCircleForMysql / queryListInPolygonForMysql
  对应的 @SelectProvider,删除 h2/kingbase/postgresql 变体
- GroupMapper.updateParentId / updateParentIdWithBusinessGroup /
  fixParentId:仅保留 MySQL JOIN 语法,删除 3 种方言 UPDATE
- RegionMapper.updateParentId:同上

项目固定使用 MySQL,这些方言变体在本仓库永远不会命中,删除后启动
不再需要依赖 databaseIdProvider 配置。

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
This commit is contained in:
lzh
2026-04-22 14:00:29 +08:00
parent 3a3f7b78d4
commit 4f0c8f7162
3 changed files with 7 additions and 109 deletions

View File

@@ -641,17 +641,12 @@ public interface CommonGBChannelMapper extends BaseMapperX<CommonGBChannel> {
@Param("minLatitude") Double minLatitude, @Param("maxLatitude") Double maxLatitude,
@Param("level") Integer level, @Param("groupList") List<CameraGroup> groupList);
@SelectProvider(type = ChannelProvider.class, method = "queryListInCircleForMysql", databaseId = "mysql")
@SelectProvider(type = ChannelProvider.class, method = "queryListInCircleForMysql", databaseId = "h2")
@SelectProvider(type = ChannelProvider.class, method = "queryListInCircleForKingBase", databaseId = "kingbase")
@SelectProvider(type = ChannelProvider.class, method = "queryListInCircleForKingBase", databaseId = "postgresql")
// 仅支持 MySQL项目未配置 databaseIdProvider移除 H2/KingBase/PostgreSQL 变体)
@SelectProvider(type = ChannelProvider.class, method = "queryListInCircleForMysql")
List<CameraChannel> queryListInCircle(@Param("centerLongitude") Double centerLongitude, @Param("centerLatitude") Double centerLatitude,
@Param("radius") Double radius, @Param("level") Integer level, @Param("groupList") List<CameraGroup> groupList);
@SelectProvider(type = ChannelProvider.class, method = "queryListInPolygonForMysql", databaseId = "mysql")
@SelectProvider(type = ChannelProvider.class, method = "queryListInPolygonForMysql", databaseId = "h2")
@SelectProvider(type = ChannelProvider.class, method = "queryListInPolygonForKingBase", databaseId = "kingbase")
@SelectProvider(type = ChannelProvider.class, method = "queryListInPolygonForKingBase", databaseId = "postgresql")
@SelectProvider(type = ChannelProvider.class, method = "queryListInPolygonForMysql")
List<CameraChannel> queryListInPolygon(@Param("pointList") List<Point> pointList, @Param("level") Integer level, @Param("groupList") List<CameraGroup> groupList);
@SelectProvider(type = ChannelProvider.class, method = "queryListForSyMobile")

View File

@@ -217,30 +217,7 @@ public interface GroupMapper extends BaseMapperX<Group> {
" set w1.parent_id = w2.id" +
" where w1.id in " +
" <foreach collection='groupListForAdd' item='item' open='(' separator=',' close=')' > #{item.id}</foreach>" +
" </script>", databaseId = "mysql")
@Update(value = " <script>" +
" update video_common_group w1 " +
" inner join (select * from video_common_group ) w2 on w1.parent_device_id = w2.device_id " +
" set w1.parent_id = w2.id" +
" where w1.id in " +
" <foreach collection='groupListForAdd' item='item' open='(' separator=',' close=')' > #{item.id}</foreach>" +
" </script>", databaseId = "h2")
@Update( value = " <script>" +
" update video_common_group w1\n" +
" set parent_id = w2.id\n" +
" from video_common_group w2\n" +
" where w1.parent_device_id = w2.device_id\n" +
" and w1.id in " +
" <foreach collection='groupListForAdd' item='item' open='(' separator=',' close=')' > #{item.id}</foreach>" +
" </script>", databaseId = "postgresql")
@Update( value = " <script>" +
" update video_common_group w1\n" +
" set parent_id = w2.id\n" +
" from video_common_group w2\n" +
" where w1.parent_device_id = w2.device_id\n" +
" and w1.id in " +
" <foreach collection='groupListForAdd' item='item' open='(' separator=',' close=')' > #{item.id}</foreach>" +
" </script>", databaseId = "kingbase")
" </script>")
void updateParentId(List<Group> groupListForAdd);
@Update(value = " <script>" +
@@ -254,43 +231,7 @@ public interface GroupMapper extends BaseMapperX<Group> {
" set w1.parent_id = w2.id" +
" where w1.id in " +
" <foreach collection='groupListForAdd' item='item' open='(' separator=',' close=')' > #{item.id}</foreach>" +
" </script>", databaseId = "mysql")
@Update(value = " <script>" +
" update video_common_group w1 " +
" inner join (select * from video_common_group ) w2" +
" on w1.parent_device_id is null" +
" and w2.parent_device_id is null" +
" and w2.device_id = w2.business_group " +
" and w1.business_group = w2.device_id " +
" and w1.device_id != w1.business_group " +
" set w1.parent_id = w2.id" +
" where w1.id in " +
" <foreach collection='groupListForAdd' item='item' open='(' separator=',' close=')' > #{item.id}</foreach>" +
" </script>", databaseId = "h2")
@Update( value = " <script>" +
" update video_common_group w1 " +
" set parent_id = w2.id " +
" from video_common_group w2 " +
" where w1.parent_device_id is null " +
" and w2.parent_device_id is null " +
" and w2.device_id = w2.business_group " +
" and w1.business_group = w2.device_id " +
" and w1.device_id != w1.business_group " +
" and w1.id in " +
" <foreach collection='groupListForAdd' item='item' open='(' separator=',' close=')' > #{item.id}</foreach>" +
" </script>", databaseId = "kingbase")
@Update( value = " <script>" +
" update video_common_group w1 " +
" set parent_id = w2.id " +
" from video_common_group w2 " +
" where w1.parent_device_id is null " +
" and w2.parent_device_id is null " +
" and w2.device_id = w2.business_group " +
" and w1.business_group = w2.device_id " +
" and w1.device_id != w1.business_group " +
" and w1.id in " +
" <foreach collection='groupListForAdd' item='item' open='(' separator=',' close=')' > #{item.id}</foreach>" +
" </script>", databaseId = "postgresql")
" </script>")
void updateParentIdWithBusinessGroup(List<Group> groupListForAdd);
@Select(" <script>" +
@@ -338,22 +279,7 @@ public interface GroupMapper extends BaseMapperX<Group> {
" JOIN video_common_group g2" +
" ON g1.parent_device_id = g2.device_id" +
" SET g1.parent_id = g2.id" +
" WHERE g1.alias IS NOT NULL;", databaseId = "mysql")
@Update(value = " UPDATE video_common_group g1" +
" JOIN video_common_group g2" +
" ON g1.parent_device_id = g2.device_id" +
" SET g1.parent_id = g2.id" +
" WHERE g1.alias IS NOT NULL;", databaseId = "h2")
@Update(value = " UPDATE video_common_group AS g1" +
" SET parent_id = g2.id" +
" FROM video_common_group AS g2" +
" WHERE g1.parent_device_id = g2.device_id" +
" AND g1.alias IS NOT NULL;", databaseId = "kingbase")
@Update(value = " UPDATE video_common_group AS g1" +
" SET parent_id = g2.id" +
" FROM video_common_group AS g2" +
" WHERE g1.parent_device_id = g2.device_id" +
" AND g1.alias IS NOT NULL;", databaseId = "postgresql")
" WHERE g1.alias IS NOT NULL;")
void fixParentId();
}

View File

@@ -116,30 +116,7 @@ public interface RegionMapper extends BaseMapperX<Region> {
" set w1.parent_id = w2.id" +
" where w1.id in " +
" <foreach collection='regionListForAdd' item='item' open='(' separator=',' close=')' > #{item.id}</foreach>" +
" </script>", databaseId = "mysql")
@Update(value = " <script>" +
" update video_common_region w1 " +
" inner join (select * from video_common_region ) w2 on w1.parent_device_id = w2.device_id " +
" set w1.parent_id = w2.id" +
" where w1.id in " +
" <foreach collection='regionListForAdd' item='item' open='(' separator=',' close=')' > #{item.id}</foreach>" +
" </script>", databaseId = "h2")
@Update( value = " <script>" +
" update video_common_region w1\n" +
" set parent_id = w2.id\n" +
" from video_common_region w2\n" +
" where w1.parent_device_id = w2.device_id\n" +
" and w1.id in " +
" <foreach collection='regionListForAdd' item='item' open='(' separator=',' close=')' > #{item.id}</foreach>" +
" </script>", databaseId = "kingbase")
@Update( value = " <script>" +
" update video_common_region w1\n" +
" set parent_id = w2.id\n" +
" from video_common_region w2\n" +
" where w1.parent_device_id = w2.device_id\n" +
" and w1.id in " +
" <foreach collection='regionListForAdd' item='item' open='(' separator=',' close=')' > #{item.id}</foreach>" +
" </script>", databaseId = "postgresql")
" </script>")
void updateParentId(List<Region> regionListForAdd);
@Update(" <script>" +