Browse Source

add updatePhotoPath rpc api

deason 11 months ago
parent
commit
41c5097554

+ 24 - 4
examcloud-core-basic-api-provider/src/main/java/cn/com/qmth/examcloud/core/basic/api/provider/StudentCloudServiceProvider.java

@@ -24,6 +24,8 @@ import io.swagger.annotations.Api;
 import io.swagger.annotations.ApiOperation;
 import org.apache.commons.collections.CollectionUtils;
 import org.apache.commons.lang3.StringUtils;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.data.jpa.domain.Specification;
 import org.springframework.transaction.annotation.Transactional;
@@ -33,10 +35,7 @@ import org.springframework.web.bind.annotation.RequestMapping;
 import org.springframework.web.bind.annotation.RestController;
 
 import javax.persistence.criteria.Predicate;
-import java.util.ArrayList;
-import java.util.HashMap;
-import java.util.List;
-import java.util.Map;
+import java.util.*;
 
 /**
  * {@link StatusException} 状态码范围:056XXX<br>
@@ -52,6 +51,8 @@ public class StudentCloudServiceProvider extends ControllerSupport implements St
 
     private static final long serialVersionUID = -571041158847398070L;
 
+    private static final Logger log = LoggerFactory.getLogger(StudentCloudServiceProvider.class);
+
     @Autowired
     OrgRepo orgRepo;
 
@@ -209,6 +210,25 @@ public class StudentCloudServiceProvider extends ControllerSupport implements St
         return resp;
     }
 
+    @ApiOperation(value = "更新学生底照")
+    @PostMapping("updatePhotoPath")
+    @Transactional
+    @Override
+    public UpdatePhotoPathResp updatePhotoPath(@RequestBody UpdatePhotoPathReq req) {
+        StudentEntity student = GlobalHelper.getEntity(studentRepo, req.getStudentId(), StudentEntity.class);
+        if (student == null) {
+            log.warn("学生信息不存在!studentId:{}", req.getStudentId());
+            throw new StatusException("500404", "学生信息不存在!");
+        }
+
+        student.setPhotoPath(req.getPhotoPath());
+        student.setUpdateTime(new Date());
+        StudentEntity saved = studentRepo.save(student);
+        studentCache.remove(saved.getId());
+
+        return new UpdatePhotoPathResp();
+    }
+
     @ApiOperation(value = "更新学生状态")
     @PostMapping("updateStudentStatus")
     @Transactional