Skip to content

Commit d4f3deb

Browse files
committed
add supplier function
1 parent 3f738af commit d4f3deb

File tree

13 files changed

+321
-38
lines changed

13 files changed

+321
-38
lines changed

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

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
import com.giit.www.college.service.OrderBookBiz;
44
import com.giit.www.entity.Section;
55
import com.giit.www.entity.custom.ChangedItems;
6+
import com.giit.www.entity.custom.OrderBookReviewVo;
67
import com.giit.www.entity.custom.OrderBookVo;
78
import com.giit.www.util.TermContainer;
89
import org.springframework.http.HttpStatus;
@@ -43,8 +44,9 @@ public String orderBookView(Model m, HttpSession httpSession) {
4344
}
4445

4546
@RequestMapping("orderbook_review.view")
46-
public String orderBookReviewView(Model m) {
47-
m.addAttribute("notReviewedBookList", orderBookBiz.findAllNotReviewedBook());
47+
public String orderBookReviewView(Model m, HttpSession session) {
48+
//TODO 放到SESSION方便处理
49+
session.setAttribute("notReviewedBookList", orderBookBiz.findAllNotReviewedBook());
4850
return "/teacher/orderbook_review";
4951
}
5052

@@ -61,7 +63,6 @@ public String orderBookAddedView(Model m, HttpSession session) {
6163
}
6264

6365

64-
//TODO 这里的数据提交没有回显,会给用户带来不便,如果设计是一个问题!!!
6566
@RequestMapping("add")
6667
public String add(HttpServletRequest request, HttpSession session) {
6768
Map map = request.getParameterMap();
@@ -79,7 +80,9 @@ public void update(@RequestBody ChangedItems changedItems, HttpSession session)
7980
}
8081

8182
@RequestMapping("audit")
82-
public void audit() {
83-
orderBookBiz.audit();
83+
public String audit(HttpSession session) {
84+
List<OrderBookReviewVo> orderBookReviewVoList = (List<OrderBookReviewVo>) session.getAttribute("notReviewedBookList");
85+
orderBookBiz.audit(orderBookReviewVoList);
86+
return "orderbook.do/orderbook_review.view"
8487
}
8588
}

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

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
import com.giit.www.entity.custom.AddedBookVo;
55
import com.giit.www.entity.custom.ChangedItems;
66
import com.giit.www.entity.custom.OrderBookReviewVo;
7+
import com.giit.www.entity.custom.ReviewedBookVo;
78
import org.apache.ibatis.annotations.Param;
89

910
import java.util.List;
@@ -21,4 +22,8 @@ public interface OrderBookDao {
2122
public void delete(@Param("secId") int secId, @Param("bookTitle") String bookTitle, @Param("isbn") String isbn);
2223

2324
public List<OrderBookReviewVo> findAllNotReviewedBook();
25+
26+
public void audit(@Param("secId") int secId, @Param("bookTitle") String bookTitle, @Param("isbn") String isbn);
27+
28+
public List<ReviewedBookVo> findAllReviewedBook();
2429
}

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

Lines changed: 27 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66

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

9-
<resultMap id="orderBookReviewVo" type="OrderBookReviewVo">
9+
<resultMap id="orderBookReviewVo_map" type="OrderBookReviewVo">
1010
<result property="secId" column="sec_id"/>
1111
<result property="speciality" column="speciality"/>
1212
<result property="courseTitle" column="course_title"/>
@@ -19,7 +19,7 @@
1919
<result property="remark" column="remark"/>
2020
</resultMap>
2121

22-
<resultMap id="addedBookInfo" type="AddedBookVo">
22+
<resultMap id="addedBookInfo_map" type="AddedBookVo">
2323
<result property="secId" column="sec_id"/>
2424
<result property="courseTitle" column="course_title"/>
2525
<collection property="bookInfoList" ofType="BookInfo">
@@ -34,11 +34,20 @@
3434
</collection>
3535
</resultMap>
3636

37+
<resultMap id="reviewedBookVo_map" type="ReviewedBookVo">
38+
<result property="bookTitle" column="book_title"/>
39+
<result property="isbn" column="isbn"/>
40+
<result property="dateOfPrinting" column="date_of_printing"/>
41+
<result property="author" column="author"/>
42+
<result property="press" column="press"/>
43+
<collection property="countList" column="count" ofType="Integer"/>
44+
</resultMap>
45+
3746
<insert id="add" parameterType="OrderBook">
3847
INSERT INTO order_book(staff_id,sec_id,book_title,isbn,remark,approval) VALUES(#{staffId},#{secId},#{bookTitle},#{isbn},#{remark},#{approval})
3948
</insert>
4049

41-
<select id="findAddedBookInfoList" parameterType="String" resultMap="addedBookInfo">
50+
<select id="findAddedBookInfoList" parameterType="String" resultMap="addedBookInfo_map">
4251
SELECT section.sec_id,section.course_title,book.isbn,book.book_title,date_of_printing,author,press,category,unit_price,remark
4352
FROM order_book
4453
INNER JOIN book ON order_book.book_title = book.book_title AND order_book.isbn = book.isbn
@@ -50,7 +59,7 @@
5059
SELECT count(*) FROM order_book WHERE book_title = #{bookTitle} AND isbn = #{isbn} AND sec_id != #{secId}
5160
</select>
5261

53-
<select id="findAllNotReviewedBook" resultMap="orderBookReviewVo">
62+
<select id="findAllNotReviewedBook" resultMap="orderBookReviewVo_map">
5463
SELECT section.sec_id,speciality,course.course_title,book.isbn,book.book_title,
5564
date_of_printing,author,press,category,unit_price,remark
5665
FROM order_book
@@ -60,7 +69,21 @@
6069
WHERE approval = 0
6170
</select>
6271

72+
<select id="findAllReviewedBook" resultMap="reviewedBookVo_map">
73+
SELECT book.isbn,book.book_title,
74+
date_of_printing,author,press,category,
75+
(SELECT count(student_id) FROM takes WHERE order_book.sec_id = takes.sec_id) AS count
76+
FROM order_book
77+
INNER JOIN book ON order_book.isbn = book.isbn AND order_book.book_title = book.book_title
78+
WHERE approval = 1
79+
</select>
80+
81+
6382
<delete id="delete" parameterType="map">
6483
DELETE FROM order_book WHERE sec_id = #{secId} AND book_title = #{bookTitle} AND isbn = #{isbn}
6584
</delete>
85+
86+
<update id="audit" parameterType="map">
87+
UPDATE order_book SET approval = 1 WHERE sec_id = #{secId} AND book_title = #{bookTitle} AND isbn=#{isbn}
88+
</update>
6689
</mapper>

src/com/giit/www/college/service/OrderBookBiz.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ public interface OrderBookBiz {
2020

2121
public void update(ChangedItems changedItems, String staffId);
2222

23-
public void audit();
23+
public void audit(List<OrderBookReviewVo> orderBookReviewVoList);
2424

2525
public List<OrderBookReviewVo> findAllNotReviewedBook();
2626
}

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

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -91,7 +91,8 @@ public void add(OrderBookVo orderBookVo) {
9191
orderBook.setApproval(false);
9292

9393
orderBookDao.add(orderBook);
94-
bookDao.add(book);
94+
if (bookDao.find(bookTitle, isbn) == null)
95+
bookDao.add(book);
9596

9697
}
9798
}
@@ -175,8 +176,15 @@ public void update(ChangedItems changedItems, String staffId) {
175176
}
176177

177178
@Override
178-
public void audit() {
179-
179+
public void audit(List<OrderBookReviewVo> orderBookReviewVoList) {
180+
Iterator iterator = orderBookReviewVoList.iterator();
181+
while (iterator.hasNext()) {
182+
OrderBookReviewVo orderBookReviewVo = (OrderBookReviewVo) iterator.next();
183+
int secId = orderBookReviewVo.getSecId();
184+
String bookTitle = orderBookReviewVo.getBookTitle();
185+
String isbn = orderBookReviewVo.getIsbn();
186+
orderBookDao.audit(secId, bookTitle, isbn);
187+
}
180188
}
181189

182190
@Override
Lines changed: 72 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,72 @@
1+
package com.giit.www.entity.custom;
2+
3+
import java.util.List;
4+
5+
/**
6+
* Created by c0de8ug on 16-2-16.
7+
*/
8+
public class ReviewedBookVo {
9+
String bookTitle;
10+
String isbn;
11+
String dateOfPrinting;
12+
String author;
13+
String press;
14+
List<Integer> countList;
15+
int amount;
16+
17+
public int getAmount() {
18+
return amount;
19+
}
20+
21+
public String getBookTitle() {
22+
return bookTitle;
23+
}
24+
25+
public void setBookTitle(String bookTitle) {
26+
this.bookTitle = bookTitle;
27+
}
28+
29+
public String getIsbn() {
30+
return isbn;
31+
}
32+
33+
public void setIsbn(String isbn) {
34+
this.isbn = isbn;
35+
}
36+
37+
public String getDateOfPrinting() {
38+
return dateOfPrinting;
39+
}
40+
41+
public void setDateOfPrinting(String dateOfPrinting) {
42+
this.dateOfPrinting = dateOfPrinting;
43+
}
44+
45+
public String getAuthor() {
46+
return author;
47+
}
48+
49+
public void setAuthor(String author) {
50+
this.author = author;
51+
}
52+
53+
public String getPress() {
54+
return press;
55+
}
56+
57+
public void setPress(String press) {
58+
this.press = press;
59+
}
60+
61+
public List<Integer> getCountList() {
62+
return countList;
63+
}
64+
65+
public void setCountList(List<Integer> countList) {
66+
this.countList = countList;
67+
}
68+
69+
public void setAmount(int amount) {
70+
this.amount = amount;
71+
}
72+
}
Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
package com.giit.www.supplier.controller;
2+
3+
import com.giit.www.supplier.service.SupplierBiz;
4+
import org.springframework.stereotype.Controller;
5+
import org.springframework.ui.Model;
6+
import org.springframework.web.bind.annotation.RequestMapping;
7+
8+
import javax.annotation.Resource;
9+
10+
/**
11+
* Created by c0de8ug on 16-2-16.
12+
*/
13+
14+
@Controller
15+
@RequestMapping("supplier.do")
16+
public class SupplierController {
17+
18+
@Resource(name = "supplierBizImpl")
19+
SupplierBiz supplierBiz;
20+
21+
@RequestMapping("supplier.view")
22+
public String supplierView(Model m) {
23+
m.addAttribute("reviewedBookList", supplierBiz.findAllReviewedBook());
24+
return "/supplier/supplier";
25+
}
26+
}
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
package com.giit.www.supplier.service;
2+
3+
import com.giit.www.entity.custom.ReviewedBookVo;
4+
5+
import java.util.List;
6+
7+
/**
8+
* Created by c0de8ug on 16-2-16.
9+
*/
10+
public interface SupplierBiz {
11+
public List<ReviewedBookVo> findAllReviewedBook();
12+
}
Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
package com.giit.www.supplier.service.impl;
2+
3+
import com.giit.www.college.dao.OrderBookDao;
4+
import com.giit.www.college.dao.TakesDao;
5+
import com.giit.www.entity.custom.OrderBookReviewVo;
6+
import com.giit.www.entity.custom.OrderBookVo;
7+
import com.giit.www.entity.custom.ReviewedBookVo;
8+
import com.giit.www.supplier.service.SupplierBiz;
9+
import org.springframework.stereotype.Service;
10+
11+
import javax.annotation.Resource;
12+
import java.util.Iterator;
13+
import java.util.List;
14+
15+
/**
16+
* Created by c0de8ug on 16-2-16.
17+
*/
18+
@Service
19+
public class SupplierBizImpl implements SupplierBiz {
20+
21+
@Resource
22+
private OrderBookDao orderBookDao;
23+
24+
25+
//TODO 这个代码偷懒了!!!!!要多烂有多烂直接拷贝的。。
26+
public List<ReviewedBookVo> findAllReviewedBook() {
27+
List<ReviewedBookVo> reviewedBookVoList = orderBookDao.findAllReviewedBook();
28+
29+
Iterator iterator = reviewedBookVoList.iterator();
30+
while (iterator.hasNext()) {
31+
ReviewedBookVo reviewedBookVo = (ReviewedBookVo) iterator.next();
32+
List countList = reviewedBookVo.getCountList();
33+
int amount = 0;
34+
for (int i = 0; i < countList.size(); i++) {
35+
amount = amount + (Integer) countList.get(i);
36+
}
37+
reviewedBookVo.setAmount(amount);
38+
}
39+
40+
return reviewedBookVoList;
41+
}
42+
43+
}

0 commit comments

Comments
 (0)