You've already forked FrameTour-BE
- 修改AppFaceController中list方法,将scenicId转换为Long类型传递 - 在AppGoodsController中注入FaceService,并在goodsList接口中调用faceService获取人脸列表 - 更新FaceMapper中的listByScenicAndUserId方法签名,统一scenicId参数类型为Long - GoodsServiceImpl中新增listGoodsByFaceIdList方法,实现根据人脸ID列表查询相关商品逻辑 - 商品查询支持按成片vlog和源素材分类展示,并去重处理 - 优化GoodsService接口,增加listGoodsByFaceIdList方法定义 - OrderMapper.xml
147 lines
5.5 KiB
Java
147 lines
5.5 KiB
Java
package com.ycwl.basic.controller.mobile;
|
|
|
|
import com.ycwl.basic.exception.BaseException;
|
|
import com.ycwl.basic.model.jwt.JwtInfo;
|
|
import com.ycwl.basic.model.mobile.face.FaceRecognizeResp;
|
|
import com.ycwl.basic.model.mobile.face.FaceStatusResp;
|
|
import com.ycwl.basic.model.mobile.scenic.content.ContentPageVO;
|
|
import com.ycwl.basic.model.mobile.face.FaceRecognitionUpdateReq;
|
|
import com.ycwl.basic.model.mobile.face.FaceRecognitionDetailVO;
|
|
import com.ycwl.basic.model.pc.face.entity.FaceEntity;
|
|
import com.ycwl.basic.model.pc.face.resp.FaceRespVO;
|
|
import com.ycwl.basic.model.pc.faceSample.entity.FaceSampleEntity;
|
|
import com.ycwl.basic.repository.FaceRepository;
|
|
import com.ycwl.basic.service.pc.FaceService;
|
|
import com.ycwl.basic.utils.ApiResponse;
|
|
import com.ycwl.basic.utils.JwtTokenUtil;
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
import org.springframework.web.bind.annotation.*;
|
|
import org.springframework.web.multipart.MultipartFile;
|
|
|
|
import java.util.List;
|
|
|
|
/**
|
|
* @Author:longbinbin
|
|
* @Date:2024/12/4 17:03
|
|
*/
|
|
@RestController
|
|
@RequestMapping("/api/mobile/face/v1")
|
|
// 用户人脸相关接口
|
|
public class AppFaceController {
|
|
|
|
@Autowired
|
|
private FaceService faceService;
|
|
@Autowired
|
|
private FaceRepository faceRepository;
|
|
|
|
/**
|
|
* 1、上传人脸照片
|
|
* 2、人脸照片有效性校验
|
|
* 3、校验失败,删除,提示重新上传
|
|
* 4、校验成功,保存用户人脸信息,将访问人脸照片访问地址响应给前端
|
|
* @param file
|
|
* @param scenicId
|
|
* @return
|
|
*/
|
|
// 人脸照片上传
|
|
@PostMapping("/faceUPload")
|
|
public ApiResponse<FaceRecognizeResp> faceUpload(@RequestParam("file")MultipartFile file,
|
|
@RequestParam(value = "scene", defaultValue = "", required = false) String scene,
|
|
@RequestParam("scenicId") Long scenicId) {
|
|
//获取用户id
|
|
JwtInfo worker = JwtTokenUtil.getWorker();
|
|
Long userId = worker.getUserId();
|
|
FaceRecognizeResp resp = faceService.faceUpload(file, scenicId, userId, scene);
|
|
return ApiResponse.success(resp);
|
|
}
|
|
|
|
@GetMapping("/scenic/{scenicId}/list")
|
|
public ApiResponse<List<FaceRespVO>> list(@PathVariable("scenicId") String scenicId) {
|
|
JwtInfo worker = JwtTokenUtil.getWorker();
|
|
Long userId = worker.getUserId();
|
|
List<FaceRespVO> list = faceService.listByUser(userId, Long.parseLong(scenicId));
|
|
return ApiResponse.success(list);
|
|
}
|
|
|
|
@GetMapping("/{faceId}")
|
|
public ApiResponse<FaceRespVO> getById(@PathVariable("faceId") Long faceId) {
|
|
return faceService.getById(faceId);
|
|
}
|
|
|
|
@DeleteMapping("/{faceId}")
|
|
public ApiResponse<String> deleteFace(@PathVariable("faceId") Long faceId) {
|
|
// 添加权限检查:验证当前用户是否拥有该 face
|
|
JwtInfo worker = JwtTokenUtil.getWorker();
|
|
Long userId = worker.getUserId();
|
|
|
|
FaceEntity face = faceRepository.getFace(faceId);
|
|
if (face == null) {
|
|
throw new BaseException("人脸数据不存在");
|
|
}
|
|
if (!face.getMemberId().equals(userId)) {
|
|
throw new BaseException("无权删除此人脸");
|
|
}
|
|
|
|
return faceService.deleteFace(faceId);
|
|
}
|
|
|
|
@PostMapping("/{faceId}/match")
|
|
public ApiResponse<String> match(@PathVariable("faceId") Long faceId) {
|
|
faceService.matchFaceId(faceId);
|
|
return ApiResponse.success("");
|
|
}
|
|
|
|
|
|
// 景区视频源素材列表
|
|
@GetMapping("/{faceId}/contentList")
|
|
public ApiResponse<List<ContentPageVO>> contentList(@PathVariable Long faceId) {
|
|
List<ContentPageVO> contentPageVOS = faceService.faceContentList(faceId);
|
|
return ApiResponse.success(contentPageVOS);
|
|
}
|
|
|
|
// 绑定人脸
|
|
@PostMapping("/{faceId}/bind")
|
|
public ApiResponse<String> bind(@PathVariable Long faceId) {
|
|
JwtInfo worker = JwtTokenUtil.getWorker();
|
|
Long userId = worker.getUserId();
|
|
faceService.bindFace(faceId, userId);
|
|
return ApiResponse.success("OK");
|
|
}
|
|
|
|
@GetMapping("/{faceId}/status")
|
|
public ApiResponse<FaceStatusResp> status(@PathVariable Long faceId) {
|
|
return ApiResponse.success(faceService.getFaceStatus(faceId));
|
|
}
|
|
|
|
@GetMapping("/{faceId}/extraCheck")
|
|
public ApiResponse<Boolean> hasExtraCheck(@PathVariable Long faceId) {
|
|
return ApiResponse.success(faceService.checkHasExtraCheck(faceId));
|
|
}
|
|
|
|
@GetMapping("/{faceId}/queryOtherFace")
|
|
public ApiResponse<List<FaceSampleEntity>> queryOtherFace(@PathVariable Long faceId) {
|
|
return ApiResponse.success(faceService.getLowMatchedFaceSamples(faceId));
|
|
}
|
|
|
|
@PostMapping("/{faceId}/queryOtherFace")
|
|
public ApiResponse<String> queryOtherFace(@PathVariable Long faceId, @RequestBody List<Long> faceIds) {
|
|
faceService.matchCustomFaceId(faceId, faceIds);
|
|
return ApiResponse.success("OK");
|
|
}
|
|
|
|
@PutMapping("/{faceId}/recognition")
|
|
public ApiResponse<?> updateRecognition(@PathVariable Long faceId,
|
|
@RequestBody FaceRecognitionUpdateReq req) {
|
|
req.setFaceId(faceId);
|
|
faceService.updateRecognition(req);
|
|
return ApiResponse.success("OK");
|
|
}
|
|
|
|
@GetMapping("/{faceId}/recognition/detail")
|
|
public ApiResponse<FaceRecognitionDetailVO> recognitionDetail(@PathVariable Long faceId) {
|
|
return ApiResponse.success(faceService.getRecognitionDetail(faceId));
|
|
}
|
|
|
|
|
|
}
|