LayGroupDao.xml 3.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133
  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.dao.LayGroupDao">
  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. <if test="groupname != null and groupname != ''">
  39. AND a.groupname LIKE
  40. <if test="dbName == 'oracle'">'%'||#{groupname}||'%'</if>
  41. <if test="dbName == 'mssql'">'%'+#{groupname}+'%'</if>
  42. <if test="dbName == 'mysql'">concat('%',#{groupname},'%')</if>
  43. </if>
  44. </where>
  45. <choose>
  46. <when test="page !=null and page.orderBy != null and page.orderBy != ''">
  47. ORDER BY ${page.orderBy}
  48. </when>
  49. <otherwise>
  50. ORDER BY a.update_date DESC
  51. </otherwise>
  52. </choose>
  53. </select>
  54. <select id="findAllList" resultType="LayGroup" >
  55. SELECT
  56. <include refid="layGroupColumns"/>
  57. FROM t_group a
  58. <include refid="layGroupJoins"/>
  59. <where>
  60. a.del_flag = #{DEL_FLAG_NORMAL}
  61. </where>
  62. <choose>
  63. <when test="page !=null and page.orderBy != null and page.orderBy != ''">
  64. ORDER BY ${page.orderBy}
  65. </when>
  66. <otherwise>
  67. ORDER BY a.update_date DESC
  68. </otherwise>
  69. </choose>
  70. </select>
  71. <insert id="insert">
  72. INSERT INTO t_group(
  73. id,
  74. groupname,
  75. avatar,
  76. create_by,
  77. create_date,
  78. update_by,
  79. update_date,
  80. remarks,
  81. del_flag
  82. ) VALUES (
  83. #{id},
  84. #{groupname},
  85. #{avatar},
  86. #{createBy.id},
  87. #{createDate},
  88. #{updateBy.id},
  89. #{updateDate},
  90. #{remarks},
  91. #{delFlag}
  92. )
  93. </insert>
  94. <update id="update">
  95. UPDATE t_group SET
  96. groupname = #{groupname},
  97. avatar = #{avatar},
  98. create_by = #{createBy.id},
  99. update_by = #{updateBy.id},
  100. update_date = #{updateDate},
  101. remarks = #{remarks}
  102. WHERE id = #{id}
  103. </update>
  104. <!--物理删除-->
  105. <update id="delete">
  106. DELETE FROM t_group
  107. WHERE id = #{id}
  108. </update>
  109. <!--逻辑删除-->
  110. <update id="deleteByLogic">
  111. UPDATE t_group SET
  112. del_flag = #{DEL_FLAG_DELETE}
  113. WHERE id = #{id}
  114. </update>
  115. <!-- 根据实体名称和字段名称和字段值获取唯一记录 -->
  116. <select id="findUniqueByProperty" resultType="LayGroup" statementType="STATEMENT">
  117. select * FROM t_group where ${propertyName} = '${value}'
  118. </select>
  119. </mapper>