Crazy 8 bulan lalu
induk
melakukan
48c0c6852f

+ 1 - 2
yudao-module-md/yudao-module-md-biz/src/main/java/cn/iocoder/yudao/module/md/controller/admin/AcsController.java

@@ -273,11 +273,10 @@ public class AcsController {
             @Parameter(name = "employeeNo", description = "学号", required = true),
     })
     @PreAuthorize("@ss.hasPermission('md:acs:teacher-user-image:update')")
-    public CommonResult<String> teacherUpdateUserImage(@RequestParam("photoUrl") String photoUrl,
+    public CommonResult<String> teacherUpdateUserImage(@RequestParam(value = "photoUrl",required = false) String photoUrl,
                                                        @RequestParam("employeeNo") String employeeNo) {
         try {
             String result = acsService.teacherUpdateUserImage(employeeNo,photoUrl);
-            System.out.println(result);
             return CommonResult.success(result);
         } catch (Exception e) {
             return CommonResult.error(500, "导入过程中发生错误: " + e.getMessage());

+ 12 - 12
yudao-module-md/yudao-module-md-biz/src/main/java/cn/iocoder/yudao/module/md/service/AcsService.java

@@ -338,20 +338,20 @@ public class AcsService {
     //教师添加或更新照片
     @Transactional(rollbackFor = Exception.class)
     public String teacherUpdateUserImage(String employeeNo, String photoUrl) throws Exception {
-          AdminUserDO user = userService.findUserByUserNumber(employeeNo);
-            if (photoUrl == null || photoUrl.trim().isEmpty()){//提交的为空,删除人脸
+            AdminUserDO user = userService.findUserByUserNumber(employeeNo);
+            String result = getUser(employeeNo);
+            Gson gson = new Gson();
+            JsonObject jsonObject = gson.fromJson(result, JsonObject.class);
+            JsonArray userInfoArray = jsonObject
+                    .getAsJsonObject("UserInfoSearch")
+                    .getAsJsonArray("UserInfo");
+
+            if (photoUrl.trim().isEmpty()){//去除空格后为空,删除人脸
                 deleteFace(employeeNo);//考勤机里的
-                user.setPhotoUrl("");//同步更新user表里的
-                userService.updateUser((BeanUtils.toBean(user, UserSaveReqVO.class)));
+                user.setPhotoUrl(photoUrl.trim());//同步更新user表里的
+                userService.updateUser(BeanUtils.toBean(user, UserSaveReqVO.class));
                 return "删除照片成功";
             }else {
-                String result = getUser(employeeNo);
-                Gson gson = new Gson();
-                JsonObject jsonObject = gson.fromJson(result, JsonObject.class);
-                JsonArray userInfoArray = jsonObject
-                        .getAsJsonObject("UserInfoSearch")
-                        .getAsJsonArray("UserInfo");
-
                 if (userInfoArray != null) {
                     String msg = addFaceByUrl(employeeNo, photoUrl);
                     if (msg.contains("下发人脸成功") && msg.contains("但是有异常情况")) {
@@ -403,7 +403,7 @@ public class AcsService {
     public imageImportRespVO importImages(MultipartFile file) throws Exception {
         // 校验文件类型
         if (!file.getOriginalFilename().endsWith(".zip")) {
-            throw exception(UPLOADED_FOLDER_CANNOT_EMPTY);
+            throw exception(UPLOADED_FOLDER_NOT_ZIP);
         }
         // 创建临时目录存放解压后的文件
         File tempDir = Files.createTempDirectory("user_images").toFile();

+ 4 - 1
yudao-module-system/yudao-module-system-api/src/main/java/cn/iocoder/yudao/module/system/enums/ErrorCodeConstants.java

@@ -174,7 +174,10 @@ public interface ErrorCodeConstants {
     // ========== 照片 TODO 补充编号 ==========
     ErrorCode USER_PHOTOS_NOT_EXISTS = new ErrorCode(1_002_032_000, "用户照片不存在");
 
-    ErrorCode UPLOADED_FOLDER_CANNOT_EMPTY = new ErrorCode(1_002_032_001, "上传的文件夹为空!");
+    // ========== 上传文件 TODO 补充编号 ==========
+    ErrorCode UPLOADED_FOLDER_CANNOT_EMPTY = new ErrorCode(1_002_033_001, "上传的文件夹为空!");
+
+    ErrorCode UPLOADED_FOLDER_NOT_ZIP = new ErrorCode(1_002_033_001, "上传的文件格式不为zip!");
 
 
 }