mirror of
https://github.com/PlayEdu/PlayEdu
synced 2025-06-08 02:04:04 +08:00
update
This commit is contained in:
parent
48602be6c0
commit
fd07672154
@ -0,0 +1,44 @@
|
||||
package xyz.playedu.api.controller.frontend;
|
||||
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.web.bind.annotation.GetMapping;
|
||||
import org.springframework.web.bind.annotation.PathVariable;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
import xyz.playedu.api.domain.Course;
|
||||
import xyz.playedu.api.exception.NotFoundException;
|
||||
import xyz.playedu.api.service.CourseService;
|
||||
import xyz.playedu.api.types.JsonResponse;
|
||||
|
||||
import java.util.HashMap;
|
||||
|
||||
/**
|
||||
* @Author 杭州白书科技有限公司
|
||||
* @create 2023/3/13 16:25
|
||||
*/
|
||||
@RestController
|
||||
@RequestMapping("/api/v1/course")
|
||||
public class CourseController {
|
||||
|
||||
@Autowired
|
||||
private CourseService courseService;
|
||||
|
||||
@GetMapping("/index")
|
||||
public JsonResponse index() {
|
||||
return JsonResponse.data(null);
|
||||
}
|
||||
|
||||
@GetMapping("/{id}")
|
||||
public JsonResponse detail(@PathVariable(name = "id") Integer id) throws NotFoundException {
|
||||
Course course = courseService.findOrFail(id);
|
||||
if (course.getIsShow().equals(0)) {
|
||||
throw new NotFoundException("课程不存在");
|
||||
}
|
||||
|
||||
HashMap<String, Object> data = new HashMap<>();
|
||||
data.put("course", course);
|
||||
|
||||
return JsonResponse.data(course);
|
||||
}
|
||||
|
||||
}
|
@ -0,0 +1,29 @@
|
||||
package xyz.playedu.api.controller.frontend;
|
||||
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.web.bind.annotation.GetMapping;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
import xyz.playedu.api.domain.Department;
|
||||
import xyz.playedu.api.service.DepartmentService;
|
||||
import xyz.playedu.api.types.JsonResponse;
|
||||
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
/**
|
||||
* @Author 杭州白书科技有限公司
|
||||
* @create 2023/3/13 16:23
|
||||
*/
|
||||
@RestController
|
||||
@RequestMapping("/api/v1/department")
|
||||
public class DepartmentController {
|
||||
|
||||
@Autowired
|
||||
private DepartmentService departmentService;
|
||||
|
||||
@GetMapping("/index")
|
||||
public JsonResponse index() {
|
||||
return JsonResponse.data(departmentService.all().stream().collect(Collectors.groupingBy(Department::getParentId)));
|
||||
}
|
||||
|
||||
}
|
@ -4,11 +4,17 @@ import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.validation.annotation.Validated;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
import xyz.playedu.api.PlayEduFContext;
|
||||
import xyz.playedu.api.domain.Department;
|
||||
import xyz.playedu.api.domain.User;
|
||||
import xyz.playedu.api.exception.ServiceException;
|
||||
import xyz.playedu.api.request.frontend.ChangePasswordRequest;
|
||||
import xyz.playedu.api.service.DepartmentService;
|
||||
import xyz.playedu.api.service.UserService;
|
||||
import xyz.playedu.api.types.JsonResponse;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* @Author 杭州白书科技有限公司
|
||||
* @create 2023/3/13 09:21
|
||||
@ -20,9 +26,19 @@ public class UserController {
|
||||
@Autowired
|
||||
private UserService userService;
|
||||
|
||||
@Autowired
|
||||
private DepartmentService departmentService;
|
||||
|
||||
@GetMapping("/detail")
|
||||
public JsonResponse detail() {
|
||||
return JsonResponse.data(null);
|
||||
User user = PlayEduFContext.getUser();
|
||||
List<Department> departments = departmentService.listByIds(userService.getDepIdsByUserId(user.getId()));
|
||||
|
||||
HashMap<String, Object> data = new HashMap<>();
|
||||
data.put("user", user);
|
||||
data.put("departments", departments);
|
||||
|
||||
return JsonResponse.data(data);
|
||||
}
|
||||
|
||||
@PutMapping("/password")
|
||||
|
Loading…
x
Reference in New Issue
Block a user