You've already forked FrameTour-BE
refactor(scenic): 移除景区移动端控制器和服务中的分页查询功能
- 删除 AppScenicController 中的 pageQuery 接口方法 - 删除 AppScenicController 中的 deviceCountByScenicId 接口方法 - 删除 AppScenicController 中的 scenicListByLnLa 接口方法 - 从 AppScenicService 接口中移除 pageQuery 方法定义 - 从 AppScenicService 接口中移除 deviceCountByScenicId 方法定义 - 从 AppScenicService 接口中移除 scenicListByLnLa 方法定义 - 完全移除 AppScenicController 类文件 - 简化 AppScenicServiceImpl 中
This commit is contained in:
@@ -1,120 +0,0 @@
|
|||||||
package com.ycwl.basic.controller.mobile;
|
|
||||||
|
|
||||||
import com.github.pagehelper.PageInfo;
|
|
||||||
import com.ycwl.basic.annotation.IgnoreToken;
|
|
||||||
import com.ycwl.basic.constant.BaseContextHandler;
|
|
||||||
import com.ycwl.basic.model.mobile.scenic.ScenicAppVO;
|
|
||||||
import com.ycwl.basic.model.mobile.scenic.ScenicDeviceCountVO;
|
|
||||||
import com.ycwl.basic.model.mobile.scenic.ScenicIndexVO;
|
|
||||||
import com.ycwl.basic.model.mobile.scenic.content.ContentPageVO;
|
|
||||||
import com.ycwl.basic.integration.common.manager.ScenicConfigManager;
|
|
||||||
import com.ycwl.basic.model.pc.scenic.entity.ScenicEntity;
|
|
||||||
import com.ycwl.basic.model.pc.scenic.req.ScenicReqQuery;
|
|
||||||
import com.ycwl.basic.model.pc.scenic.resp.ScenicConfigResp;
|
|
||||||
import com.ycwl.basic.model.pc.scenic.resp.ScenicRespVO;
|
|
||||||
import com.ycwl.basic.repository.ScenicRepository;
|
|
||||||
import com.ycwl.basic.service.mobile.AppScenicService;
|
|
||||||
import com.ycwl.basic.service.pc.FaceService;
|
|
||||||
import com.ycwl.basic.utils.ApiResponse;
|
|
||||||
import lombok.extern.slf4j.Slf4j;
|
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
|
||||||
import org.springframework.web.bind.annotation.GetMapping;
|
|
||||||
import org.springframework.web.bind.annotation.PathVariable;
|
|
||||||
import org.springframework.web.bind.annotation.PostMapping;
|
|
||||||
import org.springframework.web.bind.annotation.RequestBody;
|
|
||||||
import org.springframework.web.bind.annotation.RequestMapping;
|
|
||||||
import org.springframework.web.bind.annotation.RestController;
|
|
||||||
|
|
||||||
import java.util.ArrayList;
|
|
||||||
import java.util.List;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @Author:longbinbin
|
|
||||||
* @Date:2024/12/5 10:22
|
|
||||||
*/
|
|
||||||
@Slf4j
|
|
||||||
@RestController
|
|
||||||
@RequestMapping("/api/mobile/scenic/v1")
|
|
||||||
// 景区相关接口
|
|
||||||
public class AppScenicController {
|
|
||||||
|
|
||||||
@Autowired
|
|
||||||
private FaceService faceService;
|
|
||||||
@Autowired
|
|
||||||
private AppScenicService appScenicService;
|
|
||||||
@Autowired
|
|
||||||
private ScenicRepository scenicRepository;
|
|
||||||
private static final List<String> ENABLED_USER_IDs = new ArrayList<>(){{
|
|
||||||
add("3932535453961555968");
|
|
||||||
add("3936121342868459520");
|
|
||||||
add("3936940597855784960");
|
|
||||||
add("4049850382325780480");
|
|
||||||
}};
|
|
||||||
|
|
||||||
// 分页查询景区列表
|
|
||||||
@PostMapping("/page")
|
|
||||||
public ApiResponse<PageInfo<ScenicEntity>> pageQuery(@RequestBody ScenicReqQuery scenicReqQuery){
|
|
||||||
String userId = BaseContextHandler.getUserId();
|
|
||||||
if (ENABLED_USER_IDs.contains(userId)) {
|
|
||||||
return appScenicService.pageQuery(scenicReqQuery);
|
|
||||||
} else {
|
|
||||||
return ApiResponse.success(new PageInfo<>(new ArrayList<>()));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
// 根据id查询景区详情
|
|
||||||
@IgnoreToken
|
|
||||||
@GetMapping("/{id}")
|
|
||||||
public ApiResponse<ScenicRespVO> getDetails(@PathVariable Long id){
|
|
||||||
return appScenicService.getDetails(id);
|
|
||||||
}
|
|
||||||
|
|
||||||
@GetMapping("/{id}/config")
|
|
||||||
@IgnoreToken
|
|
||||||
public ApiResponse<ScenicConfigResp> getConfig(@PathVariable Long id){
|
|
||||||
ScenicConfigManager scenicConfig = scenicRepository.getScenicConfigManager(id);
|
|
||||||
ScenicConfigResp resp = new ScenicConfigResp();
|
|
||||||
resp.setWatermarkUrl(scenicConfig.getString("watermark_url"));
|
|
||||||
resp.setVideoStoreDay(scenicConfig.getInteger("video_store_day"));
|
|
||||||
resp.setAntiScreenRecordType(scenicConfig.getInteger("anti_screen_record_type"));
|
|
||||||
resp.setGroupingEnable(scenicConfig.getBoolean("grouping_enable", false));
|
|
||||||
resp.setVoucherEnable(scenicConfig.getBoolean("voucher_enable", false));
|
|
||||||
resp.setShowPhotoWhenWaiting(scenicConfig.getBoolean("show_photo_when_waiting", false));
|
|
||||||
resp.setImageSourcePackHint(scenicConfig.getString("image_source_pack_hint"));
|
|
||||||
resp.setVideoSourcePackHint(scenicConfig.getString("video_source_pack_hint"));
|
|
||||||
resp.setShareBeforeBuy(scenicConfig.getBoolean("share_before_buy"));
|
|
||||||
resp.setFaceSelectFirst(scenicConfig.getBoolean("face_select_first", false));
|
|
||||||
resp.setPrintEnableSource(scenicConfig.getBoolean("print_enable_source", true));
|
|
||||||
resp.setPrintForceFaceUpload(scenicConfig.getBoolean("print_force_face_upload", false));
|
|
||||||
resp.setPrintEnableManual(scenicConfig.getBoolean("print_enable_manual", true));
|
|
||||||
resp.setSceneMode(scenicConfig.getInteger("scene_mode", 0));
|
|
||||||
resp.setPrintEnable(scenicConfig.getBoolean("print_enable", false));
|
|
||||||
resp.setShowMyPagePaid(scenicConfig.getBoolean("show_my_page_paid", true));
|
|
||||||
resp.setShowMyPageUnpaid(scenicConfig.getBoolean("show_my_page_unpaid", true));
|
|
||||||
return ApiResponse.success(resp);
|
|
||||||
}
|
|
||||||
|
|
||||||
// 查询景区设备总数和拍到用户的机位数量
|
|
||||||
@GetMapping("/{scenicId}/deviceCount/")
|
|
||||||
public ApiResponse<ScenicDeviceCountVO> deviceCountByScenicId(@PathVariable Long scenicId){
|
|
||||||
return appScenicService.deviceCountByScenicId(scenicId);
|
|
||||||
}
|
|
||||||
|
|
||||||
// 景区视频源素材列表
|
|
||||||
@GetMapping("/contentList/")
|
|
||||||
public ApiResponse<List<ContentPageVO>> contentList() {
|
|
||||||
return faceService.contentListUseDefaultFace();
|
|
||||||
}
|
|
||||||
|
|
||||||
// 景区视频源素材列表
|
|
||||||
@GetMapping("/face/{faceId}/contentList")
|
|
||||||
public ApiResponse<List<ContentPageVO>> contentList(@PathVariable Long faceId) {
|
|
||||||
List<ContentPageVO> contentPageVOS = faceService.faceContentList(faceId);
|
|
||||||
return ApiResponse.success(contentPageVOS);
|
|
||||||
}
|
|
||||||
|
|
||||||
@PostMapping("/nearby")
|
|
||||||
public ApiResponse<List<ScenicAppVO>> nearby(@RequestBody ScenicIndexVO scenicIndexVO) {
|
|
||||||
List<ScenicAppVO> list = appScenicService.scenicListByLnLa(scenicIndexVO);
|
|
||||||
return ApiResponse.success(list);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -21,17 +21,11 @@ import java.util.List;
|
|||||||
* @Date:2024/12/6 10:23
|
* @Date:2024/12/6 10:23
|
||||||
*/
|
*/
|
||||||
public interface AppScenicService {
|
public interface AppScenicService {
|
||||||
ApiResponse<PageInfo<ScenicEntity>> pageQuery(ScenicReqQuery scenicReqQuery);
|
|
||||||
|
|
||||||
ApiResponse<ScenicDeviceCountVO> deviceCountByScenicId(Long scenicId);
|
|
||||||
|
|
||||||
ApiResponse<ScenicRespVO> getDetails(Long id);
|
ApiResponse<ScenicRespVO> getDetails(Long id);
|
||||||
|
|
||||||
ApiResponse<ScenicLoginRespVO> login(ScenicLoginReq scenicLoginReq) throws Exception;
|
ApiResponse<ScenicLoginRespVO> login(ScenicLoginReq scenicLoginReq) throws Exception;
|
||||||
|
|
||||||
ApiResponse<ScenicRegisterRespVO> register(ScenicRegisterReq scenicRegisterReq);
|
ApiResponse<ScenicRegisterRespVO> register(ScenicRegisterReq scenicRegisterReq);
|
||||||
|
|
||||||
List<ScenicAppVO> scenicListByLnLa(ScenicIndexVO scenicIndexVO);
|
|
||||||
|
|
||||||
ApiResponse<List<DeviceRespVO>> getDevices(Long scenicId);
|
ApiResponse<List<DeviceRespVO>> getDevices(Long scenicId);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -69,34 +69,6 @@ public class AppScenicServiceImpl implements AppScenicService {
|
|||||||
@Autowired
|
@Autowired
|
||||||
private ScenicRepository scenicRepository;
|
private ScenicRepository scenicRepository;
|
||||||
|
|
||||||
@Override
|
|
||||||
public ApiResponse<PageInfo<ScenicEntity>> pageQuery(ScenicReqQuery scenicReqQuery) {
|
|
||||||
|
|
||||||
ScenicReqQuery query = new ScenicReqQuery();
|
|
||||||
query.setPageSize(1000);
|
|
||||||
query.setStatus("1");
|
|
||||||
List<ScenicV2DTO> scenicList = scenicRepository.list(query);
|
|
||||||
List<ScenicEntity> list = scenicList.stream().map(scenic -> {
|
|
||||||
return scenicRepository.getScenic(Long.valueOf(scenic.getId()));
|
|
||||||
}).toList();
|
|
||||||
PageInfo<ScenicEntity> pageInfo = new PageInfo<>(list);
|
|
||||||
return ApiResponse.success(pageInfo);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public ApiResponse<ScenicDeviceCountVO> deviceCountByScenicId(Long scenicId) {
|
|
||||||
JwtInfo worker = JwtTokenUtil.getWorker();
|
|
||||||
// 通过zt-device服务获取设备统计
|
|
||||||
PageResponse<DeviceV2DTO> deviceListResponse = deviceIntegrationService.getScenicActiveDevices(scenicId, 1, 1000);
|
|
||||||
ScenicDeviceCountVO scenicDeviceCountVO = new ScenicDeviceCountVO();
|
|
||||||
if (deviceListResponse != null && deviceListResponse.getList() != null) {
|
|
||||||
scenicDeviceCountVO.setTotalDeviceCount(deviceListResponse.getList().size());
|
|
||||||
} else {
|
|
||||||
scenicDeviceCountVO.setTotalDeviceCount(0);
|
|
||||||
}
|
|
||||||
return ApiResponse.success(scenicDeviceCountVO);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public ApiResponse<ScenicRespVO> getDetails(Long id) {
|
public ApiResponse<ScenicRespVO> getDetails(Long id) {
|
||||||
ScenicEntity scenic = scenicRepository.getScenic(id);
|
ScenicEntity scenic = scenicRepository.getScenic(id);
|
||||||
@@ -218,95 +190,6 @@ public class AppScenicServiceImpl implements AppScenicService {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
public List<ScenicAppVO> scenicListByLnLa(ScenicIndexVO scenicIndexVO) {
|
|
||||||
// 参数校验
|
|
||||||
if (scenicIndexVO == null) {
|
|
||||||
log.warn("scenicListByLnLa 接收到空参数");
|
|
||||||
return Collections.emptyList();
|
|
||||||
}
|
|
||||||
if (scenicIndexVO.getLatitude() == null || scenicIndexVO.getLongitude() == null) {
|
|
||||||
log.warn("scenicListByLnLa 缺少必要的经纬度参数, latitude={}, longitude={}",
|
|
||||||
scenicIndexVO.getLatitude(), scenicIndexVO.getLongitude());
|
|
||||||
return Collections.emptyList();
|
|
||||||
}
|
|
||||||
|
|
||||||
// 从 scenicRepository 获取所有景区(1000个)
|
|
||||||
ScenicReqQuery query = new ScenicReqQuery();
|
|
||||||
query.setPageNum(1);
|
|
||||||
query.setPageSize(1000);
|
|
||||||
List<ScenicV2DTO> scenicList = scenicRepository.list(query);
|
|
||||||
|
|
||||||
if (scenicList == null || scenicList.isEmpty()) {
|
|
||||||
log.info("未查询到任何景区数据");
|
|
||||||
return Collections.emptyList();
|
|
||||||
}
|
|
||||||
|
|
||||||
List<ScenicAppVO> list = new ArrayList<>();
|
|
||||||
|
|
||||||
// 为每个景区获取详细信息(包含经纬度)
|
|
||||||
for (ScenicV2DTO scenicDTO : scenicList) {
|
|
||||||
try {
|
|
||||||
// ID 格式校验
|
|
||||||
if (StringUtils.isBlank(scenicDTO.getId())) {
|
|
||||||
log.warn("景区 ID 为空,跳过该景区");
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
|
|
||||||
// 获取景区详细信息(包含经纬度)
|
|
||||||
ScenicEntity scenicEntity = scenicRepository.getScenic(Long.parseLong(scenicDTO.getId()));
|
|
||||||
if (scenicEntity == null) {
|
|
||||||
log.warn("景区详情查询失败, scenicId={}", scenicDTO.getId());
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (scenicEntity.getLatitude() == null || scenicEntity.getLongitude() == null) {
|
|
||||||
log.warn("景区缺少经纬度信息, scenicId={}, scenicName={}",
|
|
||||||
scenicEntity.getId(), scenicEntity.getName());
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
|
|
||||||
// 计算距离
|
|
||||||
BigDecimal distance = calculateDistance(
|
|
||||||
scenicIndexVO.getLatitude(),
|
|
||||||
scenicIndexVO.getLongitude(),
|
|
||||||
scenicEntity.getLatitude(),
|
|
||||||
scenicEntity.getLongitude()
|
|
||||||
);
|
|
||||||
|
|
||||||
// 根据距离和范围筛选景区
|
|
||||||
if (scenicEntity.getRadius() != null &&
|
|
||||||
distance.compareTo(scenicEntity.getRadius().multiply(BigDecimal.valueOf(1_000L))) < 0) {
|
|
||||||
|
|
||||||
// 转换为 ScenicAppVO
|
|
||||||
ScenicAppVO scenicAppVO = new ScenicAppVO();
|
|
||||||
scenicAppVO.setId(scenicEntity.getId());
|
|
||||||
scenicAppVO.setName(scenicEntity.getName());
|
|
||||||
scenicAppVO.setCoverUrl(scenicEntity.getCoverUrl());
|
|
||||||
scenicAppVO.setRadius(scenicEntity.getRadius());
|
|
||||||
scenicAppVO.setDistance(distance);
|
|
||||||
|
|
||||||
// 获取设备数量
|
|
||||||
List<DeviceV2DTO> devices = deviceRepository.getAllDeviceByScenicId(scenicEntity.getId());
|
|
||||||
scenicAppVO.setDeviceNum(devices != null ? devices.size() : 0);
|
|
||||||
|
|
||||||
list.add(scenicAppVO);
|
|
||||||
}
|
|
||||||
} catch (NumberFormatException e) {
|
|
||||||
log.error("景区 ID 格式错误,无法转换为 Long 类型, scenicId={}, error={}",
|
|
||||||
scenicDTO.getId(), e.getMessage());
|
|
||||||
} catch (Exception e) {
|
|
||||||
log.error("处理景区信息时发生异常, scenicId={}, error={}",
|
|
||||||
scenicDTO != null ? scenicDTO.getId() : "unknown", e.getMessage(), e);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
log.info("根据经纬度筛选景区完成, 输入坐标=({}, {}), 符合条件的景区数量={}",
|
|
||||||
scenicIndexVO.getLatitude(), scenicIndexVO.getLongitude(), list.size());
|
|
||||||
|
|
||||||
return list;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public ApiResponse<List<DeviceRespVO>> getDevices(Long scenicId) {
|
public ApiResponse<List<DeviceRespVO>> getDevices(Long scenicId) {
|
||||||
PageResponse<DeviceV2DTO> deviceV2ListResponse = deviceIntegrationService.listDevices(1, 1000, null, null, null, 1, scenicId, null);
|
PageResponse<DeviceV2DTO> deviceV2ListResponse = deviceIntegrationService.listDevices(1, 1000, null, null, null, 1, scenicId, null);
|
||||||
|
|||||||
Reference in New Issue
Block a user