RoleMapper.xml 6.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172
  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.RoleMapper">
  5. <resultMap id="BaseResultMap" type="com.zhyc.xps.sys.entity.Role">
  6. <result column="role_id" property="roleId" jdbcType="BIGINT" />
  7. <result column="role_name" property="roleName" jdbcType="VARCHAR" />
  8. <result column="role_desc" property="roleDesc" jdbcType="VARCHAR" />
  9. <result column="sort_no" property="sortNo" jdbcType="BIGINT" />
  10. <result column="is_fixed" property="isFixed" jdbcType="BIGINT" />
  11. <result column="role_type_id" property="roleTypeId" jdbcType="BIGINT" />
  12. </resultMap>
  13. <sql id="Base_Column_List">
  14. role_id,
  15. role_name,
  16. role_code,
  17. role_desc,
  18. role_type_id,
  19. sort_no,
  20. is_fixed
  21. </sql>
  22. <!--基于ID查询-->
  23. <select id="getById" parameterType="java.lang.Long" resultMap="BaseResultMap">
  24. SELECT
  25. <include refid="Base_Column_List"/>
  26. FROM s_role
  27. WHERE role_id = #{roleId, jdbcType=BIGINT}
  28. </select>
  29. <!--分页查询-->
  30. <select id="getByPage" parameterType="java.util.Map" resultMap="BaseResultMap">
  31. SELECT
  32. <include refid="Base_Column_List"/>
  33. FROM s_role
  34. WHERE 1 = 1 AND deleted_flag = 0
  35. <if test="keywords != null and keywords != ''">
  36. and role_name like "%"#{keywords}"%"
  37. </if>
  38. ORDER BY role_id ASC
  39. </select>
  40. <!--列表查询-->
  41. <select id="getByList" parameterType="java.util.Map" resultMap="BaseResultMap" >
  42. SELECT
  43. <include refid="Base_Column_List"/>
  44. FROM s_role
  45. WHERE deleted_flag = 0
  46. <if test="keywords != null and keywords != ''">
  47. and role_name like "%"#{keywords}"%"
  48. </if>
  49. ORDER BY role_id ASC
  50. </select>
  51. <!--新增-->
  52. <insert id="create" useGeneratedKeys="true" keyProperty="roleId" parameterType="com.zhyc.xps.sys.entity.Role">
  53. INSERT INTO s_role
  54. <trim prefix="(" suffix=")" suffixOverrides=",">
  55. <if test="roleId != null">
  56. role_id,
  57. </if>
  58. <if test="roleName != null and roleName != ''">
  59. role_name,
  60. </if>
  61. <if test="roleCode != null and roleCode != ''">
  62. role_code,
  63. </if>
  64. <if test="roleDesc != null and roleDesc != ''">
  65. role_desc,
  66. </if>
  67. <if test="isFixed != null">
  68. is_fixed,
  69. </if>
  70. <if test="roleTypeId != null">
  71. role_type_id,
  72. </if>
  73. <if test="sortNo != null">
  74. sort_no,
  75. </if>
  76. <if test="createdBy != null">
  77. created_by,
  78. </if>
  79. <if test="createdAt != null">
  80. created_at,
  81. </if>
  82. </trim>
  83. <trim prefix="values (" suffix=")" suffixOverrides=",">
  84. <if test="roleId != null">
  85. #{roleId,jdbcType=BIGINT},
  86. </if>
  87. <if test="roleName != null and roleName != ''">
  88. #{roleName,jdbcType=VARCHAR},
  89. </if>
  90. <if test="roleCode != null and roleCode != ''">
  91. #{roleCode,jdbcType=VARCHAR},
  92. </if>
  93. <if test="roleDesc != null and roleDesc != ''">
  94. #{roleDesc,jdbcType=VARCHAR},
  95. </if>
  96. <if test="isFixed != null">
  97. #{isFixed,jdbcType=BIGINT},
  98. </if>
  99. <if test="roleTypeId != null">
  100. #{roleTypeId,jdbcType=BIGINT},
  101. </if>
  102. <if test="sortNo != null">
  103. #{sortNo,jdbcType=BIGINT},
  104. </if>
  105. <if test="createdBy != null">
  106. #{createdBy,jdbcType=BIGINT},
  107. </if>
  108. <if test="createdAt != null">
  109. #{createdAt,jdbcType=DATE},
  110. </if>
  111. </trim>
  112. </insert>
  113. <!--更新-->
  114. <update id="update" parameterType="com.zhyc.xps.sys.entity.Role">
  115. UPDATE s_role
  116. <trim suffixOverrides=",">
  117. <set>
  118. <if test="roleName != null and roleName != ''">
  119. role_name = #{roleName,jdbcType=VARCHAR},
  120. </if>
  121. <if test="roleCode != null and roleCode != ''">
  122. role_code = #{roleCode,jdbcType=VARCHAR},
  123. </if>
  124. <if test="roleDesc != null">
  125. role_desc = #{roleDesc,jdbcType=VARCHAR},
  126. </if>
  127. <if test="sortNo != null">
  128. sort_no = #{sortNo,jdbcType=BIGINT},
  129. </if>
  130. <if test="isFixed != null">
  131. is_fixed = #{isFixed,jdbcType=BIGINT},
  132. </if>
  133. <if test="roleTypeId != null">
  134. role_type_id = #{roleTypeId,jdbcType=BIGINT},
  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 role_id = #{roleId, jdbcType=BIGINT}
  145. </update>
  146. <!--删除 -->
  147. <update id="delete" parameterType="java.util.Map">
  148. UPDATE s_role
  149. <trim suffixOverrides=",">
  150. <set>
  151. <if test="deletedBy != null">
  152. deleted_by = #{deletedBy ,jdbcType=BIGINT},
  153. </if>
  154. <if test="deletedAt != null">
  155. deleted_at = #{deletedAt ,jdbcType=DATE},
  156. </if>
  157. <if test="deletedFlag != null">
  158. deleted_flag = #{deletedFlag ,jdbcType=BIGINT},
  159. </if>
  160. </set>
  161. </trim>
  162. WHERE role_id = #{roleId, jdbcType=BIGINT}
  163. </update>
  164. </mapper>