TeacherMapper.xml 5.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118
  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. <mapper namespace="com.schoolinout.system.mapper.TeacherMapper">
  6. <resultMap type="Teacher" id="TeacherResult">
  7. <result property="id" column="id"/>
  8. <result property="schoolId" column="school_id"/>
  9. <result property="teacherName" column="teacher_name"/>
  10. <result property="gender" column="gender"/>
  11. <result property="phone" column="phone"/>
  12. <result property="delFlag" column="del_flag"/>
  13. <result property="createBy" column="create_by"/>
  14. <result property="createTime" column="create_time"/>
  15. <result property="updateBy" column="update_by"/>
  16. <result property="updateTime" column="update_time"/>
  17. </resultMap>
  18. <sql id="selectTeacherVo">
  19. select id,
  20. school_id,
  21. teacher_name,
  22. gender,
  23. phone,
  24. del_flag,
  25. create_by,
  26. create_time,
  27. update_by,
  28. update_time
  29. from tb_school_teacher
  30. </sql>
  31. <select id="selectTeacherList" parameterType="Teacher" resultMap="TeacherResult">
  32. <include refid="selectTeacherVo"/>
  33. <where>
  34. <if test="schoolId != null ">and school_id = #{schoolId}</if>
  35. <if test="teacherName != null and teacherName != ''">and teacher_name like concat('%', #{teacherName},
  36. '%')
  37. </if>
  38. <if test="gender != null and gender != ''">and gender = #{gender}</if>
  39. <if test="phone != null and phone != ''">and phone like concat('%', #{phone}, '%')</if>
  40. </where>
  41. </select>
  42. <select id="selectTeacherById" parameterType="Long" resultMap="TeacherResult">
  43. <include refid="selectTeacherVo"/>
  44. where id = #{id}
  45. </select>
  46. <select id="selectTeacherOption" resultType="com.schoolinout.system.domain.vo.OptionVo">
  47. SELECT id as value,
  48. teacher_name as label
  49. FROM tb_school_teacher
  50. where school_id = #{schoolId}
  51. </select>
  52. <select id="selectTeacherByIdAndSchoolId" resultType="com.schoolinout.system.domain.Teacher">
  53. <include refid="selectTeacherVo"/>
  54. where
  55. id = #{teacherId}
  56. AND
  57. school_id = #{schoolId}
  58. </select>
  59. <insert id="insertTeacher" parameterType="Teacher" useGeneratedKeys="true" keyProperty="id">
  60. insert into tb_school_teacher
  61. <trim prefix="(" suffix=")" suffixOverrides=",">
  62. <if test="schoolId != null">school_id,</if>
  63. <if test="teacherName != null and teacherName != ''">teacher_name,</if>
  64. <if test="gender != null and gender != ''">gender,</if>
  65. <if test="phone != null and phone != ''">phone,</if>
  66. <if test="delFlag != null">del_flag,</if>
  67. <if test="createBy != null">create_by,</if>
  68. <if test="createTime != null">create_time,</if>
  69. <if test="updateBy != null">update_by,</if>
  70. <if test="updateTime != null">update_time,</if>
  71. </trim>
  72. <trim prefix="values (" suffix=")" suffixOverrides=",">
  73. <if test="schoolId != null">#{schoolId},</if>
  74. <if test="teacherName != null and teacherName != ''">#{teacherName},</if>
  75. <if test="gender != null and gender != ''">#{gender},</if>
  76. <if test="phone != null and phone != ''">#{phone},</if>
  77. <if test="delFlag != null">#{delFlag},</if>
  78. <if test="createBy != null">#{createBy},</if>
  79. <if test="createTime != null">#{createTime},</if>
  80. <if test="updateBy != null">#{updateBy},</if>
  81. <if test="updateTime != null">#{updateTime},</if>
  82. </trim>
  83. </insert>
  84. <update id="updateTeacher" parameterType="Teacher">
  85. update tb_school_teacher
  86. <trim prefix="SET" suffixOverrides=",">
  87. <if test="schoolId != null">school_id = #{schoolId},</if>
  88. <if test="teacherName != null and teacherName != ''">teacher_name = #{teacherName},</if>
  89. <if test="gender != null and gender != ''">gender = #{gender},</if>
  90. <if test="phone != null and phone != ''">phone = #{phone},</if>
  91. <if test="delFlag != null">del_flag = #{delFlag},</if>
  92. <if test="createBy != null">create_by = #{createBy},</if>
  93. <if test="createTime != null">create_time = #{createTime},</if>
  94. <if test="updateBy != null">update_by = #{updateBy},</if>
  95. <if test="updateTime != null">update_time = #{updateTime},</if>
  96. </trim>
  97. where id = #{id}
  98. </update>
  99. <delete id="deleteTeacherById" parameterType="Long">
  100. delete
  101. from tb_school_teacher
  102. where id = #{id}
  103. </delete>
  104. <delete id="deleteTeacherByIds" parameterType="String">
  105. delete from tb_school_teacher where id in
  106. <foreach item="id" collection="array" open="(" separator="," close=")">
  107. #{id}
  108. </foreach>
  109. </delete>
  110. </mapper>