OrgMapper.xml 12 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286
  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.zhyc.xps.sys.mapper.OrgMapper">
  4. <resultMap id="BaseResultMap" type="com.zhyc.xps.sys.entity.Org">
  5. <result column="oc_id" property="ocId" jdbcType="BIGINT" />
  6. <result column="org_name" property="orgName" jdbcType="VARCHAR" />
  7. <result column="org_code" property="orgCode" jdbcType="VARCHAR" />
  8. <result column="org_cat_id" property="orgCatId" jdbcType="BIGINT" />
  9. <result column="org_area_code" property="orgAreaCode" jdbcType="VARCHAR" />
  10. <result column="org_area_name" property="orgAreaName" jdbcType="VARCHAR" />
  11. <result column="org_lxr" property="orgLxr" jdbcType="VARCHAR" />
  12. <result column="org_lxdh" property="orgLxdh" jdbcType="VARCHAR" />
  13. <result column="org_dzyx" property="orgDzyx" jdbcType="VARCHAR" />
  14. <result column="org_address" property="orgAddress" jdbcType="VARCHAR" />
  15. <result column="org_wzjd" property="orgWzjd" jdbcType="DECIMAL" /><!--位置经度-->
  16. <result column="org_wzwd" property="orgWzwd" jdbcType="DECIMAL" /><!--位置纬度-->
  17. <result column="org_desc" property="orgDesc" jdbcType="VARCHAR" />
  18. </resultMap>
  19. <resultMap id="OrgDtoMap" type="com.zhyc.xps.sys.dto.OrgDto" extends="BaseResultMap">
  20. <result column="org_cat_title" property="orgCatTitle" jdbcType="VARCHAR" />
  21. <result column="root_id" property="rootId" jdbcType="BIGINT" />
  22. <result column="parent_id" property="parentId" jdbcType="BIGINT" />
  23. <result column="admin_id" property="adminId" jdbcType="BIGINT" />
  24. <result column="group_id" property="groupId" jdbcType="BIGINT" />
  25. <result column="node_left" property="nodeLeft" jdbcType="BIGINT" />
  26. <result column="node_right" property="nodeRight" jdbcType="BIGINT" />
  27. <result column="node_level" property="nodeLevel" jdbcType="BIGINT" />
  28. <result column="is_leaf" property="isLeaf" jdbcType="BIGINT" />
  29. <result column="status" property="status" jdbcType="BIGINT" />
  30. <result column="admin_name" property="adminName" jdbcType="VARCHAR" />
  31. </resultMap>
  32. <sql id="OrgDto_Cols" >
  33. A.oc_id,
  34. A.org_name,
  35. A.org_code,
  36. A.org_cat_id,
  37. A.org_lxr,
  38. A.org_lxdh,
  39. A.org_dzyx,
  40. D.org_cat_title,
  41. A.org_area_code,
  42. A.org_area_name,
  43. A.org_address,
  44. A.org_wzjd,
  45. A.org_wzwd,
  46. A.org_desc,
  47. B.parent_id,
  48. B.root_id,
  49. B.admin_id,
  50. C.account_name AS admin_name,
  51. B.group_id,
  52. B.node_left,
  53. B.node_right,
  54. B.node_level,
  55. B.is_leaf,
  56. B.status
  57. </sql>
  58. <!-- 分页查询 -->
  59. <select id="getByPage" parameterType="java.util.Map" resultMap="OrgDtoMap">
  60. SELECT
  61. <include refid="OrgDto_Cols"/>
  62. FROM org AS A
  63. LEFT JOIN oc AS B ON (A.oc_id = B.oc_id)
  64. LEFT JOIN account AS C ON (B.oc_id = C.oc_id AND B.admin_id = C.account_id)
  65. LEFT JOIN org_cat AS D ON (A.org_cat_id = D.org_cat_id)
  66. WHERE 1=1 AND A.deleted_flag=0
  67. <if test="ocId != null">
  68. AND A.oc_id = #{ocId}
  69. </if>
  70. <if test="keywords != null and keywords != ''">
  71. AND ( A.org_name LIKE "%"#{keywords}"%"
  72. </if>
  73. <if test="orgDzyx != null">
  74. AND A.org_dzyx = #{orgDzyx ,jdbcType=VARCHAR}
  75. </if>
  76. ORDER BY A.oc_id DESC
  77. </select>
  78. <!-- 列表查询 -->
  79. <select id="getByList" parameterType="java.util.Map" resultMap="OrgDtoMap">
  80. SELECT
  81. <include refid="OrgDto_Cols"/>
  82. FROM org AS A
  83. LEFT JOIN oc AS B ON (A.oc_id = B.oc_id)
  84. LEFT JOIN account AS C ON (B.oc_id = C.oc_id AND B.admin_id = C.account_id)
  85. LEFT JOIN org_cat AS D ON (A.org_cat_id = D.org_cat_id)
  86. WHERE 1 = 1 AND A.deleted_flag = 0
  87. <if test="ocId != null">
  88. AND A.oc_id = #{ocId}
  89. </if>
  90. <if test="orgDzyx != null">
  91. AND A.org_dzyx = #{orgDzyx ,jdbcType=VARCHAR}
  92. </if>
  93. <if test="keywords != null and keywords != ''">
  94. AND ( A.org_name LIKE "%"#{keywords}"%"
  95. </if>
  96. ORDER BY A.oc_id DESC
  97. </select>
  98. <!--基于ID查询-->
  99. <select id="getById" resultMap="OrgDtoMap" >
  100. SELECT
  101. <include refid="OrgDto_Cols"/>
  102. FROM org AS A
  103. LEFT JOIN oc AS B ON (A.oc_id = B.oc_id)
  104. LEFT JOIN account AS C ON (B.oc_id = C.oc_id AND B.admin_id = C.account_id)
  105. LEFT JOIN org_cat AS D ON (A.org_cat_id = D.org_cat_id)
  106. WHERE 1=1 AND A.deleted_flag=0
  107. AND A.oc_id = #{ocId, jdbcType=BIGINT}
  108. </select>
  109. <!--新增Insert-->
  110. <insert id="create" useGeneratedKeys="true" keyProperty="ocId" parameterType="com.zhyc.xps.sys.entity.Org">
  111. INSERT INTO org
  112. <trim prefix="(" suffix=")" suffixOverrides=",">
  113. <if test="ocId != null">
  114. oc_id,
  115. </if>
  116. <if test="orgName != null and orgName != ''">
  117. org_name,
  118. </if>
  119. <if test="orgCode != null and orgCode != ''">
  120. org_code,
  121. </if>
  122. <if test="orgCatId != null">
  123. org_cat_id,
  124. </if>
  125. <if test="orgLxr != null and orgLxr != ''">
  126. org_lxr,
  127. </if>
  128. <if test="orgLxdh != null and orgLxdh != ''">
  129. orgLxdh,
  130. </if>
  131. <if test="orgDzyx != null and orgDzyx != ''">
  132. org_dzyx,
  133. </if>
  134. <if test="orgAreaCode != null and orgAreaCode != ''">
  135. org_area_code,
  136. </if>
  137. <if test="orgAreaName != null and orgAreaName != ''">
  138. org_area_name,
  139. </if>
  140. <if test="orgAddress != null and orgAddress != ''">
  141. org_address,
  142. </if>
  143. <if test="orgWzjd != null">
  144. org_wzjd,
  145. </if>
  146. <if test="orgWzwd != null">
  147. org_wzwd,
  148. </if>
  149. <if test="orgDesc != null and orgDesc != ''">
  150. org_desc,
  151. </if>
  152. <if test="createdBy != null">
  153. created_by,
  154. </if>
  155. <if test="createdAt != null">
  156. created_at,
  157. </if>
  158. </trim>
  159. <trim prefix="values (" suffix=")" suffixOverrides=",">
  160. <if test="ocId != null">
  161. #{ocId, jdbcType=BIGINT},
  162. </if>
  163. <if test="orgName != null and orgName != ''">
  164. #{orgName,jdbcType=VARCHAR},
  165. </if>
  166. <if test="orgCode != null and orgCode != ''">
  167. #{orgCode,jdbcType=VARCHAR},
  168. </if>
  169. <if test="orgCatId != null">
  170. #{orgCatId,jdbcType=BIGINT},
  171. </if>
  172. <if test="orgLxr != null and orgLxr != ''">
  173. #{orgLxr , jdbcType=VARCHAR},
  174. </if>
  175. <if test="orgLxdh != null and orgLxdh != ''">
  176. #{orgLxdh , jdbcType=VARCHAR},
  177. </if>
  178. <if test="orgDzyx != null and orgDzyx != ''">
  179. #{orgDzyx , jdbcType=VARCHAR},
  180. </if>
  181. <if test="orgAreaCode != null and orgAreaCode != ''">
  182. #{orgAreaCode , jdbcType=VARCHAR},
  183. </if>
  184. <if test="orgAreaName != null and orgAreaName != ''">
  185. #{orgAreaName , jdbcType=VARCHAR},
  186. </if>
  187. <if test="orgAddress != null and orgAddress != ''">
  188. #{orgAddress , jdbcType=VARCHAR},
  189. </if>
  190. <if test="orgWzjd != null">
  191. #{orgWzjd, jdbcType=DECIMAL},
  192. </if>
  193. <if test="orgWzwd != null">
  194. #{orgWzwd, jdbcType=DECIMAL},
  195. </if>
  196. <if test="orgDesc != null and orgDesc != ''">
  197. #{orgDesc , jdbcType=VARCHAR},
  198. </if>
  199. <if test="createdBy != null">
  200. #{createdBy , jdbcType=BIGINT},
  201. </if>
  202. <if test="createdAt != null">
  203. #{createdAt, jdbcType=TIMESTAMP},
  204. </if>
  205. </trim>
  206. </insert>
  207. <!--Update更新-->
  208. <update id="update" parameterType="com.zhyc.xps.sys.entity.Org">
  209. UPDATE org
  210. <trim suffixOverrides=",">
  211. <set>
  212. <if test="orgName != null and orgName != ''">
  213. org_name = #{orgName,jdbcType=VARCHAR},
  214. </if>
  215. <if test="orgCode != null and orgCode != ''">
  216. org_code = #{orgCode,jdbcType=VARCHAR},
  217. </if>
  218. <if test="orgCatId != null">
  219. org_cat_id = #{orgCatId,jdbcType=BIGINT},
  220. </if>
  221. <if test="orgLxr != null">
  222. org_lxr = #{orgLxr,jdbcType=VARCHAR},
  223. </if>
  224. <if test="orgLxdh != null">
  225. org_lxdh = #{orgLxdh,jdbcType=VARCHAR},
  226. </if>
  227. <if test="orgDzyx != null ">
  228. org_dzyx = #{orgDzyx , jdbcType=VARCHAR},
  229. </if>
  230. <if test="orgAreaCode != null">
  231. org_area_code = #{orgAreaCode , jdbcType=VARCHAR},
  232. </if>
  233. <if test="orgAreaName != null">
  234. org_area_name = #{orgAreaName , jdbcType=VARCHAR},
  235. </if>
  236. <if test="orgAddress != null">
  237. org_address = #{orgAddress , jdbcType=VARCHAR},
  238. </if>
  239. <if test="orgWzjd != null">
  240. org_wzjd = #{orgWzjd, jdbcType=DECIMAL},
  241. </if>
  242. <if test="orgWzwd != null">
  243. org_wzwd = #{orgWzwd, jdbcType=DECIMAL},
  244. </if>
  245. <if test="orgDesc != null">
  246. org_desc = #{orgDesc , jdbcType=VARCHAR},
  247. </if>
  248. <if test="updatedBy != null">
  249. updated_by = #{updatedBy,jdbcType=BIGINT},
  250. </if>
  251. <if test="updatedAt != null">
  252. updated_at = #{updatedAt,jdbcType=TIMESTAMP},
  253. </if>
  254. </set>
  255. </trim>
  256. WHERE oc_id = #{ocId, jdbcType=BIGINT}
  257. </update>
  258. <!--删除-->
  259. <update id="delete" parameterType="java.util.Map">
  260. UPDATE org
  261. <trim suffixOverrides=",">
  262. <set>
  263. <if test="deletedFlag != null">
  264. deleted_flag = #{deletedFlag,jdbcType=BIGINT},
  265. </if>
  266. <if test="deletedAt != null">
  267. deleted_at = #{deletedAt ,jdbcType=DATE},
  268. </if>
  269. <if test="deletedBy != null">
  270. deleted_by = #{deletedBy,jdbcType=BIGINT},
  271. </if>
  272. </set>
  273. </trim>
  274. WHERE oc_id = #{ocId ,jdbcType = BIGINT}
  275. </update>
  276. </mapper>