派生自 projectDept/qhighschool

EricsHu
2023-11-25 79ab2cbd31c022916a8e696903d5eb34b70aa403
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
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);
    }
 
}