package com.qxueyou.scc.controller;
|
|
import java.io.IOException;
|
import java.util.ArrayList;
|
import java.util.List;
|
import java.util.Map;
|
|
import javax.servlet.http.HttpServletRequest;
|
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;
|
import org.springframework.web.bind.annotation.RequestMapping;
|
import org.springframework.web.bind.annotation.RestController;
|
|
import com.qxueyou.scc.admin.classes.model.ClsClass;
|
import com.qxueyou.scc.admin.classes.service.IClassService;
|
import com.qxueyou.scc.base.model.Result;
|
import com.qxueyou.scc.base.util.ClientUtils;
|
import org.springframework.web.context.request.RequestContextHolder;
|
import org.springframework.web.context.request.ServletRequestAttributes;
|
|
/**
|
* 后台首页控制器
|
*
|
* @author xiadehu
|
*
|
*/
|
@RestController
|
@RequestMapping()
|
public class IndexController {
|
|
|
@Autowired
|
IClassService classService;
|
@Autowired
|
private ITeacherService teacherService;
|
@Value("${server.context-index}")
|
private String WEB_INDEX;
|
|
@RequestMapping(value = {"", "/", "login","web","index","welcome"})
|
public void index(HttpServletRequest httpRequest,HttpServletResponse response) throws IOException {
|
response.sendRedirect(httpRequest.getContextPath()+WEB_INDEX);
|
}
|
|
@GetMapping(value = "/admin/home/classData")
|
public Result getClassData() {
|
|
// request.getSession().invalidate();
|
// ClientUtils.isAdmin()=true;
|
//判断是否是教师
|
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) {
|
Map<String, Object> classActivityInfo = classService.getClassActivityInfo(cls.getClassId());
|
result.add(classActivityInfo);
|
}
|
|
return new Result(true,null,result);
|
}
|
|
}
|