SysOrgMapper.xml 24 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605
  1. <?xml version="1.0" encoding="UTF-8" ?>
  2. <!DOCTYPE mapper
  3. PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
  4. "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
  5. <mapper namespace="com.xunmei.system.mapper.SysOrgMapper">
  6. <resultMap type="com.xunmei.system.api.domain.SysOrg" id="SysOrgResult">
  7. <result property="id" column="id"/>
  8. <result property="address" column="address"/>
  9. <result property="code" column="code"/>
  10. <result property="guid" column="guid"/>
  11. <result property="isLock" column="is_lock"/>
  12. <result property="manager" column="manager"/>
  13. <result property="managerPhone" column="manager_phone"/>
  14. <result property="name" column="name"/>
  15. <result property="parentId" column="parent_id"/>
  16. <result property="phone" column="phone"/>
  17. <result property="cityCode" column="city_code"/>
  18. <result property="type" column="type"/>
  19. <result property="createTime" column="create_time"/>
  20. <result property="updateTime" column="update_time"/>
  21. <result property="path" column="path"/>
  22. <result property="parentGuid" column="parent_guid"/>
  23. <result property="deleted" column="deleted"/>
  24. <result property="sort" column="sort"/>
  25. <result property="source" column="source"/>
  26. <result property="shortName" column="short_name"/>
  27. <result property="remark" column="remark"/>
  28. <result property="source" column="source"/>
  29. <result property="createBy" column="create_by"/>
  30. <result property="updateBy" column="update_by"/>
  31. </resultMap>
  32. <sql id="selectSysOrgVo">
  33. select id,
  34. address,
  35. code,
  36. guid,
  37. is_lock,
  38. manager,
  39. manager_phone,
  40. name,
  41. parent_id,
  42. phone,
  43. city_code,
  44. type,
  45. create_time,
  46. update_time,
  47. parent_guid,
  48. deleted,
  49. sort,
  50. create_by,
  51. update_by,
  52. weather_city_code,
  53. org_extend_id,
  54. source,
  55. short_name,
  56. remark,
  57. path
  58. from sys_org
  59. </sql>
  60. <select id="selectSysOrgList" parameterType="com.xunmei.system.api.domain.SysOrg"
  61. resultMap="SysOrgResult">
  62. <include refid="selectSysOrgVo"/>
  63. <where>
  64. <if test="address != null and address != ''">
  65. and address = #{address}
  66. </if>
  67. <if test="code != null and code != ''">
  68. and code = #{code}
  69. </if>
  70. <!-- <if test="deviceCount != null ">-->
  71. <!-- and device_count = #{deviceCount}-->
  72. <!-- </if>-->
  73. <if test="guid != null and guid != ''">
  74. and guid = #{guid}
  75. </if>
  76. <if test="isLock != null ">
  77. and is_lock = #{isLock}
  78. </if>
  79. <if test="manager != null and manager != ''">
  80. and manager = #{manager}
  81. </if>
  82. <if test="managerPhone != null and managerPhone != ''">
  83. and manager_phone = #{managerPhone}
  84. </if>
  85. <if test="name != null and name != ''">
  86. and name like concat('%', #{name}, '%')
  87. </if>
  88. <if test="parentId != null ">
  89. and parent_id = #{parentId}
  90. </if>
  91. <if test="phone != null and phone != ''">
  92. and phone = #{phone}
  93. </if>
  94. <if test="cityCode != null and cityCode != ''">
  95. and city_code = #{cityCode}
  96. </if>
  97. <!-- <if test="openYear != null ">-->
  98. <!-- and open_year = #{openYear}-->
  99. <!-- </if>-->
  100. <!-- <if test="fitYear != null ">-->
  101. <!-- and fit_year = #{fitYear}-->
  102. <!-- </if>-->
  103. <!-- <if test="floorage != null and floorage != ''">-->
  104. <!-- and floorage = #{floorage}-->
  105. <!-- </if>-->
  106. <!-- <if test="employee != null ">-->
  107. <!-- and employee = #{employee}-->
  108. <!-- </if>-->
  109. <!-- <if test="isOwnRight != null ">-->
  110. <!-- and is_own_right = #{isOwnRight}-->
  111. <!-- </if>-->
  112. <!-- <if test="isRent != null ">-->
  113. <!-- and is_rent = #{isRent}-->
  114. <!-- </if>-->
  115. <!-- <if test="isOnly != null ">-->
  116. <!-- and is_only = #{isOnly}-->
  117. <!-- </if>-->
  118. <!-- <if test="buildYear != null ">-->
  119. <!-- and build_year = #{buildYear}-->
  120. <!-- </if>-->
  121. <!-- <if test="placeType != null ">-->
  122. <!-- and place_type = #{placeType}-->
  123. <!-- </if>-->
  124. <!-- <if test="buildHeight != null ">-->
  125. <!-- and build_height = #{buildHeight}-->
  126. <!-- </if>-->
  127. <!-- <if test="social != null ">-->
  128. <!-- and social = #{social}-->
  129. <!-- </if>-->
  130. <!-- <if test="naturalEnvir != null ">-->
  131. <!-- and natural_envir = #{naturalEnvir}-->
  132. <!-- </if>-->
  133. <if test="type != null ">
  134. and type = #{type}
  135. </if>
  136. <if test="updateBy != null and updateBy != ''">
  137. and update_by like concat('%', #{updateBy}, '%')
  138. </if>
  139. <!-- <if test="modifiedId != null ">-->
  140. <!-- and modified_id = #{modifiedId}-->
  141. <!-- </if>-->
  142. <if test="path != null and path != ''">
  143. and path = #{path}
  144. </if>
  145. <!-- <if test="vid != null ">-->
  146. <!-- and vid = #{vid}-->
  147. <!-- </if>-->
  148. <!-- <if test="level != null ">-->
  149. <!-- and level = #{level}-->
  150. <!-- </if>-->
  151. <!-- <if test="oid != null and oid != ''">-->
  152. <!-- and oid = #{oid}-->
  153. <!-- </if>-->
  154. <if test="parentGuid != null and parentGuid != ''">
  155. and parent_guid = #{parentGuid}
  156. </if>
  157. <if test="deleted != null ">
  158. and deleted = #{deleted}
  159. </if>
  160. <if test="sort != null ">
  161. and sort = #{sort}
  162. </if>
  163. <!-- <if test="location != null ">-->
  164. <!-- and location = #{location}-->
  165. <!-- </if>-->
  166. </where>
  167. </select>
  168. <select id="selectSysOrgById" parameterType="Long"
  169. resultMap="SysOrgResult">
  170. <include refid="selectSysOrgVo"/>
  171. where id = #{id}
  172. </select>
  173. <select id="selectCheckSubOrgIdList" resultType="java.lang.Long">
  174. select id
  175. from sys_org
  176. where path like concat((select path from sys_org where id = #{orgId}), '%')
  177. and deleted = 0
  178. </select>
  179. <select id="findListByOrgType" resultType="java.lang.Long">
  180. select a.id
  181. from sys_org a
  182. where a.type = #{execOrgType}
  183. and a.deleted = 0
  184. and a.is_lock = 0
  185. </select>
  186. <insert id="insertSysOrg" parameterType="com.xunmei.system.api.domain.SysOrg" useGeneratedKeys="true"
  187. keyProperty="id">
  188. insert into sys_org
  189. <trim prefix="(" suffix=")" suffixOverrides=",">
  190. <if test="address != null">
  191. address,
  192. </if>
  193. <if test="code != null">
  194. code,
  195. </if>
  196. <!-- <if test="deviceCount != null">device_count,-->
  197. <!-- </if>-->
  198. <if test="guid != null">
  199. guid,
  200. </if>
  201. <if test="isLock != null">
  202. is_lock,
  203. </if>
  204. <if test="manager != null">
  205. manager,
  206. </if>
  207. <if test="managerPhone != null">
  208. manager_phone,
  209. </if>
  210. <if test="name != null">
  211. name,
  212. </if>
  213. <if test="shortName != null">
  214. short_name,
  215. </if>
  216. <if test="parentId != null">
  217. parent_id,
  218. </if>
  219. <if test="phone != null">
  220. phone,
  221. </if>
  222. <if test="cityCode != null">
  223. city_code,
  224. </if>
  225. <!-- <if test="openYear != null">open_year,-->
  226. <!-- </if>-->
  227. <!-- <if test="fitYear != null">fit_year,-->
  228. <!-- </if>-->
  229. <!-- <if test="floorage != null">floorage,-->
  230. <!-- </if>-->
  231. <!-- <if test="employee != null">employee,-->
  232. <!-- </if>-->
  233. <!-- <if test="isOwnRight != null">is_own_right,-->
  234. <!-- </if>-->
  235. <!-- <if test="isRent != null">is_rent,-->
  236. <!-- </if>-->
  237. <!-- <if test="isOnly != null">is_only,-->
  238. <!-- </if>-->
  239. <!-- <if test="buildYear != null">build_year,-->
  240. <!-- </if>-->
  241. <!-- <if test="placeType != null">place_type,-->
  242. <!-- </if>-->
  243. <!-- <if test="buildHeight != null">build_height,-->
  244. <!-- </if>-->
  245. <!-- <if test="social != null">social,-->
  246. <!-- </if>-->
  247. <!-- <if test="naturalEnvir != null">natural_envir,-->
  248. <!-- </if>-->
  249. <if test="type != null">
  250. type,
  251. </if>
  252. <if test="createTime != null">
  253. create_time,
  254. </if>
  255. <if test="updateBy != null">
  256. update_by,
  257. </if>
  258. <if test="updateTime != null">
  259. update_time,
  260. </if>
  261. <!-- <if test="modifiedId != null">modified_id,-->
  262. <!-- </if>-->
  263. <if test="path != null">
  264. path,
  265. </if>
  266. <!-- <if test="vid != null">vid,-->
  267. <!-- </if>-->
  268. <!-- <if test="level != null">level,-->
  269. <!-- </if>-->
  270. <if test="oid != null">
  271. oid,
  272. </if>
  273. <if test="parentGuid != null">
  274. parent_guid,
  275. </if>
  276. <if test="deleted != null">
  277. deleted,
  278. </if>
  279. <if test="sort != null">
  280. sort,
  281. </if>
  282. <if test="source != null">
  283. source,
  284. </if>
  285. <if test="remark != null">
  286. remark,
  287. </if>
  288. <!-- <if test="location != null">location,-->
  289. <!-- </if>-->
  290. <if test="createBy != null">
  291. create_by,
  292. </if>
  293. <if test="updateBy != null">
  294. update_by,
  295. </if>
  296. </trim>
  297. <trim prefix="values (" suffix=")" suffixOverrides=",">
  298. <if test="address != null">
  299. #{address},
  300. </if>
  301. <if test="code != null">
  302. #{code},
  303. </if>
  304. <!-- <if test="deviceCount != null">#{deviceCount},-->
  305. <!-- </if>-->
  306. <if test="guid != null">
  307. #{guid},
  308. </if>
  309. <if test="isLock != null">
  310. #{isLock},
  311. </if>
  312. <if test="manager != null">
  313. #{manager},
  314. </if>
  315. <if test="managerPhone != null">
  316. #{managerPhone},
  317. </if>
  318. <if test="name != null">
  319. #{name},
  320. </if>
  321. <if test="shortName != null">
  322. #{shortName},
  323. </if>
  324. <if test="parentId != null">
  325. #{parentId},
  326. </if>
  327. <if test="phone != null">
  328. #{phone},
  329. </if>
  330. <if test="cityCode != null">
  331. #{cityCode},
  332. </if>
  333. <!-- <if test="openYear != null">#{openYear},-->
  334. <!-- </if>-->
  335. <!-- <if test="fitYear != null">#{fitYear},-->
  336. <!-- </if>-->
  337. <!-- <if test="floorage != null">#{floorage},-->
  338. <!-- </if>-->
  339. <!-- <if test="employee != null">#{employee},-->
  340. <!-- </if>-->
  341. <!-- <if test="isOwnRight != null">#{isOwnRight},-->
  342. <!-- </if>-->
  343. <!-- <if test="isRent != null">#{isRent},-->
  344. <!-- </if>-->
  345. <!-- <if test="isOnly != null">#{isOnly},-->
  346. <!-- </if>-->
  347. <!-- <if test="buildYear != null">#{buildYear},-->
  348. <!-- </if>-->
  349. <!-- <if test="placeType != null">#{placeType},-->
  350. <!-- </if>-->
  351. <!-- <if test="buildHeight != null">#{buildHeight},-->
  352. <!-- </if>-->
  353. <!-- <if test="social != null">#{social},-->
  354. <!-- </if>-->
  355. <!-- <if test="naturalEnvir != null">#{naturalEnvir},-->
  356. <!-- </if>-->
  357. <if test="type != null">
  358. #{type},
  359. </if>
  360. <if test="createTime != null">
  361. #{createTime},
  362. </if>
  363. <if test="updateBy != null">
  364. #{updateBy},
  365. </if>
  366. <if test="updateTime != null">
  367. #{updateTime},
  368. </if>
  369. <!-- <if test="modifiedId != null">#{modifiedId},-->
  370. <!-- </if>-->
  371. <if test="path != null">
  372. #{path},
  373. </if>
  374. <!-- <if test="vid != null">#{vid},-->
  375. <!-- </if>-->
  376. <!-- <if test="level != null">#{level},-->
  377. <!-- </if>-->
  378. <!-- <if test="oid != null">#{oid},-->
  379. <!-- </if>-->
  380. <if test="parentGuid != null">
  381. #{parentGuid},
  382. </if>
  383. <if test="deleted != null">
  384. #{deleted},
  385. </if>
  386. <if test="sort != null">
  387. #{sort},
  388. </if>
  389. <if test="source != null">
  390. #{source},
  391. </if>
  392. <if test="remark != null">
  393. #{remark},
  394. </if>
  395. <!-- <if test="location != null">#{location},-->
  396. <!-- </if>-->
  397. <if test="createBy != null">
  398. #{createBy},
  399. </if>
  400. <if test="updateBy != null">
  401. #{updateBy},
  402. </if>
  403. </trim>
  404. </insert>
  405. <update id="updateSysOrg" parameterType="com.xunmei.system.api.domain.SysOrg">
  406. update sys_org
  407. <trim prefix="SET" suffixOverrides=",">
  408. <if test="address != null">
  409. address =
  410. #{address},
  411. </if>
  412. <if test="code != null">
  413. code =
  414. #{code},
  415. </if>
  416. <!-- <if test="deviceCount != null">device_count =-->
  417. <!-- #{deviceCount},-->
  418. <!-- </if>-->
  419. <if test="guid != null">
  420. guid =
  421. #{guid},
  422. </if>
  423. <if test="isLock != null">
  424. is_lock =
  425. #{isLock},
  426. </if>
  427. <if test="manager != null">
  428. manager =
  429. #{manager},
  430. </if>
  431. <if test="managerPhone != null">
  432. manager_phone =
  433. #{managerPhone},
  434. </if>
  435. <if test="name != null">
  436. name =
  437. #{name},
  438. </if>
  439. <if test="shortName != null">
  440. short_name =
  441. #{shortName},
  442. </if>
  443. <if test="parentId != null">
  444. parent_id =
  445. #{parentId},
  446. </if>
  447. <if test="phone != null">
  448. phone =
  449. #{phone},
  450. </if>
  451. <if test="cityCode != null">
  452. city_code =
  453. #{cityCode},
  454. </if>
  455. <!-- <if test="openYear != null">open_year =-->
  456. <!-- #{openYear},-->
  457. <!-- </if>-->
  458. <!-- <if test="fitYear != null">fit_year =-->
  459. <!-- #{fitYear},-->
  460. <!-- </if>-->
  461. <!-- <if test="floorage != null">floorage =-->
  462. <!-- #{floorage},-->
  463. <!-- </if>-->
  464. <!-- <if test="employee != null">employee =-->
  465. <!-- #{employee},-->
  466. <!-- </if>-->
  467. <!-- <if test="isOwnRight != null">is_own_right =-->
  468. <!-- #{isOwnRight},-->
  469. <!-- </if>-->
  470. <!-- <if test="isRent != null">is_rent =-->
  471. <!-- #{isRent},-->
  472. <!-- </if>-->
  473. <!-- <if test="isOnly != null">is_only =-->
  474. <!-- #{isOnly},-->
  475. <!-- </if>-->
  476. <!-- <if test="buildYear != null">build_year =-->
  477. <!-- #{buildYear},-->
  478. <!-- </if>-->
  479. <!-- <if test="placeType != null">place_type =-->
  480. <!-- #{placeType},-->
  481. <!-- </if>-->
  482. <!-- <if test="buildHeight != null">build_height =-->
  483. <!-- #{buildHeight},-->
  484. <!-- </if>-->
  485. <!-- <if test="social != null">social =-->
  486. <!-- #{social},-->
  487. <!-- </if>-->
  488. <!-- <if test="naturalEnvir != null">natural_envir =-->
  489. <!-- #{naturalEnvir},-->
  490. <!-- </if>-->
  491. <if test="type != null">
  492. type =
  493. #{type},
  494. </if>
  495. <if test="createTime != null">
  496. create_time =
  497. #{createTime},
  498. </if>
  499. <if test="updateBy != null">
  500. update_by =
  501. #{updateBy},
  502. </if>
  503. <if test="updateTime != null">
  504. update_time =
  505. #{updateTime},
  506. </if>
  507. <!-- <if test="modifiedId != null">modified_id =-->
  508. <!-- #{modifiedId},-->
  509. <!-- </if>-->
  510. <if test="path != null">
  511. path =
  512. #{path},
  513. </if>
  514. <!-- <if test="vid != null">vid =-->
  515. <!-- #{vid},-->
  516. <!-- </if>-->
  517. <!-- <if test="level != null">level =-->
  518. <!-- #{level},-->
  519. <!-- </if>-->
  520. <!-- <if test="oid != null">oid =-->
  521. <!-- #{oid},-->
  522. <!-- </if>-->
  523. <if test="parentGuid != null">
  524. parent_guid =
  525. #{parentGuid},
  526. </if>
  527. <if test="deleted != null">
  528. deleted =
  529. #{deleted},
  530. </if>
  531. <if test="sort != null">
  532. sort =
  533. #{sort},
  534. </if>
  535. <if test="source != null">
  536. source =
  537. #{source},
  538. </if>
  539. <if test="remark != null">
  540. remark =
  541. #{remark},
  542. </if>
  543. <!-- <if test="location != null">location =-->
  544. <!-- #{location},-->
  545. <!-- </if>-->
  546. <if test="createBy != null">
  547. create_by =
  548. #{createBy},
  549. </if>
  550. <if test="updateBy != null">
  551. update_by =
  552. #{updateBy},
  553. </if>
  554. </trim>
  555. where id = #{id}
  556. </update>
  557. <delete id="deleteSysOrgById" parameterType="Long">
  558. delete
  559. from sys_org
  560. where id = #{id}
  561. </delete>
  562. <delete id="deleteSysOrgByIds" parameterType="String">
  563. delete from sys_org where id in
  564. <foreach item="id" collection="array" open="(" separator="," close=")">
  565. #{id}
  566. </foreach>
  567. </delete>
  568. <select id="selectSysOrgByUserId" resultType="com.xunmei.system.api.domain.SysOrg">
  569. select so.*
  570. from sys_org so
  571. inner join sys_user suo on so.id = suo.org_id
  572. where suo.id = #{userId}
  573. </select>
  574. <select id="getParentName" resultType="com.xunmei.common.core.vo.IdNameVo">
  575. select so.id,so.name,p.name as extra
  576. from sys_org so
  577. left join sys_org p on so.parent_id=p.id and p.deleted=0
  578. where so.id in
  579. <foreach collection="ids" item="id" separator="," open="(" close=")">
  580. #{id}
  581. </foreach>
  582. and so.deleted=0
  583. </select>
  584. <select id="selectSysOrgVoByUserId" resultType="com.xunmei.system.api.vo.SysOrgVO">
  585. select so.id as id, so.name as name, so.path as path, so.parent_id as parentId
  586. from sys_org so
  587. inner join sys_user suo on so.id = suo.org_id
  588. where suo.id = #{userId}
  589. </select>
  590. <select id="selectSysOrgVOList" resultType="com.xunmei.system.api.vo.SysOrgVO">
  591. SELECT id,
  592. `name`,
  593. path,
  594. parent_id
  595. FROM sys_org
  596. WHERE deleted = 0
  597. </select>
  598. </mapper>