|
|
@@ -6,6 +6,8 @@ import com.doc.biz.service.IDocDirService;
|
|
|
import com.doc.biz.service.IDocDirUserService;
|
|
|
import com.doc.biz.service.IDocSpaceService;
|
|
|
import com.doc.common.annotation.Log;
|
|
|
+import com.doc.common.config.RuoYiConfig;
|
|
|
+import com.doc.common.constant.Constants;
|
|
|
import com.doc.common.core.controller.BaseController;
|
|
|
import com.doc.common.core.domain.AjaxResult;
|
|
|
import com.doc.common.core.domain.entity.SysDept;
|
|
|
@@ -18,7 +20,10 @@ import com.doc.common.utils.SecurityUtils;
|
|
|
import com.doc.common.utils.StringUtils;
|
|
|
import com.doc.common.utils.bean.BeanUtils;
|
|
|
import com.doc.common.utils.encrypt.Sm2Util;
|
|
|
+import com.doc.common.utils.file.FileUploadUtils;
|
|
|
+import com.doc.common.utils.file.MimeTypeUtils;
|
|
|
import com.doc.common.utils.poi.ExcelUtil;
|
|
|
+import com.doc.face.service.IFaceService;
|
|
|
import com.doc.system.service.ISysDeptService;
|
|
|
import com.doc.system.service.ISysPostService;
|
|
|
import com.doc.system.service.ISysRoleService;
|
|
|
@@ -35,6 +40,7 @@ import org.springframework.web.multipart.MultipartFile;
|
|
|
|
|
|
import javax.annotation.Resource;
|
|
|
import javax.servlet.http.HttpServletResponse;
|
|
|
+import java.io.File;
|
|
|
import java.util.ArrayList;
|
|
|
import java.util.List;
|
|
|
import java.util.stream.Collectors;
|
|
|
@@ -65,6 +71,8 @@ public class SysUserController extends BaseController {
|
|
|
private IDocDirUserService dirUserService;
|
|
|
@Resource
|
|
|
private IDocDirService dirService;
|
|
|
+ @Resource
|
|
|
+ private IFaceService faceService;
|
|
|
|
|
|
/**
|
|
|
* 获取用户列表
|
|
|
@@ -273,6 +281,34 @@ public class SysUserController extends BaseController {
|
|
|
return success(message);
|
|
|
}
|
|
|
|
|
|
+ @Log(title = "用户管理", businessType = BusinessType.IMPORT)
|
|
|
+ @PreAuthorize("@ss.hasPermi('system:user:face')")
|
|
|
+ @PostMapping("/importFace")
|
|
|
+ public AjaxResult importFace(MultipartFile file) throws Exception {
|
|
|
+ AjaxResult ajax = AjaxResult.success();
|
|
|
+ if (!file.isEmpty()) {
|
|
|
+ String fileName = file.getOriginalFilename();
|
|
|
+ String[] tmp = fileName.split("\\.");
|
|
|
+ tmp = tmp[0].split("-");
|
|
|
+ if (tmp.length > 1) {
|
|
|
+ Long userId = Long.parseLong(tmp[1]);
|
|
|
+ SysUser user = userService.selectUserById(userId);
|
|
|
+ String avatar = FileUploadUtils.upload(RuoYiConfig.getAvatarPath(), file, MimeTypeUtils.IMAGE_EXTENSION);
|
|
|
+ if (userService.updateUserAvatar(user.getUserName(), avatar)) {
|
|
|
+ // 本地资源路径
|
|
|
+ String localPath = RuoYiConfig.getProfile();
|
|
|
+ // 数据库资源地址
|
|
|
+ String path = localPath + StringUtils.substringAfter(avatar, Constants.RESOURCE_PREFIX);
|
|
|
+ boolean flag = faceService.detectFaces(userId, new File(path));
|
|
|
+ ajax.put("face", flag);
|
|
|
+ ajax.put("name", user.getNickName());
|
|
|
+ return ajax;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ return error();
|
|
|
+ }
|
|
|
+
|
|
|
@PostMapping("/importTemplate")
|
|
|
public void importTemplate(HttpServletResponse response) {
|
|
|
ExcelUtil<SysUser> util = new ExcelUtil<SysUser>(SysUser.class);
|