添加地图APP,会员请求高德地图数据功能
pom引入分词模块com.hankcs.hanlp pom引入请求限制: @RateLimiter(count = 10,keyResolver= ClientIpRateLimiterKeyResolver.class, timeUnit = TimeUnit.MINUTES)针对IP级别,每分钟请求10次
This commit is contained in:
parent
0a3d001d9c
commit
7e281f26b6
|
@ -50,6 +50,15 @@
|
|||
<groupId>cn.iocoder.boot</groupId>
|
||||
<artifactId>yudao-spring-boot-starter-excel</artifactId>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>com.hankcs</groupId>
|
||||
<artifactId>hanlp</artifactId>
|
||||
<version>portable-1.2.7</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>cn.iocoder.boot</groupId>
|
||||
<artifactId>yudao-spring-boot-starter-protection</artifactId>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
|
||||
</project>
|
||||
|
|
|
@ -0,0 +1,78 @@
|
|||
package cn.iocoder.yudao.module.map.controller.app.lbs;
|
||||
import cn.iocoder.yudao.framework.common.pojo.CommonResult;
|
||||
import cn.iocoder.yudao.framework.common.pojo.PageResult;
|
||||
import cn.iocoder.yudao.framework.common.util.object.BeanUtils;
|
||||
import cn.iocoder.yudao.framework.ratelimiter.core.annotation.RateLimiter;
|
||||
import cn.iocoder.yudao.framework.ratelimiter.core.keyresolver.impl.ClientIpRateLimiterKeyResolver;
|
||||
import cn.iocoder.yudao.module.map.controller.app.lbs.vo.AppMapLbsReqVO;
|
||||
import cn.iocoder.yudao.module.map.controller.admin.keywordsearch.vo.KeywordSearchRespVO;
|
||||
import cn.iocoder.yudao.module.map.dal.dataobject.keywordsearch.KeywordSearchDO;
|
||||
import cn.iocoder.yudao.module.map.dal.dataobject.pois.PoisDO;
|
||||
import cn.iocoder.yudao.module.map.dal.dataobject.pois.PoisIndoorDO;
|
||||
import cn.iocoder.yudao.module.map.service.keywordsearch.KeywordSearchService;
|
||||
import cn.iocoder.yudao.module.map.service.pois.PoisService;
|
||||
import com.hankcs.hanlp.HanLP;
|
||||
import com.hankcs.hanlp.seg.common.Term;
|
||||
import com.hankcs.hanlp.tokenizer.NLPTokenizer;
|
||||
import io.swagger.v3.oas.annotations.tags.Tag;
|
||||
import io.swagger.v3.oas.annotations.Operation;
|
||||
import jakarta.annotation.Resource;
|
||||
import jakarta.validation.Valid;
|
||||
import org.springframework.security.access.prepost.PreAuthorize;
|
||||
import org.springframework.validation.annotation.Validated;
|
||||
import org.springframework.web.bind.annotation.GetMapping;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.concurrent.TimeUnit;
|
||||
|
||||
import static cn.iocoder.yudao.framework.common.pojo.CommonResult.success;
|
||||
|
||||
@Tag(name = "地图 App - 地图服务")
|
||||
@RestController
|
||||
@RequestMapping("/map/lbs")
|
||||
@Validated
|
||||
public class AppLbsController {
|
||||
|
||||
@Resource
|
||||
private KeywordSearchService kwService;
|
||||
|
||||
@Resource
|
||||
private PoisService poisService;
|
||||
|
||||
@GetMapping("/get-poi-types")
|
||||
@Operation(summary = "获取高德POI类型")
|
||||
public CommonResult<String> getGdPoiTypes() {
|
||||
return success("");
|
||||
}
|
||||
|
||||
@GetMapping("/get-search-list")
|
||||
@Operation(summary = "获取查询数据列表")
|
||||
public CommonResult<String> getSearchList() {
|
||||
return success("");
|
||||
}
|
||||
|
||||
/**
|
||||
* 请求高德POI2.0接口获得地图数据,限制每个IP每分钟10次请求
|
||||
*
|
||||
* @param pageReqVO 分页查询
|
||||
* @return 搜索记录分页
|
||||
*/
|
||||
@GetMapping("/get-map-data")
|
||||
@RateLimiter(count = 10,keyResolver= ClientIpRateLimiterKeyResolver.class, timeUnit = TimeUnit.MINUTES)
|
||||
@Operation(summary = "请求高德POI2.0接口获得地图数据")
|
||||
public CommonResult<String> getMapData(@Valid AppMapLbsReqVO pageReqVO) {
|
||||
return poisService.getPoiData(pageReqVO);
|
||||
}
|
||||
|
||||
@GetMapping("/test-hanlp")
|
||||
@Operation(summary = "测试hanlp分词")
|
||||
public void test() {
|
||||
List<Term> termList = NLPTokenizer.segment("中国科学院计算技术研究所的宗成庆教授正在教授自然语言处理课程");
|
||||
for (Term term : termList) {
|
||||
System.out.println(term.word + " " + term.nature);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1,19 @@
|
|||
package cn.iocoder.yudao.module.map.controller.app.lbs.vo;
|
||||
|
||||
|
||||
import io.swagger.v3.oas.annotations.media.Schema;
|
||||
import cn.iocoder.yudao.framework.common.pojo.PageParam;
|
||||
import lombok.Data;
|
||||
|
||||
@Data
|
||||
public class AppMapLbsReqVO extends PageParam {
|
||||
|
||||
@Schema(description = "关键字", example = "机械")
|
||||
private String keywords;
|
||||
|
||||
@Schema(description = "搜索区划", example = "北京市")
|
||||
private String region;
|
||||
|
||||
@Schema(description = "是否精准模式(1精准,0分词模糊)", example = "0")
|
||||
private int isFocus;
|
||||
}
|
|
@ -0,0 +1,68 @@
|
|||
package cn.iocoder.yudao.module.map.controller.app.lbs.vo;
|
||||
|
||||
import io.swagger.v3.oas.annotations.media.Schema;
|
||||
import lombok.*;
|
||||
import java.util.*;
|
||||
import jakarta.validation.constraints.*;
|
||||
import cn.iocoder.yudao.module.map.dal.dataobject.pois.PoisBusinessDO;
|
||||
import cn.iocoder.yudao.module.map.dal.dataobject.pois.PoisNaviDO;
|
||||
import cn.iocoder.yudao.module.map.dal.dataobject.pois.PoisPhotosDO;
|
||||
|
||||
@Schema(description = "APP - 高德POI数据相应 Response VO")
|
||||
@Data
|
||||
@ToString(callSuper = true)
|
||||
public class AppMapLbsRespVO {
|
||||
@Schema(description = "POI名称", requiredMode = Schema.RequiredMode.REQUIRED, example = "王五")
|
||||
@NotEmpty(message = "POI名称不能为空")
|
||||
private String name;
|
||||
|
||||
@Schema(description = "经纬度", requiredMode = Schema.RequiredMode.REQUIRED, example = "116.413232,39.899947")
|
||||
@NotEmpty(message = "经纬度不能为空")
|
||||
private String location;
|
||||
|
||||
@Schema(description = "所属类型", requiredMode = Schema.RequiredMode.REQUIRED, example = "汽车服务;汽车养护/装饰;汽车养护|汽车服务;洗车场;洗车场|汽车维修;汽车维修;汽车维修")
|
||||
@NotEmpty(message = "所属类型不能为空")
|
||||
private String type;
|
||||
|
||||
@Schema(description = "分类编码", requiredMode = Schema.RequiredMode.REQUIRED, example = "010400|010500|030000")
|
||||
@NotEmpty(message = "分类编码不能为空")
|
||||
private String typecode;
|
||||
|
||||
@Schema(description = "省份", requiredMode = Schema.RequiredMode.REQUIRED, example = "北京市")
|
||||
@NotEmpty(message = "省份不能为空")
|
||||
private String pname;
|
||||
|
||||
@Schema(description = "城市", requiredMode = Schema.RequiredMode.REQUIRED, example = "北京市")
|
||||
@NotEmpty(message = "城市不能为空")
|
||||
private String cityName;
|
||||
|
||||
@Schema(description = "区县", requiredMode = Schema.RequiredMode.REQUIRED, example = "东城区")
|
||||
@NotEmpty(message = "区县不能为空")
|
||||
private String adname;
|
||||
|
||||
@Schema(description = "详细地址", requiredMode = Schema.RequiredMode.REQUIRED, example = "宝鼎中心C座B2层(崇文门地铁站D西南口步行480米)")
|
||||
@NotEmpty(message = "详细地址不能为空")
|
||||
private String address;
|
||||
|
||||
@Schema(description = "省份编码", example = "110000")
|
||||
private String pcode;
|
||||
|
||||
@Schema(description = "区域编码", example = "110101")
|
||||
private String adcode;
|
||||
|
||||
@Schema(description = "城市编码", example = "010")
|
||||
private String citycode;
|
||||
|
||||
@Schema(description = "poi唯一标识", requiredMode = Schema.RequiredMode.REQUIRED, example = "B0GUKCE3AI")
|
||||
@NotEmpty(message = "poi唯一标识不能为空")
|
||||
private String poiId;
|
||||
|
||||
@Schema(description = "高德POI商业信息")
|
||||
private PoisBusinessDO poisBusiness;
|
||||
|
||||
@Schema(description = "高德POI导航信息")
|
||||
private PoisNaviDO poisNavi;
|
||||
|
||||
@Schema(description = "高德POI图片信息")
|
||||
private PoisPhotosDO poisPhotos;
|
||||
}
|
|
@ -0,0 +1,8 @@
|
|||
package cn.iocoder.yudao.module.map.enums;
|
||||
|
||||
public interface LogRecordConstants {
|
||||
String POI_DATA = "POI数据";
|
||||
String POI_DATA_REQUEST = "POI数据请求";
|
||||
String POI_DATA_REQUEST_SUCCESS = "POI数据请求成功";
|
||||
String POI_DATA_REQUEST_ERROR = "POI数据请求失败";
|
||||
}
|
|
@ -1,6 +1,9 @@
|
|||
package cn.iocoder.yudao.module.map.service.pois;
|
||||
|
||||
import java.util.*;
|
||||
|
||||
import cn.iocoder.yudao.framework.common.pojo.CommonResult;
|
||||
import cn.iocoder.yudao.module.map.controller.app.lbs.vo.AppMapLbsReqVO;
|
||||
import jakarta.validation.*;
|
||||
import cn.iocoder.yudao.module.map.controller.admin.pois.vo.*;
|
||||
import cn.iocoder.yudao.module.map.dal.dataobject.pois.PoisDO;
|
||||
|
@ -96,4 +99,12 @@ public interface PoisService {
|
|||
*/
|
||||
PoisPhotosDO getPoisPhotosByPoisId(Long poisId);
|
||||
|
||||
|
||||
/**
|
||||
* 请求高德POI2.0接口获得地图数据
|
||||
*
|
||||
* @param pageReqVO 分页查询
|
||||
* @return 搜索记录分页
|
||||
*/
|
||||
CommonResult<String> getPoiData(AppMapLbsReqVO pageReqVO);
|
||||
}
|
Loading…
Reference in New Issue