| | |
| | | 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; |
| | |
| | | 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; |
| | |
| | | @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 |