管道基础大数据平台系统开发-【后端】-Server
1
13693261870
2022-12-23 8a373a66936407266e860a19c0d44c406baae7cc
src/main/java/com/lf/server/mapper/all/GeomBaseMapper.java
@@ -1,21 +1,51 @@
package com.lf.server.mapper.all;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.annotations.Update;
/**
 * 空间基础Mapper
 * @author WWW
 * @param <T>
 * @param <T> 泛型
 */
public interface GeomBaseMapper<T> extends BaseMapper<T> {
public interface GeomBaseMapper<T> extends BasicMapper<T> {
    /**
     * 根据ID查询WKT
     *
     * @param gid
     * @return
     * @param tab 表名
     * @param gid GID
     * @return WKT
     */
    @Select("select st_astext(geom) geom from bd.dlg_agnp where gid = #{gid}")
    public String selectWktById(@Param("gid") Integer gid);
    @Select("select ST_AsText(geom) geom from ${tab} where gid = #{gid}")
    public String selectWktById(@Param("tab") String tab, @Param("gid") Integer gid);
    /**
     * 根据表名查询空间参考
     *
     * @param tab 表名
     * @return SRID
     */
    @Select("select ST_SRID(geom) from ${tab} where geom is not null limit 1")
    public Integer selectSrid(@Param("tab") String tab);
    /**
     * 根据表名查询空间类型
     *
     * @param tab 表名
     * @return SRID
     */
    @Select("select ST_GeometryType(geom) from ${tab} where geom is not null limit 1")
    public String selectGeometryType(@Param("tab") String tab);
    /**
     * 更新空间位置
     *
     * @param tab 表名
     * @param gid GID
     * @param wkt WKT
     * @return 影响行数
     */
    @Update("update ${tab} set geom = ST_GeomFromText('${wkt}') where gid = #{gid}")
    public Integer updateGeom(@Param("tab") String tab, @Param("gid") Integer gid, @Param("wkt") String wkt);
}