package com.peanut.modules.master.controller; import com.baomidou.mybatisplus.extension.plugins.pagination.Page; import com.peanut.common.utils.R; import com.peanut.modules.common.entity.CourseEntity; import com.peanut.modules.common.entity.CoursePsyche; import com.peanut.modules.common.entity.CourseToPsyche; import com.peanut.modules.common.service.CoursePsycheService; import com.peanut.modules.common.service.CourseToPsycheService; import com.peanut.modules.common.to.ParamTo; import com.peanut.modules.master.service.CourseService; import lombok.extern.slf4j.Slf4j; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.web.bind.annotation.RequestBody; import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.bind.annotation.RestController; import java.util.List; @Slf4j @RestController("masterCoursePsyche") @RequestMapping("master/coursePsyche") public class CoursePsycheController { @Autowired private CoursePsycheService coursePsycheService; @Autowired private CourseToPsycheService courseToPsycheService; @Autowired private CourseService courseService; @RequestMapping("/getCoursePsycheList") public R getCoursePsycheList(){ List coursePsycheList = coursePsycheService.getCoursePsycheList(); return R.ok().put("Psyches",coursePsycheList); } @RequestMapping("/addCoursePsyche") public R addCoursePsyche(@RequestBody CoursePsyche coursePsyche){ coursePsycheService.save(coursePsyche); return R.ok().put("Psyche",coursePsyche); } @RequestMapping("/delCoursePsyche") public R delCoursePsyche(@RequestBody ParamTo param){ return coursePsycheService.delCoursePsyche(param.getId()); } @RequestMapping("/editCoursePsyche") public R editCoursePsyche(@RequestBody CoursePsyche coursePsyche){ return coursePsycheService.editCoursePsyche(coursePsyche); } @RequestMapping("/getCourseListForPsyche") public R getCourseListForPsyche(@RequestBody ParamTo param){ List courseListForPsyche = courseService.getCourseListForPsyche(param.getId()); return R.ok().put("courseList",courseListForPsyche); } @RequestMapping("/getCourseListCanPsyche") public R getCourseListCanPsyche(@RequestBody ParamTo param){ Page courseListCanPsyche = courseService.getCourseListCanPsyche(param); return R.ok().put("page",courseListCanPsyche); } @RequestMapping("/bindCourseAndPsyche") public R bindCourseAndPsyche(@RequestBody CourseToPsyche courseToPsyche){ return courseToPsycheService.bindCourseAndPsyche(courseToPsyche); } @RequestMapping("/unbindCourseAndPsyche") public R unbindCourseAndPsyche(@RequestBody CourseToPsyche courseToPsyche){ boolean b = courseToPsycheService.removeById(courseToPsyche.getId()); if(b){ return R.ok(); }else { return R.error("error"); } } @RequestMapping("/updateCourseToPsycheSort") public R updateCourseToPsycheSort(@RequestBody CourseToPsyche courseToPsyche){ courseToPsycheService.updateById(courseToPsyche); return R.ok(); } }