PositionMapper.xml 6.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180
  1. <?xml version="1.0" encoding="UTF-8"?>
  2. <!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
  3. "http://mybatis.org/dtd/mybatis-3-mapper.dtd" >
  4. <mapper namespace="com.zhyc.xps.sys.mapper.PositionMapper">
  5. <resultMap id="PositionDtoResultMap" type="com.zhyc.xps.sys.dto.PositionDto">
  6. <result column="oc_id" property="ocId" jdbcType="BIGINT"/>
  7. <result column="position_id" property="positionId" jdbcType="BIGINT"/>
  8. <result column="position_name" property="positionName" jdbcType="VARCHAR"/>
  9. <result column="position_desc" property="positionDesc" jdbcType="VARCHAR"/>
  10. <result column="is_fixed" property="isFixed" jdbcType="BIGINT"/>
  11. </resultMap>
  12. <sql id="PositionDto_Cols">
  13. A.oc_id,
  14. A.position_id,
  15. A.position_name,
  16. A.position_desc,
  17. A.is_fixed
  18. </sql>
  19. <!--基于ID查询-->
  20. <select id="getById" resultMap="PositionDtoResultMap">
  21. SELECT
  22. <include refid="PositionDto_Cols"/>
  23. FROM s_position AS A
  24. WHERE A.oc_id = #{ocId} AND A.position_id = #{positionId}
  25. </select>
  26. <!--分页查询-->
  27. <select id="getByPage" parameterType="java.util.Map" resultMap="PositionDtoResultMap" >
  28. SELECT
  29. <include refid="PositionDto_Cols"/>
  30. FROM s_position AS A
  31. WHERE A.deleted_flag = 0
  32. <if test="ocId != null">
  33. AND A.oc_id = #{ocId, jdbcType=BIGINT}
  34. </if>
  35. <if test="positionId != null">
  36. AND A.position_id = #{positionId, jdbcType=BIGINT}
  37. </if>
  38. <if test="keywords != null and keywords != ''">
  39. AND A.position_name LIKE "%"#{keywords}"%"
  40. </if>
  41. <if test="positionName != null and positionName != ''">
  42. AND A.position_name = #{positionName,jdbcType=VARCHAR}
  43. </if>
  44. order by A.position_id ASC
  45. </select>
  46. <!--列表查询-->
  47. <select id="getByList" parameterType="java.util.Map" resultMap="PositionDtoResultMap">
  48. SELECT
  49. <include refid="PositionDto_Cols"/>
  50. FROM s_position AS A
  51. WHERE A.deleted_flag = 0
  52. <if test="ocId != null">
  53. AND A.oc_id = #{ocId, jdbcType=BIGINT}
  54. </if>
  55. <if test="positionId != null">
  56. AND A.position_id = #{positionId, jdbcType=BIGINT}
  57. </if>
  58. <if test="keywords != null and keywords != ''">
  59. AND A.position_name like "%"#{keywords}"%"
  60. </if>
  61. </select>
  62. <!--列表查询-->
  63. <select id="selectByList" parameterType="java.util.Map" resultMap="PositionDtoResultMap">
  64. SELECT
  65. <include refid="PositionDto_Cols"/>
  66. FROM s_position AS A
  67. WHERE A.deleted_flag = 0 AND A.is_fixed = 0 AND A.oc_id = #{ocId, jdbcType=BIGINT}
  68. <if test="positionId != null">
  69. AND A.position_id = #{positionId, jdbcType=BIGINT}
  70. </if>
  71. <if test="keywords != null and keywords != ''">
  72. AND A.position_name like "%"#{keywords}"%"
  73. </if>
  74. </select>
  75. <!--新增-->
  76. <insert id="create" parameterType="com.zhyc.xps.sys.entity.Position">
  77. INSERT INTO s_position
  78. <trim prefix="(" suffix=")" suffixOverrides=",">
  79. <if test="ocId != null">
  80. oc_id,
  81. </if>
  82. <if test="positionId != null">
  83. position_id,
  84. </if>
  85. <if test="positionName != null and positionName !=''">
  86. position_name,
  87. </if>
  88. <if test="positionDesc != null and positionDesc !=''">
  89. position_desc,
  90. </if>
  91. <if test="isFixed != null">
  92. is_fixed,
  93. </if>
  94. <if test="createdBy != null">
  95. created_by,
  96. </if>
  97. <if test="createdAt != null">
  98. created_at,
  99. </if>
  100. </trim>
  101. <trim prefix="values (" suffix=")" suffixOverrides=",">
  102. <if test="ocId != null">
  103. #{ocId,jdbcType=BIGINT},
  104. </if>
  105. <if test="positionId != null">
  106. #{positionId ,jdbcType=BIGINT},
  107. </if>
  108. <if test="positionName != null and positionName !=''">
  109. #{positionName ,jdbcType=VARCHAR},
  110. </if>
  111. <if test="positionDesc != null and positionDesc != ''">
  112. #{positionDesc ,jdbcType=VARCHAR},
  113. </if>
  114. <if test="isFixed != null">
  115. #{isFixed ,jdbcType=BIGINT},
  116. </if>
  117. <if test="createdBy != null">
  118. #{createdBy ,jdbcType=BIGINT},
  119. </if>
  120. <if test="createdAt != null">
  121. #{createdAt ,jdbcType=DATE},
  122. </if>
  123. </trim>
  124. </insert>
  125. <!--更新UPDATE-->
  126. <update id="update" parameterType="com.zhyc.xps.sys.entity.Position">
  127. UPDATE s_position
  128. <trim suffixOverrides=",">
  129. <set>
  130. <if test="positionName != null and positionName != ''">
  131. position_name = #{positionName ,jdbcType=VARCHAR},
  132. </if>
  133. <if test="positionDesc != null">
  134. position_desc = #{positionDesc ,jdbcType=VARCHAR},
  135. </if>
  136. <if test="updatedBy != null">
  137. updated_by = #{updatedBy ,jdbcType=BIGINT},
  138. </if>
  139. <if test="updatedAt != null">
  140. updated_at = #{updatedAt ,jdbcType=DATE}
  141. </if>
  142. </set>
  143. </trim>
  144. WHERE 1 = 1
  145. <if test="ocId != null">
  146. AND oc_id = #{ocId ,jdbcType=BIGINT}
  147. </if>
  148. <if test="positionId != null">
  149. AND position_id = #{positionId, jdbcType=BIGINT}
  150. </if>
  151. </update>
  152. <!--删除-->
  153. <update id="delete" parameterType="java.util.Map">
  154. UPDATE s_position
  155. <trim suffixOverrides=",">
  156. <set>
  157. <if test="deletedFlag != null">
  158. deleted_flag = #{deletedFlag ,jdbcType=BIGINT},
  159. </if>
  160. <if test="deletedBy != null">
  161. deleted_by = #{deletedBy ,jdbcType=BIGINT},
  162. </if>
  163. <if test="deletedAt != null">
  164. deleted_at = #{deletedAt ,jdbcType=DATE},
  165. </if>
  166. </set>
  167. </trim>
  168. WHERE oc_id = #{ocId, jdbcType=BIGINT}
  169. AND position_id = #{positionId, jdbcType=BIGINT}
  170. </update>
  171. </mapper>