派生自 projectDept/qhighschool

EricsHu
2023-11-24 0ad2f07a292895eeb3b9618eb1e275568c63a59e
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
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 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;
    
    @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:ClientUtils.getUserId();
        
        List<ClsClass> 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()));
        }
        
        return new Result(true,null,result);
    }
 
}