whyclxw
3 天以前 29aed8c1fde9c1fc6d248ba8028914e038442306
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
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,"删除返回");
    }
}