|
|
@@ -5,8 +5,10 @@ import cn.dev33.satoken.stp.StpUtil;
|
|
|
import cn.hutool.core.bean.BeanUtil;
|
|
|
import cn.hutool.core.util.ObjectUtil;
|
|
|
import cn.hutool.core.util.StrUtil;
|
|
|
+import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
|
|
import com.baomidou.mybatisplus.core.metadata.IPage;
|
|
|
import com.github.yulichang.toolkit.MPJWrappers;
|
|
|
+import com.xjrsoft.common.enums.DeleteMark;
|
|
|
import com.xjrsoft.common.enums.GenderDictionaryEnum;
|
|
|
import com.xjrsoft.common.model.result.R;
|
|
|
import com.xjrsoft.common.model.result.RT;
|
|
|
@@ -15,6 +17,7 @@ import com.xjrsoft.common.page.PageOutput;
|
|
|
import com.xjrsoft.common.utils.TreeUtil;
|
|
|
import com.xjrsoft.common.utils.VoToColumnUtil;
|
|
|
import com.xjrsoft.module.base.entity.BaseClass;
|
|
|
+import com.xjrsoft.module.base.entity.BaseGrade;
|
|
|
import com.xjrsoft.module.base.service.IBaseClassService;
|
|
|
import com.xjrsoft.module.base.service.IBaseGradeService;
|
|
|
import com.xjrsoft.module.student.dto.AddBaseStudentUserDto;
|
|
|
@@ -42,7 +45,9 @@ import org.springframework.web.multipart.MultipartFile;
|
|
|
|
|
|
import javax.validation.Valid;
|
|
|
import java.util.ArrayList;
|
|
|
+import java.util.HashSet;
|
|
|
import java.util.List;
|
|
|
+import java.util.Set;
|
|
|
|
|
|
@RestController
|
|
|
@RequestMapping("/student" + "/studentmanager")
|
|
|
@@ -97,15 +102,50 @@ public class StudentManagerController {
|
|
|
@ApiOperation(value = "学生年纪班级树")
|
|
|
@SaCheckPermission("studentmanager:detail")
|
|
|
public RT<List<BaseStudentTreeVo>> tree() {
|
|
|
+ List<String> roleList = StpUtil.getRoleList();
|
|
|
+
|
|
|
+ long teacherId = StpUtil.getLoginIdAsLong();
|
|
|
+ List<BaseClass> classList = baseClassService.list(
|
|
|
+ new QueryWrapper<BaseClass>().lambda().eq(BaseClass::getDeleteMark, DeleteMark.NODELETE.getCode())
|
|
|
+ );
|
|
|
List<BaseStudentTreeVo> voList = new ArrayList<>();
|
|
|
- baseGradeService.list().forEach((node) -> {
|
|
|
+
|
|
|
+ List<BaseGrade> gradeList = baseGradeService.list(
|
|
|
+ new QueryWrapper<BaseGrade>().lambda().eq(BaseGrade::getDeleteMark, DeleteMark.NODELETE.getCode())
|
|
|
+ );
|
|
|
+ if(roleList.size() == 2 && roleList.contains("CLASSTE") && roleList.contains("TEACHER")){
|
|
|
+ Set<Long> gradeSet = new HashSet<>();
|
|
|
+ for (BaseClass baseClass : classList) {
|
|
|
+ if(baseClass.getTeacherId().equals(teacherId)){
|
|
|
+ gradeSet.add(baseClass.getGradeId());
|
|
|
+ voList.add(new BaseStudentTreeVo(){{
|
|
|
+ setId(baseClass.getId());
|
|
|
+ setName(baseClass.getName());
|
|
|
+ setParentId(baseClass.getGradeId());
|
|
|
+ }});
|
|
|
+ }
|
|
|
+ }
|
|
|
+ gradeList.forEach((node) -> {
|
|
|
+ if(gradeSet.contains(node.getId())){
|
|
|
+ voList.add(new BaseStudentTreeVo(){{
|
|
|
+ setId(node.getId());
|
|
|
+ setName(node.getName());
|
|
|
+ }});
|
|
|
+ }
|
|
|
+ });
|
|
|
+
|
|
|
+ List<BaseStudentTreeVo> treeVoList = TreeUtil.build(voList);
|
|
|
+
|
|
|
+ return RT.ok(treeVoList);
|
|
|
+ }
|
|
|
+ gradeList.forEach((node) -> {
|
|
|
voList.add(new BaseStudentTreeVo(){{
|
|
|
setId(node.getId());
|
|
|
setName(node.getName());
|
|
|
}});
|
|
|
});
|
|
|
|
|
|
- baseClassService.list().forEach((node)->{
|
|
|
+ classList.forEach((node)->{
|
|
|
voList.add(new BaseStudentTreeVo(){{
|
|
|
setId(node.getId());
|
|
|
setName(node.getName());
|