init
This commit is contained in:
@@ -0,0 +1,13 @@
|
||||
package com.sl;
|
||||
|
||||
import org.springframework.boot.SpringApplication;
|
||||
import org.springframework.boot.autoconfigure.SpringBootApplication;
|
||||
|
||||
@SpringBootApplication
|
||||
public class ServiceScopeApplication {
|
||||
|
||||
public static void main(String[] args) {
|
||||
SpringApplication.run(ServiceScopeApplication.class, args);
|
||||
}
|
||||
|
||||
}
|
@@ -0,0 +1,133 @@
|
||||
package com.sl.ms.scope.controller;
|
||||
|
||||
import com.sl.ms.scope.dto.ServiceScopeDTO;
|
||||
import com.sl.ms.scope.entity.ServiceScopeEntity;
|
||||
import com.sl.ms.scope.enums.ServiceTypeEnum;
|
||||
import com.sl.ms.scope.service.ScopeService;
|
||||
import com.sl.ms.scope.util.EntityUtils;
|
||||
import com.sl.transport.common.util.ResponseEntityUtils;
|
||||
import io.swagger.annotations.Api;
|
||||
import io.swagger.annotations.ApiImplicitParam;
|
||||
import io.swagger.annotations.ApiImplicitParams;
|
||||
import io.swagger.annotations.ApiOperation;
|
||||
import org.springframework.data.mongodb.core.geo.GeoJsonPoint;
|
||||
import org.springframework.http.ResponseEntity;
|
||||
import org.springframework.validation.annotation.Validated;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
import javax.validation.constraints.NotNull;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* 服务范围
|
||||
*/
|
||||
@Api(tags = "服务范围")
|
||||
@RestController
|
||||
@RequestMapping("scopes")
|
||||
@Validated
|
||||
public class ScopeController {
|
||||
|
||||
@Resource
|
||||
private ScopeService scopeService;
|
||||
|
||||
/**
|
||||
* 新增或更新服务服务范围
|
||||
*
|
||||
* @return REST标准响应
|
||||
*/
|
||||
@ApiOperation(value = "新增/更新", notes = "新增或更新服务服务范围")
|
||||
@PostMapping
|
||||
public ResponseEntity<Void> saveScope(@RequestBody ServiceScopeDTO serviceScopeDTO) {
|
||||
ServiceScopeEntity serviceScopeEntity = EntityUtils.toEntity(serviceScopeDTO);
|
||||
Long bid = serviceScopeEntity.getBid();
|
||||
ServiceTypeEnum type = ServiceTypeEnum.codeOf(serviceScopeEntity.getType());
|
||||
Boolean result = this.scopeService.saveOrUpdate(bid, type, serviceScopeEntity.getPolygon());
|
||||
if (result) {
|
||||
return ResponseEntityUtils.ok();
|
||||
}
|
||||
return ResponseEntityUtils.error();
|
||||
}
|
||||
|
||||
/**
|
||||
* 删除服务范围
|
||||
*
|
||||
* @param bid 业务id
|
||||
* @param type 类型
|
||||
* @return REST标准响应
|
||||
*/
|
||||
@ApiImplicitParams({
|
||||
@ApiImplicitParam(name = "bid", value = "业务id,可以是机构或快递员", dataTypeClass = Long.class),
|
||||
@ApiImplicitParam(name = "type", value = "类型,1-机构,2-快递员", dataTypeClass = Integer.class)
|
||||
})
|
||||
@ApiOperation(value = "删除", notes = "删除服务范围")
|
||||
@DeleteMapping("{bid}/{type}")
|
||||
public ResponseEntity<Void> delete(@NotNull(message = "bid不能为空") @PathVariable("bid") Long bid,
|
||||
@NotNull(message = "type不能为空") @PathVariable("type") Integer type) {
|
||||
Boolean result = this.scopeService.delete(bid, ServiceTypeEnum.codeOf(type));
|
||||
if (result) {
|
||||
return ResponseEntityUtils.ok();
|
||||
}
|
||||
return ResponseEntityUtils.error();
|
||||
}
|
||||
|
||||
/**
|
||||
* 查询服务范围
|
||||
*
|
||||
* @param bid 业务id
|
||||
* @param type 类型
|
||||
* @return 服务范围数据
|
||||
*/
|
||||
@ApiImplicitParams({
|
||||
@ApiImplicitParam(name = "bid", value = "业务id,可以是机构或快递员", dataTypeClass = Long.class),
|
||||
@ApiImplicitParam(name = "type", value = "类型,1-机构,2-快递员", dataTypeClass = Integer.class)
|
||||
})
|
||||
@ApiOperation(value = "查询", notes = "查询服务范围")
|
||||
@GetMapping("{bid}/{type}")
|
||||
public ResponseEntity<ServiceScopeDTO> queryServiceScope(@NotNull(message = "bid不能为空") @PathVariable("bid") Long bid,
|
||||
@NotNull(message = "type不能为空") @PathVariable("type") Integer type) {
|
||||
ServiceScopeEntity serviceScopeEntity = this.scopeService.queryByBidAndType(bid, ServiceTypeEnum.codeOf(type));
|
||||
return ResponseEntityUtils.ok(EntityUtils.toDTO(serviceScopeEntity));
|
||||
}
|
||||
|
||||
/**
|
||||
* 地址查询服务范围
|
||||
*
|
||||
* @param type 类型,1-机构,2-快递员
|
||||
* @param address 详细地址,如:北京市昌平区金燕龙办公楼传智教育总部
|
||||
* @return 服务范围数据列表
|
||||
*/
|
||||
@ApiImplicitParams({
|
||||
@ApiImplicitParam(name = "type", value = "类型,1-机构,2-快递员", dataTypeClass = Integer.class),
|
||||
@ApiImplicitParam(name = "address", value = "详细地址,如:北京市昌平区金燕龙办公楼传智教育总部", dataTypeClass = String.class)
|
||||
})
|
||||
@ApiOperation(value = "地址查询服务范围", notes = "地址查询服务范围")
|
||||
@GetMapping("address")
|
||||
public ResponseEntity<List<ServiceScopeDTO>> queryListByAddress(@NotNull(message = "type不能为空") @RequestParam("type") Integer type,
|
||||
@NotNull(message = "address不能为空") @RequestParam("address") String address) {
|
||||
List<ServiceScopeEntity> serviceScopeEntityList = this.scopeService.queryListByPoint(ServiceTypeEnum.codeOf(type), address);
|
||||
return ResponseEntityUtils.ok(EntityUtils.toDTOList(serviceScopeEntityList));
|
||||
}
|
||||
|
||||
/**
|
||||
* 位置查询服务范围
|
||||
*
|
||||
* @param type 类型,1-机构,2-快递员
|
||||
* @param longitude 经度
|
||||
* @param latitude 纬度
|
||||
* @return 服务范围数据列表
|
||||
*/
|
||||
@ApiImplicitParams({
|
||||
@ApiImplicitParam(name = "type", value = "类型,1-机构,2-快递员", dataTypeClass = Integer.class),
|
||||
@ApiImplicitParam(name = "longitude", value = "经度", dataTypeClass = Double.class),
|
||||
@ApiImplicitParam(name = "latitude", value = "纬度", dataTypeClass = Double.class)
|
||||
})
|
||||
@ApiOperation(value = "位置查询服务范围", notes = "位置查询服务范围")
|
||||
@GetMapping("location")
|
||||
public ResponseEntity<List<ServiceScopeDTO>> queryListByAddress(@NotNull(message = "type不能为空") @RequestParam("type") Integer type,
|
||||
@NotNull(message = "longitude不能为空") @RequestParam("longitude") Double longitude,
|
||||
@NotNull(message = "latitude不能为空") @RequestParam("latitude") Double latitude) {
|
||||
List<ServiceScopeEntity> serviceScopeEntityList = this.scopeService.queryListByPoint(ServiceTypeEnum.codeOf(type), new GeoJsonPoint(longitude, latitude));
|
||||
return ResponseEntityUtils.ok(EntityUtils.toDTOList(serviceScopeEntityList));
|
||||
}
|
||||
}
|
@@ -0,0 +1,45 @@
|
||||
package com.sl.ms.scope.entity;
|
||||
|
||||
import com.fasterxml.jackson.annotation.JsonIgnore;
|
||||
import lombok.Data;
|
||||
import org.bson.types.ObjectId;
|
||||
import org.springframework.data.annotation.Id;
|
||||
import org.springframework.data.mongodb.core.geo.GeoJsonPolygon;
|
||||
import org.springframework.data.mongodb.core.index.GeoSpatialIndexType;
|
||||
import org.springframework.data.mongodb.core.index.GeoSpatialIndexed;
|
||||
import org.springframework.data.mongodb.core.index.Indexed;
|
||||
import org.springframework.data.mongodb.core.mapping.Document;
|
||||
|
||||
/**
|
||||
* 服务范围实体
|
||||
*/
|
||||
@Data
|
||||
@Document("sl_service_scope")
|
||||
public class ServiceScopeEntity {
|
||||
|
||||
@Id
|
||||
@JsonIgnore
|
||||
private ObjectId id;
|
||||
|
||||
/**
|
||||
* 业务id,可以是机构或快递员
|
||||
*/
|
||||
@Indexed
|
||||
private Long bid;
|
||||
|
||||
/**
|
||||
* 类型 {@link com.sl.ms.scope.enums.ServiceTypeEnum}
|
||||
*/
|
||||
@Indexed
|
||||
private Integer type;
|
||||
|
||||
/**
|
||||
* 多边形范围,是闭合的范围,开始经纬度与结束经纬度必须一样
|
||||
* x: 经度,y:纬度
|
||||
*/
|
||||
@GeoSpatialIndexed(type = GeoSpatialIndexType.GEO_2DSPHERE)
|
||||
private GeoJsonPolygon polygon;
|
||||
|
||||
private Long created; //创建时间
|
||||
private Long updated; //更新时间
|
||||
}
|
@@ -0,0 +1,46 @@
|
||||
package com.sl.ms.scope.enums;
|
||||
|
||||
import cn.hutool.core.util.EnumUtil;
|
||||
import com.sl.transport.common.enums.BaseEnum;
|
||||
|
||||
/**
|
||||
* 服务类型枚举
|
||||
*
|
||||
* @author zzj
|
||||
* @version 1.0
|
||||
*/
|
||||
public enum ServiceTypeEnum implements BaseEnum {
|
||||
|
||||
ORGAN(1, "机构"),
|
||||
COURIER(2, "快递员");
|
||||
|
||||
/**
|
||||
* 类型编码
|
||||
*/
|
||||
private final Integer code;
|
||||
|
||||
/**
|
||||
* 类型值
|
||||
*/
|
||||
private final String value;
|
||||
|
||||
|
||||
ServiceTypeEnum(Integer code, String value) {
|
||||
this.code = code;
|
||||
this.value = value;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Integer getCode() {
|
||||
return code;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getValue() {
|
||||
return value;
|
||||
}
|
||||
|
||||
public static ServiceTypeEnum codeOf(Integer code) {
|
||||
return EnumUtil.getBy(ServiceTypeEnum::getCode, code);
|
||||
}
|
||||
}
|
@@ -0,0 +1,76 @@
|
||||
package com.sl.ms.scope.service;
|
||||
|
||||
import com.sl.ms.scope.entity.ServiceScopeEntity;
|
||||
import com.sl.ms.scope.enums.ServiceTypeEnum;
|
||||
import org.springframework.data.mongodb.core.geo.GeoJsonPoint;
|
||||
import org.springframework.data.mongodb.core.geo.GeoJsonPolygon;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* 服务范围Service
|
||||
*/
|
||||
public interface ScopeService {
|
||||
|
||||
/**
|
||||
* 新增或更新服务范围
|
||||
*
|
||||
* @param bid 业务id
|
||||
* @param type 类型
|
||||
* @param polygon 多边形坐标点
|
||||
* @return 是否成功
|
||||
*/
|
||||
Boolean saveOrUpdate(Long bid, ServiceTypeEnum type, GeoJsonPolygon polygon);
|
||||
|
||||
/**
|
||||
* 根据主键id删除数据
|
||||
*
|
||||
* @param id 主键
|
||||
* @return 是否成功
|
||||
*/
|
||||
Boolean delete(String id);
|
||||
|
||||
/**
|
||||
* 根据业务id和类型删除数据
|
||||
*
|
||||
* @param bid 业务id
|
||||
* @param type 类型
|
||||
* @return 是否成功
|
||||
*/
|
||||
Boolean delete(Long bid, ServiceTypeEnum type);
|
||||
|
||||
/**
|
||||
* 根据主键查询数据
|
||||
*
|
||||
* @param id 主键
|
||||
* @return 服务范围数据
|
||||
*/
|
||||
ServiceScopeEntity queryById(String id);
|
||||
|
||||
/**
|
||||
* 根据业务id和类型查询数据
|
||||
*
|
||||
* @param bid 业务id
|
||||
* @param type 类型
|
||||
* @return 服务范围数据
|
||||
*/
|
||||
ServiceScopeEntity queryByBidAndType(Long bid, ServiceTypeEnum type);
|
||||
|
||||
/**
|
||||
* 根据坐标点查询所属的服务对象
|
||||
*
|
||||
* @param type 类型
|
||||
* @param point 坐标点
|
||||
* @return 服务范围数据
|
||||
*/
|
||||
List<ServiceScopeEntity> queryListByPoint(ServiceTypeEnum type, GeoJsonPoint point);
|
||||
|
||||
/**
|
||||
* 根据详细地址查询所属的服务对象
|
||||
*
|
||||
* @param type 类型
|
||||
* @param address 详细地址,如:北京市昌平区金燕龙办公楼传智教育总部
|
||||
* @return 服务范围数据
|
||||
*/
|
||||
List<ServiceScopeEntity> queryListByPoint(ServiceTypeEnum type, String address);
|
||||
}
|
@@ -0,0 +1,64 @@
|
||||
package com.sl.ms.scope.util;
|
||||
|
||||
import cn.hutool.core.bean.BeanUtil;
|
||||
import cn.hutool.core.collection.CollUtil;
|
||||
import cn.hutool.core.util.ObjectUtil;
|
||||
import com.sl.ms.scope.dto.Coordinate;
|
||||
import com.sl.ms.scope.dto.ServiceScopeDTO;
|
||||
import com.sl.ms.scope.entity.ServiceScopeEntity;
|
||||
import org.springframework.data.geo.Point;
|
||||
import org.springframework.data.mongodb.core.geo.GeoJsonPolygon;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
/**
|
||||
* 实体工具类
|
||||
*/
|
||||
public class EntityUtils {
|
||||
|
||||
public static ServiceScopeDTO toDTO(ServiceScopeEntity entity) {
|
||||
if (ObjectUtil.isEmpty(entity)) {
|
||||
return null;
|
||||
}
|
||||
ServiceScopeDTO serviceScopeDTO = BeanUtil.toBeanIgnoreError(entity, ServiceScopeDTO.class);
|
||||
//设置范围
|
||||
List<Coordinate> coordinateList = entity.getPolygon().getPoints()
|
||||
.stream().map(point -> new Coordinate(point.getX(), point.getY()))
|
||||
.collect(Collectors.toList());
|
||||
serviceScopeDTO.setPolygon(coordinateList);
|
||||
return serviceScopeDTO;
|
||||
}
|
||||
|
||||
public static List<ServiceScopeDTO> toDTOList(List<ServiceScopeEntity> entityList) {
|
||||
if (CollUtil.isEmpty(entityList)) {
|
||||
return Collections.emptyList();
|
||||
}
|
||||
List<ServiceScopeDTO> list = new ArrayList<>();
|
||||
entityList.forEach(entity -> list.add(toDTO(entity)));
|
||||
return list;
|
||||
}
|
||||
|
||||
public static ServiceScopeEntity toEntity(ServiceScopeDTO dto) {
|
||||
if (ObjectUtil.isEmpty(dto)) {
|
||||
return null;
|
||||
}
|
||||
ServiceScopeEntity serviceScopeEntity = BeanUtil.toBeanIgnoreError(dto, ServiceScopeEntity.class);
|
||||
List<Point> pointList = dto.getPolygon().stream()
|
||||
.map(coordinate -> new Point(coordinate.getLongitude(), coordinate.getLatitude()))
|
||||
.collect(Collectors.toList());
|
||||
serviceScopeEntity.setPolygon(new GeoJsonPolygon(pointList));
|
||||
return serviceScopeEntity;
|
||||
}
|
||||
|
||||
public static List<ServiceScopeEntity> toEntity(List<ServiceScopeDTO> dtoList) {
|
||||
if (CollUtil.isEmpty(dtoList)) {
|
||||
return Collections.emptyList();
|
||||
}
|
||||
List<ServiceScopeEntity> list = new ArrayList<>();
|
||||
dtoList.forEach(dto -> list.add(toEntity(dto)));
|
||||
return list;
|
||||
}
|
||||
}
|
@@ -0,0 +1,7 @@
|
||||
|
||||
_ ${spring.application.name} ${application.version}
|
||||
___ | | ___ __ __ _ __ _ __ ___ ___ ___ Port: ${server.port}
|
||||
/ __|| | _____ / _ \\ \/ /| '_ \ | '__|/ _ \/ __|/ __| Pid: ${pid} Profile(s): ${AnsiColor.GREEN}${spring.profiles.active}${AnsiColor.DEFAULT}
|
||||
\__ \| ||_____|| __/ > < | |_) || | | __/\__ \\__ \
|
||||
|___/|_| \___|/_/\_\| .__/ |_| \___||___/|___/ https://sl-express.itheima.net/
|
||||
|_|
|
@@ -0,0 +1,25 @@
|
||||
server:
|
||||
port: 18089
|
||||
tomcat:
|
||||
uri-encoding: UTF-8
|
||||
threads:
|
||||
max: 1000
|
||||
min-spare: 30
|
||||
spring:
|
||||
cloud:
|
||||
nacos:
|
||||
username: nacos
|
||||
password: nacos
|
||||
server-addr: 192.168.150.101:8848
|
||||
discovery:
|
||||
namespace: ecae68ba-7b43-4473-a980-4ddeb6157bdc
|
||||
ip: 192.168.150.1
|
||||
config:
|
||||
namespace: ecae68ba-7b43-4473-a980-4ddeb6157bdc
|
||||
shared-configs: #共享配置
|
||||
- data-id: shared-spring-mongodb.yml
|
||||
group: SHARED_GROUP
|
||||
refresh: false
|
||||
- data-id: shared-spring-eaglemap.yml
|
||||
group: SHARED_GROUP
|
||||
refresh: false
|
@@ -0,0 +1,24 @@
|
||||
server:
|
||||
port: 18089
|
||||
tomcat:
|
||||
uri-encoding: UTF-8
|
||||
threads:
|
||||
max: 1000
|
||||
min-spare: 30
|
||||
spring:
|
||||
cloud:
|
||||
nacos:
|
||||
username: nacos
|
||||
password: vO5/dZ9,iL
|
||||
server-addr: nacos-service.yjy-public-slwl-java-prod.svc.cluster.local:8848
|
||||
discovery:
|
||||
namespace: 92312ba8-1119-440f-81af-c29618df303b
|
||||
config:
|
||||
namespace: 92312ba8-1119-440f-81af-c29618df303b
|
||||
shared-configs: #共享配置
|
||||
- data-id: shared-spring-mongodb.yml
|
||||
group: SHARED_GROUP
|
||||
refresh: false
|
||||
- data-id: shared-spring-eaglemap.yml
|
||||
group: SHARED_GROUP
|
||||
refresh: false
|
@@ -0,0 +1,24 @@
|
||||
server:
|
||||
port: 18089
|
||||
tomcat:
|
||||
uri-encoding: UTF-8
|
||||
threads:
|
||||
max: 1000
|
||||
min-spare: 30
|
||||
spring:
|
||||
cloud:
|
||||
nacos:
|
||||
username: nacos
|
||||
password: nacos
|
||||
server-addr: 192.168.150.101:8848
|
||||
discovery:
|
||||
namespace: ecae68ba-7b43-4473-a980-4ddeb6157bdc
|
||||
config:
|
||||
namespace: ecae68ba-7b43-4473-a980-4ddeb6157bdc
|
||||
shared-configs: #共享配置
|
||||
- data-id: shared-spring-mongodb.yml
|
||||
group: SHARED_GROUP
|
||||
refresh: false
|
||||
- data-id: shared-spring-eaglemap.yml
|
||||
group: SHARED_GROUP
|
||||
refresh: false
|
@@ -0,0 +1,24 @@
|
||||
server:
|
||||
port: 18089
|
||||
tomcat:
|
||||
uri-encoding: UTF-8
|
||||
threads:
|
||||
max: 1000
|
||||
min-spare: 30
|
||||
spring:
|
||||
cloud:
|
||||
nacos:
|
||||
username: nacos
|
||||
password: nacos
|
||||
server-addr: nacos-service.yjy-public-slwl-java.svc.cluster.local:8848
|
||||
discovery:
|
||||
namespace: 92312ba8-1119-440f-81af-c29618df303b
|
||||
config:
|
||||
namespace: 92312ba8-1119-440f-81af-c29618df303b
|
||||
shared-configs: #共享配置
|
||||
- data-id: shared-spring-mongodb.yml
|
||||
group: SHARED_GROUP
|
||||
refresh: false
|
||||
- data-id: shared-spring-eaglemap.yml
|
||||
group: SHARED_GROUP
|
||||
refresh: false
|
@@ -0,0 +1,23 @@
|
||||
application:
|
||||
version: v1.0
|
||||
logging:
|
||||
config: classpath:logback-spring.xml
|
||||
spring:
|
||||
application:
|
||||
name: sl-express-ms-service-scope
|
||||
profiles:
|
||||
active: local
|
||||
mvc:
|
||||
pathmatch:
|
||||
#解决异常:swagger Failed to start bean 'documentationPluginsBootstrapper'; nested exception is java.lang.NullPointerException
|
||||
#因为Springfox使用的路径匹配是基于AntPathMatcher的,而Spring Boot 2.6.X使用的是PathPatternMatcher
|
||||
matching-strategy: ant_path_matcher
|
||||
sl:
|
||||
swagger:
|
||||
package-path: com.sl.ms.scope.controller
|
||||
title: 神领物流 - 服务范围微服务接口文档
|
||||
description: 该微服务完成网点、快递员的服务范围相关业务功能。
|
||||
contact-name: 传智教育·研究院
|
||||
contact-url: http://www.itcast.cn/
|
||||
contact-email: yjy@itcast.cn
|
||||
version: ${application.version}
|
@@ -0,0 +1,41 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<!--scan: 当此属性设置为true时,配置文件如果发生改变,将会被重新加载,默认值为true。-->
|
||||
<!--scanPeriod: 设置监测配置文件是否有修改的时间间隔,如果没有给出时间单位,默认单位是毫秒。当scan为true时,此属性生效。默认的时间间隔为1分钟。-->
|
||||
<!--debug: 当此属性设置为true时,将打印出logback内部日志信息,实时查看logback运行状态。默认值为false。-->
|
||||
<configuration debug="false" scan="false" scanPeriod="60 seconds">
|
||||
<springProperty scope="context" name="appName" source="spring.application.name"/>
|
||||
<!--文件名-->
|
||||
<property name="logback.appname" value="${appName}"/>
|
||||
<!--文件位置-->
|
||||
<property name="logback.logdir" value="/data/logs"/>
|
||||
|
||||
<!-- 定义控制台输出 -->
|
||||
<appender name="stdout" class="ch.qos.logback.core.ConsoleAppender">
|
||||
<layout class="ch.qos.logback.classic.PatternLayout">
|
||||
<pattern>%d{yyyy-MM-dd HH:mm:ss.SSS} - [%thread] - %-5level - %logger{50} - %msg%n</pattern>
|
||||
</layout>
|
||||
</appender>
|
||||
|
||||
|
||||
<appender name="FILE" class="ch.qos.logback.core.rolling.RollingFileAppender">
|
||||
<filter class="ch.qos.logback.classic.filter.ThresholdFilter">
|
||||
<level>DEBUG</level>
|
||||
</filter>
|
||||
<File>${logback.logdir}/${logback.appname}/${logback.appname}.log</File>
|
||||
<rollingPolicy class="ch.qos.logback.core.rolling.TimeBasedRollingPolicy">
|
||||
<FileNamePattern>${logback.logdir}/${logback.appname}/${logback.appname}.%d{yyyy-MM-dd}.log.zip</FileNamePattern>
|
||||
<maxHistory>90</maxHistory>
|
||||
</rollingPolicy>
|
||||
<encoder>
|
||||
<charset>UTF-8</charset>
|
||||
<pattern>%d [%thread] %-5level %logger{36} %line - %msg%n</pattern>
|
||||
</encoder>
|
||||
</appender>
|
||||
|
||||
|
||||
<!--evel:用来设置打印级别,大小写无关:TRACE, DEBUG, INFO, WARN, ERROR, ALL 和 OFF,-->
|
||||
<!--不能设置为INHERITED或者同义词NULL。默认是DEBUG。-->
|
||||
<root level="INFO">
|
||||
<appender-ref ref="stdout"/>
|
||||
</root>
|
||||
</configuration>
|
@@ -0,0 +1,65 @@
|
||||
package com.sl.ms.scope.service;
|
||||
|
||||
import com.sl.ms.scope.entity.ServiceScopeEntity;
|
||||
import com.sl.ms.scope.enums.ServiceTypeEnum;
|
||||
import org.junit.jupiter.api.Test;
|
||||
import org.springframework.boot.test.context.SpringBootTest;
|
||||
import org.springframework.data.geo.Point;
|
||||
import org.springframework.data.mongodb.core.geo.GeoJsonPoint;
|
||||
import org.springframework.data.mongodb.core.geo.GeoJsonPolygon;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
|
||||
@SpringBootTest
|
||||
public class ScopeServiceTest {
|
||||
|
||||
@Resource
|
||||
private ScopeService scopeService;
|
||||
|
||||
@Test
|
||||
void saveOrUpdate() {
|
||||
List<Point> pointList = Arrays.asList(new Point(116.340064,40.061245),
|
||||
new Point(116.347081,40.061836),
|
||||
new Point(116.34751,40.05842),
|
||||
new Point(116.342446,40.058092),
|
||||
new Point(116.340064,40.061245));
|
||||
Boolean result = this.scopeService.saveOrUpdate(2L, ServiceTypeEnum.ORGAN, new GeoJsonPolygon(pointList));
|
||||
System.out.println(result);
|
||||
}
|
||||
|
||||
@Test
|
||||
void delete() {
|
||||
}
|
||||
|
||||
@Test
|
||||
void testDelete() {
|
||||
}
|
||||
|
||||
@Test
|
||||
void queryById() {
|
||||
}
|
||||
|
||||
@Test
|
||||
void queryByBidAndType() {
|
||||
}
|
||||
|
||||
@Test
|
||||
void queryListByPoint() {
|
||||
}
|
||||
|
||||
@Test
|
||||
void testQueryListByPoint() {
|
||||
GeoJsonPoint point = new GeoJsonPoint(116.344828,40.05911);
|
||||
List<ServiceScopeEntity> serviceScopeEntities = this.scopeService.queryListByPoint(ServiceTypeEnum.ORGAN, point);
|
||||
serviceScopeEntities.forEach(serviceScopeEntity -> System.out.println(serviceScopeEntity));
|
||||
}
|
||||
|
||||
@Test
|
||||
void testQueryListByPoint2() {
|
||||
String address = "北京市昌平区金燕龙办公楼";
|
||||
List<ServiceScopeEntity> serviceScopeEntities = this.scopeService.queryListByPoint(ServiceTypeEnum.ORGAN, address);
|
||||
serviceScopeEntities.forEach(serviceScopeEntity -> System.out.println(serviceScopeEntity));
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user