Skip to content

Commit 24753f2

Browse files
committed
Merge branch 'dev'
2 parents 258849b + a6460b5 commit 24753f2

25 files changed

+661
-72
lines changed

src/com/giit/www/college/controller/ClazzController.java

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
package com.giit.www.college.controller;
22

33
import com.giit.www.college.service.ClazzBiz;
4+
import com.giit.www.util.TermContainer;
45
import org.springframework.stereotype.Controller;
56
import org.springframework.ui.Model;
67
import org.springframework.web.bind.annotation.RequestBody;
@@ -40,6 +41,7 @@ public String findAll(Model m) {
4041
public String findDeptAndSpec(Model m) {
4142
m.addAttribute("deptAndSpecJson", clazzBiz.findDeptAndSpecJson());
4243
m.addAttribute("deptNameList", clazzBiz.findDeptNameList());
44+
m.addAttribute("termList", TermContainer.getTermList());
4345
return "/admin/college/clazz_add";
4446
}
4547
}

src/com/giit/www/college/controller/OrderBookController.java

Lines changed: 30 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,23 @@
11
package com.giit.www.college.controller;
22

33
import com.giit.www.college.service.OrderBookBiz;
4+
import com.giit.www.entity.Section;
5+
import com.giit.www.entity.custom.ChangedItems;
6+
import com.giit.www.entity.custom.OrderBookVo;
7+
import com.giit.www.util.TermContainer;
8+
import org.springframework.http.HttpStatus;
49
import org.springframework.stereotype.Controller;
510
import org.springframework.ui.Model;
11+
import org.springframework.web.bind.annotation.RequestBody;
612
import org.springframework.web.bind.annotation.RequestMapping;
13+
import org.springframework.web.bind.annotation.ResponseBody;
14+
import org.springframework.web.bind.annotation.ResponseStatus;
715

816
import javax.annotation.Resource;
17+
import javax.servlet.http.HttpServletRequest;
918
import javax.servlet.http.HttpSession;
1019
import java.util.List;
20+
import java.util.Map;
1121

1222
/**
1323
* Created by c0de8ug on 16-2-13.
@@ -24,9 +34,10 @@ public String orderBookView(Model m, HttpSession httpSession) {
2434
String staffId = (String) httpSession.getAttribute("username");
2535

2636
//TODO 这里的year应该从服务器端开课的地方拿,但是如何拿怎么拿有点不理解,先给它一个值
27-
List<String> courseList = orderBookBiz.findSelectedCourseTitle(staffId, "20162");
28-
int courseCount = courseList.size();
29-
m.addAttribute("selectedCourseList", courseList);
37+
//而且对于一个老师上多门相同的课区分也有问题
38+
List<Section> sectionList = orderBookBiz.findSelectedSection(staffId, TermContainer.now());
39+
int courseCount = sectionList.size();
40+
m.addAttribute("selectedSectionList", sectionList);
3041
m.addAttribute("courseCount", courseCount);
3142
return "/teacher/orderbook";
3243
}
@@ -42,14 +53,27 @@ public String orderBookAddView(Model m) {
4253
}
4354

4455
@RequestMapping("orderbook_added.view")
45-
public String orderBookAddedView(Model m) {
56+
public String orderBookAddedView(Model m, HttpSession session) {
57+
String staffId = (String) session.getAttribute("username");
58+
m.addAttribute("addedBookInfoList", orderBookBiz.findAddedBookInfoList(staffId));
4659
return "/teacher/orderbook_added";
4760
}
4861

4962

63+
//TODO 这里的数据提交没有回显,会给用户带来不便,如果设计是一个问题!!!
5064
@RequestMapping("add")
51-
public String add() {
52-
return "/orderbook.do/orderbook.view";
65+
public String add(HttpServletRequest request, HttpSession session) {
66+
Map map = request.getParameterMap();
67+
OrderBookVo orderBookVo = new OrderBookVo();
68+
orderBookVo.setStaffId((String) session.getAttribute("username"));
69+
orderBookVo.setMap(map);
70+
orderBookBiz.add(orderBookVo);
71+
return "redirect:/orderbook.do/orderbook.view";
5372
}
5473

74+
@RequestMapping("update")
75+
@ResponseStatus(value = HttpStatus.OK)
76+
public void update(@RequestBody ChangedItems changedItems, HttpSession session) {
77+
orderBookBiz.update(changedItems, (String) session.getAttribute("username"));
78+
}
5579
}
Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,18 @@
11
package com.giit.www.college.dao;
22

3+
import com.giit.www.entity.Book;
4+
import org.apache.ibatis.annotations.Param;
5+
36
import java.util.List;
47

58
/**
69
* Created by c0de8ug on 16-2-14.
710
*/
811
public interface BookDao {
9-
public List<String> findSelctedCourse();
1012

11-
public void add();
13+
public void add(Book book);
1214

15+
public void delete(@Param("bookTitle") String bookTitle, @Param("isbn") String isbn);
1316

17+
public Book find(@Param("bookTitle") String bookTitle, @Param("isbn") String isbn);
1418
}

src/com/giit/www/college/dao/BookDao.xml

Lines changed: 9 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -6,27 +6,16 @@
66

77
<mapper namespace="com.giit.www.college.dao.BookDao">
88

9-
<resultMap id="book_map" type="Book">
10-
<id property="clazzId" column="class_id"/>
11-
<result property="clazzName" column="class_name"/>
12-
<result property="year" column="year"/>
13-
<result property="specName" column="spec_name"/>
14-
</resultMap>
9+
<insert id="add" parameterType="Book">
10+
INSERT INTO book(book_title,isbn,data_of_printing,author,press,category,unit_price)
11+
VALUES(#{bookTitle},#{isbn},#{dataOfPrinting},#{author},#{press},#{category},#{unitPrice})
12+
</insert>
1513

16-
<select id="findSelctedCourse" parameterType="map" resultType="String">
17-
SELECT DISTINCT course_title FROM section WHERE staff_id = #{staffId} AND year = #{year};
14+
<select id="find" parameterType="map" resultType="Book">
15+
SELECT * FROM book WHERE book_title = #{bookTitle} AND isbn = #{isbn}
1816
</select>
1917

20-
<insert id="add" parameterType="Book">
21-
INSERT INTO book(book_title,isbn,data_of_printing,author,press,category,unit_price) VALUES
22-
(
23-
bookTitle,
24-
isbn,
25-
dataOfPrinting,
26-
author,
27-
press,
28-
category,
29-
unitPrice,
30-
)
31-
</insert>
18+
<delete id="delete" parameterType="map">
19+
DELETE FROM book WHERE book_title = #{bookTitle} AND isbn = #{isbn}
20+
</delete>
3221
</mapper>
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,21 @@
11
package com.giit.www.college.dao;
22

3+
import com.giit.www.entity.OrderBook;
4+
import com.giit.www.entity.custom.AddedBookVo;
5+
import com.giit.www.entity.custom.ChangedItems;
6+
import org.apache.ibatis.annotations.Param;
7+
8+
import java.util.List;
9+
310
/**
411
* Created by c0de8ug on 16-2-13.
512
*/
613
public interface OrderBookDao {
14+
public void add(OrderBook orderBook);
15+
16+
public List<AddedBookVo> findAddedBookInfoList(String staffId);
17+
18+
public int usedByOtherSec(@Param("bookTitle") String bookTitle, @Param("isbn") String isbn, @Param("secId") int secId);
19+
20+
public void delete(@Param("secId") int secId, @Param("bookTitle") String bookTitle, @Param("isbn") String isbn);
721
}

src/com/giit/www/college/dao/OrderBookDao.xml

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,4 +6,40 @@
66

77
<mapper namespace="com.giit.www.college.dao.OrderBookDao">
88

9+
10+
<resultMap id="addedBookInfo" type="AddedBookVo">
11+
<result property="secId" column="sec_id"/>
12+
<result property="courseTitle" column="course_title"/>
13+
<collection property="bookInfoList" ofType="BookInfo">
14+
<result property="bookTitle" column="book_title"/>
15+
<result property="isbn" column="isbn"/>
16+
<result property="dataOfPrinting" column="data_of_printing"/>
17+
<result property="author" column="author"/>
18+
<result property="press" column="press"/>
19+
<result property="category" column="category"/>
20+
<result property="unitPrice" column="unit_price"/>
21+
<result property="remark" column="remark"/>
22+
</collection>
23+
</resultMap>
24+
25+
<insert id="add" parameterType="OrderBook">
26+
INSERT INTO order_book(staff_id,sec_id,book_title,isbn,remark) VALUES(#{staffId},#{secId},#{bookTitle},#{isbn},#{remark})
27+
</insert>
28+
29+
30+
<select id="findAddedBookInfoList" parameterType="String" resultMap="addedBookInfo">
31+
SELECT section.sec_id,section.course_title,book.isbn,book.book_title,data_of_printing,author,press,category,unit_price,remark
32+
FROM order_book
33+
INNER JOIN book ON order_book.book_title = book.book_title AND order_book.isbn = book.isbn
34+
INNER JOIN section ON order_book.sec_id = section.sec_id
35+
WHERE order_book.staff_id = #{value}
36+
</select>
37+
38+
<select id="usedByOtherSec" parameterType="map" resultType="int">
39+
SELECT count(*) FROM order_book WHERE book_title = #{bookTitle} AND isbn = #{isbn} AND sec_id != #{secId}
40+
</select>
41+
42+
<delete id="delete" parameterType="map">
43+
DELETE FROM order_book WHERE sec_id = #{secId} AND book_title = #{bookTitle} AND isbn = #{isbn}
44+
</delete>
945
</mapper>

src/com/giit/www/college/dao/SectionDao.java

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,5 +18,7 @@ public interface SectionDao {
1818

1919
public void add(Section section);
2020

21-
public List<String> findSelectedCourseTitle(@Param("staffId") String staffId, @Param("year") String year);
21+
public List<Section> findSelectedSection(@Param("staffId") String staffId, @Param("year") String year);
22+
23+
int getSecId(String item, String s);
2224
}

src/com/giit/www/college/dao/SectionDao.xml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,8 +23,8 @@
2323
</collection>
2424
</resultMap>
2525

26-
<select id="findSelectedCourseTitle" parameterType="map" resultType="String">
27-
SELECT course_title FROM section WHERE staff_id = #{staffId} AND year = #{year}
26+
<select id="findSelectedSection" parameterType="map" resultMap="sec_map">
27+
SELECT sec_id,course_title FROM section WHERE staff_id = #{staffId} AND year = #{year}
2828
</select>
2929

3030
<select id="findAll" resultMap="sec_map">
Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,21 @@
11
package com.giit.www.college.service;
22

3+
import com.giit.www.entity.Section;
4+
import com.giit.www.entity.custom.AddedBookVo;
5+
import com.giit.www.entity.custom.ChangedItems;
6+
import com.giit.www.entity.custom.OrderBookVo;
7+
38
import java.util.List;
49

510
/**
611
* Created by c0de8ug on 16-2-13.
712
*/
813
public interface OrderBookBiz {
9-
public List<String> findSelectedCourseTitle(String staffId, String year);
14+
public List<Section> findSelectedSection(String staffId, String year);
15+
16+
public void add(OrderBookVo orderBookVo);
17+
18+
public List<AddedBookVo> findAddedBookInfoList(String staffId);
19+
20+
public void update(ChangedItems changedItems, String staffId);
1021
}

src/com/giit/www/college/service/impl/ClazzBizImpl.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -66,6 +66,7 @@ public String findDeptAndSpecJson() {
6666
}
6767

6868
//TODO 在这里感觉不应该查询两次应该使用上面的结果keyset,磁盘的开销远大于运算,如果开一个deptAndSpecList变量存储这个变量是线程安全的么,留坑= =!
69+
//感觉这里应该是取决于biz的BEAN在spring中的作用域
6970
@Override
7071
public List<String> findDeptNameList() {
7172
return deptDao.findAllDeptName();

0 commit comments

Comments
 (0)