OfficeDao.xml 3.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173
  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.thinkgem.jeesite.modules.sys.dao.OfficeDao">
  4. <sql id="officeColumns">
  5. a.id,
  6. a.parent_id AS "parent.id",
  7. a.parent_ids,
  8. a.area_id AS "area.id",
  9. a.code,
  10. a.name,
  11. a.sort,
  12. a.type,
  13. a.grade,
  14. a.address,
  15. a.zip_code,
  16. a.master,
  17. a.phone,
  18. a.fax,
  19. a.email,
  20. a.remarks,
  21. a.create_by AS "createBy.id",
  22. a.create_date,
  23. a.update_by AS "updateBy.id",
  24. a.update_date,
  25. a.del_flag,
  26. a.useable AS useable,
  27. a.primary_person AS "primaryPerson.id",
  28. a.deputy_person AS "deputyPerson.id",
  29. p.name AS "parent.name",
  30. ar.name AS "area.name",
  31. ar.parent_ids AS "area.parentIds",
  32. pp.name AS "primaryPerson.name",
  33. dp.name AS "deputyPerson.name"
  34. </sql>
  35. <sql id="officeJoins">
  36. LEFT JOIN sys_office p ON p.id = a.parent_id
  37. LEFT JOIN sys_area ar ON ar.id = a.area_id
  38. LEFT JOIN SYS_USER pp ON pp.id = a.primary_person
  39. LEFT JOIN SYS_USER dp ON dp.id = a.deputy_person
  40. </sql>
  41. <select id="get" resultType="Office">
  42. SELECT
  43. <include refid="officeColumns"/>
  44. FROM sys_office a
  45. <include refid="officeJoins"/>
  46. WHERE a.id = #{id}
  47. </select>
  48. <select id="findList" resultType="Office">
  49. SELECT
  50. <include refid="officeColumns"/>
  51. FROM sys_office a
  52. <include refid="officeJoins"/>
  53. WHERE a.del_flag = #{DEL_FLAG_NORMAL}
  54. <!-- 数据范围过滤 -->
  55. ${sqlMap.dsf}
  56. OR a.id = #{currentUser.office.id}
  57. ORDER BY a.code
  58. </select>
  59. <select id="findAllList" resultType="Office">
  60. SELECT
  61. <include refid="officeColumns"/>
  62. FROM sys_office a
  63. <include refid="officeJoins"/>
  64. WHERE a.del_flag = #{DEL_FLAG_NORMAL}
  65. ORDER BY a.code
  66. </select>
  67. <select id="findByParentIdsLike" resultType="Office">
  68. SELECT
  69. <include refid="officeColumns"/>
  70. FROM sys_office a
  71. <include refid="officeJoins"/>
  72. WHERE a.del_flag = #{DEL_FLAG_NORMAL} AND a.parent_ids LIKE #{parentIds}
  73. ORDER BY a.code
  74. </select>
  75. <insert id="insert" parameterType="office" keyProperty="id" useGeneratedKeys="true">
  76. INSERT INTO sys_office(
  77. parent_id,
  78. parent_ids,
  79. area_id,
  80. code,
  81. name,
  82. sort,
  83. type,
  84. grade,
  85. address,
  86. zip_code,
  87. master,
  88. phone,
  89. fax,
  90. email,
  91. create_by,
  92. create_date,
  93. update_by,
  94. update_date,
  95. remarks,
  96. del_flag,
  97. useable,
  98. primary_person,
  99. deputy_person
  100. ) VALUES (
  101. #{parent.id},
  102. #{parentIds},
  103. #{area.id},
  104. #{code},
  105. #{name},
  106. #{sort},
  107. #{type},
  108. #{grade},
  109. #{address},
  110. #{zipCode},
  111. #{master},
  112. #{phone},
  113. #{fax},
  114. #{email},
  115. #{createBy.id},
  116. #{createDate},
  117. #{updateBy.id},
  118. #{updateDate},
  119. #{remarks},
  120. #{delFlag},
  121. #{useable},
  122. #{primaryPerson.id},
  123. #{deputyPerson.id}
  124. )
  125. </insert>
  126. <update id="update">
  127. UPDATE sys_office SET
  128. parent_id = #{parent.id},
  129. parent_ids = #{parentIds},
  130. area_id = #{area.id},
  131. code = #{code},
  132. name = #{name},
  133. type = #{type},
  134. grade = #{grade},
  135. address = #{address},
  136. zip_code = #{zipCode},
  137. master = #{master},
  138. phone = #{phone},
  139. fax = #{fax},
  140. email = #{email},
  141. update_by = #{updateBy.id},
  142. update_date = #{updateDate},
  143. remarks = #{remarks},
  144. useable=#{useable},
  145. primary_person=#{primaryPerson.id},
  146. deputy_person=#{deputyPerson.id}
  147. WHERE id = #{id}
  148. </update>
  149. <update id="updateParentIds">
  150. UPDATE sys_office SET
  151. parent_id = #{parent.id},
  152. parent_ids = #{parentIds}
  153. WHERE id = #{id}
  154. </update>
  155. <update id="delete">
  156. DELETE FROM sys_office
  157. WHERE id = #{id} OR parent_ids LIKE
  158. <if test="dbName == 'oracle'">'%,'||#{id}||',%'</if>
  159. <if test="dbName == 'mssql'">'%,'+#{id}+',%'</if>
  160. <if test="dbName == 'mysql'">CONCAT('%,', #{id}, ',%')</if>
  161. </update>
  162. </mapper>