对象分类 | 描述 |
---|---|
POINT | 点 |
MULTIPOINT | 多点 |
LINESTRING | 线 |
LINEARRING | 线环 |
MULTILINESTRING | 点串 |
POLYGON | 面 |
MULTIPOLYGON | 多面 |
POLYHEDRALSURFACE | 多面体表面 |
TRIANGLE | 三角形 |
TIN | 不规则三角网 |
CIRCULARSTRING | 曲线串 |
MULTICURVE | 多(曲)线 |
MULTISURFACE | 多面 |
GEOMETRYCOLLECTION | 复合对象 |
1.添加pom依赖
org.postgresql
postgresql
net.postgis
postgis-jdbc
2.5.0
com.github.pagehelper
pagehelper-spring-boot-starter
1.2.12
org.mybatis.spring.boot
mybatis-spring-boot-starter
2.yml配置文件
spring:
datasource:
username: root
password: 1234
url: jdbc:postgresql://127.0.0.1:5432/db?useUnicode=true&characterEncoding=utf8¤tSchema=public&stringtype=unspecified
driver-class-name: org.postgresql.Driver
type: com.alibaba.druid.pool.DruidDataSource #数据源类型
initial-size: 5
min-idle: 5
max-active: 50
max-wait: 60000
mybatis:
type-aliases-package: com.cherry.manager.entity # 所有POJO类所在包路径
mapper-locations: classpath:mapper/*.xml # mapper映射文件 logImpl
configuration:
log-impl: org.apache.ibatis.logging.stdout.StdOutImpl
cache-enabled: true
map-underscore-to-camel-case: true
swagger:
enable: true
pagehelper:
helper-dialect: postgresql
reasonable: true
support-methods-arguments: true
params: count=countSql
响应结果类:
JSONFormatter.class
import com.google.gson.FieldNamingPolicy;
import com.google.gson.Gson;
import com.google.gson.GsonBuilder;
import com.google.gson.JsonElement;
import java.lang.reflect.Type;
import java.util.List;
/**
* JSONFormatter converts objects to JSON representation and vice-versa. This
* class depends on Google's GSON library to do the transformation. This class
* is not thread-safe.
*/
public final class JSONFormatter {
/**
* FieldNamingPolicy used by the underlying Gson library. Alter this
* property to set a fieldnamingpolicy other than
* LOWER_CASE_WITH_UNDERSCORES used by PayPal REST APIs
*/
private static FieldNamingPolicy FIELD_NAMING_POLICY = FieldNamingPolicy.IDENTITY;
/**
* Gson
*/
public static Gson GSON = new GsonBuilder()
.setDateFormat("yyyy-MM-dd HH:mm:ss")
// .setPrettyPrinting() // beautify format
.setFieldNamingPolicy(FIELD_NAMING_POLICY).create();
/*
* JSONFormatter is coupled to the stubs generated using the SDK generator.
* Since PayPal REST APIs support only JSON, this class is bound to the
* stubs for their json representation.
*/
private JSONFormatter() {
}
/**
* Set a format for gson FIELD_NAMING_POLICY. See {@link FieldNamingPolicy}
*
* @param FIELD_NAMING_POLICY
*/
public static final void setFIELD_NAMING_POLICY(
FieldNamingPolicy FIELD_NAMING_POLICY) {
GSON = new GsonBuilder().setPrettyPrinting()
.setFieldNamingPolicy(FIELD_NAMING_POLICY).create();
}
/**
* Converts a Raw Type to JSON String
*
* @param Type to be converted
* @param t Object of the type
* @return JSON representation
*/
public static String toJSON(T t) {
return GSON.toJson(t);
}
/**
* Converts a Raw Type to JSON String
*
* @param Type to be converted
* @param t Object of the type
* @param e Type typeOfSrc = new TypeToken<Collection<Foo>>(){}.getType();
* @return JSON representation
*/
public static String toJSON(T t, Type e) {
return GSON.toJson(t, e);
}
/**
* Converts a JSON String to object representation
*
* @param Type to be converted
* @param responseString JSON representation
* @param clazz Target class
* @return Object of the target type
*/
public static T fromJSON(String responseString, Class clazz) {
T t = null;
if (clazz.isAssignableFrom(responseString.getClass())) {
t = clazz.cast(responseString);
} else {
t = GSON.fromJson(responseString, clazz);
}
return t;
}
/**
* Converts a JSON String to object representation
*
* @param Type to be converted
* @param responseString String of the type
* @param e Type typeOfSrc = new TypeToken<Collection<Foo>>(){}.getType();
* @return JSON representation
*/
public static T fromJSON(String responseString, Type clazz) {
return GSON.fromJson(responseString, clazz);
}
/**
* Converts a JSON Element to object representation
*
* @param Type to be converted
* @param response JSON element
* @param clazz Target class
* @return Object of the target type
*/
public static T fromJSON(JsonElement response, Class clazz) {
return GSON.fromJson(response, clazz);
}
/**
* Converts a JSON Element to list representation
*
* @param Type to be converted
* @param response JSON element
* @param clazz Target class
* @return Object of the target type
*/
public static List fromList(JsonElement response, Class clazz) {
return GSON.fromJson(response, new JSONList(clazz));
}
/**
* Converts a JSON String to list representation
*
* @param Type to be converted
* @param response JSON element
* @param clazz Target class
* @return Object of the target type
*/
public static List fromList(String response, Class clazz) {
return GSON.fromJson(response, new JSONList(clazz));
}
}
JSONList.class
import com.google.gson.internal.$Gson$Types;
import java.lang.reflect.ParameterizedType;
import java.lang.reflect.Type;
import java.util.List;
public class JSONList implements ParameterizedType {
final Type type;
private Class super T> wrapped;
public JSONList(Class cls) {
this.wrapped = cls;
this.type = null; //getSuperclassTypeParameter(cls);
}
/**
* Returns the type from super class's type parameter in
*/
static Type getSuperclassTypeParameter(Class> subclass) {
Type superclass = subclass.getGenericSuperclass();
if (superclass instanceof Class) {
throw new RuntimeException("Missing type parameter.");
}
ParameterizedType parameterized = (ParameterizedType) superclass;
return $Gson$Types.canonicalize(parameterized.getActualTypeArguments()[0]);
}
@Override
public Type[] getActualTypeArguments() {
return new Type[]{wrapped};
}
@Override
public Type getOwnerType() {
return type;
}
@Override
public Type getRawType() {
return List.class;
}
}
ServiceCodeEnum.class
import org.slf4j.helpers.MessageFormatter;
import org.springframework.http.HttpStatus;
public enum ServiceCodeEnum implements ServiceCodeInterface {
/**
* 执行成功 200
*/
SUCCESS(HttpStatus.OK.value(), "执行成功"),
/**
* 参数异常 400
*/
PARAM_ERROR(HttpStatus.BAD_REQUEST.value(), "参数异常"),
/**
* 数据校验错误 400
*/
VALIDATOR_ERROR(HttpStatus.BAD_REQUEST.value(), "请求数据不合法:
{}"),
// /**
// * 非法请求/Token超时 401
// */
// AUTH_CHECK_FIAL(HttpStatus.UNAUTHORIZED.value(), "Illegal request/link invalid"),
/**
* token 为空 401
*/
TOKEN_IS_NULL(HttpStatus.UNAUTHORIZED.value(), "身份令牌(token)不能为空"),
/**
* token 身份令牌(token)有误 401
*/
TOKEN_IS_ERROR(HttpStatus.UNAUTHORIZED.value(), "身份令牌(token)有误"),
/**
* 登录超时 401
*/
LOGIN_TIME_OUT(HttpStatus.UNAUTHORIZED.value(), "登录超时,请重新登录"),
/**
* 当前账号在其他设备上登录 401
*/
OTHER_LOGIN(HttpStatus.UNAUTHORIZED.value(), "当前账号在其他设备上登录"),
/**
* 无权限 403
*/
FORBIDDEN(HttpStatus.FORBIDDEN.value(), "暂无权限,请联系管理员授权"),
/**
* 资源不存在 404
*/
NOT_FOUND(HttpStatus.NOT_FOUND.value(), "您请求的资源不存在"),
/**
* 处理请求方式非法 405
*/
ILLEGAL_WAY_ERROR(HttpStatus.METHOD_NOT_ALLOWED.value(), "请求方式非法"),
/**
* 数据已存在,数据库唯一索引抛出 409
*/
DATA_IS_EXISTS(HttpStatus.CONFLICT.value(), "数据库数据已存在,请检查参数"),
/**
* 处理自定义异常 412
*/
HANDLING_ERROR(HttpStatus.PRECONDITION_FAILED.value(), "请求业务异常"),
/**
* 系统异常 - 后台报错 500
*/
SYS_ERROR(HttpStatus.INTERNAL_SERVER_ERROR.value(), "未知异常,请联系管理员"),
/**
* 远程接口调用失败 500
*/
HTTP_ERROR(HttpStatus.INTERNAL_SERVER_ERROR.value(), "远程接口调用失败"),
/**
* 数据保存失败
*/
DATA_SAVE_FAIL(1002, "Failed to save data"),
/**
* 上传文件异常
*/
FILE_UPLOAD_SIZE(1003, "MaxUploadSize:Please contact the administrator!"),
DATA_IS_NULL(1004, "数据不存在"),
DATA_NOT_NULL(1005, "子级存在数据,请先删除子级数据!"),
CLASSIFICATION_NAME_IS_EXISTS(1006, "类别名称已经存在!"),
ROUTE_NAME_IS_EXISTS(1007, "路由名称或路径已经存在!"),
INTERFACE_PATH_IS_EXISTS(1008, "接口路径已经存在!"),
/**
* ---------------------------------------------------- 数据库 ----------------------------------------------------
*/
TREE_FIRST_NODE_IS_ZERO(1003, "树形结构的第一级节点数据不能为‘0’"),
/**
* ---------------------------------------------------- 用户相关 ----------------------------------------------------
*/
FILE_IS_EMPTY(1000001, "您上传的文件为空,路径:{}"),
ONLY_ZIP(1000002, "仅支持Zip上传"),
FILE_IS_LONG(1000003, "文件超过{}M"),
CHECK_FILE_MD5(1000004, "文件MD5无效"),
PASSWORD_MODIFY(11003, "密码已修改,请重新登录"),
NO_PROJECT_MANAGER_AUTHORITY(11000, "您没有权限管理当前项目数据"),
USER_NOT_HAS_ROLE(11009, "您暂无角色信息,请联系管理员分配"),
USER_NOT_FOUND(11001, "用户不存在"),
ORI_PASSWORD_ERROR(11002, "旧密码输入有误"),
PASSWORD_ERROR(11003, "密码输入有误"),
SMS_CODE_ERROR(11005, "验证码输入有误,请重新输入"),
USER_NOT_USED(11006, "用户未启用或者被锁定"),
PASSWORD_IS_NULL(11007, "密码为空"),
USERNAME_CANNOT_IS_MOBILE_OR_EMAIL(11008, "用户名不可为手机号或邮箱"),
MOBILE_MISMATCH(11009, "手机号不匹配"),
USER_IS_USERD(11010, "该账户已经激活,请勿重复操作"),
CHECK_PASSWORD_ERROR(11011, "密码校验失败"),
FILE_EXISTS(11000, "文件已存在,请检查版本号"),
/**
* ---------------------------------------------------- 用户相关 ----------------------------------------------------
*/
PARENT_ID_CANNOT_SELF_OR_CHILD(12001, "父节点不能为自身或子节点"),
/**
* ---------------------------------------------------- minio相关 ----------------------------------------------------
*/
MINIO_BUCKET_NOT_EXISTS(1600, "文件服务器存储空间不存在"),
MINIO_DOWNLOAD_ERROR(1601, "文件服务器下载文件失败"),
MINIO_DELETE_ERROR(1602, "文件服务器删除文件失败"),
/**
* ---------------------------------------------------- 视频相关 ----------------------------------------------------
*/
VIDEO_NOT_FOUND(18001, "视频不存在"),
/**
* ---------------------------------------------------- 华丽的分割线 ----------------------------------------------------
*/
INVALID_OPERATION(9999, "illegal operation"),
/**
* 项目授权码 失效 98401
*/
AUTHORIZATION_CODE_OUT(98401, "项目授权码无效,请联系管理员授权"),
/**
* 项目授权码 为空 98401
*/
AUTHORIZATION_CODE_IS_NULL(98401, "项目暂未授权,请联系管理员授权"),
/**
* 项目授权码 无效
*/
AUTHORIZATION_CODE_ERROR(98500, "项目授权码无效,请联系管理员授权"),
;
/**
* 错误码
*/
private final int code;
/**
* 错误信息
*/
private final String message;
/**
* 重写构造方法
*
* @param code 异常码
* @param message 异常消息
*/
ServiceCodeEnum(int code, String message) {
this.code = code;
this.message = message;
}
@Override
public int getCode() {
return code;
}
@Override
public String getMessage() {
return message;
}
@Override
public String getMessage(String... args) {
if (args != null && args.length > 0) {
return MessageFormatter.arrayFormat(message, args).getMessage();
}
return message;
}
}
ServiceCodeInterface.class
package com.cherry.common.result;
/**
* 错误码枚举
*/
public interface ServiceCodeInterface {
public int getCode();
public String getMessage(String... args);
public String getMessage();
}
ServiceResponse.class
package com.cherry.common.result;
import com.cherry.common.gosn.JSONFormatter;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
@Data
@ApiModel(description = "响应结果公共格式")
public class ServiceResponse {
/**
* 状态码
*/
@ApiModelProperty("状态码")
protected Integer status;
/**
* 结果载体
*/
@ApiModelProperty("结果载体")
protected R data;
/**
* 描述
*/
@ApiModelProperty("结果描述")
protected String message;
public ServiceResponse() {
this(null);
}
public ServiceResponse(R result) {
this(result, ServiceCodeEnum.SUCCESS);
}
public ServiceResponse(R result, Integer status, String message) {
this.status = status;
this.data = result;
this.message = message;
}
public ServiceResponse(R result, ServiceCodeInterface code) {
this.status = code.getCode();
this.data = result;
this.message = code.getMessage();
}
/**
* Construct a successful response with given object.
*
* @return constructed server response
*/
public static ServiceResponse ofSuccess() {
return new ServiceResponse();
}
/**
* Construct a successful response with given object.
*
* @param result result object
* @param type of the result
* @return constructed server response
*/
public static ServiceResponse ofSuccess(T result) {
return new ServiceResponse(result);
}
/**
* Construct a failed response with given exception.
*
* @return constructed server response
*/
public static ServiceResponse ofFailure() {
return new ServiceResponse(null, ServiceCodeEnum.PARAM_ERROR);
}
/**
* Construct a failed response with given exception.
*
* @param code additional message of the failure
* @return constructed server response
*/
public static ServiceResponse ofFailure(Integer code, String desc) {
return new ServiceResponse(null, code, desc);
}
/**
* 重载
*
* @param code
* @param
* @return
*/
public static ServiceResponse ofFailure(ServiceCodeInterface code) {
return new ServiceResponse(null, code);
}
/**
* Construct a failed response with given exception.
*
* @param code cause of the failure
* @param desc cause of the failure
* @return constructed server response
*/
public static ServiceResponse ofFailure(T result, Integer code, String desc) {
return new ServiceResponse(result, code, desc);
}
/**
* 重载
*
* @param result
* @param code
* @param
* @return
*/
public static ServiceResponse ofFailure(T result, ServiceCodeInterface code) {
return new ServiceResponse(result, code);
}
@Override
public String toString() {
return JSONFormatter.toJSON(this);
}
}
创建数据库
CREATE TABLE public.ftest (
id int4 NOT NULL,
geom postgis.geometry NULL,
CONSTRAINT ftest_pkey PRIMARY KEY (id)
);
控制层:
import com.cherry.common.result.ServiceResponse;
import com.github.pagehelper.PageInfo;
import com.cherry.manager.entity.Ftest;
import com.cherry.manager.service.FtestService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.MediaType;
import org.springframework.web.bind.annotation.*;
import java.util.Arrays;
import java.util.List;
/**
* (Ftest)表控制层
*
* @since 2022-09-22 15:39:05
*/
@Api(tags = "")
@RestController
@RequestMapping("ftest")
@CrossOrigin
public class FtestController {
@Autowired
FtestService service;
/**
* 新增记录
*
* @param entity 数据实体
* @return 新增记录
*/
@ApiOperation(value = "新增记录", notes = "新增记录")
@PostMapping(value = "/point", produces = MediaType.APPLICATION_JSON_VALUE)
public ServiceResponse addPoint(@RequestBody @ApiParam("json格式对象") Ftest entity) {
service.savePoint(entity);
return ServiceResponse.ofSuccess(entity);
}
@ApiOperation(value = "新增记录", notes = "新增记录")
@PostMapping(value = "/points", produces = MediaType.APPLICATION_JSON_VALUE)
public ServiceResponse addPoints(@RequestBody @ApiParam("json格式对象") Ftest entity) {
service.savePoints(entity);
return ServiceResponse.ofSuccess(entity);
}
/**
* 删除记录
*
* @param ids ids
* @return 删除结果
*/
@ApiOperation(value = "删除记录", notes = "删除记录")
@DeleteMapping(value = "/{ids}", produces = MediaType.APPLICATION_JSON_VALUE)
public ServiceResponse delete(@PathVariable("ids") @ApiParam(value = "删除的id", required = true) String... ids) {
return ServiceResponse.ofSuccess(service.removeByIds(Arrays.asList(ids)));
}
/**
* 修改记录
*
* @param entity 数据实体
* @return 新增结果
*/
@ApiOperation(value = "修改记录", notes = "修改记录")
@PutMapping(value = "", produces = MediaType.APPLICATION_JSON_VALUE)
public ServiceResponse update(@RequestBody @ApiParam(value = "json格式对象", required = true) Ftest entity) {
return ServiceResponse.ofSuccess(service.updateEntityById(entity));
}
/**
* 分页查询
*
* @return
*/
@ApiOperation(value = "分页查询", notes = "分页查询")
@GetMapping(value = "page/{current}/{pageSize}", produces = MediaType.APPLICATION_JSON_VALUE)
public ServiceResponse> page(@PathVariable("current") int current,
@PathVariable("pageSize") int pageSize) {
return ServiceResponse.ofSuccess( service.getPageInfo(current, pageSize));
}
/**
* 查询列表
*
* @return 搜索结果集
*/
@ApiOperation(value = "查询列表", notes = "查询列表")
@GetMapping(value = "/list", produces = MediaType.APPLICATION_JSON_VALUE)
public ServiceResponse> list() {
return ServiceResponse.ofSuccess(service.listEntity());
}
/**
* 查询详情
*
* @param id id
* @return 查询结果
*/
@ApiOperation(value = "查询详情", notes = "查询详情")
@GetMapping(value = "/info/{id}", produces = MediaType.APPLICATION_JSON_VALUE)
public ServiceResponse info(@PathVariable("id") @ApiParam(value = "查询的ID", required = true) Integer id) {
return ServiceResponse.ofSuccess(service.getEntityById(id));
}
/**
* 根据id集合查询
*
* @param ids
* @return
*/
@ApiOperation(value = "根据id集合查询", notes = "根据id集合查询")
@GetMapping(value = "/listByIds/{ids}", produces = MediaType.APPLICATION_JSON_VALUE)
public ServiceResponse> listByIds(@PathVariable("ids") @ApiParam(value = "查询的ID", required = true) String... ids) {
return ServiceResponse.ofSuccess(service.listEntityByIds(Arrays.asList(ids)));
}
/**
* 查找最近点位
* @param lng
* @param lat
* @return
*/
@ApiOperation(value = "查找最近的点", notes = "查找最近的点")
@GetMapping(value = "/getRecent/{lng}/{lat}", produces = MediaType.APPLICATION_JSON_VALUE)
public ServiceResponse getRecent(@PathVariable("lng") @ApiParam(value = "经度", required = true) Double lng,
@PathVariable("lat") @ApiParam(value = "纬度", required = true) Double lat) {
return ServiceResponse.ofSuccess(service.selectRecentOne(lng,lat));
}
}
entity实体类
package com.cherry.manager.entity;
import java.io.Serializable;
import com.alibaba.fastjson.JSONObject;
import com.baomidou.mybatisplus.annotation.TableField;
import com.baomidou.mybatisplus.annotation.TableName;
import io.swagger.annotations.ApiModelProperty;
import lombok.*;
import lombok.experimental.Accessors;
/**
* (Ftest)实体类
*
* @since 2022-09-22 15:50:00
*/
@Data
@EqualsAndHashCode
@ToString(callSuper = true)
@Accessors(chain = true)
@AllArgsConstructor
@NoArgsConstructor
@TableName("ftest")
public class Ftest implements Serializable {
private static final long serialVersionUID = 286631027980693537L;
@ApiModelProperty(value = "${column.comment}")
@TableField(value = "id")
private Integer id;
@ApiModelProperty(value = "${column.comment}")
@TableField(value = "geom")
private String geom;
@ApiModelProperty(value = "点集合")
@TableField(exist = false)
private Point[] points;
@ApiModelProperty(value = "点集合")
@TableField(exist = false)
private Point[][] linePoints;
@ApiModelProperty(value = "geomObject")
@TableField(value = "geomObject")
private JSONObject geomObject;
@ApiModelProperty("距离")
@TableField(exist = false)
private Double distance
}
dao层
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.cherry.manager.entity.Ftest;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
import java.util.List;
/**
* (Ftest)表数据库访问层
*
* @since 2022-09-22 15:39:05
*/
@Mapper
public interface FtestDao extends BaseMapper {
void savePoint(@Param("id") Integer id, @Param("points") String points);
Boolean updateEntityById(@Param("id") Integer id, @Param("pointStr") String pointStr);
List selectAll();
Ftest getEntityById(@Param("id") Integer id);
List listEntityByIds(@Param("ids") List ids);
IPage pageEntity(Page pageQuery);
Ftest selectRecentOne(@Param("point") String point);
}
service接口层:
import com.baomidou.mybatisplus.extension.service.IService;
import com.cherry.manager.entity.Ftest;
import com.github.pagehelper.PageInfo;
import java.util.List;
/**
* (Ftest)表服务接口
*
* @since 2022-09-22 15:39:06
*/
public interface FtestService extends IService {
void savePoint(Ftest entity);
void savePoints(Ftest entity);
Boolean updateEntityById(Ftest entity);
List listEntity();
Ftest getEntityById(Integer id);
List listEntityByIds(List asList);
PageInfo getPageInfo(int current, int pageSize);
Ftest selectRecentOne(Double lng,Double lat);
}
serviceImpl层:
import com.alibaba.fastjson.JSONObject;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.cherry.manager.entity.Ftest;
import com.cherry.manager.dao.FtestDao;
import com.cherry.manager.entity.Point;
import com.cherry.manager.service.FtestService;
import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Service;
import java.util.Arrays;
import java.util.List;
/**
* (Ftest)表服务实现类
*
* @since 2022-09-22 15:39:06
*/
@Slf4j
@Service
public class FtestServiceImpl extends ServiceImpl implements FtestService {
public String getPostgisPoint( Point[][] point){
StringBuilder pointStr = new StringBuilder("SRID=4326;MULTILINESTRING(");
Arrays.stream(point).forEach(e->{
pointStr.append("(");
for (int i=0;i listEntity() {
List list = this.baseMapper.selectAll();
list.stream().forEach(e->{
e.setGeomObject(JSONObject.parseObject(e.getGeom()));
});
return list;
}
@Override
public Ftest getEntityById(Integer id) {
Ftest ftest = this.baseMapper.getEntityById(id);
ftest.setGeomObject(JSONObject.parseObject(ftest.getGeom()));
return ftest;
}
@Override
public List listEntityByIds(List asList) {
List list = this.baseMapper.listEntityByIds(asList);
list.stream().forEach(e->{
e.setGeomObject(JSONObject.parseObject(e.getGeom()));
});
return list;
}
@Override
public PageInfo getPageInfo(int current, int pageSize) {
PageHelper.startPage(current,pageSize);
List list = this.baseMapper.selectAll();
list.stream().forEach(e->{
e.setGeomObject(JSONObject.parseObject(e.getGeom()));
});
return new PageInfo<>(list);
}
@Override
public Ftest selectRecentOne(Double lng, Double lat) {
String point = "Point("+lng+" "+lat+")";
Ftest ftest = this.baseMapper.selectRecentOne(point);
ftest.setGeomObject(JSONObject.parseObject(ftest.getGeom()));
return ftest;
}
}
xml文件:
insert into ftest(id,geom) values(#{id},#{points})
update ftest set geom = #{pointStr} where id = #{id};