删除人脸逻辑

This commit is contained in:
2025-02-24 10:31:24 +08:00
parent 6bb9b053ab
commit 84bb5727e9
8 changed files with 37 additions and 1 deletions

View File

@ -59,6 +59,11 @@ AppFaceController {
return faceService.getById(faceId); return faceService.getById(faceId);
} }
@DeleteMapping("/{faceId}")
public ApiResponse deleteFace(@PathVariable("faceId") Long faceId) {
return faceService.deleteFace(faceId);
}
@PostMapping("/{faceId}/match") @PostMapping("/{faceId}/match")
public ApiResponse match(@PathVariable("faceId") Long faceId) { public ApiResponse match(@PathVariable("faceId") Long faceId) {
faceService.matchFaceId(faceId); faceService.matchFaceId(faceId);

View File

@ -8,6 +8,7 @@ import com.ycwl.basic.model.wvp.WvpSyncReqVo;
import com.ycwl.basic.service.pc.DeviceService; import com.ycwl.basic.service.pc.DeviceService;
import com.ycwl.basic.storage.StorageFactory; import com.ycwl.basic.storage.StorageFactory;
import com.ycwl.basic.storage.adapters.IStorageAdapter; import com.ycwl.basic.storage.adapters.IStorageAdapter;
import com.ycwl.basic.storage.utils.StorageUtil;
import com.ycwl.basic.utils.ApiResponse; import com.ycwl.basic.utils.ApiResponse;
import io.swagger.annotations.Api; import io.swagger.annotations.Api;
import lombok.extern.slf4j.Slf4j; import lombok.extern.slf4j.Slf4j;
@ -42,7 +43,7 @@ public class WvpController {
@PostMapping("/scenic/{scenicId}/{taskId}/uploadUrl") @PostMapping("/scenic/{scenicId}/{taskId}/uploadUrl")
public String uploadUrl(@PathVariable("scenicId") Long scenicId, @PathVariable("taskId") Long taskId) { public String uploadUrl(@PathVariable("scenicId") Long scenicId, @PathVariable("taskId") Long taskId) {
IStorageAdapter adapter = StorageFactory.use("assets-ext"); IStorageAdapter adapter = StorageFactory.use("assets-ext");
return adapter.getUrlForUpload(WvpPassiveStorageOperator.getUrlForTask(taskId)); return adapter.getUrlForUpload(new Date(System.currentTimeMillis() + 1000 * 60 * 60), "video/mp4", StorageUtil.joinPath("video-source", taskId.toString() + ".mp4"));
} }
@PostMapping("/scenic/{scenicId}/{taskId}/success") @PostMapping("/scenic/{scenicId}/{taskId}/success")
public ApiResponse<String> success(@PathVariable("scenicId") Long scenicId, @PathVariable("taskId") Long taskId, @RequestBody FileObject fileObject) { public ApiResponse<String> success(@PathVariable("scenicId") Long scenicId, @PathVariable("taskId") Long taskId, @RequestBody FileObject fileObject) {

View File

@ -72,4 +72,6 @@ public interface SourceMapper {
int deleteNotRelateSource(int type, Date endDate); int deleteNotRelateSource(int type, Date endDate);
int deleteNotBuyRelations(Long scenicId, Date endDate); int deleteNotBuyRelations(Long scenicId, Date endDate);
int deleteNotBuyFaceRelation(Long userId, Long faceId);
} }

View File

@ -52,4 +52,6 @@ public interface VideoMapper {
VideoEntity getEntity(Long videoId); VideoEntity getEntity(Long videoId);
int deleteNotBuyRelations(Long scenicId, Date endDate); int deleteNotBuyRelations(Long scenicId, Date endDate);
int deleteNotBuyFaceRelations(Long userId, Long faceId);
} }

View File

@ -8,6 +8,7 @@ import com.ycwl.basic.mapper.FaceSampleMapper;
import com.ycwl.basic.mapper.SourceMapper; import com.ycwl.basic.mapper.SourceMapper;
import com.ycwl.basic.mapper.StatisticsMapper; import com.ycwl.basic.mapper.StatisticsMapper;
import com.ycwl.basic.mapper.FaceMapper; import com.ycwl.basic.mapper.FaceMapper;
import com.ycwl.basic.mapper.VideoMapper;
import com.ycwl.basic.model.mobile.face.FaceRecognizeResp; import com.ycwl.basic.model.mobile.face.FaceRecognizeResp;
import com.ycwl.basic.model.mobile.order.IsBuyRespVO; import com.ycwl.basic.model.mobile.order.IsBuyRespVO;
import com.ycwl.basic.model.mobile.statistic.req.StatisticsRecordAddReq; import com.ycwl.basic.model.mobile.statistic.req.StatisticsRecordAddReq;
@ -64,6 +65,8 @@ public class FaceServiceImpl implements FaceService {
private OrderBiz orderBiz; private OrderBiz orderBiz;
@Autowired @Autowired
private FaceRepository faceRepository; private FaceRepository faceRepository;
@Autowired
private VideoMapper videoMapper;
@Override @Override
public ApiResponse<PageInfo<FaceRespVO>> pageQuery(FaceReqQuery faceReqQuery) { public ApiResponse<PageInfo<FaceRespVO>> pageQuery(FaceReqQuery faceReqQuery) {
@ -274,4 +277,17 @@ public class FaceServiceImpl implements FaceService {
return scenicDbSearchResult; return scenicDbSearchResult;
} }
@Override
public ApiResponse deleteFace(Long faceId) {
FaceEntity face = faceRepository.getFace(faceId);
faceMapper.deleteById(faceId);
faceRepository.clearFaceCache(faceId);
new Thread(() -> {
sourceMapper.deleteNotBuyFaceRelation(face.getMemberId(), faceId);
videoMapper.deleteNotBuyFaceRelations(face.getMemberId(), faceId);
faceService.deleteFaceSample(USER_FACE_DB_NAME+face.getScenicId().toString(), faceId.toString());
}).start();
return ApiResponse.success("删除成功");
}
} }

View File

@ -29,4 +29,6 @@ public interface FaceService {
SearchFaceRespVo matchFaceId(Long faceId); SearchFaceRespVo matchFaceId(Long faceId);
SearchFaceRespVo matchFaceId(Long faceId, boolean isNew); SearchFaceRespVo matchFaceId(Long faceId, boolean isNew);
ApiResponse deleteFace(Long faceId);
} }

View File

@ -51,6 +51,10 @@
delete from member_source delete from member_source
where scenic_id = #{scenicId} and is_buy = 0 and create_time &lt;= #{endDate} where scenic_id = #{scenicId} and is_buy = 0 and create_time &lt;= #{endDate}
</delete> </delete>
<delete id="deleteNotBuyFaceRelation">
delete from member_source
where member_id = #{userId} and face_id = #{faceId} and is_buy = 0
</delete>
<select id="list" resultType="com.ycwl.basic.model.pc.source.resp.SourceRespVO"> <select id="list" resultType="com.ycwl.basic.model.pc.source.resp.SourceRespVO">
select so.id, so.scenic_id, de.name as deviceName, device_id, url, so.create_time, so.update_time,sc.`name` as scenicName, so.video_url, so.`type`, so.face_sample_id select so.id, so.scenic_id, de.name as deviceName, device_id, url, so.create_time, so.update_time,sc.`name` as scenicName, so.video_url, so.`type`, so.face_sample_id

View File

@ -57,6 +57,10 @@
delete from member_video delete from member_video
where scenic_id = #{scenicId} and is_buy = 0 and create_time &lt; #{endTime} where scenic_id = #{scenicId} and is_buy = 0 and create_time &lt; #{endTime}
</delete> </delete>
<delete id="deleteNotBuyFaceRelations">
delete from member_video
where member_id = #{userId} and face_id = #{faceId} and is_buy = 0
</delete>
<select id="list" resultType="com.ycwl.basic.model.pc.video.resp.VideoRespVO"> <select id="list" resultType="com.ycwl.basic.model.pc.video.resp.VideoRespVO">
select v.id, v.scenic_id, template_id, task_id, worker_id, video_url, v.create_time, v.update_time, select v.id, v.scenic_id, template_id, task_id, worker_id, video_url, v.create_time, v.update_time,
s.name scenicName, s.latitude, s.longitude, t.name templateName, t.price templatePrice,t.cover_url templateCoverUrl s.name scenicName, s.latitude, s.longitude, t.name templateName, t.price templatePrice,t.cover_url templateCoverUrl