|
@@ -0,0 +1,139 @@
|
|
|
|
+package com.xjrsoft.module.textbook.controller;
|
|
|
|
+
|
|
|
|
+import cn.dev33.satoken.annotation.SaCheckPermission;
|
|
|
|
+import cn.hutool.core.bean.BeanUtil;
|
|
|
|
+import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
|
|
|
+import com.baomidou.mybatisplus.core.metadata.IPage;
|
|
|
|
+import com.github.yulichang.wrapper.MPJLambdaWrapper;
|
|
|
|
+import com.xjrsoft.common.exception.MyException;
|
|
|
|
+import com.xjrsoft.common.model.result.RT;
|
|
|
|
+import com.xjrsoft.common.page.ConventPage;
|
|
|
|
+import com.xjrsoft.common.page.PageOutput;
|
|
|
|
+import com.xjrsoft.common.utils.VoToColumnUtil;
|
|
|
|
+import com.xjrsoft.module.base.entity.BaseCourseSubject;
|
|
|
|
+import com.xjrsoft.module.teacher.entity.XjrUser;
|
|
|
|
+import com.xjrsoft.module.textbook.dto.*;
|
|
|
|
+import com.xjrsoft.module.textbook.entity.SubjectGroup;
|
|
|
|
+import com.xjrsoft.module.textbook.entity.SubjectGroupCourse;
|
|
|
|
+import com.xjrsoft.module.textbook.service.ISubjectGroupCourseService;
|
|
|
|
+import com.xjrsoft.module.textbook.service.ISubjectGroupService;
|
|
|
|
+import com.xjrsoft.module.textbook.vo.SubjectGroupCoursePageVo;
|
|
|
|
+import com.xjrsoft.module.textbook.vo.SubjectGroupPageVo;
|
|
|
|
+import com.xjrsoft.module.textbook.vo.SubjectGroupVo;
|
|
|
|
+import io.swagger.annotations.Api;
|
|
|
|
+import io.swagger.annotations.ApiOperation;
|
|
|
|
+import lombok.AllArgsConstructor;
|
|
|
|
+import org.springframework.web.bind.annotation.*;
|
|
|
|
+
|
|
|
|
+import javax.validation.Valid;
|
|
|
|
+import java.util.List;
|
|
|
|
+
|
|
|
|
+/**
|
|
|
|
+* @title: 学科组管理
|
|
|
|
+* @Author szs
|
|
|
|
+* @Date: 2023-12-25
|
|
|
|
+* @Version 1.0
|
|
|
|
+*/
|
|
|
|
+@RestController
|
|
|
|
+@RequestMapping("/textbook" + "/subjectGroup")
|
|
|
|
+@Api(value = "/textbook" + "/subjectGroup",tags = "学科组管理代码")
|
|
|
|
+@AllArgsConstructor
|
|
|
|
+public class SubjectGroupController {
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+ private final ISubjectGroupService subjectGroupService;
|
|
|
|
+
|
|
|
|
+ private final ISubjectGroupCourseService subjectGroupCourseService;
|
|
|
|
+
|
|
|
|
+ @GetMapping(value = "/page")
|
|
|
|
+ @ApiOperation(value="学科组管理列表(分页)")
|
|
|
|
+ @SaCheckPermission("subjectgroup:detail")
|
|
|
|
+ public RT<PageOutput<SubjectGroupPageVo>> page(@Valid SubjectGroupPageDto dto){
|
|
|
|
+
|
|
|
|
+ MPJLambdaWrapper<SubjectGroup> queryWrapper = new MPJLambdaWrapper<>();
|
|
|
|
+ queryWrapper
|
|
|
|
+ .select(SubjectGroup::getId)
|
|
|
|
+ .selectAs(XjrUser::getName,SubjectGroupPageVo::getLeaderUserIdCN)
|
|
|
|
+ .select(SubjectGroup.class,x -> VoToColumnUtil.fieldsToColumns(SubjectGroupPageVo.class).contains(x.getProperty()))
|
|
|
|
+ .leftJoin(XjrUser.class,XjrUser::getId,SubjectGroup::getLeaderUserId)
|
|
|
|
+ .orderByDesc(SubjectGroup::getId);
|
|
|
|
+ IPage<SubjectGroupPageVo> page = subjectGroupService.selectJoinListPage(ConventPage.getPage(dto),SubjectGroupPageVo.class, queryWrapper);
|
|
|
|
+ PageOutput<SubjectGroupPageVo> pageOutput = ConventPage.getPageOutput(page, SubjectGroupPageVo.class);
|
|
|
|
+ return RT.ok(pageOutput);
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ @GetMapping(value = "/info")
|
|
|
|
+ @ApiOperation(value="根据id查询学科组管理信息")
|
|
|
|
+ @SaCheckPermission("subjectgroup:detail")
|
|
|
|
+ public RT<SubjectGroupVo> info(@RequestParam Long id){
|
|
|
|
+ SubjectGroup subjectGroup = subjectGroupService.getById(id);
|
|
|
|
+ if (subjectGroup == null) {
|
|
|
|
+ return RT.error("找不到此数据!");
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ MPJLambdaWrapper<SubjectGroupCourse> queryWrapper = new MPJLambdaWrapper<>();
|
|
|
|
+ queryWrapper
|
|
|
|
+ .select(SubjectGroup::getId)
|
|
|
|
+ .selectAs(BaseCourseSubject::getName, SubjectGroupCoursePageVo::getCourseSubjectIdCN)
|
|
|
|
+ .select(SubjectGroupCourse.class,x -> VoToColumnUtil.fieldsToColumns(SubjectGroupCoursePageVo.class).contains(x.getProperty()))
|
|
|
|
+ .leftJoin(BaseCourseSubject.class,BaseCourseSubject::getId,SubjectGroupCourse::getCourseSubjectId)
|
|
|
|
+ .eq(SubjectGroupCourse::getSubjectGroupId,subjectGroup.getId())
|
|
|
|
+ .orderByDesc(SubjectGroupCourse::getId);
|
|
|
|
+
|
|
|
|
+ List<SubjectGroupCoursePageVo> subjectGroupCourseList = subjectGroupCourseService.selectJoinList(SubjectGroupCoursePageVo.class,queryWrapper);
|
|
|
|
+ SubjectGroupVo subjectGroupVo = BeanUtil.toBean(subjectGroup, SubjectGroupVo.class);
|
|
|
|
+ subjectGroupVo.setSubjectGroupCourseList(subjectGroupCourseList);
|
|
|
|
+ return RT.ok(subjectGroupVo);
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+ @PostMapping
|
|
|
|
+ @ApiOperation(value = "新增学科组管理")
|
|
|
|
+ @SaCheckPermission("subjectgroup:add")
|
|
|
|
+ public RT<Boolean> add(@Valid @RequestBody AddSubjectGroupDto dto){
|
|
|
|
+ Boolean isSuccess = subjectGroupService.add(dto);
|
|
|
|
+ return RT.ok(isSuccess);
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ @PostMapping("/addCourse")
|
|
|
|
+ @ApiOperation(value = "新增学科组下面的课程")
|
|
|
|
+ @SaCheckPermission("subjectgroup:add")
|
|
|
|
+ public RT<Boolean> addCourse(@Valid @RequestBody AddCourseToSubjectGroupDto dto){
|
|
|
|
+ Boolean isSuccess = subjectGroupService.addCourse(dto);
|
|
|
|
+ return RT.ok(isSuccess);
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+ @PutMapping
|
|
|
|
+ @ApiOperation(value = "修改学科组管理")
|
|
|
|
+ @SaCheckPermission("subjectgroup:edit")
|
|
|
|
+ public RT<Boolean> update(@Valid @RequestBody UpdateSubjectGroupDto dto){
|
|
|
|
+ SubjectGroup subjectGroup = BeanUtil.toBean(dto, SubjectGroup.class);
|
|
|
|
+ return RT.ok(subjectGroupService.updateById(subjectGroup));
|
|
|
|
+
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ @DeleteMapping
|
|
|
|
+ @ApiOperation(value = "删除学科组管理")
|
|
|
|
+ @SaCheckPermission("subjectgroup:delete")
|
|
|
|
+ public RT<Boolean> delete(@Valid @RequestBody List<Long> ids){
|
|
|
|
+ for(Long id : ids){
|
|
|
|
+ LambdaQueryWrapper<SubjectGroupCourse> queryWrapper = new LambdaQueryWrapper<>();
|
|
|
|
+ queryWrapper
|
|
|
|
+ .eq(SubjectGroupCourse::getSubjectGroupId,id);
|
|
|
|
+ Long count = subjectGroupCourseService.count(queryWrapper);
|
|
|
|
+ if(count > 0){
|
|
|
|
+ throw new MyException("学科组下面有课程");
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ return RT.ok(subjectGroupService.removeBatchByIds(ids));
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ @DeleteMapping("/deleteCourse")
|
|
|
|
+ @ApiOperation(value = "删除学科组下面的课程")
|
|
|
|
+ @SaCheckPermission("subjectgroup:delete")
|
|
|
|
+ public RT<Boolean> deleteCourse(@Valid @RequestBody List<Long> ids){
|
|
|
|
+ return RT.ok(subjectGroupCourseService.removeBatchByIds(ids));
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+}
|