|
@@ -2,17 +2,19 @@ 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 cn.hutool.core.util.ObjectUtil;
|
|
|
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.dto.AddCourseToSubjectGroupDto;
|
|
|
+import com.xjrsoft.module.textbook.dto.AddSubjectGroupDto;
|
|
|
+import com.xjrsoft.module.textbook.dto.SubjectGroupPageDto;
|
|
|
+import com.xjrsoft.module.textbook.dto.UpdateSubjectGroupDto;
|
|
|
import com.xjrsoft.module.textbook.entity.SubjectGroup;
|
|
|
import com.xjrsoft.module.textbook.entity.SubjectGroupCourse;
|
|
|
import com.xjrsoft.module.textbook.service.ISubjectGroupCourseService;
|
|
@@ -56,6 +58,8 @@ public class SubjectGroupController {
|
|
|
.selectAs(XjrUser::getName,SubjectGroupPageVo::getLeaderUserIdCN)
|
|
|
.select(SubjectGroup.class,x -> VoToColumnUtil.fieldsToColumns(SubjectGroupPageVo.class).contains(x.getProperty()))
|
|
|
.leftJoin(XjrUser.class,XjrUser::getId,SubjectGroup::getLeaderUserId)
|
|
|
+ .like(ObjectUtil.isNotNull(dto.getGroupName()) && dto.getGroupName().equals(""),SubjectGroup::getGroupName,dto.getGroupName())
|
|
|
+ .eq(ObjectUtil.isNotNull(dto.getLeaderUserId()) && dto.getLeaderUserId() > 0, SubjectGroup::getLeaderUserId, dto.getLeaderUserId())
|
|
|
.orderByDesc(SubjectGroup::getId);
|
|
|
IPage<SubjectGroupPageVo> page = subjectGroupService.selectJoinListPage(ConventPage.getPage(dto),SubjectGroupPageVo.class, queryWrapper);
|
|
|
for (SubjectGroupPageVo subjectGroupPageVo : page.getRecords()) {
|
|
@@ -118,30 +122,25 @@ public class SubjectGroupController {
|
|
|
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));
|
|
|
+ return RT.ok(subjectGroupService.updateCourse(dto));
|
|
|
+ }
|
|
|
|
|
|
+ @PutMapping("/updateCourse")
|
|
|
+ @ApiOperation(value = "修改学科组管理")
|
|
|
+ @SaCheckPermission("subjectgroup:edit")
|
|
|
+ public RT<Boolean> updateCourse(@Valid @RequestBody UpdateSubjectGroupDto dto){
|
|
|
+ return RT.ok(subjectGroupService.updateCourse(dto));
|
|
|
}
|
|
|
|
|
|
@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));
|
|
|
+ return RT.ok(subjectGroupService.delete(ids));
|
|
|
}
|
|
|
|
|
|
@DeleteMapping("/deleteCourse")
|