修改百度人脸对比

dev_xd
lj7788@126.com 2025-09-24 17:29:41 +08:00
parent 2f8097e3ce
commit 621e3e4b59
15 changed files with 978 additions and 43 deletions

View File

@ -12,20 +12,21 @@ import org.springframework.context.annotation.Configuration;
@ConfigurationProperties(prefix = "baidu.face")
public class BaiduFaceProperties {
private String imgUrl="https://xiangguan.sxyanzhu.com";
/**
* App ID
*/
private String appId = "7034646";
private String appId = "119949649";//"117160042";//
/**
* API Key
*/
private String apiKey = "L3PiEzO9dMFJDExMTjOxuTtq";
private String apiKey = "L3PiEzO9dMFJDExMTjOxuTtq";//"rS40xCCuGuVNFRopPI0jlMuj";//
/**
* Secret Key
*/
private String secretKey = "40LMey6WC1MYIqLU4m5Qe8K4foFUM1bc";
private String secretKey ="40LMey6WC1MYIqLU4m5Qe8K4foFUM1bc" ;//"3bY7dADqQq3O4UpXpFA1FJAj6LN57QCS";//
/**
*
@ -49,6 +50,14 @@ public class BaiduFaceProperties {
// Getter和Setter方法
public String getImgUrl() {
return imgUrl;
}
public void setImgUrl(String imgUrl) {
this.imgUrl = imgUrl;
}
public String getAppId() {
return appId;
}

View File

@ -0,0 +1,344 @@
package com.yanzhu.common.core.utils;
import com.baidu.aip.face.AipFace;
import com.yanzhu.common.core.config.BaiduFaceProperties;
import com.yanzhu.common.core.utils.bean.BaiduFaceUserInfo;
import org.json.JSONObject;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;
import javax.annotation.PostConstruct;
import java.util.HashMap;
/**
* API
*
*
* @author yanzhu
*/
@Component
public class BaiduFaceManageUtils {
@Autowired
private BaiduFaceProperties baiduFaceProperties;
// 初始化AipFace客户端
private static AipFace client;
// QPS限制相关常量
private static int QPS_LIMIT_DELAY = 1000; // 1秒延迟避免QPS限制
private static int MAX_RETRY_ATTEMPTS = 3; // 最大重试次数
private static int RETRY_DELAY = 2000; // 重试延迟(毫秒)
private static String imgBaseUrl="";
@PostConstruct
public void init() {
// 从配置中获取参数
String appId = baiduFaceProperties.getAppId();
String apiKey = baiduFaceProperties.getApiKey();
String secretKey = baiduFaceProperties.getSecretKey();
imgBaseUrl=baiduFaceProperties.getImgUrl();
// 初始化AipFace客户端
client = new AipFace(appId, apiKey, secretKey);
// 设置网络连接参数
client.setConnectionTimeoutInMillis(2000);
client.setSocketTimeoutInMillis(60000);
// 更新静态变量
QPS_LIMIT_DELAY = baiduFaceProperties.getQpsLimitDelay();
MAX_RETRY_ATTEMPTS = baiduFaceProperties.getMaxRetryAttempts();
RETRY_DELAY = baiduFaceProperties.getRetryDelay();
}
public static void staticInit(BaiduFaceProperties baiduFaceProperties) {
// 从配置中获取参数
String appId = baiduFaceProperties.getAppId();
String apiKey = baiduFaceProperties.getApiKey();
String secretKey = baiduFaceProperties.getSecretKey();
imgBaseUrl=baiduFaceProperties.getImgUrl();
// 初始化AipFace客户端
client = new AipFace(appId, apiKey, secretKey);
// 设置网络连接参数
client.setConnectionTimeoutInMillis(2000);
client.setSocketTimeoutInMillis(60000);
// 更新静态变量
QPS_LIMIT_DELAY = baiduFaceProperties.getQpsLimitDelay();
MAX_RETRY_ATTEMPTS = baiduFaceProperties.getMaxRetryAttempts();
RETRY_DELAY = baiduFaceProperties.getRetryDelay();
}
/**
*
*
*
* @param imageBase64 Base64
* @param groupId ID
* @param userId ID
* @param userInfo 256B
* @return ID
*/
public static JSONObject faceRegister(String imageBase64, String groupId, String userId, String userInfo) {
try {
// 检查client是否已初始化
if (client == null) {
System.err.println("错误: Baidu AipFace client未初始化请确保在Spring容器中正确初始化BaiduFaceManageUtils");
return null;
}
// 添加延迟以避免QPS限制
Thread.sleep(QPS_LIMIT_DELAY);
// 传入可选参数调用接口
HashMap<String, String> options = new HashMap<String, String>();
if (userInfo != null && !userInfo.isEmpty()) {
options.put("user_info", userInfo);
}
options.put("quality_control", "NORMAL");
options.put("liveness_control", "LOW");
options.put("action_type", "REPLACE"); // 若在此用户组下不存在此用户ID则添加否则更新
// 调用百度人脸识别API的人脸注册接口
JSONObject response = client.addUser(imageBase64, "BASE64", groupId, userId, options);
return response;
} catch (Exception e) {
e.printStackTrace();
return null;
}
}
/**
*
*
*
* @param imageBase64 Base64
* @param groupId ID
* @param userId ID
* @param userInfo
* @return
*/
public static JSONObject faceUpdate(String imageBase64, String groupId, String userId, String userInfo) {
try {
// 检查client是否已初始化
if (client == null) {
System.err.println("错误: Baidu AipFace client未初始化请确保在Spring容器中正确初始化BaiduFaceManageUtils");
return null;
}
// 添加延迟以避免QPS限制
Thread.sleep(QPS_LIMIT_DELAY);
// 传入可选参数调用接口
HashMap<String, String> options = new HashMap<String, String>();
if (userInfo != null && !userInfo.isEmpty()) {
options.put("user_info", userInfo);
}
options.put("quality_control", "NORMAL");
options.put("liveness_control", "LOW");
// 调用百度人脸识别API的人脸更新接口
JSONObject response = client.updateUser(imageBase64, "BASE64", groupId, userId, options);
return response;
} catch (Exception e) {
e.printStackTrace();
return null;
}
}
/**
*
*
*
* @param userId ID
* @param groupId ID
* @return
*/
public static JSONObject faceDelete(String userId, String groupId) {
try {
// 检查client是否已初始化
if (client == null) {
System.err.println("错误: Baidu AipFace client未初始化请确保在Spring容器中正确初始化BaiduFaceManageUtils");
return null;
}
// 添加延迟以避免QPS限制
Thread.sleep(QPS_LIMIT_DELAY);
// 传入可选参数调用接口
HashMap<String, String> options = new HashMap<String, String>();
// 调用百度人脸识别API的人脸删除接口
JSONObject response = client.faceDelete(userId, groupId, "", options);
return response;
} catch (Exception e) {
e.printStackTrace();
return null;
}
}
/**
*
*
*
* @param userId ID
* @param groupId ID
* @return
*/
public static JSONObject getUserInfo(String userId, String groupId) {
try {
// 检查client是否已初始化
if (client == null) {
System.err.println("错误: Baidu AipFace client未初始化请确保在Spring容器中正确初始化BaiduFaceManageUtils");
return null;
}
// 添加延迟以避免QPS限制
Thread.sleep(QPS_LIMIT_DELAY);
// 传入可选参数调用接口
HashMap<String, String> options = new HashMap<String, String>();
// 调用百度人脸识别API的用户信息查询接口
JSONObject response = client.getUser(userId, groupId, options);
return response;
} catch (Exception e) {
e.printStackTrace();
return null;
}
}
/**
*
*
*
* @param userId ID
* @param groupId ID
* @return
*/
public static JSONObject getFaceList(String userId, String groupId) {
try {
// 检查client是否已初始化
if (client == null) {
System.err.println("错误: Baidu AipFace client未初始化请确保在Spring容器中正确初始化BaiduFaceManageUtils");
return null;
}
// 添加延迟以避免QPS限制
Thread.sleep(QPS_LIMIT_DELAY);
// 传入可选参数调用接口
HashMap<String, String> options = new HashMap<String, String>();
// 调用百度人脸识别API的获取用户人脸列表接口
JSONObject response = client.faceGetlist(userId, groupId, options);
return response;
} catch (Exception e) {
e.printStackTrace();
return null;
}
}
/**
*
*
*
* @param startIndex 0
* @param length 1001000
* @return
*/
public static JSONObject getGroupList(int startIndex, int length) {
try {
// 检查client是否已初始化
if (client == null) {
System.err.println("错误: Baidu AipFace client未初始化请确保在Spring容器中正确初始化BaiduFaceManageUtils");
return null;
}
// 添加延迟以避免QPS限制
Thread.sleep(QPS_LIMIT_DELAY);
// 传入可选参数调用接口
HashMap<String, String> options = new HashMap<String, String>();
options.put("start", String.valueOf(startIndex));
options.put("length", String.valueOf(length));
// 调用百度人脸识别API的获取用户组列表接口
JSONObject response = client.getGroupList(options);
return response;
} catch (Exception e) {
e.printStackTrace();
return null;
}
}
/**
*
*
*
* @param imageBase64 Base64
* @param groupIds ID
* @return
*/
public static JSONObject faceSearch(String imageBase64, String groupIds) {
try {
// 检查client是否已初始化
if (client == null) {
System.err.println("错误: Baidu AipFace client未初始化请确保在Spring容器中正确初始化BaiduFaceManageUtils");
return null;
}
// 添加延迟以避免QPS限制
Thread.sleep(QPS_LIMIT_DELAY);
// 传入可选参数调用接口
HashMap<String, Object> options = new HashMap<String, Object>();
options.put("quality_control", "NORMAL");
options.put("liveness_control", "LOW");
options.put("max_user_num", "3"); // 最多返回3个匹配用户
// 调用百度人脸识别API的人脸搜索接口
JSONObject response = client.search(imageBase64, "BASE64", groupIds, options);
return response;
} catch (Exception e) {
e.printStackTrace();
return null;
}
}
/**
*
*
*
* @param userId ID
* @param srcGroupId ID
* @param dstGroupId ID
* @return
*/
public static JSONObject faceCopy(String userId, String srcGroupId, String dstGroupId) {
try {
// 检查client是否已初始化
if (client == null) {
System.err.println("错误: Baidu AipFace client未初始化请确保在Spring容器中正确初始化BaiduFaceManageUtils");
return null;
}
// 添加延迟以避免QPS限制
Thread.sleep(QPS_LIMIT_DELAY);
// 传入可选参数调用接口
HashMap<String, String> options = new HashMap<String, String>();
options.put("src_group_id", srcGroupId);
options.put("dst_group_id", dstGroupId);
// 调用百度人脸识别API的人脸复制接口
JSONObject response = client.userCopy(userId, options);
return response;
} catch (Exception e) {
e.printStackTrace();
return null;
}
}
}

View File

@ -1,8 +1,11 @@
package com.yanzhu.common.core.utils;
import com.alibaba.fastjson2.JSON;
import com.baidu.aip.face.AipFace;
import com.baidu.aip.face.MatchRequest;
import com.yanzhu.common.core.config.BaiduFaceProperties;
import com.yanzhu.common.core.utils.BaiduFaceManageUtils;
import com.yanzhu.common.core.utils.bean.BaiduFaceUserInfo;
import org.json.JSONObject;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;
@ -37,6 +40,7 @@ public class BaiduFaceSimilarityUtils {
private static int QPS_LIMIT_DELAY = 1000; // 1秒延迟避免QPS限制
private static int MAX_RETRY_ATTEMPTS = 3; // 最大重试次数
private static int RETRY_DELAY = 2000; // 重试延迟(毫秒)
private static String imgBaseUrl="https://xiangguan.sxyanzhu.com";
@PostConstruct
public void init() {
@ -44,6 +48,7 @@ public class BaiduFaceSimilarityUtils {
String appId = baiduFaceProperties.getAppId();
String apiKey = baiduFaceProperties.getApiKey();
String secretKey = baiduFaceProperties.getSecretKey();
imgBaseUrl=baiduFaceProperties.getImgUrl();
// 初始化AipFace客户端
client = new AipFace(appId, apiKey, secretKey);
@ -125,6 +130,130 @@ public class BaiduFaceSimilarityUtils {
return similarity >= SIMILARITY_THRESHOLD;
}
/**
* 使
*
*
* @param imageBase64_1 Base64
* @param imageBase64_2 Base64
* @param groupId ID
* @param userId ID
* @return 0-1
*/
public static double calculateFaceSimilarityWithFaceLibrary(String imageBase64_1, String imageBase64_2, String groupId, String userId) {
try {
// 先将第一张图片注册到人脸库
JSONObject registerResult = BaiduFaceManageUtils.faceRegister(imageBase64_1, groupId, userId, "临时用户");
// 检查注册结果
if (registerResult != null && registerResult.has("error_code")) {
String errorCode = registerResult.getString("error_code");
if (!"0".equals(errorCode)) {
System.err.println("人脸注册失败: " + registerResult.optString("error_msg", "未知错误"));
return 0.0;
}
}
// 使用第二张图片在人脸库中搜索
JSONObject searchResult = BaiduFaceManageUtils.faceSearch(imageBase64_2, groupId);
// 检查搜索结果
if (searchResult != null && searchResult.has("error_code")) {
String errorCode = searchResult.getString("error_code");
if (!"0".equals(errorCode)) {
System.err.println("人脸搜索失败: " + searchResult.optString("error_msg", "未知错误"));
return 0.0;
}
// 解析搜索结果
if (searchResult.has("result") && !searchResult.isNull("result")) {
JSONObject result = searchResult.getJSONObject("result");
if (result != null && result.has("user_list")) {
org.json.JSONArray userList = result.getJSONArray("user_list");
if (userList.length() > 0) {
JSONObject user = userList.getJSONObject(0);
if (user.has("score")) {
// 百度API返回的相似度是百分比需要转换为0-1范围
double score = user.getDouble("score");
return score / 100.0;
}
}
}
}
}
return 0.0;
} catch (Exception e) {
e.printStackTrace();
return 0.0;
}
}
/**
* IDnull
*
* @param imgUrl Base64
* @param groupId ID
* @return IDnull
*/
public static BaiduFaceUserInfo findFaceSimilarityWithFaceLibrary(String imgUrl, String groupId) {
try {
if(StringUtils.isBlank(imgUrl)){
return null;
}
if(!imgUrl.toLowerCase().startsWith("http")){
imgUrl=imgBaseUrl+imgUrl;
}
String imageBase64=downloadAndEncodeImage(imgUrl);
if (imageBase64 == null) {
return null;
}
// 使用百度人脸识别API进行人脸搜索
JSONObject searchResult = BaiduFaceManageUtils.faceSearch(imageBase64, groupId);
// 检查搜索结果
if (searchResult != null && searchResult.has("error_code")) {
Long errorCode = searchResult.getLong("error_code");
if (0 == errorCode) { // 请求成功
// 解析搜索结果
if (searchResult.has("result") && !searchResult.isNull("result")) {
JSONObject result = searchResult.getJSONObject("result");
if (result != null && result.has("user_list")) {
org.json.JSONArray userList = result.getJSONArray("user_list");
if (userList.length() > 0) {
JSONObject user = userList.getJSONObject(0);
if (user.has("score")) {
double score = user.getDouble("score");
BaiduFaceUserInfo userInfo = new BaiduFaceUserInfo();
userInfo.setSimilarity(score);
if (score >= SIMILARITY_THRESHOLD) {
if (user.has("user_info")) {
userInfo.setUserId(user.getString("user_id"));
userInfo.setGroupId(user.getString("group_id"));
if (user.has("user_info")) {
String jUser = user.getString("user_info");
userInfo.setUserInfo(JSON.parseObject(jUser, Map.class));
return userInfo;
}
}
}
}
}
}
} else {
System.err.println("人脸搜索失败: " + searchResult.optString("error_msg", "未知错误"));
}
}
return null; // 未找到匹配的用户
}
return null;
} catch (Exception e) {
e.printStackTrace();
return null;
}
}
/**
* Base64
*
@ -146,7 +275,14 @@ public class BaiduFaceSimilarityUtils {
// 将图片转换为Base64编码
ByteArrayOutputStream baos = new ByteArrayOutputStream();
ImageIO.write(image, "jpg", baos);
// 根据图片URL的扩展名确定图片格式如果没有扩展名或不是png则默认使用jpg
String format = "jpg";
if (imageUrl.toLowerCase().endsWith(".png")) {
format = "png";
}
ImageIO.write(image, format, baos);
byte[] imageBytes = baos.toByteArray();
return Base64.getEncoder().encodeToString(imageBytes);
} catch (Exception e) {
@ -243,7 +379,72 @@ public class BaiduFaceSimilarityUtils {
}
}
public static void main(String[] args) {
public static void main(String[] args) throws IOException {
String userPicture3 = "/statics/2025/09/03/c4e2c8fb9d9f66e03902f9e3fea17f99_20250903165717A003.jpg";
String userPicture1 = "https://xiangguan.sxyanzhu.com/statics/2025/09/16/8f24c9ee7a0c533679043412dc746e27_20250916092139A739.png";
//String imageBase64 = downloadAndEncodeImage(userPicture3);
String groupId="G191";
BaiduFaceManageUtils.staticInit(new BaiduFaceProperties());
BaiduFaceUserInfo user=findFaceSimilarityWithFaceLibrary(userPicture3, groupId);
if(user==null){https://xiangguan.sxyanzhu.com/statics/2025/09/16/8f24c9ee7a0c533679043412dc746e27_20250916092139A739.png
System.out.printf("未找到匹配用户");
}else{
System.out.println("匹配用户:"+JSON.toJSONString(user));
}
}
public static void main6(String[] args) {
String userPicture1 = "https://xiangguan.sxyanzhu.com/statics/2025/09/03/836e5c21f83604894486069394dcd22e_20250903170015A004.jpg";
String userPicture2 = "http://62.234.3.186/statics/2025/06/11/a28457e2847333886c8e0f4fd9cd24bc_20250611101313A331.jpg";
String userPicture3 = "https://xiangguan.sxyanzhu.com/statics/2025/09/03/c4e2c8fb9d9f66e03902f9e3fea17f99_20250903165717A003.jpg";
String userPicture4 = "https://xiangguan.sxyanzhu.com/statics/2025/09/03/8c7dd922ad47494fc02c388e12c00eac_20250903132353A852.png";
String userPicture5 = "http://62.234.3.186/statics/2025/06/11/87052f8fa3eaa8840bc2e4fe556a825e_20250611101011A328.jpg";
String userPicture6 = "https://xiangguan.sxyanzhu.com/statics/2025/09/05/a851473a6f5f6373b1ea73487d36dfba_20250905095748A594.jpg";
// 打印每张图片的人脸信息
List<BaiduFaceUserInfo> users = new ArrayList<BaiduFaceUserInfo>();
users.add(new BaiduFaceUserInfo("U0001","张三", "G002", userPicture1));
users.add(new BaiduFaceUserInfo("U0002","李君", "G002", userPicture2));
users.add(new BaiduFaceUserInfo("U0003","王五", "G002", userPicture4));
users.add(new BaiduFaceUserInfo("U0004","赵六", "G002", userPicture5));
users.add(new BaiduFaceUserInfo("U0005","龙小孟", "G002", userPicture6));
BaiduFaceManageUtils.staticInit(new BaiduFaceProperties());
// 把users注册到百度人脸库
System.out.println("开始注册用户到百度人脸库...");
for (BaiduFaceUserInfo user : users) {
try {
// 下载图片并转换为Base64编码
String imageBase64 = downloadAndEncodeImage(user.getImage());
if (imageBase64 != null) {
// 调用百度人脸库管理工具注册用户
JSONObject result = BaiduFaceManageUtils.faceUpdate(imageBase64, user.getGroupId(), user.getUserId().toString(), JSON.toJSONString(user));
if (result != null && result.has("error_code")) {
long errorCode = result.getLong("error_code");
if (errorCode==0) {
System.out.println("用户 " + user.getUserId() + " 注册成功");
} else {
String errorMsg = result.getString("error_msg");
if(StringUtils.isNotBlank(errorMsg) && errorMsg.contains("not exists")){
result=BaiduFaceManageUtils.faceRegister(imageBase64, user.getGroupId(), user.getUserId().toString(), JSON.toJSONString(user));
}else{
System.err.println("用户 " + user.getUserId() + " 注册失败: " + result.optString("error_msg", "未知错误"));
}
}
}
} else {
System.err.println("用户 " + user.getUserId() + " 图片下载失败");
}
} catch (Exception e) {
e.printStackTrace();
System.err.println("用户 " + user.getUserId() + " 注册异常");
}
}
System.out.println("用户注册完成");
}
public static void main1(String[] args) {
System.out.println("开始测试人脸相似度算法...");
// 测试1同一个人的不同照片应该匹配
@ -279,4 +480,76 @@ public class BaiduFaceSimilarityUtils {
System.out.println("\n测试完成。");
}
// 人脸注册
public static String faceAdd(BaiduFaceUserInfo bfUser) {
String imgUrl= bfUser.getImage();
if (imgUrl==null||imgUrl.isEmpty()){
return "注册失败:无图片";
}
if(!imgUrl.toLowerCase().startsWith("http")){
imgUrl=imgBaseUrl+imgUrl;
}
try{
String imageBase64 = downloadAndEncodeImage(imgUrl);
if (StringUtils.isNotEmpty(imageBase64)){
JSONObject result = BaiduFaceManageUtils.faceRegister(imageBase64, bfUser.getGroupId(), bfUser.getUserId(), bfUser.getUserInfoStr());
long errorCode = result.getLong("error_code");
if (errorCode==0) {
return "注册成功:" + bfUser.getUserId() + " 注册成功";
} else {
return "注册失败:" + bfUser.getUserId() + " ," + result.optString("error_msg");
}
}else{
return "注册失败:图片编码失败";
}
}catch (Exception e){
e.printStackTrace();
return "注册异常:"+e.getMessage();
}
}
// 人脸更新
public static String faceUpdate(BaiduFaceUserInfo bfUser) {
String imgUrl= bfUser.getImage();
if (imgUrl==null||imgUrl.isEmpty()){
return "更新失败:无图片";
}
if(!imgUrl.toLowerCase().startsWith("http")){
imgUrl=imgBaseUrl+imgUrl;
}
try{
String imageBase64 = downloadAndEncodeImage(imgUrl);
if (StringUtils.isNotEmpty(imageBase64)){
JSONObject result = BaiduFaceManageUtils.faceUpdate(imageBase64, bfUser.getGroupId(), bfUser.getUserId(), bfUser.getUserInfoStr());
long errorCode = result.getLong("error_code");
if (errorCode==0) {
return "更新成功:" + bfUser.getUserId() + " 更新成功";
} else {
String errorMsg = result.getString("error_msg");
if(StringUtils.isNotBlank(errorMsg) && errorMsg.contains("not exist")){
return faceAdd(bfUser);
}
return "更新失败:" + bfUser.getUserId() + " ," + result.optString("error_msg");
}
}else{
return "更新失败:图片编码失败";
}
}catch (Exception e){
e.printStackTrace();
return "更新异常:"+e.getMessage();
}
}
// 人脸删除
public static String faceDelete(String userId,String groupId) {
JSONObject result = BaiduFaceManageUtils.faceDelete(userId,groupId);
long errorCode = result.getLong("error_code");
if (errorCode==0) {
return "删除成功:" + userId + " 删除成功";
} else {
return "删除失败:" + groupId + " ," + result.optString("error_msg");
}
}
}

View File

@ -11,7 +11,7 @@ public class OcrService {
public static final String TOKEN_URL="https://aip.baidubce.com/oauth/2.0/token";
public static final String OCR_URL="https://aip.baidubce.com/rest/2.0/ocr/v1/idcard";
public static final String APP_ID = "6283230";
public static final String APP_ID = "117160042";
public static final String APP_KEY="rS40xCCuGuVNFRopPI0jlMuj";
public static final String APP_SECRET="3bY7dADqQq3O4UpXpFA1FJAj6LN57QCS";

View File

@ -0,0 +1,81 @@
package com.yanzhu.common.core.utils.bean;
import com.alibaba.fastjson2.JSON;
import java.util.HashMap;
import java.util.Map;
public class BaiduFaceUserInfo {
public BaiduFaceUserInfo(String userId, String userName, String groupId, String image) {
this.userId = userId;
this.groupId = groupId;
this.image = image;
this.userInfo=new HashMap<>();
this.userInfo.put("userId", userId);
this.userInfo.put("userName", userName);
this.userInfo.put("projectId", groupId);
}
public BaiduFaceUserInfo(String userId, String groupId, String image) {
this.userId = userId;
this.groupId = groupId;
this.image = image;
this.userInfo=new HashMap<>();
}
public BaiduFaceUserInfo() {
this.userInfo=new HashMap<>();
}
private String userId;
private String groupId;
private String image;
private double similarity;
public double getSimilarity() {
return similarity;
}
public void setSimilarity(double similarity) {
this.similarity = similarity;
}
public String getUserId() {
return userId;
}
public void setUserId(String userId) {
this.userId = userId;
}
public String getGroupId() {
return groupId;
}
public void setGroupId(String groupId) {
this.groupId = groupId;
}
public String getImage() {
return image;
}
public void setImage(String image) {
this.image = image;
}
private Map<String, Object> userInfo;
public Map<String, Object> getUserInfo() {
return userInfo;
}
public void setUserInfo(Map<String, Object> userInfo) {
this.userInfo = userInfo;
}
public String getUserInfoStr() {
return JSON.toJSONString(userInfo);
}
}

View File

@ -0,0 +1,49 @@
package com.yanzhu.services;
import com.yanzhu.manage.domain.ProProjectInfoSubdeptsUsers;
import com.yanzhu.system.api.domain.SysUser;
public interface IBaiduFaceService {
/**
*
* @param user
* @return
*/
String addSysUser(SysUser user);
/**
*
* @param user
* @return
*/
String updateSysUser(SysUser user);
/**
*
* @param userIds
* @return
*/
String deleteSysUser(Long[] userIds);
/**
*
* @param proProjectInfoSubdeptsUsers
* @return
*/
String updateProUser(ProProjectInfoSubdeptsUsers proProjectInfoSubdeptsUsers);
/**
*
* @param ids
* @return
*/
String deleteProUser(Long[] ids);
/**
*
* @param proProjectInfoSubdeptsUsers
* @return
*/
String addProUser(ProProjectInfoSubdeptsUsers proProjectInfoSubdeptsUsers);
}

View File

@ -0,0 +1,158 @@
package com.yanzhu.services.impl;
import com.yanzhu.common.core.utils.BaiduFaceSimilarityUtils;
import com.yanzhu.common.core.utils.bean.BaiduFaceUserInfo;
import com.yanzhu.common.core.utils.StringUtils;
import com.yanzhu.manage.domain.ProProjectInfoSubdeptsUsers;
import com.yanzhu.manage.mapper.ProProjectInfoSubdeptsUsersMapper;
import com.yanzhu.services.IBaiduFaceService;
import com.yanzhu.system.api.domain.SysUser;
import com.yanzhu.system.mapper.SysUserMapper;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
@Service
public class BaiduFaceService implements IBaiduFaceService {
@Autowired
private SysUserMapper sysUserMapper;
@Autowired
private ProProjectInfoSubdeptsUsersMapper proProjectInfoSubdeptsUsersMapper;
/**
*
* @param user
* @return
*/
@Override
public String addSysUser(SysUser user) {
if(StringUtils.isEmpty(user.getAvatar())){
return "失败:无照片";
}
BaiduFaceUserInfo bfUser = new BaiduFaceUserInfo();
bfUser.setUserId("S"+user.getUserId());
bfUser.setGroupId("G"+user.getDeptId());
bfUser.setImage(user.getAvatar());
bfUser.getUserInfo().put("userName", user.getUserName());
bfUser.getUserInfo().put("userId", user.getUserId());
bfUser.getUserInfo().put("projectId", user.getDeptId());
bfUser.getUserInfo().put("phone", user.getPhonenumber());
bfUser.getUserInfo().put("cardCode", user.getCardCode());
return BaiduFaceSimilarityUtils.faceAdd(bfUser);
}
/**
*
* @param user
* @return
*/
@Override
public String updateSysUser(SysUser user) {
if(StringUtils.isEmpty(user.getAvatar())){
return "失败:无照片";
}
SysUser oldUser=sysUserMapper.selectUserByUserId(user.getUserId());
if(oldUser==null){
return "失败:用户不存在";
}
if(StringUtils.equals(oldUser.getAvatar(),user.getAvatar())){
return "失败:照片未改变";
}
BaiduFaceUserInfo bfUser = new BaiduFaceUserInfo();
bfUser.setUserId("S"+user.getUserId());
bfUser.setGroupId("G"+user.getDeptId());
bfUser.setImage(user.getAvatar());
bfUser.getUserInfo().put("userName", user.getUserName());
bfUser.getUserInfo().put("userId", user.getUserId());
bfUser.getUserInfo().put("projectId", user.getDeptId());
bfUser.getUserInfo().put("phone", user.getPhonenumber());
bfUser.getUserInfo().put("cardCode", user.getCardCode());
return BaiduFaceSimilarityUtils.faceUpdate(bfUser);
}
/**
*
* @param userIds
* @return
*/
@Override
public String deleteSysUser(Long[] userIds) {
for(Long userId:userIds){
SysUser user=sysUserMapper.selectUserByUserId(userId);
if(user!=null){
BaiduFaceSimilarityUtils.faceDelete("S"+user.getUserId(),"G"+user.getDeptId());
}
}
return "删除成功";
}
/**
*
* @param proProjectInfoSubdeptsUsers
* @return
*/
@Override
public String updateProUser(ProProjectInfoSubdeptsUsers proProjectInfoSubdeptsUsers) {
if(StringUtils.isEmpty(proProjectInfoSubdeptsUsers.getUserPicture())){
return "失败:无照片";
}
ProProjectInfoSubdeptsUsers oldUser=proProjectInfoSubdeptsUsersMapper.selectProProjectInfoSubdeptsUsersById(proProjectInfoSubdeptsUsers.getId());
if(oldUser==null){
return "失败:用户不存在";
}
if(StringUtils.equals(oldUser.getUserPicture(),proProjectInfoSubdeptsUsers.getUserPicture())){
return "失败:照片未改变";
}
BaiduFaceUserInfo bfUser = new BaiduFaceUserInfo();
bfUser.setUserId("P"+proProjectInfoSubdeptsUsers.getUserId());
bfUser.setGroupId("G"+proProjectInfoSubdeptsUsers.getProjectId());
bfUser.setImage(proProjectInfoSubdeptsUsers.getUserPicture());
bfUser.getUserInfo().put("userName", proProjectInfoSubdeptsUsers.getUserName());
bfUser.getUserInfo().put("userId", proProjectInfoSubdeptsUsers.getUserId());
bfUser.getUserInfo().put("projectId", proProjectInfoSubdeptsUsers.getProjectId());
bfUser.getUserInfo().put("phone", proProjectInfoSubdeptsUsers.getUserPhone());
bfUser.getUserInfo().put("cardCode", proProjectInfoSubdeptsUsers.getCardCode());
return BaiduFaceSimilarityUtils.faceUpdate(bfUser);
}
/**
*
* @param userIds
* @return
*/
@Override
public String deleteProUser(Long[] userIds) {
for(Long userId:userIds){
ProProjectInfoSubdeptsUsers user=proProjectInfoSubdeptsUsersMapper.selectProProjectInfoSubdeptsUsersById(userId);
if(user!=null){
BaiduFaceSimilarityUtils.faceDelete("P"+user.getUserId(),"G"+user.getProjectId());
}
}
return "删除成功";
}
/**
*
* @param proProjectInfoSubdeptsUsers
* @return
*/
@Override
public String addProUser(ProProjectInfoSubdeptsUsers proProjectInfoSubdeptsUsers) {
if(StringUtils.isEmpty(proProjectInfoSubdeptsUsers.getUserPicture())){
return "失败:无照片";
}
BaiduFaceUserInfo bfUser = new BaiduFaceUserInfo();
bfUser.setUserId("P"+proProjectInfoSubdeptsUsers.getUserId());
bfUser.setGroupId("G"+proProjectInfoSubdeptsUsers.getProjectId());
bfUser.setImage(proProjectInfoSubdeptsUsers.getUserPicture());
bfUser.getUserInfo().put("userName", proProjectInfoSubdeptsUsers.getUserName());
bfUser.getUserInfo().put("userId", proProjectInfoSubdeptsUsers.getUserId());
bfUser.getUserInfo().put("projectId", proProjectInfoSubdeptsUsers.getProjectId());
bfUser.getUserInfo().put("phone", proProjectInfoSubdeptsUsers.getUserPhone());
bfUser.getUserInfo().put("cardCode", proProjectInfoSubdeptsUsers.getCardCode());
return BaiduFaceSimilarityUtils.faceAdd(bfUser);
}
}

View File

@ -165,6 +165,8 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
<select id="selectProProjectInfoSubdeptsUsersByParamId" resultMap="ProProjectInfoSubdeptsUsersResult">
<include refid="selectProProjectInfoSubdeptsUsersVo"/>
where psu.project_id = #{proId} and psu.user_id = #{userId}
order by ifnull(psu.update_time, date('2099-12-31')) desc,psu.create_time desc
limit 1
</select>
<insert id="insertProProjectInfoSubdeptsUsers" parameterType="ProProjectInfoSubdeptsUsers" useGeneratedKeys="true" keyProperty="id">

View File

@ -7,6 +7,7 @@ import net.hasor.spring.boot.EnableHasor;
import net.hasor.spring.boot.EnableHasorWeb;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.context.annotation.ComponentScan;
/**
*
@ -17,6 +18,7 @@ import org.springframework.boot.autoconfigure.SpringBootApplication;
@EnableCustomSwagger2
@EnableRyFeignClients
@SpringBootApplication
@ComponentScan(basePackages = {"com.yanzhu"})
@EnableHasor()
@EnableHasorWeb()
public class YanZhuManageApplication

View File

@ -4,7 +4,9 @@ import java.util.List;
import java.io.IOException;
import javax.servlet.http.HttpServletResponse;
import cn.hutool.core.util.NumberUtil;
import com.yanzhu.common.core.utils.BaiduFaceSimilarityUtils;
import com.yanzhu.common.core.utils.bean.BaiduFaceUserInfo;
import com.yanzhu.common.core.utils.poi.ExcelUtil;
import com.yanzhu.common.core.web.controller.BaseController;
import com.yanzhu.common.core.web.domain.AjaxResult;
@ -129,17 +131,13 @@ public class ProMobileAttendanceConfigController extends BaseController
@PostMapping("/attendance")
public AjaxResult attendance(@RequestBody ProMobileAttendanceData attData){
//根据用户上传的照片与用户信息的照片计算相似度
String userPicture =attData.getBasePath()+ attData.getUserPicture();
String attImg=attData.getBasePath()+attData.getAttImg();
// 使用专门为人脸识别考勤优化的相似度计算
double similarity = BaiduFaceSimilarityUtils.calculateFaceSimilarity(userPicture, attImg);
System.out.println("相似度:"+similarity);
String attImg=attData.getAttImg();
double threshold=BaiduFaceSimilarityUtils.SIMILARITY_THRESHOLD;
if (similarity >= threshold) {
BaiduFaceUserInfo baiduFaceUserInfo=BaiduFaceSimilarityUtils.findFaceSimilarityWithFaceLibrary(attImg,"G"+attData.getProjectId());
double similarity =baiduFaceUserInfo!=null? baiduFaceUserInfo.getSimilarity():0;
if (baiduFaceUserInfo!=null) {
// 相似度达标,允许考勤
attData.setUserId(NumberUtil.parseLong(baiduFaceUserInfo.getUserInfo().get("userId").toString()));
int cnt=attendanceUbiDataService.addMobiileAttendanceData(attData);
attData.setAttDevice("mobile");
cnt+=proMobileAttendanceDataService.insertProMobileAttendanceData(attData);

View File

@ -8,7 +8,6 @@ import com.yanzhu.manage.domain.ProCostOutput;
import com.yanzhu.manage.mapper.ProCostOutputMapper;
import com.yanzhu.manage.service.IProCostOutputService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.actuate.web.mappings.MappingsEndpoint;
import org.springframework.stereotype.Service;
/**
@ -22,8 +21,7 @@ public class ProCostOutputServiceImpl implements IProCostOutputService
{
@Autowired
private ProCostOutputMapper proCostOutputMapper;
@Autowired
private MappingsEndpoint mappingsEndpoint;
/**
*

View File

@ -23,6 +23,7 @@ import com.yanzhu.manage.utils.pdf.FileUtil;
import com.yanzhu.manage.utils.pdf.PdfImageSignetUtil;
import com.yanzhu.manage.utils.pdf.PoiUtil;
import com.yanzhu.security.utils.DictUtils;
import com.yanzhu.services.IBaiduFaceService;
import com.yanzhu.system.api.RemoteFlowService;
import com.yanzhu.system.api.RemoteUserService;
import com.yanzhu.system.api.domain.SysUser;
@ -90,6 +91,8 @@ public class ProProjectInfoSubdeptsUsersServiceImpl implements IProProjectInfoSu
@Autowired
private IProUserInoutRecordService iProUserInoutRecordService;
@Autowired
private IBaiduFaceService baiduFaceService;
private static final Logger log = LoggerFactory.getLogger(ProProjectInfoSubdeptsUsersServiceImpl.class);
@ -156,6 +159,7 @@ public class ProProjectInfoSubdeptsUsersServiceImpl implements IProProjectInfoSu
proProjectInfoSubdeptsUsers.setSubDeptName(proProjectInfo.getProjectName());
}
}
baiduFaceService.addProUser(proProjectInfoSubdeptsUsers);
return proProjectInfoSubdeptsUsersMapper.insertProProjectInfoSubdeptsUsers(proProjectInfoSubdeptsUsers);
}
/**
@ -279,7 +283,7 @@ public class ProProjectInfoSubdeptsUsersServiceImpl implements IProProjectInfoSu
FileUtil.copyFile(file,new File(savePath));
}
proProjectInfoSubdeptsUsers.setQrCode(profilePath);
proProjectInfoSubdeptsUsersMapper.updateProProjectInfoSubdeptsUsers(proProjectInfoSubdeptsUsers);
updateProjectInfoSubdeptsUsers(proProjectInfoSubdeptsUsers);
}catch (Exception e){
log.error(e.getMessage());
}
@ -348,7 +352,7 @@ public class ProProjectInfoSubdeptsUsersServiceImpl implements IProProjectInfoSu
deptUser.setUserPicture(proProjectInfoSubdeptsUsers.getUserPicture());
deptUser.setUpdateBy(SecurityUtils.getUsername());
deptUser.setUpdateTime(DateUtils.getNowDate());
proProjectInfoSubdeptsUsersMapper.updateProProjectInfoSubdeptsUsers(deptUser);
updateProjectInfoSubdeptsUsers(deptUser);
/**
* ...
*/
@ -383,7 +387,7 @@ public class ProProjectInfoSubdeptsUsersServiceImpl implements IProProjectInfoSu
if(oldUserData.getApproveStatus()==ApproveStatus.refuse.getCode()){
// 删除用户冗余数据...
oldUserData.setIsDel(IsDelEnums.DEL.getCode());
proProjectInfoSubdeptsUsersMapper.updateProProjectInfoSubdeptsUsers(oldUserData);
updateProjectInfoSubdeptsUsers(oldUserData);
}else{
throw new ServiceException("手机号码已存在");
}
@ -707,14 +711,14 @@ public class ProProjectInfoSubdeptsUsersServiceImpl implements IProProjectInfoSu
FileUtil.copyFile(file,new File(savePath));
}
proProjectInfoSubdeptsUsers.setQrCode(profilePath);
return proProjectInfoSubdeptsUsersMapper.updateProProjectInfoSubdeptsUsers(proProjectInfoSubdeptsUsers);
return updateProjectInfoSubdeptsUsers(proProjectInfoSubdeptsUsers);
}catch (Exception e){
log.error(e.getMessage());
}
}
}
}
return proProjectInfoSubdeptsUsersMapper.updateProProjectInfoSubdeptsUsers(proProjectInfoSubdeptsUsers);
return updateProjectInfoSubdeptsUsers(proProjectInfoSubdeptsUsers);
}
/**
@ -750,7 +754,7 @@ public class ProProjectInfoSubdeptsUsersServiceImpl implements IProProjectInfoSu
}
user.setUseStatus(status);
iProUserInoutRecordService.addRecord(user);
return proProjectInfoSubdeptsUsersMapper.updateProProjectInfoSubdeptsUsers(user);
return updateProjectInfoSubdeptsUsers(user);
}
/**
@ -994,10 +998,14 @@ public class ProProjectInfoSubdeptsUsersServiceImpl implements IProProjectInfoSu
sysUser.setActiveProjectId(proProjectInfoSubdeptsUsers.getProjectId());
remoteUserService.registerUserInfo(sysUser, SecurityConstants.INNER);
proProjectInfoSubdeptsUsersMapper.updateProProjectInfoSubdeptsUsers(proProjectInfoSubdeptsUsers);
updateProjectInfoSubdeptsUsers(proProjectInfoSubdeptsUsers);
return proProjectInfoSubdeptsUsers;
}
public int updateProjectInfoSubdeptsUsers(ProProjectInfoSubdeptsUsers proProjectInfoSubdeptsUsers){
baiduFaceService.updateProUser(proProjectInfoSubdeptsUsers);
return proProjectInfoSubdeptsUsersMapper.updateProProjectInfoSubdeptsUsers(proProjectInfoSubdeptsUsers);
}
/**
*
*
@ -1010,6 +1018,7 @@ public class ProProjectInfoSubdeptsUsersServiceImpl implements IProProjectInfoSu
for(Long id:ids){
uniService.syncUserRevoke(id);
}
baiduFaceService.deleteProUser(ids);
return proProjectInfoSubdeptsUsersMapper.deleteProProjectInfoSubdeptsUsersByIds(ids);
}
@ -1023,6 +1032,7 @@ public class ProProjectInfoSubdeptsUsersServiceImpl implements IProProjectInfoSu
public int deleteProProjectInfoSubdeptsUsersById(Long id)
{
uniService.syncUserRevoke(id);
baiduFaceService.deleteProUser(new Long[]{id});
return proProjectInfoSubdeptsUsersMapper.deleteProProjectInfoSubdeptsUsersById(id);
}
@ -1130,7 +1140,7 @@ public class ProProjectInfoSubdeptsUsersServiceImpl implements IProProjectInfoSu
}
}
int res = proProjectInfoSubdeptsUsersMapper.updateProProjectInfoSubdeptsUsers(proSubdeptsUser);
int res = updateProjectInfoSubdeptsUsers(proSubdeptsUser);
// 保存业务签名
basSignetMapper.deleteBasSignetByParams(proSubdeptsUser.getProjectId(),proSubdeptsUser.getUserId());
@ -1286,7 +1296,7 @@ public class ProProjectInfoSubdeptsUsersServiceImpl implements IProProjectInfoSu
proProjectInfoSubdeptsUsers.setUseStatus(UseStateEnums.IN.getCode());
proProjectInfoSubdeptsUsers.setUseDate(DateUtils.getNowDate());
proProjectInfoSubdeptsUsers.setApproveStatus(ApproveStatus.exempt.getCode());
proProjectInfoSubdeptsUsersMapper.updateProProjectInfoSubdeptsUsers(proProjectInfoSubdeptsUsers);
updateProjectInfoSubdeptsUsers(proProjectInfoSubdeptsUsers);
// 人员入场信息
uniService.syncUniUser(proProjectInfoSubdeptsUsers,true);
}
@ -1324,7 +1334,7 @@ public class ProProjectInfoSubdeptsUsersServiceImpl implements IProProjectInfoSu
}
if(flag){
proProjectInfoSubdeptsUsers.setEduFilePath(newFilePath.replace(ProfileConfig.profilePath,ProfileConfig.profile));
proProjectInfoSubdeptsUsersMapper.updateProProjectInfoSubdeptsUsers(proProjectInfoSubdeptsUsers);
updateProjectInfoSubdeptsUsers(proProjectInfoSubdeptsUsers);
}
}
}
@ -1360,7 +1370,7 @@ public class ProProjectInfoSubdeptsUsersServiceImpl implements IProProjectInfoSu
}
if(flag){
proProjectInfoSubdeptsUsers.setEduFilePath(newFilePath.replace(ProfileConfig.profilePath,ProfileConfig.profile));
proProjectInfoSubdeptsUsersMapper.updateProProjectInfoSubdeptsUsers(proProjectInfoSubdeptsUsers);
updateProjectInfoSubdeptsUsers(proProjectInfoSubdeptsUsers);
}
}
}
@ -1396,7 +1406,7 @@ public class ProProjectInfoSubdeptsUsersServiceImpl implements IProProjectInfoSu
}
if(flag){
proProjectInfoSubdeptsUsers.setEduFilePath(newFilePath.replace(ProfileConfig.profilePath,ProfileConfig.profile));
proProjectInfoSubdeptsUsersMapper.updateProProjectInfoSubdeptsUsers(proProjectInfoSubdeptsUsers);
updateProjectInfoSubdeptsUsers(proProjectInfoSubdeptsUsers);
}
}
}
@ -1483,7 +1493,7 @@ public class ProProjectInfoSubdeptsUsersServiceImpl implements IProProjectInfoSu
try {
ProProjectInfoSubdeptsUsers proProjectInfoSubdeptsUsers = proProjectInfoSubdeptsUsersMapper.selectProProjectInfoSubdeptsUsersById(proUserId);
proProjectInfoSubdeptsUsers.setApproveStatus(ApproveStatus.refuse.getCode());
proProjectInfoSubdeptsUsersMapper.updateProProjectInfoSubdeptsUsers(proProjectInfoSubdeptsUsers);
updateProjectInfoSubdeptsUsers(proProjectInfoSubdeptsUsers);
}catch (Exception e){
e.printStackTrace();
}
@ -1578,7 +1588,7 @@ public class ProProjectInfoSubdeptsUsersServiceImpl implements IProProjectInfoSu
if(res>0){
ProProjectInfoSubdeptsUsers proProjectInfoSubdeptsUsers = proProjectInfoSubdeptsUsersMapper.selectProProjectInfoSubdeptsUsersByParamId(id,userId);
proProjectInfoSubdeptsUsers.setSortBy(0L);
res = proProjectInfoSubdeptsUsersMapper.updateProProjectInfoSubdeptsUsers(proProjectInfoSubdeptsUsers);
res = updateProjectInfoSubdeptsUsers(proProjectInfoSubdeptsUsers);
}
boolean isAdmin= (SecurityUtils.isAdmin(userId) || SecurityUtils.isGSAdmin());
@ -1709,7 +1719,7 @@ public class ProProjectInfoSubdeptsUsersServiceImpl implements IProProjectInfoSu
}
if(flag){
proProjectInfoSubdeptsUsers.setEduFilePath(newFilePath.replace(ProfileConfig.profilePath,ProfileConfig.profile));
proProjectInfoSubdeptsUsersMapper.updateProProjectInfoSubdeptsUsers(proProjectInfoSubdeptsUsers);
updateProjectInfoSubdeptsUsers(proProjectInfoSubdeptsUsers);
}
}else{
throw new ServiceException("未查询三级安全教育主管签名信息...");

View File

@ -5,6 +5,7 @@ import org.springframework.boot.autoconfigure.SpringBootApplication;
import com.yanzhu.common.security.annotation.EnableCustomConfig;
import com.yanzhu.common.security.annotation.EnableRyFeignClients;
import com.yanzhu.common.swagger.annotation.EnableCustomSwagger2;
import org.springframework.context.annotation.ComponentScan;
/**
*
@ -14,6 +15,7 @@ import com.yanzhu.common.swagger.annotation.EnableCustomSwagger2;
@EnableCustomConfig
@EnableCustomSwagger2
@EnableRyFeignClients
@ComponentScan(basePackages = {"com.yanzhu"})
@SpringBootApplication
public class YanZhuSystemApplication
{

View File

@ -19,6 +19,7 @@ import com.yanzhu.common.security.service.TokenService;
import com.yanzhu.common.security.utils.SecurityUtils;
import com.yanzhu.manage.domain.AttendanceCfg;
import com.yanzhu.manage.mapper.AttendanceCfgMapper;
import com.yanzhu.services.IBaiduFaceService;
import com.yanzhu.system.api.domain.SysDept;
import com.yanzhu.system.api.domain.SysRole;
import com.yanzhu.system.api.domain.SysUser;
@ -77,6 +78,8 @@ public class SysUserController extends BaseController {
@Autowired
private AttendanceCfgMapper attendanceCfgMapper;
@Autowired
private IBaiduFaceService baiduFaceService;
/**
*
*/
@ -377,7 +380,9 @@ public class SysUserController extends BaseController {
}*/
user.setCreateBy(SecurityUtils.getUsername());
user.setPassword(SecurityUtils.encryptPassword(user.getPassword()));
return toAjax(userService.insertUser(user));
AjaxResult result= toAjax(userService.insertUser(user));
baiduFaceService.addSysUser(user);
return result;
}
/**
@ -386,7 +391,9 @@ public class SysUserController extends BaseController {
@Log(title = "用户管理", businessType = BusinessType.INSERT)
@PostMapping("/addUser")
public AjaxResult addUser(@Validated @RequestBody SysUser user) {
return toAjax(userService.insertUserWx(user));
AjaxResult result= toAjax(userService.insertUserWx(user));
baiduFaceService.addSysUser(user);
return result;
}
@GetMapping("/getUserByName/{userName}")
@ -409,6 +416,7 @@ public class SysUserController extends BaseController {
return error("修改用户'" + user.getUserName() + "'失败,邮箱账号已存在");
}
user.setUpdateBy(SecurityUtils.getUsername());
baiduFaceService.updateSysUser(user);
return toAjax(userService.updateUser(user));
}
@ -422,6 +430,7 @@ public class SysUserController extends BaseController {
if (ArrayUtils.contains(userIds, SecurityUtils.getUserId())) {
return error("当前用户不能删除");
}
baiduFaceService.deleteSysUser(userIds);
return toAjax(userService.deleteUserByIds(userIds));
}

View File

@ -30,7 +30,7 @@ Page({
uuid: "",
codeUrl: "",
checked: true,
logo: config.baseImgUrl + "/cdn/app_logo.png",
logo: config.baseImgUrl + "/cdn/app_logo.png?v=20250922",
},
//获取填写的账号信息