LayGroupUserMapper.xml 3.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144
  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.jeeplus.modules.iim.mapper.LayGroupUserMapper">
  4. <sql id="layGroupUserColumns">
  5. a.id AS "id",
  6. a.create_by AS "createBy.id",
  7. a.create_date AS "createDate",
  8. a.update_by AS "updateBy.id",
  9. a.update_date AS "updateDate",
  10. a.remarks AS "remarks",
  11. a.del_flag AS "delFlag",
  12. a.user_id AS "user.id",
  13. a.group_id AS "group.id",
  14. t_user.name AS "user.name",
  15. t_user.photo AS "user.photo",
  16. t_user.login_name AS "user.loginName"
  17. </sql>
  18. <sql id="layGroupUserJoins">
  19. LEFT JOIN t_group b ON b.id = a.group_id
  20. LEFT JOIN sys_user t_user ON t_user.id = a.user_id
  21. </sql>
  22. <select id="get" resultType="LayGroupUser" >
  23. SELECT
  24. <include refid="layGroupUserColumns"/>
  25. FROM group_user a
  26. <include refid="layGroupUserJoins"/>
  27. WHERE a.id = #{id}
  28. </select>
  29. <select id="findList" resultType="LayGroupUser" >
  30. SELECT
  31. <include refid="layGroupUserColumns"/>
  32. FROM group_user a
  33. <include refid="layGroupUserJoins"/>
  34. <where>
  35. a.del_flag = #{DEL_FLAG_NORMAL}
  36. <if test="user != null and user.id != null and user.id != ''">
  37. AND a.user_id = #{user.id}
  38. </if>
  39. <if test="group != null and group.id != null and group.id != ''">
  40. AND a.group_id = #{group.id}
  41. </if>
  42. </where>
  43. <choose>
  44. <when test="page !=null and page.orderBy != null and page.orderBy != ''">
  45. ORDER BY ${page.orderBy}
  46. </when>
  47. <otherwise>
  48. ORDER BY a.create_date ASC
  49. </otherwise>
  50. </choose>
  51. </select>
  52. <select id="findAllList" resultType="LayGroupUser" >
  53. SELECT
  54. <include refid="layGroupUserColumns"/>
  55. FROM group_user a
  56. <include refid="layGroupUserJoins"/>
  57. <where>
  58. a.del_flag = #{DEL_FLAG_NORMAL}
  59. </where>
  60. <choose>
  61. <when test="page !=null and page.orderBy != null and page.orderBy != ''">
  62. ORDER BY ${page.orderBy}
  63. </when>
  64. <otherwise>
  65. ORDER BY a.create_date ASC
  66. </otherwise>
  67. </choose>
  68. </select>
  69. <insert id="insert">
  70. INSERT INTO group_user(
  71. id,
  72. create_by,
  73. create_date,
  74. update_by,
  75. update_date,
  76. remarks,
  77. del_flag,
  78. user_id,
  79. group_id
  80. ) VALUES (
  81. #{id},
  82. #{createBy.id},
  83. #{createDate},
  84. #{updateBy.id},
  85. #{updateDate},
  86. #{remarks},
  87. #{delFlag},
  88. #{user.id},
  89. #{group.id}
  90. )
  91. </insert>
  92. <update id="update">
  93. UPDATE group_user SET
  94. update_by = #{updateBy.id},
  95. update_date = #{updateDate},
  96. remarks = #{remarks},
  97. user_id = #{user.id},
  98. group_id = #{group.id}
  99. WHERE id = #{id}
  100. </update>
  101. <!--物理删除-->
  102. <update id="delete">
  103. DELETE FROM group_user
  104. <choose>
  105. <when test="id !=null and id != ''">
  106. WHERE id = #{id}
  107. </when>
  108. <otherwise>
  109. WHERE group_id = #{group.id}
  110. </otherwise>
  111. </choose>
  112. </update>
  113. <!--逻辑删除-->
  114. <update id="deleteByLogic">
  115. UPDATE group_user SET
  116. del_flag = #{DEL_FLAG_DELETE}
  117. <choose>
  118. <when test="id !=null and id != ''">
  119. WHERE id = #{id}
  120. </when>
  121. <otherwise>
  122. WHERE group_id = #{group.id}
  123. </otherwise>
  124. </choose>
  125. </update>
  126. <!-- 根据实体名称和字段名称和字段值获取唯一记录 -->
  127. <select id="findUniqueByProperty" resultType="LayGroupUser" statementType="STATEMENT">
  128. select * FROM group_user where ${propertyName} = '${value}'
  129. </select>
  130. </mapper>