فهرست منبع

feat&fix: 等待eval和coder的接口更新

mjh 4 سال پیش
والد
کامیت
d2fb93a050

+ 1 - 0
seecoder-portal-server/src/main/java/cn/seecoder/seecoderportalserver/config/SpringSecurityConfiguration.java

@@ -70,6 +70,7 @@ public class SpringSecurityConfiguration extends WebSecurityConfigurerAdapter {
                         "/api/course/student",
                         "/api/course/student",
                         "/api/course/example",
                         "/api/course/example",
                         "/api/course/getCourseByCoderId",
                         "/api/course/getCourseByCoderId",
+                        "/api/course/getCourseByEvalId",
                         "/api/course/selection/confirm",
                         "/api/course/selection/confirm",
                         "/api/course/selection/cancel",
                         "/api/course/selection/cancel",
                         "/api/course/checkName",
                         "/api/course/checkName",

+ 2 - 0
seecoder-portal-server/src/main/java/cn/seecoder/seecoderportalserver/repository/CourseRepository.java

@@ -18,4 +18,6 @@ public interface CourseRepository extends JpaRepository<Course, Long> {
     Optional<Course> findCourseByCoderId(Integer coderId);
     Optional<Course> findCourseByCoderId(Integer coderId);
 
 
     Optional<Course> findCourseByInvitationCode(String code);
     Optional<Course> findCourseByInvitationCode(String code);
+
+    Optional<Course> findCourseByEvalId(Integer evalId);
 }
 }

+ 8 - 3
seecoder-portal-server/src/main/java/cn/seecoder/seecoderportalserver/service/CourseService.java

@@ -139,9 +139,9 @@ public class CourseService {
                 .collect(Collectors.toList());
                 .collect(Collectors.toList());
     }
     }
 
 
-    public CourseVO getCourseByCoderId(Integer coderId) {
+    public Long getCourseByCoderId(Integer coderId) {
         Course course = courseRepository.findCourseByCoderId(coderId).orElseThrow(CustomErrorException::courseNotFound);
         Course course = courseRepository.findCourseByCoderId(coderId).orElseThrow(CustomErrorException::courseNotFound);
-        return courseMapper.courseToCourseVO(course);
+        return course.getState() == ObjectState.DELETED ? null : courseMapper.courseToCourseVO(course).getId();
     }
     }
 
 
     public Boolean checkCourseNameUnique(Long id, String name) {
     public Boolean checkCourseNameUnique(Long id, String name) {
@@ -151,7 +151,7 @@ public class CourseService {
 
 
     public CourseVO getCourseById(Long id) {
     public CourseVO getCourseById(Long id) {
         Course course = courseRepository.findById(id).orElseThrow(CustomErrorException::courseNotFound);
         Course course = courseRepository.findById(id).orElseThrow(CustomErrorException::courseNotFound);
-        return courseMapper.courseToCourseVO(course);
+        return course.getState() == ObjectState.DELETED ? null : courseMapper.courseToCourseVO(course);
     }
     }
 
 
     public String confirmCourseSelection(CourseSelectionKey courseSelectionKey, Long userId) {
     public String confirmCourseSelection(CourseSelectionKey courseSelectionKey, Long userId) {
@@ -203,4 +203,9 @@ public class CourseService {
         Course course = courseRepository.findCourseByInvitationCode(code).orElse(null);
         Course course = courseRepository.findCourseByInvitationCode(code).orElse(null);
         return course == null || course.getId().equals(id);
         return course == null || course.getId().equals(id);
     }
     }
+
+    public Long getCourseByEvalId(int evalId) {
+        Course course = courseRepository.findCourseByEvalId(evalId).orElseThrow(CustomErrorException::courseNotFound);
+        return course.getState() == ObjectState.DELETED ? null : courseMapper.courseToCourseVO(course).getId();
+    }
 }
 }

+ 34 - 0
seecoder-portal-server/src/main/java/cn/seecoder/seecoderportalserver/service/ExamService.java

@@ -0,0 +1,34 @@
+package cn.seecoder.seecoderportalserver.service;
+
+import cn.seecoder.seecoderportalcommon.vo.CourseVO;
+import cn.seecoder.seecoderportalserver.service.Impl.CoderService;
+import cn.seecoder.seecoderportalserver.service.Impl.EvalService;
+import com.alibaba.fastjson.JSONArray;
+import com.alibaba.fastjson.JSONObject;
+import org.springframework.stereotype.Service;
+
+@Service
+public class ExamService {
+    private final CourseService courseService;
+    private final CoderService coderService;
+    private final EvalService evalService;
+
+    public ExamService(CourseService courseService, CoderService coderService, EvalService evalService) {
+        this.courseService = courseService;
+        this.coderService = coderService;
+        this.evalService = evalService;
+    }
+
+    public JSONObject getCoderRecommendExams() {
+        JSONObject result = new JSONObject();
+        result.put("res", new JSONArray());
+        for (CourseVO courseVO : courseService.getExampleCourses()) {
+
+        }
+        return result;
+    }
+
+    public JSONObject getEvalRecommendExams() {
+        return null;
+    }
+}

+ 6 - 1
seecoder-portal-server/src/main/java/cn/seecoder/seecoderportalserver/web/rest/CourseController.java

@@ -57,7 +57,7 @@ public class CourseController {
     }
     }
 
 
     @GetMapping("/getCourseByCoderId")
     @GetMapping("/getCourseByCoderId")
-    public OkResponse<CourseVO> getCourseByCoderId(@RequestParam Integer coderId) {
+    public OkResponse<Long> getCourseByCoderId(@RequestParam Integer coderId) {
         return OkResponse.of(courseService.getCourseByCoderId(coderId));
         return OkResponse.of(courseService.getCourseByCoderId(coderId));
     }
     }
 
 
@@ -85,4 +85,9 @@ public class CourseController {
     public OkResponse<Boolean> checkCourseCodeUnique(@RequestParam Long id, @RequestParam String code){
     public OkResponse<Boolean> checkCourseCodeUnique(@RequestParam Long id, @RequestParam String code){
         return OkResponse.of(courseService.checkCourseCodeUnique(id, code));
         return OkResponse.of(courseService.checkCourseCodeUnique(id, code));
     }
     }
+
+    @GetMapping("/getCourseByEvalId")
+    public OkResponse<Long> getCourseByEvalId(@RequestParam int evalId){
+        return OkResponse.of(courseService.getCourseByEvalId(evalId));
+    }
 }
 }

+ 28 - 0
seecoder-portal-server/src/main/java/cn/seecoder/seecoderportalserver/web/rest/ExamController.java

@@ -0,0 +1,28 @@
+package cn.seecoder.seecoderportalserver.web.rest;
+
+import cn.seecoder.seecoderportalserver.service.ExamService;
+import cn.seecoder.seecoderportalserver.utility.OkResponse;
+import com.alibaba.fastjson.JSONObject;
+import org.springframework.web.bind.annotation.GetMapping;
+import org.springframework.web.bind.annotation.RequestMapping;
+import org.springframework.web.bind.annotation.RestController;
+
+@RestController
+@RequestMapping("/api")
+public class ExamController {
+    private final ExamService examService;
+
+    public ExamController(ExamService examService) {
+        this.examService = examService;
+    }
+
+//    @GetMapping("/coder/exam/recommend")
+//    public OkResponse<JSONObject> getCoderRecommendExams() {
+//        return OkResponse.of(examService.getCoderRecommendExams());
+//    }
+
+//    @GetMapping("eval/exam/recommend")
+//    public OkResponse<JSONObject> getEvalRecommendExams() {
+//        return OkResponse.of(examService.getEvalRecommendExams());
+//    }
+}