Skip to content

Commit 74f28af

Browse files
committed
fininshed spec
1 parent b914e3f commit 74f28af

27 files changed

+652
-38
lines changed
Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
package com.giit.www.college.controller;
2+
3+
import com.giit.www.college.service.ClassBiz;
4+
import com.giit.www.college.service.impl.ClassBizImpl;
5+
import org.springframework.stereotype.Controller;
6+
import org.springframework.ui.Model;
7+
import org.springframework.web.bind.annotation.RequestMapping;
8+
9+
import javax.annotation.Resource;
10+
import java.util.List;
11+
12+
/**
13+
* Created by c0de8ug on 16-2-11.
14+
*/
15+
@Controller
16+
@RequestMapping("class.do")
17+
public class ClassController {
18+
19+
@Resource(name = "classBizImpl")
20+
private ClassBiz classBiz;
21+
22+
public String add(Class clazz) {
23+
classBiz.add(clazz);
24+
return "redirect:/class.do/findAll";
25+
}
26+
27+
public String delete(int classId) {
28+
classBiz.delete(classId);
29+
return "redirect:/class.do/findAll";
30+
}
31+
32+
public String findAll(Model m) {
33+
m.addAttribute("classList", classBiz.findAll());
34+
return "/college/class";
35+
}
36+
}

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

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ public class DeptController {
2121

2222
@RequestMapping("findAll")
2323
public String findAll(Model m) {
24-
m.addAttribute("departments", deptBiz.findAll());
24+
m.addAttribute("deptList", deptBiz.findAll());
2525
return "/college/dept";
2626
}
2727

@@ -43,4 +43,5 @@ public String delete(int deptId) {
4343
return "redirect:/dept.do/findAll";
4444
}
4545

46+
4647
}
Lines changed: 56 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,56 @@
1+
package com.giit.www.college.controller;
2+
3+
import com.giit.www.college.service.DeptBiz;
4+
import com.giit.www.college.service.SpecBiz;
5+
import com.giit.www.entity.Spec;
6+
import org.apache.ibatis.annotations.Param;
7+
import org.springframework.stereotype.Controller;
8+
import org.springframework.ui.Model;
9+
import org.springframework.web.bind.annotation.RequestMapping;
10+
11+
import javax.annotation.Resource;
12+
13+
/**
14+
* Created by c0de8ug on 16-2-11.
15+
*/
16+
@Controller
17+
@RequestMapping("spec.do")
18+
public class SpecController {
19+
20+
@Resource(name = "specBizImpl")
21+
SpecBiz specBiz;
22+
23+
24+
@RequestMapping("findDept")
25+
public String findDept(Model m) {
26+
m.addAttribute("deptNameList", specBiz.findDpet());
27+
return "/college/spec_add";
28+
}
29+
30+
//TODO 该名字deptAndSpec不好,但是不知道如何命名-, -
31+
@RequestMapping("findDeptAndSpec")
32+
public String findDeptAndSpec(Model m) {
33+
m.addAttribute("deptAndSpec", specBiz.findDeptAndSpec());
34+
return "/college/spec";
35+
}
36+
37+
@RequestMapping("update")
38+
public String update(@Param("specName") String newSpecName, @Param("newSpecName")String specName) {
39+
specBiz.update( specName, newSpecName);
40+
return "redirect:/spec.do/findDeptAndSpec";
41+
}
42+
43+
@RequestMapping("add")
44+
public String add(Spec spec) {
45+
specBiz.add(spec);
46+
return "redirect:/spec.do/findDeptAndSpec";
47+
}
48+
49+
@RequestMapping("delete")
50+
public String delete(String specName) {
51+
specBiz.delete(specName);
52+
return "redirect:/spec.do/findDeptAndSpec";
53+
}
54+
55+
}
56+

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

Lines changed: 8 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -8,30 +8,20 @@
88

99
<resultMap id="class_map" type="Class">
1010
<id property="classId" column="class_id"/>
11-
<result property="className" column="dept_name"/>
11+
<result property="className" column="class_name"/>
12+
<result property="year" column="year"/>
13+
<result property="specName" column="spec_name"/>
1214
</resultMap>
1315

14-
<select id="findAll" resultMap="dept_map">
15-
SELECT * FROM department
16+
<select id="findAll" resultMap="class_map">
17+
SELECT * FROM class
1618
</select>
1719

18-
<select id="findById" parameterType="int" resultMap="class_map">
19-
SELECT * FROM department WHERE dept_id = #{value}
20-
</select>
21-
22-
<select id="findByName" parameterType="String" resultMap="class_map">
23-
SELECT * FROM department WHERE dept_name = #{value}
24-
</select>
25-
26-
<update id="update" parameterType="Class">
27-
UPDATE user SET dept_name = #{deptName} WHERE dept_id = #{deptId}
28-
</update>
29-
30-
<insert id="add" parameterType="String">
31-
INSERT INTO department(dept_name) VALUES(#{value})
20+
<insert id="add" parameterType="Class">
21+
INSERT INTO class(class_id,class_name,year,spec_name) VALUES (#{classId},#{className},#{year},#{specName})
3222
</insert>
3323

3424
<delete id="delete" parameterType="int">
35-
DELETE FROM department WHERE dept_id = #{value}
25+
DELETE FROM class WHERE class_id = #{value}
3626
</delete>
3727
</mapper>
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,16 @@
11
package com.giit.www.college.dao;
22

3+
import java.util.List;
4+
35
/**
46
* Created by c0de8ug on 16-2-11.
57
*/
68
public interface ClassDao {
9+
public void add(Class clazz);
10+
11+
public void delete(int clazzId);
12+
13+
public List<Class> findAll();
14+
15+
716
}

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

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

3+
import com.giit.www.entity.custom.DeptAndSpec;
34
import com.giit.www.entity.Dept;
45

56
import java.util.List;
@@ -15,4 +16,7 @@ public interface DeptDao {
1516
public void update(Dept dept);
1617

1718
public void delete(int deptId);
19+
20+
public List<String> findAllDeptName();
21+
1822
}

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

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -11,16 +11,17 @@
1111
<result property="deptName" column="dept_name"/>
1212
</resultMap>
1313

14+
1415
<select id="findAll" resultMap="dept_map">
1516
SELECT * FROM department
1617
</select>
1718

18-
<select id="findById" parameterType="int" resultMap="dept_map">
19-
SELECT * FROM department WHERE dept_id = #{value}
19+
<select id="findAllDeptName" resultType="String">
20+
SELECT dept_name FROM department
2021
</select>
2122

22-
<select id="findByName" parameterType="String" resultMap="dept_map">
23-
SELECT * FROM department WHERE dept_name = #{value}
23+
<select id="findById" parameterType="int" resultMap="dept_map">
24+
SELECT * FROM department WHERE dept_id = #{value}
2425
</select>
2526

2627
<update id="update" parameterType="Dept">
Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
package com.giit.www.college.dao;
2+
3+
import com.giit.www.entity.Spec;
4+
import com.giit.www.entity.custom.DeptAndSpec;
5+
import org.apache.ibatis.annotations.Param;
6+
7+
import java.util.List;
8+
9+
/**
10+
* Created by c0de8ug on 16-2-11.
11+
*/
12+
public interface SpecDao {
13+
public List<Spec> findAll();
14+
15+
public void update(@Param("specName") String specName,@Param("newSpecName") String newSpecName);
16+
17+
public void add(Spec spec);
18+
19+
public void delete(String specName);
20+
21+
public List<DeptAndSpec> findDeptAndSpec();
22+
}
Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
1+
<?xml version="1.0" encoding="UTF-8" ?>
2+
<!DOCTYPE mapper
3+
PUBLIC "-//mybatis.org//DTD mapper 3.0//EN"
4+
"http://mybatis.org/dtd/mybatis-3-mapper.dtd">
5+
6+
7+
<mapper namespace="com.giit.www.college.dao.SpecDao">
8+
9+
<resultMap id="spec_map" type="Spec">
10+
<id property="deptId" column="dept_id"/>
11+
<result property="deptName" column="dept_name"/>
12+
</resultMap>
13+
14+
15+
<resultMap id="dept_spec" type="DeptAndSpec">
16+
<result property="deptName" column="dept_name"/>
17+
<collection property="specName" ofType="String">
18+
<result property="specName" column="spec_name"/>
19+
</collection>
20+
</resultMap>
21+
22+
<select id="findDeptAndSpec" resultMap="dept_spec">
23+
SELECT dept_name,spec_name FROM speciality
24+
</select>
25+
26+
<select id="findAll" resultMap="spec_map">
27+
SELECT * FROM speciality
28+
</select>
29+
30+
<select id="findById" parameterType="int" resultMap="spec_map">
31+
SELECT * FROM department WHERE dept_id = #{value}
32+
</select>
33+
34+
<update id="update" parameterType="map">
35+
UPDATE speciality SET spec_name = #{newSpecName} WHERE spec_name = #{specName}
36+
</update>
37+
38+
<insert id="add" parameterType="Spec">
39+
INSERT INTO speciality(dept_name,spec_name) VALUES(#{deptName},#{specName})
40+
</insert>
41+
42+
<delete id="delete" parameterType="String">
43+
DELETE FROM speciality WHERE spec_name = #{value}
44+
</delete>
45+
</mapper>
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
package com.giit.www.college.service;
2+
3+
import java.util.List;
4+
5+
/**
6+
* Created by c0de8ug on 16-2-11.
7+
*/
8+
public interface ClassBiz {
9+
public void add(Class clazz);
10+
11+
public void delete(int clazzId);
12+
13+
public List<Class> findAll();
14+
15+
}

0 commit comments

Comments
 (0)