DepartmentMapper.xml

    1. <?xml version="1.0" encoding="UTF-8"?>
    2. <!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
    3. <mapper namespace="com.wzy.dao.DepartmentMapper">
    4. <resultMap id="BaseResultMap" type="com.wzy.pojo.Department">
    5. <id column="dept_id" jdbcType="INTEGER" property="deptId" />
    6. <result column="dept_name" jdbcType="VARCHAR" property="deptName" />
    7. </resultMap>
    8. <sql id="Example_Where_Clause">
    9. <where>
    10. <foreach collection="oredCriteria" item="criteria" separator="or">
    11. <if test="criteria.valid">
    12. <trim prefix="(" prefixOverrides="and" suffix=")">
    13. <foreach collection="criteria.criteria" item="criterion">
    14. <choose>
    15. <when test="criterion.noValue">
    16. and ${criterion.condition}
    17. </when>
    18. <when test="criterion.singleValue">
    19. and ${criterion.condition} #{criterion.value}
    20. </when>
    21. <when test="criterion.betweenValue">
    22. and ${criterion.condition} #{criterion.value} and #{criterion.secondValue}
    23. </when>
    24. <when test="criterion.listValue">
    25. and ${criterion.condition}
    26. <foreach close=")" collection="criterion.value" item="listItem" open="(" separator=",">
    27. #{listItem}
    28. </foreach>
    29. </when>
    30. </choose>
    31. </foreach>
    32. </trim>
    33. </if>
    34. </foreach>
    35. </where>
    36. </sql>
    37. <sql id="Update_By_Example_Where_Clause">
    38. <where>
    39. <foreach collection="example.oredCriteria" item="criteria" separator="or">
    40. <if test="criteria.valid">
    41. <trim prefix="(" prefixOverrides="and" suffix=")">
    42. <foreach collection="criteria.criteria" item="criterion">
    43. <choose>
    44. <when test="criterion.noValue">
    45. and ${criterion.condition}
    46. </when>
    47. <when test="criterion.singleValue">
    48. and ${criterion.condition} #{criterion.value}
    49. </when>
    50. <when test="criterion.betweenValue">
    51. and ${criterion.condition} #{criterion.value} and #{criterion.secondValue}
    52. </when>
    53. <when test="criterion.listValue">
    54. and ${criterion.condition}
    55. <foreach close=")" collection="criterion.value" item="listItem" open="(" separator=",">
    56. #{listItem}
    57. </foreach>
    58. </when>
    59. </choose>
    60. </foreach>
    61. </trim>
    62. </if>
    63. </foreach>
    64. </where>
    65. </sql>
    66. <sql id="Base_Column_List">
    67. dept_id, dept_name
    68. </sql>
    69. <select id="selectByExample" parameterType="com.wzy.pojo.DepartmentExample" resultMap="BaseResultMap">
    70. select
    71. <if test="distinct">
    72. distinct
    73. </if>
    74. <include refid="Base_Column_List" />
    75. from myb_dept
    76. <if test="_parameter != null">
    77. <include refid="Example_Where_Clause" />
    78. </if>
    79. <if test="orderByClause != null">
    80. order by ${orderByClause}
    81. </if>
    82. </select>
    83. <select id="selectByPrimaryKey" parameterType="java.lang.Integer" resultMap="BaseResultMap">
    84. select
    85. <include refid="Base_Column_List" />
    86. from myb_dept
    87. where dept_id = #{deptId,jdbcType=INTEGER}
    88. </select>
    89. <delete id="deleteByPrimaryKey" parameterType="java.lang.Integer">
    90. delete from myb_dept
    91. where dept_id = #{deptId,jdbcType=INTEGER}
    92. </delete>
    93. <delete id="deleteByExample" parameterType="com.wzy.pojo.DepartmentExample">
    94. delete from myb_dept
    95. <if test="_parameter != null">
    96. <include refid="Example_Where_Clause" />
    97. </if>
    98. </delete>
    99. <insert id="insert" parameterType="com.wzy.pojo.Department">
    100. insert into myb_dept (dept_id, dept_name)
    101. values (#{deptId,jdbcType=INTEGER}, #{deptName,jdbcType=VARCHAR})
    102. </insert>
    103. <insert id="insertSelective" parameterType="com.wzy.pojo.Department">
    104. insert into myb_dept
    105. <trim prefix="(" suffix=")" suffixOverrides=",">
    106. <if test="deptId != null">
    107. dept_id,
    108. </if>
    109. <if test="deptName != null">
    110. dept_name,
    111. </if>
    112. </trim>
    113. <trim prefix="values (" suffix=")" suffixOverrides=",">
    114. <if test="deptId != null">
    115. #{deptId,jdbcType=INTEGER},
    116. </if>
    117. <if test="deptName != null">
    118. #{deptName,jdbcType=VARCHAR},
    119. </if>
    120. </trim>
    121. </insert>
    122. <select id="countByExample" parameterType="com.wzy.pojo.DepartmentExample" resultType="java.lang.Long">
    123. select count(*) from myb_dept
    124. <if test="_parameter != null">
    125. <include refid="Example_Where_Clause" />
    126. </if>
    127. </select>
    128. <update id="updateByExampleSelective" parameterType="map">
    129. update myb_dept
    130. <set>
    131. <if test="record.deptId != null">
    132. dept_id = #{record.deptId,jdbcType=INTEGER},
    133. </if>
    134. <if test="record.deptName != null">
    135. dept_name = #{record.deptName,jdbcType=VARCHAR},
    136. </if>
    137. </set>
    138. <if test="_parameter != null">
    139. <include refid="Update_By_Example_Where_Clause" />
    140. </if>
    141. </update>
    142. <update id="updateByExample" parameterType="map">
    143. update myb_dept
    144. set dept_id = #{record.deptId,jdbcType=INTEGER},
    145. dept_name = #{record.deptName,jdbcType=VARCHAR}
    146. <if test="_parameter != null">
    147. <include refid="Update_By_Example_Where_Clause" />
    148. </if>
    149. </update>
    150. <update id="updateByPrimaryKeySelective" parameterType="com.wzy.pojo.Department">
    151. update myb_dept
    152. <set>
    153. <if test="deptName != null">
    154. dept_name = #{deptName,jdbcType=VARCHAR},
    155. </if>
    156. </set>
    157. where dept_id = #{deptId,jdbcType=INTEGER}
    158. </update>
    159. <update id="updateByPrimaryKey" parameterType="com.wzy.pojo.Department">
    160. update myb_dept
    161. set dept_name = #{deptName,jdbcType=VARCHAR}
    162. where dept_id = #{deptId,jdbcType=INTEGER}
    163. </update>
    164. </mapper>