forked from cmzalvin/giit
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathOrderBookController.java
More file actions
95 lines (83 loc) · 3.83 KB
/
OrderBookController.java
File metadata and controls
95 lines (83 loc) · 3.83 KB
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
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
package com.giit.www.college.controller;
import com.giit.www.college.service.OrderBookBiz;
import com.giit.www.entity.Section;
import com.giit.www.entity.custom.ChangedItems;
import com.giit.www.entity.custom.OrderBookReviewVo;
import com.giit.www.entity.custom.OrderBookVo;
import com.giit.www.util.TermContainer;
import org.apache.shiro.authz.annotation.Logical;
import org.apache.shiro.authz.annotation.RequiresRoles;
import org.springframework.http.HttpStatus;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.web.bind.annotation.ResponseStatus;
import javax.annotation.Resource;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpSession;
import java.util.List;
import java.util.Map;
/**
* Created by c0de8ug on 16-2-13.
*/
//TODO URL我自己定义全小写
@Controller
@RequestMapping("orderbook.do")
public class OrderBookController {
@Resource(name = "orderBookBizImpl")
private OrderBookBiz orderBookBiz;
@RequiresRoles(value = {"admin", "teacher"}, logical = Logical.OR)
@RequestMapping("orderbook.view")
public String orderBookView(Model m, HttpSession httpSession) {
String staffId = (String) httpSession.getAttribute("username");
List<Section> sectionList = orderBookBiz.findSelectedSection(staffId, TermContainer.now());
int courseCount = sectionList.size();
m.addAttribute("selectedSectionList", sectionList);
m.addAttribute("courseCount", courseCount);
return "/teacher/orderbook";
}
@RequiresRoles(value = {"admin", "teacher"}, logical = Logical.OR)
@RequestMapping("orderbook_review.view")
public String orderBookReviewView(Model m, HttpSession session) {
//TODO 放到SESSION方便处理
session.setAttribute("notReviewedBookList", orderBookBiz.findAllNotReviewedBook());
return "/teacher/orderbook_review";
}
@RequiresRoles(value = {"admin", "teacher"}, logical = Logical.OR)
@RequestMapping("orderbook_add.view")
public String orderBookAddView(Model m) {
return "/teacher/orderbook_add";
}
@RequiresRoles(value = {"admin", "teacher"}, logical = Logical.OR)
@RequestMapping("orderbook_added.view")
public String orderBookAddedView(Model m, HttpSession session) {
String staffId = (String) session.getAttribute("username");
m.addAttribute("addedBookInfoList", orderBookBiz.findAddedBookInfoList(staffId));
return "/teacher/orderbook_added";
}
@RequiresRoles(value = {"admin", "teacher"}, logical = Logical.OR)
@RequestMapping("add")
public String add(HttpServletRequest request, HttpSession session) {
Map map = request.getParameterMap();
OrderBookVo orderBookVo = new OrderBookVo();
orderBookVo.setStaffId((String) session.getAttribute("username"));
orderBookVo.setMap(map);
orderBookBiz.add(orderBookVo);
return "redirect:/orderbook.do/orderbook.view";
}
@RequiresRoles(value = {"admin", "teacher"}, logical = Logical.OR)
@RequestMapping("update")
@ResponseStatus(value = HttpStatus.OK)
public void update(@RequestBody ChangedItems changedItems, HttpSession session) {
orderBookBiz.update(changedItems, (String) session.getAttribute("username"));
}
@RequiresRoles(value = {"admin", "teacher"}, logical = Logical.OR)
@RequestMapping("audit")
public String audit(HttpSession session) {
List<OrderBookReviewVo> orderBookReviewVoList = (List<OrderBookReviewVo>) session.getAttribute("notReviewedBookList");
orderBookBiz.audit(orderBookReviewVoList);
return "redirect:/orderbook.do/orderbook_review.view";
}
}