Skip to content

Commit 2eb0080

Browse files
committed
finished clazz function
1 parent 74f28af commit 2eb0080

21 files changed

+347
-118
lines changed

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

Lines changed: 0 additions & 36 deletions
This file was deleted.
Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
package com.giit.www.college.controller;
2+
3+
import com.giit.www.college.service.ClazzBiz;
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-11.
12+
*/
13+
@Controller
14+
@RequestMapping("clazz.do")
15+
public class ClazzController {
16+
17+
@Resource(name = "clazzBizImpl")
18+
private ClazzBiz clazzBiz;
19+
20+
@RequestMapping("add")
21+
public String add(String deptName, String specName, String year) {
22+
clazzBiz.add(deptName, specName, year);
23+
return "redirect:/class.do/findAll";
24+
}
25+
26+
@RequestMapping("delete")
27+
public String delete(int clazzId) {
28+
clazzBiz.delete(clazzId);
29+
return "redirect:/clazz.do/findAll";
30+
}
31+
32+
@RequestMapping("findAll")
33+
public String findAll(Model m) {
34+
m.addAttribute("clazzList", clazzBiz.findAll());
35+
return "/college/clazz";
36+
}
37+
38+
@RequestMapping("findDeptAndSpec")
39+
public String findDeptAndSpec(Model m) {
40+
m.addAttribute("deptAndSpec", clazzBiz.findDeptAndSpec());
41+
return "/college/clazz_add";
42+
}
43+
}
Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
package com.giit.www.college.controller;
2+
3+
import com.giit.www.college.service.SectionBiz;
4+
import org.springframework.stereotype.Controller;
5+
6+
import javax.annotation.Resource;
7+
8+
/**
9+
* Created by c0de8ug on 16-2-12.
10+
*/
11+
@Controller
12+
public class SectionController {
13+
@Resource(name = "sectionBizImpl")
14+
private SectionBiz sectionBiz;
15+
16+
17+
}

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

Lines changed: 0 additions & 16 deletions
This file was deleted.
Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
package com.giit.www.college.dao;
2+
3+
import com.giit.www.entity.Clazz;
4+
import org.apache.ibatis.annotations.Param;
5+
6+
import java.util.List;
7+
8+
/**
9+
* Created by c0de8ug on 16-2-11.
10+
*/
11+
public interface ClazzDao {
12+
public void add(Clazz clazz);
13+
14+
public void delete(int clazzId);
15+
16+
public List<Class> findAll();
17+
18+
public int getClassCount(@Param("specName") String specName, @Param("year") String year);
19+
}
Lines changed: 11 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -4,24 +4,28 @@
44
"http://mybatis.org/dtd/mybatis-3-mapper.dtd">
55

66

7-
<mapper namespace="com.giit.www.college.dao.ClassDao">
7+
<mapper namespace="com.giit.www.college.dao.ClazzDao">
88

9-
<resultMap id="class_map" type="Class">
10-
<id property="classId" column="class_id"/>
11-
<result property="className" column="class_name"/>
9+
<resultMap id="clazz_map" type="Clazz">
10+
<id property="clazzId" column="class_id"/>
11+
<result property="clazzName" column="class_name"/>
1212
<result property="year" column="year"/>
1313
<result property="specName" column="spec_name"/>
1414
</resultMap>
1515

16-
<select id="findAll" resultMap="class_map">
16+
<select id="findAll" resultMap="clazz_map">
1717
SELECT * FROM class
1818
</select>
1919

20-
<insert id="add" parameterType="Class">
21-
INSERT INTO class(class_id,class_name,year,spec_name) VALUES (#{classId},#{className},#{year},#{specName})
20+
<insert id="add" parameterType="Clazz">
21+
INSERT INTO class(class_id,class_name,year,spec_name) VALUES (#{clazzId},#{className},#{year},#{specName})
2222
</insert>
2323

2424
<delete id="delete" parameterType="int">
2525
DELETE FROM class WHERE class_id = #{value}
2626
</delete>
27+
28+
<select id="getClassCount" parameterType="map" resultType="int">
29+
SELECT count(spec_name) FROM class WHERE spec_name = #{specName} AND year = #{year}
30+
</select>
2731
</mapper>

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

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,8 @@ public interface DeptDao {
1313

1414
public void add(String deptName);
1515

16+
public String findIdByName(String deptName);
17+
1618
public void update(Dept dept);
1719

1820
public void delete(int deptId);

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

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,9 @@
2424
SELECT * FROM department WHERE dept_id = #{value}
2525
</select>
2626

27+
<select id="findIdByName" parameterType="String" resultType="String">
28+
SELECT dept_id FROM department WHERE dept_name = #{value}
29+
</select>
2730
<update id="update" parameterType="Dept">
2831
UPDATE department SET dept_name = #{deptName} WHERE dept_id = #{deptId}
2932
</update>

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

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,11 +12,13 @@
1212
public interface SpecDao {
1313
public List<Spec> findAll();
1414

15-
public void update(@Param("specName") String specName,@Param("newSpecName") String newSpecName);
15+
public void update(@Param("specName") String specName, @Param("newSpecName") String newSpecName);
1616

1717
public void add(Spec spec);
1818

1919
public void delete(String specName);
2020

2121
public List<DeptAndSpec> findDeptAndSpec();
22+
23+
public String findIdByName(String specName);
2224
}

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -27,8 +27,8 @@
2727
SELECT * FROM speciality
2828
</select>
2929

30-
<select id="findById" parameterType="int" resultMap="spec_map">
31-
SELECT * FROM department WHERE dept_id = #{value}
30+
<select id="findIdByName" parameterType="String" resultType="String">
31+
SELECT spec_id FROM speciality WHERE spec_name = #{value}
3232
</select>
3333

3434
<update id="update" parameterType="map">

0 commit comments

Comments
 (0)