package com.ycl.jxkg.controller.student;
|
|
|
import com.ycl.jxkg.base.BaseApiController;
|
import com.ycl.jxkg.base.Result;
|
import com.ycl.jxkg.domain.Subject;
|
import com.ycl.jxkg.domain.User;
|
import com.ycl.jxkg.service.SubjectService;
|
import com.ycl.jxkg.vo.student.education.SubjectEditRequestVO;
|
import com.ycl.jxkg.vo.student.education.SubjectVO;
|
import lombok.RequiredArgsConstructor;
|
import org.springframework.beans.BeanUtils;
|
import org.springframework.beans.factory.annotation.Autowired;
|
import org.springframework.web.bind.annotation.*;
|
|
import java.util.List;
|
import java.util.stream.Collectors;
|
|
@RequiredArgsConstructor
|
@RestController("StudentEducationController")
|
@RequestMapping(value = "/api/student/education")
|
public class EducationController extends BaseApiController {
|
|
private final SubjectService subjectService;
|
|
@RequestMapping(value = "/subject/list", method = RequestMethod.POST)
|
public Result<List<SubjectVO>> list() {
|
User user = getCurrentUser();
|
List<Subject> subjects = subjectService.getSubjectByLevel(user.getUserLevel());
|
List<SubjectVO> subjectVOS = subjects.stream().map(d -> {
|
SubjectVO subjectVO = new SubjectVO();
|
BeanUtils.copyProperties(d, subjectVO);
|
subjectVO.setId(String.valueOf(d.getId()));
|
return subjectVO;
|
}).collect(Collectors.toList());
|
return Result.ok(subjectVOS);
|
}
|
|
@RequestMapping(value = "/subject/select/{id}", method = RequestMethod.POST)
|
public Result<SubjectEditRequestVO> select(@PathVariable Integer id) {
|
Subject subject = subjectService.getById(id);
|
SubjectEditRequestVO vo = new SubjectEditRequestVO();
|
BeanUtils.copyProperties(subject, vo);
|
return Result.ok(vo);
|
}
|
|
}
|