SysRoleMapper.xml 3.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113
  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.gxzc.zen.api.sys.mapper.SysRoleMapper">
  4. <!-- 通用查询映射结果 -->
  5. <resultMap id="BaseResultMap" type="com.gxzc.zen.api.sys.model.SysRole">
  6. <result column="id" property="id"/>
  7. <result column="enable" property="enable"/>
  8. <result column="remark" property="remark"/>
  9. <result column="create_time" property="createTime"/>
  10. <result column="create_by" property="createBy"/>
  11. <result column="update_time" property="updateTime"/>
  12. <result column="update_by" property="updateBy"/>
  13. <result column="name" property="name"/>
  14. <result column="code" property="code"/>
  15. <result column="perms" property="perms"/>
  16. </resultMap>
  17. <sql id="dynamicSqlWhere">
  18. <where>
  19. <if test="p != null">
  20. <if test="p.enable != null">
  21. <choose>
  22. <when test="p.enable == true">
  23. AND enable = 1
  24. </when>
  25. <otherwise>
  26. AND enable = 0
  27. </otherwise>
  28. </choose>
  29. </if>
  30. <if test="p.name != null">
  31. AND `name` LIKE CONCAT('%', #{p.name}, '%')
  32. </if>
  33. <if test="p.code != null">
  34. AND code LIKE CONCAT('%', #{p.code}, '%')
  35. </if>
  36. <if test="p.id != null">
  37. AND id = #{p.id}
  38. </if>
  39. </if>
  40. </where>
  41. </sql>
  42. <sql id="dynamicSqlSet">
  43. <set>
  44. <if test="et.name != null">
  45. `name` = #{et.name},
  46. </if>
  47. <if test="et.code != null">
  48. code = #{et.code},
  49. </if>
  50. <if test="et.perms != null">
  51. perms = #{et.perms},
  52. </if>
  53. <if test="et.createTime != null">
  54. create_time = #{et.createTime},
  55. </if>
  56. <if test="et.createBy != null">
  57. create_by = #{et.createBy},
  58. </if>
  59. <if test="et.updateTime != null">
  60. update_time = #{et.updateTime},
  61. </if>
  62. <if test="et.updateBy != null">
  63. update_by = #{et.updateBy},
  64. </if>
  65. <if test="et.remark != null">
  66. remark = #{et.remark},
  67. </if>
  68. <if test="et.enable != null">
  69. <choose>
  70. <when test="et.enable == true">
  71. `enable` = 1
  72. </when>
  73. <otherwise>
  74. `enable` = 0
  75. </otherwise>
  76. </choose>
  77. </if>
  78. </set>
  79. </sql>
  80. <select id="selectByParams" resultType="com.gxzc.zen.api.sys.model.SysRole">
  81. SELECT *
  82. FROM sys_role
  83. <include refid="dynamicSqlWhere"/>
  84. ORDER BY id
  85. </select>
  86. <select id="selectByParamsPage" resultType="com.gxzc.zen.api.sys.model.SysRole">
  87. SELECT *
  88. FROM sys_role
  89. <include refid="dynamicSqlWhere"/>
  90. ORDER BY id
  91. </select>
  92. <update id="updateNoLogic" parameterType="com.gxzc.zen.api.sys.model.SysRole">
  93. UPDATE sys_role
  94. <include refid="dynamicSqlSet"/>
  95. <where>
  96. ${ew.sqlSegment}
  97. </where>
  98. </update>
  99. <delete id="physicalDelete">
  100. DELETE FROM sys_role
  101. <where>
  102. ${ew.sqlSegment}
  103. </where>
  104. </delete>
  105. </mapper>