You've already forked FrameTour-BE
refactor(face): 重构人脸服务接口和实现
- 修改 getById 方法返回类型为 FaceEntity 并直接调用仓库层 - 移除删除人脸时的用户权限检查逻辑 - 删除 contentListUseDefaultFace 方法的实现 - 从服务接口中移除 contentListUseDefaultFace 方法定义
This commit is contained in:
@@ -64,23 +64,17 @@ public class AppFaceController {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@GetMapping("/{faceId}")
|
@GetMapping("/{faceId}")
|
||||||
public ApiResponse<FaceRespVO> getById(@PathVariable("faceId") Long faceId) {
|
public ApiResponse<FaceEntity> getById(@PathVariable("faceId") Long faceId) {
|
||||||
return faceService.getById(faceId);
|
FaceEntity face = faceRepository.getFace(faceId);
|
||||||
|
return ApiResponse.success(face);
|
||||||
}
|
}
|
||||||
|
|
||||||
@DeleteMapping("/{faceId}")
|
@DeleteMapping("/{faceId}")
|
||||||
public ApiResponse<String> deleteFace(@PathVariable("faceId") Long faceId) {
|
public ApiResponse<String> deleteFace(@PathVariable("faceId") Long faceId) {
|
||||||
// 添加权限检查:验证当前用户是否拥有该 face
|
|
||||||
JwtInfo worker = JwtTokenUtil.getWorker();
|
|
||||||
Long userId = worker.getUserId();
|
|
||||||
|
|
||||||
FaceEntity face = faceRepository.getFace(faceId);
|
FaceEntity face = faceRepository.getFace(faceId);
|
||||||
if (face == null) {
|
if (face == null) {
|
||||||
throw new BaseException("人脸数据不存在");
|
throw new BaseException("人脸数据不存在");
|
||||||
}
|
}
|
||||||
if (!face.getMemberId().equals(userId)) {
|
|
||||||
throw new BaseException("无权删除此人脸");
|
|
||||||
}
|
|
||||||
|
|
||||||
return faceService.deleteFace(faceId);
|
return faceService.deleteFace(faceId);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -40,8 +40,6 @@ public interface FaceService {
|
|||||||
|
|
||||||
List<ContentPageVO> faceContentList(Long faceId);
|
List<ContentPageVO> faceContentList(Long faceId);
|
||||||
|
|
||||||
ApiResponse<List<ContentPageVO>> contentListUseDefaultFace();
|
|
||||||
|
|
||||||
void bindFace(Long faceId, Long memberId);
|
void bindFace(Long faceId, Long memberId);
|
||||||
|
|
||||||
String bindWxaCode(Long faceId);
|
String bindWxaCode(Long faceId);
|
||||||
|
|||||||
@@ -677,13 +677,6 @@ public class FaceServiceImpl implements FaceService {
|
|||||||
return contentList;
|
return contentList;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
public ApiResponse<List<ContentPageVO>> contentListUseDefaultFace() {
|
|
||||||
FaceRespVO lastFaceByUserId = faceMapper.findLastFaceByUserId(BaseContextHandler.getUserId());
|
|
||||||
List<ContentPageVO> contentPageVOS = faceContentList(lastFaceByUserId.getId());
|
|
||||||
return ApiResponse.success(contentPageVOS);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void bindFace(Long faceId, Long memberId) {
|
public void bindFace(Long faceId, Long memberId) {
|
||||||
FaceEntity face = faceRepository.getFace(faceId);
|
FaceEntity face = faceRepository.getFace(faceId);
|
||||||
|
|||||||
Reference in New Issue
Block a user