|
|
@ -3,83 +3,105 @@
|
|
|
|
"http://mybatis.org/dtd/mybatis-3-mapper.dtd" >
|
|
|
|
"http://mybatis.org/dtd/mybatis-3-mapper.dtd" >
|
|
|
|
<mapper namespace="com.itheima.dao.StudentDao" >
|
|
|
|
<mapper namespace="com.itheima.dao.StudentDao" >
|
|
|
|
|
|
|
|
|
|
|
|
<!--分页查询-->
|
|
|
|
<!-- 分页查询学生列表 -->
|
|
|
|
<select id="getStudentList" parameterType="Student" resultType="Student">
|
|
|
|
<select id="getStudentList" parameterType="Student" resultType="Student">
|
|
|
|
select *from d_student
|
|
|
|
select * from d_student
|
|
|
|
<where>
|
|
|
|
<where>
|
|
|
|
|
|
|
|
<!-- 如果学生姓名不为空且不为空字符串,则按学生姓名模糊查询 -->
|
|
|
|
<if test="s_name!=null and s_name!='' ">
|
|
|
|
<if test="s_name!=null and s_name!='' ">
|
|
|
|
and s_name like '%${s_name}%'
|
|
|
|
and s_name like '%${s_name}%'
|
|
|
|
</if>
|
|
|
|
</if>
|
|
|
|
|
|
|
|
<!-- 如果学生ID不为空且不为0,则按学生ID模糊查询 -->
|
|
|
|
<if test="s_studentid!=null and s_studentid!=0">
|
|
|
|
<if test="s_studentid!=null and s_studentid!=0">
|
|
|
|
and s_studentid like '%${s_studentid}%'
|
|
|
|
and s_studentid like '%${s_studentid}%'
|
|
|
|
</if>
|
|
|
|
</if>
|
|
|
|
|
|
|
|
<!-- 如果班级ID不为空且不为0,则按班级ID模糊查询 -->
|
|
|
|
<if test="s_classid!=null and s_classid!=0">
|
|
|
|
<if test="s_classid!=null and s_classid!=0">
|
|
|
|
and s_classid like '%${s_classid}%'
|
|
|
|
and s_classid like '%${s_classid}%'
|
|
|
|
</if>
|
|
|
|
</if>
|
|
|
|
|
|
|
|
<!-- 如果班级名称不为空且不为空字符串,则按班级名称模糊查询 -->
|
|
|
|
<if test="s_classname!=null and s_classname!='' ">
|
|
|
|
<if test="s_classname!=null and s_classname!='' ">
|
|
|
|
and s_classname like '%${s_classname}%'
|
|
|
|
and s_classname like '%${s_classname}%'
|
|
|
|
</if>
|
|
|
|
</if>
|
|
|
|
</where>
|
|
|
|
</where>
|
|
|
|
ORDER BY s_id asc
|
|
|
|
<!-- 按学生ID升序排序 -->
|
|
|
|
|
|
|
|
ORDER BY s_id asc
|
|
|
|
|
|
|
|
<!-- 分页参数 -->
|
|
|
|
limit #{currentPage},#{pageSize}
|
|
|
|
limit #{currentPage},#{pageSize}
|
|
|
|
</select>
|
|
|
|
</select>
|
|
|
|
<!--查询数据总数-->
|
|
|
|
|
|
|
|
<select id="totalCount" resultType="Integer">
|
|
|
|
<!-- 查询学生总数 -->
|
|
|
|
|
|
|
|
<select id="totalCount" resultType="Integer">
|
|
|
|
select count(s_studentid) from d_student
|
|
|
|
select count(s_studentid) from d_student
|
|
|
|
<where>
|
|
|
|
<where>
|
|
|
|
<if test="s_name!=null and s_name!='' ">
|
|
|
|
<!-- 如果学生姓名不为空且不为空字符串,则按学生姓名模糊查询 -->
|
|
|
|
and s_name like '%${s_name}%'
|
|
|
|
<if test="s_name!=null and s_name!='' ">
|
|
|
|
</if>
|
|
|
|
and s_name like '%${s_name}%'
|
|
|
|
<if test="s_studentid!=null and s_studentid!=0">
|
|
|
|
</if>
|
|
|
|
and s_studentid like '%${s_studentid}%'
|
|
|
|
<!-- 如果学生ID不为空且不为0,则按学生ID模糊查询 -->
|
|
|
|
</if>
|
|
|
|
<if test="s_studentid!=null and s_studentid!=0">
|
|
|
|
<if test="s_classid!=null and s_classid!=0">
|
|
|
|
and s_studentid like '%${s_studentid}%'
|
|
|
|
and s_classid like '%${s_classid}%'
|
|
|
|
</if>
|
|
|
|
</if>
|
|
|
|
<!-- 如果班级ID不为空且不为0,则按班级ID模糊查询 -->
|
|
|
|
<if test="s_classname!=null and s_classname!='' ">
|
|
|
|
<if test="s_classid!=null and s_classid!=0">
|
|
|
|
and s_classname like '%${s_classname}%'
|
|
|
|
and s_classid like '%${s_classid}%'
|
|
|
|
</if>
|
|
|
|
</if>
|
|
|
|
</where>
|
|
|
|
<!-- 如果班级名称不为空且不为空字符串,则按班级名称模糊查询 -->
|
|
|
|
|
|
|
|
<if test="s_classname!=null and s_classname!='' ">
|
|
|
|
|
|
|
|
and s_classname like '%${s_classname}%'
|
|
|
|
|
|
|
|
</if>
|
|
|
|
|
|
|
|
</where>
|
|
|
|
</select>
|
|
|
|
</select>
|
|
|
|
<!--通过id删除学生信息-->
|
|
|
|
|
|
|
|
<delete id="deleteStudent" parameterType="Integer" >
|
|
|
|
<!-- 通过ID删除学生信息 -->
|
|
|
|
|
|
|
|
<delete id="deleteStudent" parameterType="Integer">
|
|
|
|
delete from d_student where s_id=#{s_id}
|
|
|
|
delete from d_student where s_id=#{s_id}
|
|
|
|
</delete>
|
|
|
|
</delete>
|
|
|
|
<!--添加学生信息-->
|
|
|
|
|
|
|
|
|
|
|
|
<!-- 添加学生信息 -->
|
|
|
|
<insert id="addStudent" parameterType="Student" keyProperty="s_id" useGeneratedKeys="true">
|
|
|
|
<insert id="addStudent" parameterType="Student" keyProperty="s_id" useGeneratedKeys="true">
|
|
|
|
insert into d_student (s_studentid,s_name,s_sex,s_age,s_phone,s_classid,s_classname,s_dormitoryid)
|
|
|
|
insert into d_student (s_studentid, s_name, s_sex, s_age, s_phone, s_classid, s_classname, s_dormitoryid)
|
|
|
|
values(#{s_studentid},#{s_name},#{s_sex},#{s_age},#{s_phone},#{s_classid},#{s_classname},#{s_dormitoryid})
|
|
|
|
values(#{s_studentid}, #{s_name}, #{s_sex}, #{s_age}, #{s_phone}, #{s_classid}, #{s_classname}, #{s_dormitoryid})
|
|
|
|
</insert>
|
|
|
|
</insert>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
<!-- 通过ID查询学生信息 -->
|
|
|
|
<select id="findStudentById" parameterType="Integer" resultType="Student" >
|
|
|
|
<select id="findStudentById" parameterType="Integer" resultType="Student">
|
|
|
|
select * from d_student where s_id=#{s_id}
|
|
|
|
select * from d_student where s_id=#{s_id}
|
|
|
|
</select>
|
|
|
|
</select>
|
|
|
|
<!--修改学生信息-->
|
|
|
|
|
|
|
|
|
|
|
|
<!-- 修改学生信息 -->
|
|
|
|
<update id="updateStudent" parameterType="Student">
|
|
|
|
<update id="updateStudent" parameterType="Student">
|
|
|
|
update d_student
|
|
|
|
update d_student
|
|
|
|
<set>
|
|
|
|
<set>
|
|
|
|
|
|
|
|
<!-- 如果学生ID不为空且不为0,则更新学生ID -->
|
|
|
|
<if test="s_studentid!=null and s_studentid!=0">
|
|
|
|
<if test="s_studentid!=null and s_studentid!=0">
|
|
|
|
s_studentid=#{s_studentid},
|
|
|
|
s_studentid=#{s_studentid},
|
|
|
|
</if>
|
|
|
|
</if>
|
|
|
|
|
|
|
|
<!-- 如果学生姓名不为空且不为空字符串,则更新学生姓名 -->
|
|
|
|
<if test="s_name !=null and s_name !=''">
|
|
|
|
<if test="s_name !=null and s_name !=''">
|
|
|
|
s_name=#{s_name},
|
|
|
|
s_name=#{s_name},
|
|
|
|
</if>
|
|
|
|
</if>
|
|
|
|
|
|
|
|
<!-- 如果学生性别不为空且不为空字符串,则更新学生性别 -->
|
|
|
|
<if test="s_sex !=null and s_sex !=''">
|
|
|
|
<if test="s_sex !=null and s_sex !=''">
|
|
|
|
s_sex=#{s_sex},
|
|
|
|
s_sex=#{s_sex},
|
|
|
|
</if>
|
|
|
|
</if>
|
|
|
|
|
|
|
|
<!-- 如果学生年龄不为空且不为0,则更新学生年龄 -->
|
|
|
|
<if test="s_age !=null and s_age !=0">
|
|
|
|
<if test="s_age !=null and s_age !=0">
|
|
|
|
s_age=#{s_age},
|
|
|
|
s_age=#{s_age},
|
|
|
|
</if>
|
|
|
|
</if>
|
|
|
|
|
|
|
|
<!-- 如果学生电话不为空且不为0,则更新学生电话 -->
|
|
|
|
<if test="s_phone !=null and s_phone !=0">
|
|
|
|
<if test="s_phone !=null and s_phone !=0">
|
|
|
|
s_phone=#{s_phone},
|
|
|
|
s_phone=#{s_phone},
|
|
|
|
</if>
|
|
|
|
</if>
|
|
|
|
|
|
|
|
<!-- 如果班级ID不为空且不为0,则更新班级ID -->
|
|
|
|
<if test="s_classid!=null and s_classid!=0">
|
|
|
|
<if test="s_classid!=null and s_classid!=0">
|
|
|
|
s_classid=#{s_classid},
|
|
|
|
s_classid=#{s_classid},
|
|
|
|
</if>
|
|
|
|
</if>
|
|
|
|
|
|
|
|
<!-- 如果班级名称不为空且不为空字符串,则更新班级名称 -->
|
|
|
|
<if test="s_classname !=null and s_classname !=''">
|
|
|
|
<if test="s_classname !=null and s_classname !=''">
|
|
|
|
s_classname=#{s_classname},
|
|
|
|
s_classname=#{s_classname},
|
|
|
|
</if>
|
|
|
|
</if>
|
|
|
|
|
|
|
|
<!-- 如果宿舍ID不为空且不为0,则更新宿舍ID -->
|
|
|
|
<if test="s_dormitoryid!=null and s_dormitoryid!=0">
|
|
|
|
<if test="s_dormitoryid!=null and s_dormitoryid!=0">
|
|
|
|
s_dormitoryid=#{s_dormitoryid},
|
|
|
|
s_dormitoryid=#{s_dormitoryid},
|
|
|
|
</if>
|
|
|
|
</if>
|
|
|
@ -87,6 +109,7 @@
|
|
|
|
where s_id = #{s_id}
|
|
|
|
where s_id = #{s_id}
|
|
|
|
</update>
|
|
|
|
</update>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
<!-- 获取所有学生信息 -->
|
|
|
|
<select id="getAll" resultType="Student">
|
|
|
|
<select id="getAll" resultType="Student">
|
|
|
|
select * from d_student;
|
|
|
|
select * from d_student;
|
|
|
|
</select>
|
|
|
|
</select>
|
|
|
|