From 28aaf2ffa1dbb860a292ba330a7e9362e60e7832 Mon Sep 17 00:00:00 2001
From: kongzy <kongzy>
Date: Fri, 12 Jul 2024 16:41:03 +0800
Subject: [PATCH] update
---
assess-system/src/main/java/com/gkhy/assess/system/service/impl/SysUserFaceServiceImpl.java | 31 +++++++++++++++++++++----------
1 files changed, 21 insertions(+), 10 deletions(-)
diff --git a/assess-system/src/main/java/com/gkhy/assess/system/service/impl/SysUserFaceServiceImpl.java b/assess-system/src/main/java/com/gkhy/assess/system/service/impl/SysUserFaceServiceImpl.java
index c384eb1..2114126 100644
--- a/assess-system/src/main/java/com/gkhy/assess/system/service/impl/SysUserFaceServiceImpl.java
+++ b/assess-system/src/main/java/com/gkhy/assess/system/service/impl/SysUserFaceServiceImpl.java
@@ -1,5 +1,7 @@
package com.gkhy.assess.system.service.impl;
+import com.gkhy.assess.common.exception.ApiException;
+import com.gkhy.assess.common.utils.StringUtils;
import com.gkhy.assess.system.domain.SysUser;
import com.gkhy.assess.system.domain.SysUserFace;
import com.gkhy.assess.system.domain.vo.UploadObjectVO;
@@ -8,6 +10,7 @@
import com.gkhy.assess.system.service.SysCommonService;
import com.gkhy.assess.system.service.SysUserFaceService;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
+import com.gkhy.assess.system.service.SysUserService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
@@ -25,20 +28,28 @@
@Autowired
private SysCommonService commonService;
@Autowired
- private SysUserMapper userMapper;
+ private SysUserService userService;
@Override
- @Transactional
- public int addUserFace(SysUserFace userFace) {
- int row=0;
- SysUserFace oldUserFace=baseMapper.getFaceByUserId(userFace.getUserId());
+ @Transactional(rollbackFor = RuntimeException.class)
+ public UploadObjectVO addUserFace(SysUserFace userFace) {
+
+ // SysUserFace oldUserFace=baseMapper.getFaceByUserId(userFace.getUserId());
UploadObjectVO uploadObjectVO =commonService.doUpload(userFace.getFile());
- if(oldUserFace==null){
- row= baseMapper.insert(userFace);
+ /*if(oldUserFace==null){
+ baseMapper.insert(userFace);
}else{
- row= baseMapper.updateById(new SysUserFace().setId(oldUserFace.getId()).setFaceBase(userFace.getFaceBase()));
+ baseMapper.updateById(new SysUserFace().setId(oldUserFace.getId()).setFaceBase(userFace.getFaceBase()));
+ }*/
+ boolean res=userService.updateById(new SysUser().setId(userFace.getUserId()).setIdPhoto(uploadObjectVO.getPath()));
+ if(!res){
+ throw new ApiException("人脸数据上传失败");
}
- userMapper.updateById(new SysUser().setId(userFace.getUserId()).setIdPhoto(uploadObjectVO.getPath()));
- return row;
+ SysUser sysUser=userService.getById(userFace.getUserId());
+ userService.delCacheByUsername(sysUser.getUsername(),sysUser.getIdentity());
+ if(StringUtils.isNotBlank(sysUser.getPhone())) {
+ userService.delCacheByUsername(sysUser.getPhone(), sysUser.getIdentity());
+ }
+ return uploadObjectVO;
}
@Override
--
Gitblit v1.9.2