Skip to content

Commit 3f738af

Browse files
committed
Add elective function
1 parent cdb03ff commit 3f738af

11 files changed

Lines changed: 59 additions & 20 deletions

File tree

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

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -36,12 +36,6 @@ public String studentUpdateView(Model m) {
3636

3737
return "/admin/college/student_update";
3838
}
39-
40-
@RequestMapping("student_elective.view")
41-
public String studentElectiveView() {
42-
return "/student/elective";
43-
}
44-
4539
@RequestMapping("add")
4640
public String add(Model m, Student student) {
4741
studentBiz.add(student);

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

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77
<mapper namespace="com.giit.www.college.dao.OrderBookDao">
88

99
<resultMap id="orderBookReviewVo" type="OrderBookReviewVo">
10+
<result property="secId" column="sec_id"/>
1011
<result property="speciality" column="speciality"/>
1112
<result property="courseTitle" column="course_title"/>
1213
<result property="bookTitle" column="book_title"/>
@@ -50,7 +51,7 @@
5051
</select>
5152

5253
<select id="findAllNotReviewedBook" resultMap="orderBookReviewVo">
53-
SELECT speciality,course.course_title,book.isbn,book.book_title,
54+
SELECT section.sec_id,speciality,course.course_title,book.isbn,book.book_title,
5455
date_of_printing,author,press,category,unit_price,remark
5556
FROM order_book
5657
INNER JOIN book ON order_book.isbn = book.isbn AND order_book.book_title = book.book_title

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

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,4 +21,6 @@ public interface SectionDao {
2121
public List<Section> findSelectedSection(@Param("staffId") String staffId, @Param("year") String year);
2222

2323
int getSecId(String item, String s);
24+
25+
public List<Section> findAll();
2426
}
Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,15 @@
11
package com.giit.www.college.dao;
22

3+
import org.apache.ibatis.annotations.Param;
4+
35
/**
46
* Created by c0de8ug on 16-2-16.
57
*/
68

79
public interface TakesDao {
810
public int getStdCountInSection(int secId);
911

10-
public void add(int secId, int stdId);
12+
public void add(@Param("secId") int secId, @Param("stdId") String stdId);
13+
14+
public void delete(@Param("secId") int secId, @Param("stdId") String stdId);
1115
}

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

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,4 +10,11 @@
1010
SELECT count(student_id) FROM takes WHERE sec_id = #{value}
1111
</select>
1212

13+
<insert id="add" parameterType="map">
14+
INSERT INTO takes(student_id,sec_Id) VALUES(#{stdId},#{secId})
15+
</insert>
16+
17+
<delete id="delete" parameterType="map">
18+
DELETE FROM takes WHERE student_id = #{stdId} AND sec_id = #{secId}
19+
</delete>
1320
</mapper>

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -190,7 +190,7 @@ public List<OrderBookReviewVo> findAllNotReviewedBook() {
190190
temp.setStdCount(stdCount);
191191
}
192192

193-
return orderBookDao.findAllNotReviewedBook();
193+
return orderBookReviewVoList;
194194
}
195195

196196
}

src/com/giit/www/student/controller/ElectiveController.java

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22

33
import com.giit.www.student.service.ElectiveBiz;
44
import org.springframework.stereotype.Controller;
5+
import org.springframework.ui.Model;
56
import org.springframework.web.bind.annotation.RequestMapping;
67

78
import javax.annotation.Resource;
@@ -18,15 +19,23 @@ public class ElectiveController {
1819

1920

2021
@RequestMapping("elective.view")
21-
public String electiveView() {
22+
public String electiveView(Model m) {
23+
m.addAttribute("sectionList", electiveBiz.findAllSection());
2224
return "/student/elective";
2325
}
2426

25-
2627
@RequestMapping("add")
2728
public String add(int secId, HttpSession session) {
2829
String stdId = (String) session.getAttribute("username");
2930
electiveBiz.add(secId, stdId);
30-
return "/elective.do/elective_view";
31+
return "redirect:/elective.do/elective_view";
3132
}
33+
34+
@RequestMapping("delete")
35+
public String delete(int secId, HttpSession session) {
36+
String stdId = (String) session.getAttribute("username");
37+
electiveBiz.delete(secId, stdId);
38+
return "redirect:/elective.do/elective_view";
39+
}
40+
3241
}
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,17 @@
11
package com.giit.www.student.service;
22

3+
import com.giit.www.entity.Section;
4+
import com.giit.www.entity.custom.SectionCustom;
5+
6+
import java.util.List;
7+
38
/**
49
* Created by c0de8ug on 16-2-16.
510
*/
611
public interface ElectiveBiz {
712
public void add(int secId, String stdId);
13+
14+
public List<SectionCustom> findAllSection();
15+
16+
public void delete(int secId, String stdId);
817
}

src/com/giit/www/student/service/Impl/ElectiveBizImpl.java

Lines changed: 18 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,14 @@
11
package com.giit.www.student.service.Impl;
22

3+
import com.giit.www.college.dao.SectionDao;
34
import com.giit.www.college.dao.TakesDao;
5+
import com.giit.www.entity.Section;
6+
import com.giit.www.entity.custom.SectionCustom;
47
import com.giit.www.student.service.ElectiveBiz;
58
import org.springframework.stereotype.Service;
69

710
import javax.annotation.Resource;
11+
import java.util.List;
812

913
/**
1014
* Created by c0de8ug on 16-2-16.
@@ -15,7 +19,20 @@ public class ElectiveBizImpl implements ElectiveBiz {
1519
@Resource
1620
private TakesDao takesDao;
1721

18-
public void add(int secId,int stdId) {
22+
@Resource
23+
private SectionDao sectionDao;
24+
25+
public void add(int secId, String stdId) {
1926
takesDao.add(secId, stdId);
2027
}
28+
29+
@Override
30+
public List<SectionCustom> findAllSection() {
31+
return sectionDao.findAllCustom();
32+
}
33+
34+
@Override
35+
public void delete(int secId, String stdId) {
36+
takesDao.delete(secId,stdId);
37+
}
2138
}

web/WEB-INF/view/student/elective.jsp

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -23,21 +23,17 @@
2323
<th>课程ID</th>
2424
<th>课程名称</th>
2525
<th>授课老师</th>
26-
<th>授课周次,星期,节次</th>
27-
<th>上课教室</th>
2826
<th></th>
2927
</tr>
3028
</thead>
3129
<tbody>
3230
<c:forEach var="section" items="${sectionList}">
3331
<tr>
34-
<td>${section.sectionId}</td>
32+
<td>${section.secId}</td>
3533
<td>${section.courseTitle}</td>
3634
<td>${section.teacher}</td>
37-
<td>${section.weeks}${section.week} ${section.time}节</td>
38-
<td>${section.classroom}</td>
3935
<td>
40-
<a href="/elective.do/add?sectionId=${section.id}"
36+
<a href="/elective.do/add?secId=${section.secId}"
4137
onclick="return confirm('是否选择该课')">选课</a>
4238
</td>
4339
</tr>

0 commit comments

Comments
 (0)