소스 검색

教师功能仅差所授课程的考勤数据

bfzgs 2 년 전
부모
커밋
6eff093082

+ 1 - 0
final-gateway/src/main/java/org/brynhild/graduation/gateway/rule/config/AuthorityMap.groovy

@@ -15,6 +15,7 @@ class AuthorityMap {
         {
             put("/admin", Arrays.asList(AccountConstant.ADMIN))
             put("/student",Arrays.asList(AccountConstant.USER))
+            put("/teacher",Arrays.asList(AccountConstant.TEACHER))
 //        put("/system",AccountConstant.SYSTEM)
         }
     }

+ 2 - 0
final-persistence/src/main/java/org/brynhild/graduation/persistence/timetable/repository/TimeTableRepository.groovy

@@ -15,5 +15,7 @@ interface TimeTableRepository extends LogicDeleteRepository<TimeTable> {
 
     List<TimeTable> findTimeTableByClazz(String clazz);
 
+    List<TimeTable> findTimeTableByTeacher(Long teacher)
+
 
 }

+ 52 - 0
final-timetable/src/main/java/org/brynhild/graduation/timetable/controller/TeacherController.groovy

@@ -0,0 +1,52 @@
+package org.brynhild.graduation.timetable.controller
+
+import jakarta.annotation.Resource
+import org.brynhild.graduation.common.transfer.dto.Result
+import org.brynhild.graduation.common.utils.RequestBodyVerifier
+import org.brynhild.graduation.timetable.service.ITimeTableService
+import org.brynhild.graduation.transfer.timetable.vo.QueryTeachingClassRequest
+import org.brynhild.graduation.transfer.timetable.vo.QueryTimeTableRequest
+import org.springframework.beans.factory.annotation.Autowired
+import org.springframework.validation.BindingResult
+import org.springframework.validation.annotation.Validated
+import org.springframework.web.bind.annotation.PostMapping
+import org.springframework.web.bind.annotation.RequestBody
+import org.springframework.web.bind.annotation.RequestMapping
+import org.springframework.web.bind.annotation.RestController
+
+@RestController
+@RequestMapping("/teacher")
+class TeacherController {
+    private RequestBodyVerifier verifier
+    private ITimeTableService tableService
+
+    @PostMapping("/timetable")
+    Result queryStudentTimetable(@RequestBody @Validated QueryTimeTableRequest request, BindingResult result){
+        if(result.hasErrors()){
+            return verifier.convertToErrors(result);
+        }
+        return tableService.findTimeTable(request);
+    }
+
+    @PostMapping("/clazz")
+    Result queryTeachingClass(@RequestBody @Validated QueryTeachingClassRequest request,BindingResult result){
+        if(result.hasErrors()){
+            return verifier.convertToErrors(result);
+        }
+        println request
+        return tableService.queryTeachingClass(request)
+    }
+
+
+    @Autowired
+    @Resource
+    void setVerifier(RequestBodyVerifier verifier) {
+        this.verifier = verifier
+    }
+
+    @Autowired
+    @Resource
+    void setTableService(ITimeTableService tableService) {
+        this.tableService = tableService
+    }
+}

+ 3 - 0
final-timetable/src/main/java/org/brynhild/graduation/timetable/service/ITimeTableService.groovy

@@ -6,6 +6,7 @@ import org.brynhild.graduation.transfer.timetable.vo.AdminDeleteTimeTable
 import org.brynhild.graduation.transfer.timetable.vo.AdminModifyTimeTable
 import org.brynhild.graduation.transfer.timetable.vo.AdminQueryClassStatistic
 import org.brynhild.graduation.transfer.timetable.vo.AdminQueryStudentStatistic
+import org.brynhild.graduation.transfer.timetable.vo.QueryTeachingClassRequest
 import org.brynhild.graduation.transfer.timetable.vo.QueryTimeTableRequest
 
 interface ITimeTableService {
@@ -25,4 +26,6 @@ interface ITimeTableService {
     Result generateClassStatistic(AdminQueryClassStatistic info, String token)
 
     Result generateStudentStatistic(AdminQueryStudentStatistic info, String token)
+
+    Result queryTeachingClass(QueryTeachingClassRequest request)
 }

+ 9 - 0
final-timetable/src/main/java/org/brynhild/graduation/timetable/service/impl/TimeTableServiceImpl.groovy

@@ -32,6 +32,7 @@ import org.brynhild.graduation.transfer.timetable.vo.AdminDeleteTimeTable
 import org.brynhild.graduation.transfer.timetable.vo.AdminModifyTimeTable
 import org.brynhild.graduation.transfer.timetable.vo.AdminQueryClassStatistic
 import org.brynhild.graduation.transfer.timetable.vo.AdminQueryStudentStatistic
+import org.brynhild.graduation.transfer.timetable.vo.QueryTeachingClassRequest
 import org.brynhild.graduation.transfer.timetable.vo.QueryTimeTableRequest
 import org.brynhild.graduation.transfer.view.ViewConvertor
 import org.springframework.beans.factory.annotation.Autowired
@@ -298,6 +299,14 @@ class TimeTableServiceImpl implements ITimeTableService {
         return new Result(true,"生成成功",list)
     }
 
+    @Override
+    Result queryTeachingClass(QueryTeachingClassRequest request) {
+        def listOfTables = tableRepository.findTimeTableByTeacher(request.getTeacherId())
+        def collect = listOfTables.stream().map { Long.parseLong(it.clazz) }.collect(Collectors.toSet())
+        def classes = classRepository.findAllById(collect)
+        return new Result(true,"查询成功",classes)
+    }
+
     @Autowired
     @Resource
     void setConfig(CosConfig config) {

+ 11 - 0
final-transfer/src/main/java/org/brynhild/graduation/transfer/timetable/vo/QueryTeachingClassRequest.java

@@ -0,0 +1,11 @@
+package org.brynhild.graduation.transfer.timetable.vo;
+
+import lombok.Data;
+
+import javax.validation.constraints.NotNull;
+
+@Data
+public class QueryTeachingClassRequest {
+    @NotNull
+    private Long teacherId;
+}

+ 0 - 10
final-user/src/main/java/org/brynhild/graduation/user/controller/AndroidController.java

@@ -1,10 +0,0 @@
-package org.brynhild.graduation.user.controller;
-
-import org.springframework.web.bind.annotation.RequestMapping;
-import org.springframework.web.bind.annotation.RestController;
-
-@RestController
-@RequestMapping("/android")
-public class AndroidController {
-
-}

+ 0 - 15
final-user/src/main/java/org/brynhild/graduation/user/controller/SystemController.java

@@ -1,15 +0,0 @@
-package org.brynhild.graduation.user.controller;
-
-import org.springframework.web.bind.annotation.GetMapping;
-import org.springframework.web.bind.annotation.RequestMapping;
-import org.springframework.web.bind.annotation.RestController;
-
-@RestController
-@RequestMapping("/system")
-public class SystemController {
-
-    @GetMapping("/test")
-    public String test() {
-        return "test";
-    }
-}

+ 28 - 0
final-user/src/main/java/org/brynhild/graduation/user/controller/TeacherController.java

@@ -0,0 +1,28 @@
+package org.brynhild.graduation.user.controller;
+
+import lombok.RequiredArgsConstructor;
+import org.brynhild.graduation.common.constant.AccountConstant;
+import org.brynhild.graduation.common.transfer.dto.Result;
+import org.brynhild.graduation.common.utils.RequestBodyVerifier;
+import org.brynhild.graduation.transfer.user.vo.QueryUserRequest;
+import org.brynhild.graduation.user.service.ITeacherService;
+import org.springframework.validation.BindingResult;
+import org.springframework.validation.annotation.Validated;
+import org.springframework.web.bind.annotation.*;
+
+@RequestMapping("/teacher")
+@RestController
+@RequiredArgsConstructor
+public class TeacherController {
+    private final RequestBodyVerifier verifier;
+    private final ITeacherService teacherService;
+
+    @PostMapping("/user")
+    public Result findUser(@RequestBody @Validated QueryUserRequest info, BindingResult result,
+                           @RequestHeader(AccountConstant.ACCOUNT_HEADER) String token) {
+        if (result.hasErrors()) {
+            return verifier.convertToErrors(result);
+        }
+        return teacherService.findUser(info, token);
+    }
+}

+ 0 - 21
final-user/src/main/java/org/brynhild/graduation/user/controller/TestController.groovy

@@ -1,21 +0,0 @@
-package org.brynhild.graduation.user.controller
-
-
-import jakarta.annotation.Resource
-import org.brynhild.graduation.common.utils.JwtUtil
-import org.springframework.beans.factory.annotation.Autowired
-import org.springframework.web.bind.annotation.RequestMapping
-import org.springframework.web.bind.annotation.RestController
-
-@RestController
-@RequestMapping("/test")
-class TestController {
-
-    private JwtUtil jwtUtil
-
-    @Autowired
-    @Resource
-    void setJwtUtil(JwtUtil jwtUtil) {
-        this.jwtUtil = jwtUtil
-    }
-}

+ 8 - 0
final-user/src/main/java/org/brynhild/graduation/user/service/ITeacherService.java

@@ -0,0 +1,8 @@
+package org.brynhild.graduation.user.service;
+
+import org.brynhild.graduation.common.transfer.dto.Result;
+import org.brynhild.graduation.transfer.user.vo.QueryUserRequest;
+
+public interface ITeacherService {
+    Result findUser(QueryUserRequest info, String token);
+}

+ 37 - 0
final-user/src/main/java/org/brynhild/graduation/user/service/impl/TeacherServiceImpl.groovy

@@ -0,0 +1,37 @@
+package org.brynhild.graduation.user.service.impl
+
+import jakarta.annotation.Resource
+import org.brynhild.graduation.common.transfer.dto.Result
+import org.brynhild.graduation.persistence.user.entity.User
+import org.brynhild.graduation.persistence.user.repository.UserRepository
+import org.brynhild.graduation.transfer.user.vo.QueryUserRequest
+import org.brynhild.graduation.user.service.ITeacherService
+import org.springframework.beans.factory.annotation.Autowired
+import org.springframework.stereotype.Service
+
+@Service
+class TeacherServiceImpl implements ITeacherService{
+    private UserRepository userRepository
+
+    @Override
+    Result findUser(QueryUserRequest info, String token) {
+        def userList = new ArrayList<User>()
+        if (info.id != null) {
+            def optional = userRepository.findById(info.id)
+            if (optional.isPresent()) {
+                userList.add(optional.get())
+                return new Result(true, "查询成功", userList)
+            } else {
+                return new Result(false, "无相关用户")
+            }
+        }
+        def specification = info.getSpecification()
+        return new Result(true, "查询成功", userRepository.findAll(specification))
+    }
+
+    @Autowired
+    @Resource
+    void setUserRepository(UserRepository userRepository) {
+        this.userRepository = userRepository
+    }
+}