You've already forked FrameTour-BE
查询景区信息和机位接口实现
This commit is contained in:
@ -0,0 +1,15 @@
|
||||
package com.ycwl.basic.controller.mobile;
|
||||
|
||||
import io.swagger.annotations.Api;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
|
||||
/**
|
||||
* @Author:longbinbin
|
||||
* @Date:2024/12/6 10:18
|
||||
*/
|
||||
@RestController
|
||||
@RequestMapping("/api/mobile/scenic/v1")
|
||||
@Api(tags = "设备相关接口")
|
||||
public class AppDeviceController {
|
||||
}
|
@ -1,8 +1,17 @@
|
||||
package com.ycwl.basic.controller.mobile;
|
||||
|
||||
import com.github.pagehelper.PageInfo;
|
||||
import com.ycwl.basic.model.mobile.scenic.ScenicAppVO;
|
||||
import com.ycwl.basic.model.mobile.scenic.ScenicDeviceCountVO;
|
||||
import com.ycwl.basic.model.pc.scenic.req.ScenicReqQuery;
|
||||
import com.ycwl.basic.model.pc.scenic.resp.ScenicRespVO;
|
||||
import com.ycwl.basic.service.mobile.AppScenicService;
|
||||
import com.ycwl.basic.service.pc.ScenicService;
|
||||
import com.ycwl.basic.utils.ApiResponse;
|
||||
import io.swagger.annotations.Api;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
import io.swagger.annotations.ApiOperation;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
|
||||
/**
|
||||
* @Author:longbinbin
|
||||
@ -13,5 +22,25 @@ import org.springframework.web.bind.annotation.RestController;
|
||||
@Api(tags = "景区相关接口")
|
||||
public class AppScenicController {
|
||||
|
||||
@Autowired
|
||||
private AppScenicService appScenicService;
|
||||
|
||||
@ApiOperation("分页查询景区列表")
|
||||
@PostMapping("/page")
|
||||
public ApiResponse<PageInfo<ScenicAppVO>> pageQuery(@RequestBody ScenicReqQuery scenicReqQuery){
|
||||
return appScenicService.pageQuery(scenicReqQuery);
|
||||
}
|
||||
@ApiOperation("根据id查询景区详情")
|
||||
@GetMapping("getDetails/{id}")
|
||||
public ApiResponse<ScenicRespVO> getDetails(@PathVariable Long id){
|
||||
return appScenicService.getDetails(id);
|
||||
}
|
||||
|
||||
@ApiOperation("查询景区设备总数和拍到用户的机位数量")
|
||||
@GetMapping("/deviceCountByScenicId/{scenicId}")
|
||||
public ApiResponse<ScenicDeviceCountVO> deviceCountByScenicId(@PathVariable Long scenicId){
|
||||
return appScenicService.deviceCountByScenicId(scenicId);
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
@ -1,5 +1,6 @@
|
||||
package com.ycwl.basic.mapper.pc;
|
||||
|
||||
import com.ycwl.basic.model.mobile.scenic.ScenicDeviceCountVO;
|
||||
import com.ycwl.basic.model.pc.device.entity.DeviceEntity;
|
||||
import com.ycwl.basic.model.pc.device.req.DeviceAddOrUpdateReq;
|
||||
import com.ycwl.basic.model.pc.device.req.DeviceReqQuery;
|
||||
@ -23,4 +24,6 @@ public interface DeviceMapper {
|
||||
int updateStatus(Long id);
|
||||
|
||||
List<DeviceRespVO> listByScenicId(Long scenicId);
|
||||
|
||||
ScenicDeviceCountVO deviceCountByScenicId(Long scenicId, String userId);
|
||||
}
|
||||
|
@ -1,10 +1,12 @@
|
||||
package com.ycwl.basic.mapper.pc;
|
||||
|
||||
import com.ycwl.basic.model.mobile.scenic.ScenicAppVO;
|
||||
import com.ycwl.basic.model.pc.scenic.entity.ScenicConfigEntity;
|
||||
import com.ycwl.basic.model.pc.scenic.entity.ScenicEntity;
|
||||
import com.ycwl.basic.model.pc.scenic.req.ScenicAddOrUpdateReq;
|
||||
import com.ycwl.basic.model.pc.scenic.req.ScenicReqQuery;
|
||||
import com.ycwl.basic.model.pc.scenic.resp.ScenicRespVO;
|
||||
import com.ycwl.basic.utils.ApiResponse;
|
||||
import org.apache.ibatis.annotations.Mapper;
|
||||
|
||||
import java.util.List;
|
||||
@ -41,4 +43,8 @@ public interface ScenicMapper {
|
||||
* @param scenicId
|
||||
*/
|
||||
void deleteConfigByscenicId(Long scenicId);
|
||||
|
||||
List<ScenicAppVO> appList(ScenicReqQuery scenicReqQuery);
|
||||
|
||||
ApiResponse<ScenicRespVO> getAppById(Long id);
|
||||
}
|
||||
|
@ -0,0 +1,70 @@
|
||||
package com.ycwl.basic.model.mobile.scenic;
|
||||
|
||||
import com.fasterxml.jackson.annotation.JsonFormat;
|
||||
import com.ycwl.basic.model.pc.scenic.entity.ScenicConfigEntity;
|
||||
import io.swagger.annotations.ApiModel;
|
||||
import io.swagger.annotations.ApiModelProperty;
|
||||
import lombok.Data;
|
||||
|
||||
import java.math.BigDecimal;
|
||||
import java.util.Date;
|
||||
|
||||
/**
|
||||
* @Author:longbinbin
|
||||
* @Date:2024/12/6 10:25
|
||||
*/
|
||||
@Data
|
||||
@ApiModel("移动端景区响应参数")
|
||||
public class ScenicAppVO {
|
||||
private Long id;
|
||||
/**
|
||||
* 景区名称
|
||||
*/
|
||||
@ApiModelProperty("景区名称")
|
||||
private String name;
|
||||
/**
|
||||
* 联系电话
|
||||
*/
|
||||
@ApiModelProperty("联系电话")
|
||||
private String phone;
|
||||
/**
|
||||
* 景区介绍
|
||||
*/
|
||||
@ApiModelProperty("景区介绍")
|
||||
private String introduction;
|
||||
/**
|
||||
* 经度
|
||||
*/
|
||||
@ApiModelProperty("经度")
|
||||
private BigDecimal longitude;
|
||||
/***
|
||||
* 纬度
|
||||
*/
|
||||
@ApiModelProperty("纬度")
|
||||
private BigDecimal latitude;
|
||||
/**
|
||||
* 半径(km)
|
||||
*/
|
||||
@ApiModelProperty("半径(km)")
|
||||
private BigDecimal radius;
|
||||
/**
|
||||
* 省份
|
||||
*/
|
||||
@ApiModelProperty("省份")
|
||||
private String province;
|
||||
/**
|
||||
* 城市
|
||||
*/
|
||||
@ApiModelProperty("城市")
|
||||
private String city;
|
||||
/**
|
||||
* 区
|
||||
*/
|
||||
@ApiModelProperty("区")
|
||||
private String area;
|
||||
/**
|
||||
* 详细地址
|
||||
*/
|
||||
@ApiModelProperty("详细地址")
|
||||
private String address;
|
||||
}
|
@ -0,0 +1,18 @@
|
||||
package com.ycwl.basic.model.mobile.scenic;
|
||||
|
||||
import io.swagger.annotations.ApiModel;
|
||||
import io.swagger.annotations.ApiModelProperty;
|
||||
import lombok.Data;
|
||||
|
||||
/**
|
||||
* @Author:longbinbin
|
||||
* @Date:2024/12/6 10:37
|
||||
*/
|
||||
@Data
|
||||
@ApiModel("移动端景区设备数量响应参数")
|
||||
public class ScenicDeviceCountVO {
|
||||
@ApiModelProperty("景区设备总数")
|
||||
private Integer totalDeviceCount;
|
||||
@ApiModelProperty("拍摄到用户的设备数量")
|
||||
private Integer shotDeviceCount;
|
||||
}
|
@ -1,5 +1,7 @@
|
||||
package com.ycwl.basic.service;
|
||||
|
||||
import cn.hutool.core.util.StrUtil;
|
||||
import com.ycwl.basic.exception.BaseException;
|
||||
import com.ycwl.basic.utils.OssUtil;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Service;
|
||||
@ -20,7 +22,12 @@ public class FileService {
|
||||
private OssUtil ossUtil;
|
||||
|
||||
public String uploadFile(MultipartFile file) throws IOException {
|
||||
return ossUtil.uploadFile(file.getInputStream(), Objects.requireNonNull(file.getOriginalFilename()));
|
||||
String originalFilename = file.getOriginalFilename();
|
||||
if (StrUtil.isBlank(originalFilename)) {
|
||||
throw new BaseException("文件上传失败,文件名不能为空");
|
||||
}
|
||||
String fileName=System.currentTimeMillis() + originalFilename.substring(originalFilename.lastIndexOf("."));
|
||||
return ossUtil.uploadFile(file.getInputStream(), fileName);
|
||||
}
|
||||
|
||||
public Boolean delete(String fileName) {
|
||||
|
@ -0,0 +1,52 @@
|
||||
package com.ycwl.basic.service.impl.mobile;
|
||||
|
||||
import com.github.pagehelper.PageHelper;
|
||||
import com.github.pagehelper.PageInfo;
|
||||
import com.ycwl.basic.constant.BaseContextHandler;
|
||||
import com.ycwl.basic.mapper.pc.DeviceMapper;
|
||||
import com.ycwl.basic.mapper.pc.ScenicMapper;
|
||||
import com.ycwl.basic.model.mobile.scenic.ScenicAppVO;
|
||||
import com.ycwl.basic.model.mobile.scenic.ScenicDeviceCountVO;
|
||||
import com.ycwl.basic.model.pc.scenic.req.ScenicReqQuery;
|
||||
import com.ycwl.basic.model.pc.scenic.resp.ScenicRespVO;
|
||||
import com.ycwl.basic.service.mobile.AppScenicService;
|
||||
import com.ycwl.basic.utils.ApiResponse;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* @Author:longbinbin
|
||||
* @Date:2024/12/6 10:23
|
||||
*/
|
||||
@Slf4j
|
||||
@Service
|
||||
public class AppScenicServiceImpl implements AppScenicService {
|
||||
|
||||
@Autowired
|
||||
private ScenicMapper scenicMapper;
|
||||
@Autowired
|
||||
private DeviceMapper deviceMapper;
|
||||
|
||||
@Override
|
||||
public ApiResponse<PageInfo<ScenicAppVO>> pageQuery(ScenicReqQuery scenicReqQuery) {
|
||||
PageHelper.startPage(scenicReqQuery.getPageNum(), scenicReqQuery.getPageSize());
|
||||
List<ScenicAppVO> list = scenicMapper.appList(scenicReqQuery);
|
||||
PageInfo<ScenicAppVO> pageInfo = new PageInfo<>(list);
|
||||
return ApiResponse.success(pageInfo);
|
||||
}
|
||||
|
||||
@Override
|
||||
public ApiResponse<ScenicDeviceCountVO> deviceCountByScenicId(Long scenicId) {
|
||||
String userId = BaseContextHandler.getUserId();
|
||||
ScenicDeviceCountVO scenicDeviceCountVO=deviceMapper.deviceCountByScenicId(scenicId,userId);
|
||||
return ApiResponse.success(scenicDeviceCountVO);
|
||||
}
|
||||
|
||||
@Override
|
||||
public ApiResponse<ScenicRespVO> getDetails(Long id) {
|
||||
return scenicMapper.getAppById(id);
|
||||
}
|
||||
}
|
@ -2,16 +2,15 @@ package com.ycwl.basic.service.impl.pc;
|
||||
|
||||
import com.github.pagehelper.PageHelper;
|
||||
import com.github.pagehelper.PageInfo;
|
||||
import com.ycwl.basic.constant.BaseContextHandler;
|
||||
import com.ycwl.basic.exception.BaseException;
|
||||
import com.ycwl.basic.mapper.pc.FaceMapper;
|
||||
import com.ycwl.basic.model.jwt.JwtInfo;
|
||||
import com.ycwl.basic.model.pc.face.entity.FaceEntity;
|
||||
import com.ycwl.basic.model.pc.face.req.FaceReqQuery;
|
||||
import com.ycwl.basic.model.pc.face.resp.FaceRespVO;
|
||||
import com.ycwl.basic.service.pc.FaceService;
|
||||
import com.ycwl.basic.utils.ApiResponse;
|
||||
import com.ycwl.basic.utils.DateUtils;
|
||||
import com.ycwl.basic.utils.SnowFlakeUtil;
|
||||
import com.ycwl.basic.utils.oss.OssUtil;
|
||||
import com.ycwl.basic.utils.*;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Service;
|
||||
@ -92,7 +91,7 @@ public class FaceServiceImpl implements FaceService {
|
||||
@Override
|
||||
public ApiResponse faceUPload(MultipartFile file) {
|
||||
//TODO 获取用户信息
|
||||
String userId="1";
|
||||
String userId = BaseContextHandler.getUserId();
|
||||
//1、上传人脸照片
|
||||
String facaeUrl = uploadFileALiOss(file, userId);
|
||||
//TODO 2、人脸照片有效性校验
|
||||
@ -104,13 +103,20 @@ public class FaceServiceImpl implements FaceService {
|
||||
//校验成功,保存用户人脸信息,将访问人脸照片访问地址响应给前端
|
||||
|
||||
FaceEntity faceEntity = new FaceEntity();
|
||||
faceEntity.setId(SnowFlakeUtil.getLongId());
|
||||
faceEntity.setMemberId(Long.parseLong(userId));
|
||||
faceEntity.setFaceUrl(facaeUrl);
|
||||
// faceEntity.setScore();
|
||||
// faceEntity.setMatchSampleIds();
|
||||
// faceEntity.setFirstMatchRate();
|
||||
// faceEntity.setMatchResult();
|
||||
//TODO 人脸数据存库
|
||||
faceMapper.add(faceEntity);
|
||||
|
||||
return ApiResponse.success(facaeUrl);
|
||||
}else {
|
||||
//校验失败,删除,提示重新上传
|
||||
|
||||
ossUtil.deleteFile(facaeUrl);
|
||||
|
||||
throw new BaseException("人脸照片校验失败,请重新上传");
|
||||
}
|
||||
@ -147,6 +153,6 @@ public class FaceServiceImpl implements FaceService {
|
||||
log.error("文件上传失败!", e);
|
||||
return null;
|
||||
}
|
||||
return ossUtil.uploadFile(inputStream,filePath,fileName) ;
|
||||
return ossUtil.uploadFile(inputStream,filePath+fileName) ;
|
||||
}
|
||||
}
|
||||
|
@ -0,0 +1,20 @@
|
||||
package com.ycwl.basic.service.mobile;
|
||||
|
||||
import com.github.pagehelper.PageInfo;
|
||||
import com.ycwl.basic.model.mobile.scenic.ScenicAppVO;
|
||||
import com.ycwl.basic.model.mobile.scenic.ScenicDeviceCountVO;
|
||||
import com.ycwl.basic.model.pc.scenic.req.ScenicReqQuery;
|
||||
import com.ycwl.basic.model.pc.scenic.resp.ScenicRespVO;
|
||||
import com.ycwl.basic.utils.ApiResponse;
|
||||
|
||||
/**
|
||||
* @Author:longbinbin
|
||||
* @Date:2024/12/6 10:23
|
||||
*/
|
||||
public interface AppScenicService {
|
||||
ApiResponse<PageInfo<ScenicAppVO>> pageQuery(ScenicReqQuery scenicReqQuery);
|
||||
|
||||
ApiResponse<ScenicDeviceCountVO> deviceCountByScenicId(Long scenicId);
|
||||
|
||||
ApiResponse<ScenicRespVO> getDetails(Long id);
|
||||
}
|
@ -20,8 +20,14 @@ public class OssUtil {
|
||||
@Autowired
|
||||
private OssConfig ossConfig;
|
||||
|
||||
/**
|
||||
* 上传文件到oss
|
||||
* @param inputStream 文件数据流
|
||||
* @param filename 文件全路径名称
|
||||
* @return
|
||||
*/
|
||||
public String uploadFile(InputStream inputStream, String filename) {
|
||||
String uploadFileName = ossConfig.getObjectName() + System.currentTimeMillis() + filename.substring(filename.lastIndexOf("."));
|
||||
String uploadFileName = ossConfig.getObjectName() + filename;
|
||||
OSS ossClient = new OSSClientBuilder().build(ossConfig.getEndPoint(), ossConfig.getAccessKeyId(), ossConfig.getAccessKeySecret());
|
||||
try {
|
||||
PutObjectRequest putObjectRequest = new PutObjectRequest(ossConfig.getBucketName(), uploadFileName, inputStream);
|
||||
|
@ -1,87 +0,0 @@
|
||||
package com.ycwl.basic.utils.oss;
|
||||
|
||||
import cn.hutool.core.util.StrUtil;
|
||||
import com.aliyun.oss.ClientException;
|
||||
import com.aliyun.oss.OSS;
|
||||
import com.aliyun.oss.OSSClientBuilder;
|
||||
import com.aliyun.oss.OSSException;
|
||||
import com.aliyun.oss.model.PutObjectRequest;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.beans.factory.annotation.Value;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
import java.io.InputStream;
|
||||
|
||||
/**
|
||||
* @Author:longbinbin
|
||||
* @Date:2024/11/6 10:12
|
||||
*
|
||||
* 参考文档:https://help.aliyun.com/zh/oss/getting-started/sdk-quick-start?spm=a2c4g.11186623.help-menu-31815.d_1_5.7065a784pbkMck
|
||||
*/
|
||||
@Slf4j
|
||||
@Component
|
||||
public class OssUtil {
|
||||
|
||||
@Value("${aliyun.oss.endpoint}")
|
||||
private String endPoint;
|
||||
@Value("${aliyun.oss.accessKeyId}")
|
||||
private String accessKeyId;
|
||||
@Value("${aliyun.oss.accessKeySecret}")
|
||||
private String accessKeySecret;
|
||||
@Value("${aliyun.oss.bucketName}")
|
||||
private String bucketName;
|
||||
@Value("${aliyun.oss.url}")
|
||||
private String url;
|
||||
|
||||
/**
|
||||
* 上传文件到oss
|
||||
* @param inputStream 文件数据输入流
|
||||
* @param filepath 文件路径
|
||||
* @param filename 文件名
|
||||
* @return
|
||||
*/
|
||||
public String uploadFile(InputStream inputStream, String filepath, String filename) {
|
||||
String uploadFileName ;
|
||||
if (StrUtil.isNotBlank(filepath)) {
|
||||
uploadFileName = filepath+filename;
|
||||
}else {
|
||||
uploadFileName=filename;
|
||||
}
|
||||
OSS ossClient = new OSSClientBuilder().build(endPoint, accessKeyId, accessKeySecret);
|
||||
try {
|
||||
PutObjectRequest putObjectRequest = new PutObjectRequest(bucketName,uploadFileName, inputStream);
|
||||
ossClient.putObject(putObjectRequest);
|
||||
log.info("人脸照片上传成功");
|
||||
String fileUrl = url+uploadFileName;
|
||||
return fileUrl;
|
||||
} catch (OSSException oe) {
|
||||
System.out.println("Caught an OSSException, which means your request made it to OSS, "
|
||||
+ "but was rejected with an error response for some reason.");
|
||||
System.out.println("Error Message:" + oe.getErrorMessage());
|
||||
System.out.println("Error Code:" + oe.getErrorCode());
|
||||
System.out.println("Request ID:" + oe.getRequestId());
|
||||
System.out.println("Host ID:" + oe.getHostId());
|
||||
} catch (ClientException ce) {
|
||||
System.out.println("Caught an ClientException, which means the client encountered "
|
||||
+ "a serious internal problem while trying to communicate with OSS, "
|
||||
+ "such as not being able to access the network.");
|
||||
System.out.println("Error Message:" + ce.getMessage());
|
||||
} finally {
|
||||
if (ossClient != null) {
|
||||
ossClient.shutdown();
|
||||
}
|
||||
}
|
||||
|
||||
return "上传失败";
|
||||
}
|
||||
|
||||
/**
|
||||
* 删除文件
|
||||
* @param filePath 文件路径
|
||||
* @return
|
||||
*/
|
||||
public Boolean deleteFile(String filePath) {
|
||||
|
||||
return null;
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user