You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
72 lines
3.0 KiB
72 lines
3.0 KiB
<?xml version="1.0" encoding="UTF-8" ?>
|
|
<!DOCTYPE mapper
|
|
PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
|
"http://mybatis.org/dtd/mybatis-3-mapper.dtd">
|
|
<mapper namespace="org.example.mapper.CourseMapper">
|
|
|
|
<resultMap type="Course" id="CourseResult">
|
|
<result property="id" column="id" />
|
|
<result property="name" column="name" />
|
|
<result property="courseNo" column="course_no" />
|
|
<result property="teacherId" column="teacher_id" />
|
|
<result property="remark" column="remark" />
|
|
<association property="teacher" column="teacher_id" select="org.example.mapper.UserMapper.selectUserById"/>
|
|
</resultMap>
|
|
|
|
<sql id="selectCourseVo">
|
|
select id, name, course_no, teacher_id, remark from course
|
|
</sql>
|
|
|
|
<select id="selectCourseList" parameterType="Course" resultMap="CourseResult">
|
|
<include refid="selectCourseVo"/>
|
|
<where>
|
|
<if test="name != null and name != ''"> and name like concat('%', #{name}, '%')</if>
|
|
<if test="teacherId != null and teacherId != ''"> and teacher_id = #{teacherId}</if>
|
|
</where>
|
|
order by id desc
|
|
</select>
|
|
|
|
<select id="selectCourseById" parameterType="Long" resultMap="CourseResult">
|
|
<include refid="selectCourseVo"/>
|
|
where id = #{id}
|
|
</select>
|
|
|
|
<insert id="insertCourse" parameterType="Course" useGeneratedKeys="true" keyProperty="id">
|
|
insert into course
|
|
<trim prefix="(" suffix=")" suffixOverrides=",">
|
|
<if test="name != null and name != ''">name,</if>
|
|
<if test="courseNo != null and courseNo != ''">course_no,</if>
|
|
<if test="teacherId != null and teacherId != ''">teacher_id,</if>
|
|
<if test="remark != null">remark,</if>
|
|
</trim>
|
|
<trim prefix="values (" suffix=")" suffixOverrides=",">
|
|
<if test="name != null and name != ''">#{name},</if>
|
|
<if test="courseNo != null and courseNo != ''">#{courseNo},</if>
|
|
<if test="teacherId != null and teacherId != ''">#{teacherId},</if>
|
|
<if test="remark != null">#{remark},</if>
|
|
</trim>
|
|
</insert>
|
|
|
|
<update id="updateCourse" parameterType="Course">
|
|
update course
|
|
<trim prefix="SET" suffixOverrides=",">
|
|
<if test="name != null and name != ''">name = #{name},</if>
|
|
<if test="courseNo != null and courseNo != ''">course_no = #{courseNo},</if>
|
|
<if test="teacherId != null and teacherId != ''">teacher_id = #{teacherId},</if>
|
|
<if test="remark != null">remark = #{remark},</if>
|
|
</trim>
|
|
where id = #{id}
|
|
</update>
|
|
|
|
<delete id="deleteCourseById" parameterType="Long">
|
|
delete from Course where id = #{id}
|
|
</delete>
|
|
|
|
<delete id="deleteCourseByIds" parameterType="String">
|
|
delete from Course where id in
|
|
<foreach item="id" collection="array" open="(" separator="," close=")">
|
|
#{id}
|
|
</foreach>
|
|
</delete>
|
|
|
|
</mapper> |