LayGroupMapper.xml 2.8 KB

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