|
@@ -11,6 +11,7 @@ import io.swagger.annotations.ApiOperation;
|
|
|
import io.swagger.annotations.ApiParam;
|
|
|
import lombok.AllArgsConstructor;
|
|
|
import org.springblade.common.constant.CommonConstant;
|
|
|
+import org.springblade.common.utils.DistanceUtils;
|
|
|
import org.springblade.core.mp.support.Condition;
|
|
|
import org.springblade.core.mp.support.Query;
|
|
|
import org.springblade.core.secure.utils.AuthUtil;
|
|
@@ -38,7 +39,7 @@ public class ApiFacilityController extends BaseController {
|
|
|
private final IUserMerchantService iUserMerchantService;
|
|
|
|
|
|
@PostMapping("/save")
|
|
|
- @ApiOperationSupport(order = 4)
|
|
|
+ @ApiOperationSupport(order = 1)
|
|
|
@ApiOperation(value = "添加设备", notes = "传入facility")
|
|
|
public R<Void> save(@Valid @RequestBody Facility facility) {
|
|
|
return R.status(iFacilityService.add(facility));
|
|
@@ -57,17 +58,59 @@ public class ApiFacilityController extends BaseController {
|
|
|
wrapper.in(Facility::getShopId, merchantShopIds);
|
|
|
} else {
|
|
|
List<Long> authShopId = iUserMerchantService.getAuthShopId(AuthUtil.getUserId());
|
|
|
+ if (CollUtil.isEmpty(authShopId)) {
|
|
|
+ return R.data(new Page<>());
|
|
|
+ }
|
|
|
wrapper.in(Facility::getShopId, authShopId);
|
|
|
}
|
|
|
IPage<Facility> pages = iFacilityService.page(Condition.getPage(query), wrapper);
|
|
|
return R.data(FacilityWrapper.build().pageVO(pages));
|
|
|
}
|
|
|
|
|
|
- @PostMapping("/delete")
|
|
|
+ @PostMapping("/details")
|
|
|
@ApiOperationSupport(order = 3)
|
|
|
+ @ApiOperation(value = "设备详情", notes = "传入id")
|
|
|
+ public R<FacilityVO> details(@ApiParam(value = "主键集合", required = true) @RequestParam Long facilityId) {
|
|
|
+ Facility facility = iFacilityService.getById(facilityId);
|
|
|
+ return R.data(FacilityWrapper.build().entityVO(facility));
|
|
|
+ }
|
|
|
+
|
|
|
+ @PostMapping("/delete")
|
|
|
+ @ApiOperationSupport(order = 4)
|
|
|
@ApiOperation(value = "删除设备", notes = "传入ids")
|
|
|
public R<Void> remove(@ApiParam(value = "主键集合", required = true) @RequestParam String ids) {
|
|
|
return R.status(iFacilityService.removeByIds(Func.toLongList(ids)));
|
|
|
}
|
|
|
|
|
|
+ /**
|
|
|
+ * 小程序查询所有设备,并返回距离
|
|
|
+ */
|
|
|
+ @GetMapping("/all")
|
|
|
+ @ApiOperationSupport(order = 5)
|
|
|
+ @ApiOperation(value = "小程序查询所有设备,并返回距离", notes = "经度纬度")
|
|
|
+ public R<List<FacilityVO>> all(@ApiParam(value = "经度", required = true) @RequestParam Double longitude,
|
|
|
+ @ApiParam(value = "纬度", required = true) @RequestParam Double latitude) {
|
|
|
+ List<Facility> pages = iFacilityService.list(Wrappers.lambdaQuery(Facility.class).eq(Facility::getUseStatus, 1));
|
|
|
+ List<FacilityVO> facilityVOS = FacilityWrapper.build().listVO(pages);
|
|
|
+ for (FacilityVO facilityVO : facilityVOS) {
|
|
|
+ facilityVO.setDistance(DistanceUtils.getDistance(longitude, latitude, Double.parseDouble(facilityVO.getLongitude()), Double.parseDouble(facilityVO.getLatitude())));
|
|
|
+ }
|
|
|
+ return R.data(facilityVOS);
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 获取商家所有未绑定设备
|
|
|
+ */
|
|
|
+ @GetMapping("/allMerchantFacility")
|
|
|
+ @ApiOperationSupport(order = 5)
|
|
|
+ @ApiOperation(value = "获取商家所有未绑定设备", notes = "获取商家所有未绑定设备")
|
|
|
+ public R<List<FacilityVO>> allMerchantFacility() {
|
|
|
+ List<Facility> list = iFacilityService.lambdaQuery()
|
|
|
+ .eq(Facility::getMerchantId, AuthUtil.getUserId())
|
|
|
+ .eq(Facility::getShopId, null)
|
|
|
+ .eq(Facility::getIsDelete, 0)
|
|
|
+ .list();
|
|
|
+ return R.data(FacilityWrapper.build().listVO(list));
|
|
|
+ }
|
|
|
+
|
|
|
}
|