FaceController.java 1.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657
  1. package com.yingyangfly.app.controller;
  2. import com.tencentcloudapi.common.exception.TencentCloudSDKException;
  3. import com.yingyangfly.common.dto.ResultResponse;
  4. import com.yingyangfly.common.log.annotation.TraceLog;
  5. import com.yingyangfly.core.annotation.Log;
  6. import com.yingyangfly.core.domain.Face;
  7. import com.yingyangfly.core.dto.AppCurrentLoginUser;
  8. import com.yingyangfly.core.dto.CurrentLoginUser;
  9. import com.yingyangfly.core.enums.OperatorType;
  10. import com.yingyangfly.core.security.util.TokenUtil;
  11. import com.yingyangfly.core.service.FaceService;
  12. import io.swagger.annotations.Api;
  13. import lombok.extern.slf4j.Slf4j;
  14. import org.springframework.beans.factory.annotation.Autowired;
  15. import org.springframework.web.bind.annotation.PostMapping;
  16. import org.springframework.web.bind.annotation.RequestMapping;
  17. import org.springframework.web.bind.annotation.RestController;
  18. import javax.annotation.Resource;
  19. import java.util.List;
  20. @Slf4j
  21. @RestController
  22. @Api(tags = "人脸照片")
  23. @RequestMapping("/face")
  24. public class FaceController {
  25. @Resource
  26. private FaceService faceService;
  27. @Autowired
  28. private TokenUtil tokenUtil;
  29. @TraceLog
  30. @PostMapping("/getHumanFace")
  31. public ResultResponse getHumanFace() {
  32. AppCurrentLoginUser appCurrentLoginUser = tokenUtil.getAppCurrentLoginUser();
  33. List<Face> faces = faceService.selectByUserId(appCurrentLoginUser.getId());
  34. if (faces.size()>0) {
  35. return ResultResponse.success(faces.get(0).getFaceBase());
  36. }
  37. return ResultResponse.success();
  38. }
  39. @Log(title = "人脸照片删除",operatorType = OperatorType.MOBILE)
  40. @PostMapping("/deleteHumanFace")
  41. @TraceLog
  42. public ResultResponse deleteHumanFace(String faceUrl) throws TencentCloudSDKException {
  43. AppCurrentLoginUser appCurrentLoginUser = tokenUtil.getAppCurrentLoginUser();
  44. return ResultResponse.success(faceService.deleteFaceUrl(appCurrentLoginUser.getId(),faceUrl));
  45. }
  46. }