派生自 projectDept/qhighschool

EricsHu
2023-11-25 79ab2cbd31c022916a8e696903d5eb34b70aa403
src/main/java/com/qxueyou/scc/controller/IndexController.java
@@ -9,6 +9,8 @@
import javax.servlet.http.HttpServletResponse;
import javax.servlet.http.HttpSession;
import com.qxueyou.scc.admin.teacher.service.ITeacherService;
import org.apache.commons.lang3.StringUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.web.bind.annotation.GetMapping;
@@ -23,7 +25,7 @@
import org.springframework.web.context.request.ServletRequestAttributes;
/**
 * 后台首页控制器
 * 后台首页控制器
 * 
 * @author xiadehu
 *
@@ -35,7 +37,8 @@
   @Autowired
   IClassService classService;
   @Autowired
   private ITeacherService teacherService;
   @Value("${server.context-index}")
   private String WEB_INDEX;
   
@@ -49,14 +52,21 @@
//      request.getSession().invalidate();
//      ClientUtils.isAdmin()=true;
      String teacherId = ClientUtils.isAdmin()?null:ClientUtils.getUserId();
      List<ClsClass> clsLst =  classService.getClassLst("",teacherId, 2000, 1, 1);
      //判断是否是教师
      String teacherId = ClientUtils.isAdmin() ? null : teacherService.getTeacherIdByUserId(ClientUtils.getUserId());
      List<ClsClass> clsLst = new ArrayList<>();
      if (StringUtils.isNotBlank(teacherId)) {
         //获取该老师下发布的课程的所属班级
       clsLst =  classService.getTeacherClassLst(teacherId);
      }else{
         //管理员查询所有班级
         clsLst =classService.getClassLst("",teacherId, 2000, 1, 1);
      }
      List<Map<String,Object>> result = new ArrayList<Map<String,Object>>(clsLst.size()*2);
      for(ClsClass cls:clsLst) {
         result.add(classService.getClassActivityInfo(cls.getClassId()));
         Map<String, Object> classActivityInfo = classService.getClassActivityInfo(cls.getClassId());
         result.add(classActivityInfo);
      }
      
      return new Result(true,null,result);