package com.whyc.service;
|
|
import com.baomidou.mybatisplus.core.conditions.update.UpdateWrapper;
|
import com.whyc.dto.Response;
|
import com.whyc.mapper.DocFaceMapper;
|
import com.whyc.pojo.DocFace;
|
import org.springframework.beans.factory.annotation.Autowired;
|
import org.springframework.stereotype.Service;
|
|
@Service
|
public class DocFaceService {
|
@Autowired(required = false)
|
private DocFaceMapper mapper;
|
|
//读取最大的faceid并生成新的faceid+1
|
public int getNewFaceId(){
|
int faceId=mapper.selectMaxFaceId();
|
if(faceId==0){
|
faceId=4001;
|
}else {
|
faceId=faceId+1;
|
}
|
return faceId;
|
}
|
//录入新的人脸
|
public int setNewFace(int faceId,String filePath){
|
DocFace face=new DocFace();
|
face.setFaceId(faceId);
|
face.setUrl(filePath);
|
int bl=mapper.insert(face);
|
return bl;
|
}
|
//修改旧的人脸
|
public int updateFace(int faceId, String filePath) {
|
UpdateWrapper wrapper=new UpdateWrapper();
|
wrapper.set("url",filePath);
|
wrapper.eq("face_id",faceId);
|
int bl=mapper.update(null,wrapper);
|
return bl;
|
}
|
//清除人脸信息
|
public Response deleteFace(int faceId) {
|
UpdateWrapper wrapper=new UpdateWrapper();
|
wrapper.set("url","");
|
wrapper.eq("face_id",faceId);
|
int bl=mapper.update(null,wrapper);
|
return new Response().setII(1,bl>0,bl,"删除返回");
|
}
|
}
|