parent
37ab806a31
commit
838a02108b
@ -0,0 +1,37 @@
|
|||||||
|
package cc.yunxi.controller;
|
||||||
|
|
||||||
|
import cc.yunxi.common.domain.CommonResult;
|
||||||
|
import cc.yunxi.domain.dto.LocationDTO;
|
||||||
|
import cc.yunxi.domain.po.StationArea;
|
||||||
|
import cc.yunxi.service.IStationAreaService;
|
||||||
|
import io.swagger.annotations.Api;
|
||||||
|
import io.swagger.annotations.ApiOperation;
|
||||||
|
import lombok.RequiredArgsConstructor;
|
||||||
|
import lombok.extern.slf4j.Slf4j;
|
||||||
|
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 javax.validation.Valid;
|
||||||
|
|
||||||
|
@Api(tags = "商户经营区域")
|
||||||
|
@RequiredArgsConstructor
|
||||||
|
@RestController
|
||||||
|
@RequestMapping("/station-area")
|
||||||
|
@Slf4j
|
||||||
|
@Validated
|
||||||
|
public class StationAreaController {
|
||||||
|
|
||||||
|
|
||||||
|
private final IStationAreaService stationAreaService;
|
||||||
|
|
||||||
|
@GetMapping("/inArea")
|
||||||
|
@ApiOperation("获取当前位置所属的经营区域")
|
||||||
|
public CommonResult<StationArea> getInArea(@Valid LocationDTO location) {
|
||||||
|
StationArea area = stationAreaService.getBelongArea(location);
|
||||||
|
if (null != area) return CommonResult.success(area);
|
||||||
|
return CommonResult.error(400, "当前位置不在经营区域内");
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
@ -0,0 +1,36 @@
|
|||||||
|
package cc.yunxi.domain.dto;
|
||||||
|
|
||||||
|
import io.swagger.annotations.ApiModelProperty;
|
||||||
|
import lombok.AllArgsConstructor;
|
||||||
|
import lombok.Data;
|
||||||
|
import lombok.NoArgsConstructor;
|
||||||
|
|
||||||
|
import javax.validation.constraints.NotNull;
|
||||||
|
import java.math.BigDecimal;
|
||||||
|
|
||||||
|
@Data
|
||||||
|
@AllArgsConstructor
|
||||||
|
@NoArgsConstructor
|
||||||
|
public class PositionDTO {
|
||||||
|
@ApiModelProperty(value = "当前经度", required = true, example = "121.404032")
|
||||||
|
@NotNull(message = "未知定位")
|
||||||
|
private BigDecimal longitude;
|
||||||
|
|
||||||
|
@ApiModelProperty(value = "当前纬度", required = true, example = "31.163973")
|
||||||
|
@NotNull(message = "未知定位")
|
||||||
|
private BigDecimal latitude;
|
||||||
|
|
||||||
|
@ApiModelProperty(value = "所属商户", required = true, example = "543049974737277765")
|
||||||
|
@NotNull(message = "未知商户")
|
||||||
|
private String companyId;
|
||||||
|
|
||||||
|
@ApiModelProperty(value = "转换为pos")
|
||||||
|
public static PositionDTO transformFromLoc(LocationDTO locationDTO, @NotNull String companyId) {
|
||||||
|
PositionDTO dto = new PositionDTO();
|
||||||
|
dto.setLongitude(new BigDecimal(locationDTO.getLongitude()));
|
||||||
|
dto.setLatitude(new BigDecimal(locationDTO.getLatitude()));
|
||||||
|
dto.setCompanyId(companyId);
|
||||||
|
return dto;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
@ -0,0 +1,7 @@
|
|||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
|
||||||
|
<mapper namespace="cc.yunxi.mapper.StationAreaMapper">
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
</mapper>
|
Loading…
Reference in new issue