AdminLocationController.java
2.57 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
package com.diligrp.rider.controller;
import com.diligrp.rider.common.exception.BizException;
import com.diligrp.rider.common.result.Result;
import com.diligrp.rider.service.RiderLocationService;
import com.diligrp.rider.vo.AdminRiderDashboardVO;
import com.diligrp.rider.vo.AdminRiderLocationVO;
import jakarta.servlet.http.HttpServletRequest;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;
import java.util.List;
@RestController
@RequestMapping("/api/admin/location")
@RequiredArgsConstructor
@Slf4j
public class AdminLocationController {
private final RiderLocationService riderLocationService;
/**
* 查询商铺内最近活跃的骑手位置列表,供后台地图初始化使用。
*/
@GetMapping("/active")
public Result<List<AdminRiderLocationVO>> active(@RequestParam(required = false) Long cityId,
HttpServletRequest request) {
String role = (String) request.getAttribute("role");
Long resolvedCityId = "substation".equals(role)
? (Long) request.getAttribute("cityId")
: cityId;
log.debug("查询商铺活跃骑手位置列表,请求参数 role={} cityId={} resolvedCityId={}",
role, cityId, resolvedCityId);
if (resolvedCityId == null || resolvedCityId < 1) {
throw new BizException(400, "请选择商铺");
}
return Result.success(riderLocationService.listActiveByCity(resolvedCityId));
}
/**
* 查询商铺内骑手看板数据。
*/
@GetMapping("/dashboard")
public Result<List<AdminRiderDashboardVO>> dashboard(@RequestParam(required = false) Long cityId,
HttpServletRequest request) {
String role = (String) request.getAttribute("role");
Long resolvedCityId = "substation".equals(role)
? (Long) request.getAttribute("cityId")
: cityId;
log.debug("查询商铺骑手看板数据,请求参数 role={} cityId={} resolvedCityId={}",
role, cityId, resolvedCityId);
if (resolvedCityId == null || resolvedCityId < 1) {
throw new BizException(400, "请选择商铺");
}
return Result.success(riderLocationService.listDashboardByCity(resolvedCityId));
}
}