OrganizationManagementMapper.xml 24 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687
  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.goafanti.common.dao.OrganizationManagementMapper">
  4. <resultMap id="BaseResultMap" type="com.goafanti.common.model.OrganizationManagement">
  5. <!--
  6. WARNING - @mbg.generated
  7. This element is automatically generated by MyBatis Generator, do not modify.
  8. This element was generated on Thu Nov 30 11:09:29 CST 2017.
  9. -->
  10. <id column="id" jdbcType="VARCHAR" property="id" />
  11. <result column="create_id" jdbcType="VARCHAR" property="createId" />
  12. <result column="create_time" jdbcType="TIMESTAMP" property="createTime" />
  13. <result column="update_time" jdbcType="TIMESTAMP" property="updateTime" />
  14. <result column="deleted_sign" jdbcType="VARCHAR" property="deletedSign" />
  15. <result column="name" jdbcType="VARCHAR" property="name" />
  16. <result column="type" jdbcType="VARCHAR" property="type" />
  17. <result column="manager_id" jdbcType="VARCHAR" property="managerId" />
  18. <result column="dep_no" jdbcType="VARCHAR" property="depNo" />
  19. <result column="super_id" jdbcType="VARCHAR" property="superId" />
  20. <result column="remarks" jdbcType="VARCHAR" property="remarks" />
  21. <result column="status" jdbcType="VARCHAR" property="status" />
  22. <result column="abbreviation" jdbcType="VARCHAR" property="abbreviation" />
  23. <result column="finance_id" jdbcType="VARCHAR" property="financeId" />
  24. </resultMap>
  25. <sql id="Example_Where_Clause">
  26. <!--
  27. WARNING - @mbg.generated
  28. This element is automatically generated by MyBatis Generator, do not modify.
  29. This element was generated on Thu Nov 30 11:09:29 CST 2017.
  30. -->
  31. <where>
  32. <foreach collection="oredCriteria" item="criteria" separator="or">
  33. <if test="criteria.valid">
  34. <trim prefix="(" prefixOverrides="and" suffix=")">
  35. <foreach collection="criteria.criteria" item="criterion">
  36. <choose>
  37. <when test="criterion.noValue">
  38. and ${criterion.condition}
  39. </when>
  40. <when test="criterion.singleValue">
  41. and ${criterion.condition} #{criterion.value}
  42. </when>
  43. <when test="criterion.betweenValue">
  44. and ${criterion.condition} #{criterion.value} and #{criterion.secondValue}
  45. </when>
  46. <when test="criterion.listValue">
  47. and ${criterion.condition}
  48. <foreach close=")" collection="criterion.value" item="listItem" open="(" separator=",">
  49. #{listItem}
  50. </foreach>
  51. </when>
  52. </choose>
  53. </foreach>
  54. </trim>
  55. </if>
  56. </foreach>
  57. </where>
  58. </sql>
  59. <sql id="Update_By_Example_Where_Clause">
  60. <!--
  61. WARNING - @mbg.generated
  62. This element is automatically generated by MyBatis Generator, do not modify.
  63. This element was generated on Thu Nov 30 11:09:29 CST 2017.
  64. -->
  65. <where>
  66. <foreach collection="example.oredCriteria" item="criteria" separator="or">
  67. <if test="criteria.valid">
  68. <trim prefix="(" prefixOverrides="and" suffix=")">
  69. <foreach collection="criteria.criteria" item="criterion">
  70. <choose>
  71. <when test="criterion.noValue">
  72. and ${criterion.condition}
  73. </when>
  74. <when test="criterion.singleValue">
  75. and ${criterion.condition} #{criterion.value}
  76. </when>
  77. <when test="criterion.betweenValue">
  78. and ${criterion.condition} #{criterion.value} and #{criterion.secondValue}
  79. </when>
  80. <when test="criterion.listValue">
  81. and ${criterion.condition}
  82. <foreach close=")" collection="criterion.value" item="listItem" open="(" separator=",">
  83. #{listItem}
  84. </foreach>
  85. </when>
  86. </choose>
  87. </foreach>
  88. </trim>
  89. </if>
  90. </foreach>
  91. </where>
  92. </sql>
  93. <sql id="Base_Column_List">
  94. <!--
  95. WARNING - @mbg.generated
  96. This element is automatically generated by MyBatis Generator, do not modify.
  97. This element was generated on Thu Nov 30 11:09:29 CST 2017.
  98. -->
  99. id, create_id, create_time, update_time, deleted_sign, name, type, manager_id, dep_no,
  100. super_id, remarks, status,abbreviation,finance_id
  101. </sql>
  102. <select id="selectByExample" parameterType="com.goafanti.common.model.OrganizationManagementExample" resultMap="BaseResultMap">
  103. <!--
  104. WARNING - @mbg.generated
  105. This element is automatically generated by MyBatis Generator, do not modify.
  106. This element was generated on Thu Nov 30 11:09:29 CST 2017.
  107. -->
  108. select
  109. <if test="distinct">
  110. distinct
  111. </if>
  112. <include refid="Base_Column_List" />
  113. from department
  114. <if test="_parameter != null">
  115. <include refid="Example_Where_Clause" />
  116. </if>
  117. <if test="orderByClause != null">
  118. order by ${orderByClause}
  119. </if>
  120. </select>
  121. <select id="selectByPrimaryKey" parameterType="java.lang.String" resultMap="BaseResultMap">
  122. <!--
  123. WARNING - @mbg.generated
  124. This element is automatically generated by MyBatis Generator, do not modify.
  125. This element was generated on Thu Nov 30 11:09:29 CST 2017.
  126. -->
  127. select
  128. <include refid="Base_Column_List" />
  129. from department
  130. where id = #{id,jdbcType=VARCHAR}
  131. </select>
  132. <delete id="deleteByPrimaryKey" parameterType="java.lang.String">
  133. <!--
  134. WARNING - @mbg.generated
  135. This element is automatically generated by MyBatis Generator, do not modify.
  136. This element was generated on Thu Nov 30 11:09:29 CST 2017.
  137. -->
  138. delete from department
  139. where id = #{id,jdbcType=VARCHAR}
  140. </delete>
  141. <delete id="deleteByExample" parameterType="com.goafanti.common.model.OrganizationManagementExample">
  142. <!--
  143. WARNING - @mbg.generated
  144. This element is automatically generated by MyBatis Generator, do not modify.
  145. This element was generated on Thu Nov 30 11:09:29 CST 2017.
  146. -->
  147. delete from department
  148. <if test="_parameter != null">
  149. <include refid="Example_Where_Clause" />
  150. </if>
  151. </delete>
  152. <insert id="insert" parameterType="com.goafanti.common.model.OrganizationManagement">
  153. <!--
  154. WARNING - @mbg.generated
  155. This element is automatically generated by MyBatis Generator, do not modify.
  156. This element was generated on Thu Nov 30 11:09:29 CST 2017.
  157. -->
  158. insert into department (id, create_id, create_time,
  159. update_time, deleted_sign, name,
  160. type, manager_id, dep_no,
  161. super_id, remarks, status
  162. )
  163. values (#{id,jdbcType=VARCHAR}, #{createId,jdbcType=VARCHAR}, #{createTime,jdbcType=TIMESTAMP},
  164. #{updateTime,jdbcType=TIMESTAMP}, #{deletedSign,jdbcType=VARCHAR}, #{name,jdbcType=VARCHAR},
  165. #{type,jdbcType=VARCHAR}, #{managerId,jdbcType=VARCHAR}, #{depNo,jdbcType=VARCHAR},
  166. #{superId,jdbcType=VARCHAR}, #{remarks,jdbcType=VARCHAR}, #{status,jdbcType=VARCHAR}
  167. )
  168. </insert>
  169. <insert id="insertSelective" parameterType="com.goafanti.common.model.OrganizationManagement">
  170. <!--
  171. WARNING - @mbg.generated
  172. This element is automatically generated by MyBatis Generator, do not modify.
  173. This element was generated on Thu Nov 30 11:09:29 CST 2017.
  174. -->
  175. insert into department
  176. <trim prefix="(" suffix=")" suffixOverrides=",">
  177. <if test="id != null">
  178. id,
  179. </if>
  180. <if test="createId != null">
  181. create_id,
  182. </if>
  183. <if test="createTime != null">
  184. create_time,
  185. </if>
  186. <if test="updateTime != null">
  187. update_time,
  188. </if>
  189. <if test="deletedSign != null">
  190. deleted_sign,
  191. </if>
  192. <if test="name != null">
  193. name,
  194. </if>
  195. <if test="type != null">
  196. type,
  197. </if>
  198. <if test="managerId != null">
  199. manager_id,
  200. </if>
  201. <if test="depNo != null">
  202. dep_no,
  203. </if>
  204. <if test="superId != null">
  205. super_id,
  206. </if>
  207. <if test="remarks != null">
  208. remarks,
  209. </if>
  210. <if test="status != null">
  211. status,
  212. </if>
  213. </trim>
  214. <trim prefix="values (" suffix=")" suffixOverrides=",">
  215. <if test="id != null">
  216. #{id,jdbcType=VARCHAR},
  217. </if>
  218. <if test="createId != null">
  219. #{createId,jdbcType=VARCHAR},
  220. </if>
  221. <if test="createTime != null">
  222. #{createTime,jdbcType=TIMESTAMP},
  223. </if>
  224. <if test="updateTime != null">
  225. #{updateTime,jdbcType=TIMESTAMP},
  226. </if>
  227. <if test="deletedSign != null">
  228. #{deletedSign,jdbcType=VARCHAR},
  229. </if>
  230. <if test="name != null">
  231. #{name,jdbcType=VARCHAR},
  232. </if>
  233. <if test="type != null">
  234. #{type,jdbcType=VARCHAR},
  235. </if>
  236. <if test="managerId != null">
  237. #{managerId,jdbcType=VARCHAR},
  238. </if>
  239. <if test="depNo != null">
  240. #{depNo,jdbcType=VARCHAR},
  241. </if>
  242. <if test="superId != null">
  243. #{superId,jdbcType=VARCHAR},
  244. </if>
  245. <if test="remarks != null">
  246. #{remarks,jdbcType=VARCHAR},
  247. </if>
  248. <if test="status != null">
  249. #{status,jdbcType=VARCHAR},
  250. </if>
  251. </trim>
  252. </insert>
  253. <select id="countByExample" parameterType="com.goafanti.common.model.OrganizationManagementExample" resultType="java.lang.Long">
  254. <!--
  255. WARNING - @mbg.generated
  256. This element is automatically generated by MyBatis Generator, do not modify.
  257. This element was generated on Thu Nov 30 11:09:29 CST 2017.
  258. -->
  259. select count(*) from department
  260. <if test="_parameter != null">
  261. <include refid="Example_Where_Clause" />
  262. </if>
  263. </select>
  264. <update id="updateByExampleSelective" parameterType="map">
  265. <!--
  266. WARNING - @mbg.generated
  267. This element is automatically generated by MyBatis Generator, do not modify.
  268. This element was generated on Thu Nov 30 11:09:29 CST 2017.
  269. -->
  270. update department
  271. <set>
  272. <if test="record.id != null">
  273. id = #{record.id,jdbcType=VARCHAR},
  274. </if>
  275. <if test="record.createId != null">
  276. create_id = #{record.createId,jdbcType=VARCHAR},
  277. </if>
  278. <if test="record.createTime != null">
  279. create_time = #{record.createTime,jdbcType=TIMESTAMP},
  280. </if>
  281. <if test="record.updateTime != null">
  282. update_time = #{record.updateTime,jdbcType=TIMESTAMP},
  283. </if>
  284. <if test="record.deletedSign != null">
  285. deleted_sign = #{record.deletedSign,jdbcType=VARCHAR},
  286. </if>
  287. <if test="record.name != null">
  288. name = #{record.name,jdbcType=VARCHAR},
  289. </if>
  290. <if test="record.type != null">
  291. type = #{record.type,jdbcType=VARCHAR},
  292. </if>
  293. <if test="record.managerId != null">
  294. manager_id = #{record.managerId,jdbcType=VARCHAR},
  295. </if>
  296. <if test="record.depNo != null">
  297. dep_no = #{record.depNo,jdbcType=VARCHAR},
  298. </if>
  299. <if test="record.superId != null">
  300. super_id = #{record.superId,jdbcType=VARCHAR},
  301. </if>
  302. <if test="record.remarks != null">
  303. remarks = #{record.remarks,jdbcType=VARCHAR},
  304. </if>
  305. <if test="record.status != null">
  306. status = #{record.status,jdbcType=VARCHAR},
  307. </if>
  308. </set>
  309. <if test="_parameter != null">
  310. <include refid="Update_By_Example_Where_Clause" />
  311. </if>
  312. </update>
  313. <update id="updateByExample" parameterType="map">
  314. <!--
  315. WARNING - @mbg.generated
  316. This element is automatically generated by MyBatis Generator, do not modify.
  317. This element was generated on Thu Nov 30 11:09:29 CST 2017.
  318. -->
  319. update department
  320. set id = #{record.id,jdbcType=VARCHAR},
  321. create_id = #{record.createId,jdbcType=VARCHAR},
  322. create_time = #{record.createTime,jdbcType=TIMESTAMP},
  323. update_time = #{record.updateTime,jdbcType=TIMESTAMP},
  324. deleted_sign = #{record.deletedSign,jdbcType=VARCHAR},
  325. name = #{record.name,jdbcType=VARCHAR},
  326. type = #{record.type,jdbcType=VARCHAR},
  327. manager_id = #{record.managerId,jdbcType=VARCHAR},
  328. dep_no = #{record.depNo,jdbcType=VARCHAR},
  329. super_id = #{record.superId,jdbcType=VARCHAR},
  330. remarks = #{record.remarks,jdbcType=VARCHAR},
  331. status = #{record.status,jdbcType=VARCHAR}
  332. <if test="_parameter != null">
  333. <include refid="Update_By_Example_Where_Clause" />
  334. </if>
  335. </update>
  336. <update id="updateByPrimaryKeySelective" parameterType="com.goafanti.common.model.OrganizationManagement">
  337. <!--
  338. WARNING - @mbg.generated
  339. This element is automatically generated by MyBatis Generator, do not modify.
  340. This element was generated on Thu Nov 30 11:09:29 CST 2017.
  341. -->
  342. update department
  343. <set>
  344. <if test="createId != null">
  345. create_id = #{createId,jdbcType=VARCHAR},
  346. </if>
  347. <if test="createTime != null">
  348. create_time = #{createTime,jdbcType=TIMESTAMP},
  349. </if>
  350. <if test="updateTime != null">
  351. update_time = #{updateTime,jdbcType=TIMESTAMP},
  352. </if>
  353. <if test="deletedSign != null">
  354. deleted_sign = #{deletedSign,jdbcType=VARCHAR},
  355. </if>
  356. <if test="name != null">
  357. name = #{name,jdbcType=VARCHAR},
  358. </if>
  359. <if test="type != null">
  360. type = #{type,jdbcType=VARCHAR},
  361. </if>
  362. <if test="managerId != null">
  363. manager_id = #{managerId,jdbcType=VARCHAR},
  364. </if>
  365. <if test="depNo != null">
  366. dep_no = #{depNo,jdbcType=VARCHAR},
  367. </if>
  368. <if test="superId != null">
  369. super_id = #{superId,jdbcType=VARCHAR},
  370. </if>
  371. <if test="remarks != null">
  372. remarks = #{remarks,jdbcType=VARCHAR},
  373. </if>
  374. <if test="status != null">
  375. status = #{status,jdbcType=VARCHAR},
  376. </if>
  377. <if test="abbreviation != null">
  378. abbreviation = #{abbreviation,jdbcType=VARCHAR},
  379. </if>
  380. <if test="financeId != null">
  381. finance_id = #{financeId,jdbcType=VARCHAR},
  382. </if>
  383. <if test="province != null">
  384. province = #{province},
  385. </if>
  386. </set>
  387. where id = #{id,jdbcType=VARCHAR}
  388. </update>
  389. <update id="updateByPrimaryKey" parameterType="com.goafanti.common.model.OrganizationManagement">
  390. <!--
  391. WARNING - @mbg.generated
  392. This element is automatically generated by MyBatis Generator, do not modify.
  393. This element was generated on Thu Nov 30 11:09:29 CST 2017.
  394. -->
  395. update department
  396. set create_id = #{createId,jdbcType=VARCHAR},
  397. create_time = #{createTime,jdbcType=TIMESTAMP},
  398. update_time = #{updateTime,jdbcType=TIMESTAMP},
  399. deleted_sign = #{deletedSign,jdbcType=VARCHAR},
  400. name = #{name,jdbcType=VARCHAR},
  401. type = #{type,jdbcType=VARCHAR},
  402. manager_id = #{managerId,jdbcType=VARCHAR},
  403. dep_no = #{depNo,jdbcType=VARCHAR},
  404. super_id = #{superId,jdbcType=VARCHAR},
  405. remarks = #{remarks,jdbcType=VARCHAR},
  406. status = #{status,jdbcType=VARCHAR}
  407. where id = #{id,jdbcType=VARCHAR}
  408. </update>
  409. <select id="selectOrganizationList" parameterType="String" resultType="com.goafanti.organization.bo.OrganizationListOut">
  410. select
  411. om.id,om.create_id as createId,om.create_time as createTime,
  412. om.update_time as updateTime,om.deleted_sign as deletedSign,
  413. om.name,om.type,
  414. om.dep_no as depNo,
  415. om.remarks,
  416. om.status,
  417. dm.name as superName,
  418. x.name as managerName
  419. from department om
  420. left join department dm on om.super_id = dm.id
  421. left join admin x on om.manager_id = x.id
  422. where
  423. om.deleted_sign = '0'
  424. and
  425. om.name != '平台超管中心'
  426. <if test="name !=null">
  427. AND om.name like CONCAT('%',#{name,jdbcType=VARCHAR},'%')
  428. </if>
  429. <if test="superId !=null">
  430. AND om.super_id=#{superId,jdbcType=VARCHAR}
  431. </if>
  432. <if test="type !=null">
  433. AND om.type=#{type,jdbcType=VARCHAR}
  434. </if>
  435. <if test="depNo !=null">
  436. AND om.dep_no=#{depNo,jdbcType=VARCHAR}
  437. </if>
  438. <if test="page_sql != null">
  439. ${page_sql}
  440. </if>
  441. </select>
  442. <select id="selectOrganizationCount" resultType="java.lang.Integer">
  443. select
  444. count(0)
  445. from department om
  446. left join department dm on om.super_id = dm.id
  447. left join admin x on om.manager_id = x.id
  448. where
  449. om.deleted_sign = '0'
  450. and
  451. om.name != '平台超管中心'
  452. <if test="name !=null">
  453. AND om.name like CONCAT('%',#{name,jdbcType=VARCHAR},'%')
  454. </if>
  455. <if test="superId !=null">
  456. AND om.super_id=#{superId,jdbcType=VARCHAR}
  457. </if>
  458. <if test="type !=null">
  459. AND om.type=#{type,jdbcType=VARCHAR}
  460. </if>
  461. <if test="depNo !=null">
  462. AND om.dep_no=#{depNo,jdbcType=VARCHAR}
  463. </if>
  464. </select>
  465. <select id="selectSuperId" resultType="com.goafanti.organization.bo.OrganizationListOut">
  466. select
  467. id,name,dep_no as depNo
  468. from department
  469. where
  470. status ='0'
  471. order by CONVERT (name USING gbk)
  472. <if test="sort ==1" >
  473. limit 10
  474. </if>
  475. </select>
  476. <insert id="insert1" parameterType="com.goafanti.organization.bo.OrganizationListOut">
  477. insert into department(
  478. id,create_id,create_time,update_time,deleted_sign,
  479. name,type,manager_id,dep_no,super_id,desc,status)
  480. values(#{id,jdbcType=VARCHAR},#{createId,jdbcType=VARCHAR},
  481. #{createTime,jdbcType=VARCHAR},#{updateTime,jdbcType=VARCHAR},
  482. #{deletedSign,jdbcType=VARCHAR},#{name,jdbcType=VARCHAR},
  483. #{type,jdbcType=VARCHAR},#{managerId,jdbcType=VARCHAR},
  484. #{depNo,jdbcType=VARCHAR},#{superId,jdbcType=VARCHAR},
  485. #{desc,jdbcType=VARCHAR},#{status,jdbcType=VARCHAR})
  486. </insert>
  487. <!-- 得到上级 -->
  488. <select id="selectDepNo" resultType="String">
  489. select
  490. dep_no as depNo
  491. from department
  492. where
  493. id=#{superId,jdbcType=VARCHAR}
  494. </select>
  495. <select id="selectDepNoByName" resultType="String">
  496. select
  497. dep_no as depNo
  498. from department
  499. where
  500. name=#{name,jdbcType=VARCHAR}
  501. </select>
  502. <select id="selectDepNoCount" parameterType="String" resultType="java.lang.Integer">
  503. select
  504. count(0)
  505. from department
  506. where
  507. <!-- dep_no like concat(#{depNo,jdbcType=VARCHAR},'%') -->
  508. super_id=#{superId,jdbcType=VARCHAR}
  509. </select>
  510. <select id="selectName" resultType="com.goafanti.admin.bo.AdminListBo">
  511. select
  512. name,id
  513. from admin
  514. where status='正常'
  515. and name like concat('%',#{name,jdbcType=VARCHAR},'%')
  516. </select>
  517. <select id="selectAllById" resultType="com.goafanti.organization.bo.OrganizationListOut">
  518. select
  519. a.id,
  520. a.create_id as createId,
  521. a.create_time as createTime,
  522. a.update_time as updateTime,
  523. a.deleted_sign as deletedSign,
  524. a.name,
  525. a.type,
  526. a.manager_id as managerId,
  527. a.dep_no as depNo,
  528. a.super_id as superId,
  529. a.remarks,
  530. a.status,
  531. a.abbreviation,
  532. a.finance_id financeId,
  533. a.province,
  534. c.name financeName,
  535. b.name as managerName
  536. from department a
  537. left join admin b on a.manager_id = b.id
  538. left join admin c on a.finance_id = c.id
  539. where
  540. a.id=#{id,jdbcType=VARCHAR}
  541. </select>
  542. <delete id="deleteById" parameterType="java.lang.String">
  543. delete from department
  544. where id = #{id,jdbcType=VARCHAR}
  545. </delete>
  546. <select id="selectAdminNameById" parameterType="java.lang.String" resultType="java.lang.String">
  547. select
  548. name
  549. from admin
  550. where
  551. id=#{id,jdbcType=VARCHAR}
  552. </select>
  553. <select id="selectIdByDepNo" parameterType="java.lang.String" resultType="java.lang.String">
  554. select
  555. id
  556. from department
  557. where
  558. dep_no=#{depNo,jdbcType=VARCHAR}
  559. </select>
  560. <select id="selectIDNBySuperId" parameterType="java.lang.String" resultType="com.goafanti.organization.bo.OrganizationListOut">
  561. select
  562. id,create_id as createId,create_time as createTime,
  563. update_time as updateTime,deleted_sign as deletedSign,
  564. name,type,manager_id as managerId,
  565. dep_no as depNo,
  566. super_id as superId,
  567. remarks,status
  568. from department
  569. where
  570. super_id=#{id,jdbcType=VARCHAR}
  571. order by dep_no
  572. </select>
  573. <update id="updateByNumber" parameterType="com.goafanti.organization.bo.OrganizationListOut">
  574. update department
  575. <set>
  576. dep_no = #{depNo,jdbcType=VARCHAR}
  577. </set>
  578. where
  579. id=#{id,jdbcType=VARCHAR}
  580. </update>
  581. <select id="selectCountBySuperId" parameterType="String" resultType="java.lang.Integer">
  582. select
  583. count(0)
  584. from department
  585. where
  586. super_id=#{superId,jdbcType=VARCHAR}
  587. </select>
  588. <select id="selectIdByName" parameterType="java.lang.String" resultType="java.lang.String">
  589. select
  590. id
  591. from department
  592. where
  593. name=#{name,jdbcType=VARCHAR}
  594. </select>
  595. <select id="selectNameById" parameterType="java.lang.String" resultType="java.lang.String">
  596. select
  597. name
  598. from department
  599. where
  600. id=#{id,jdbcType=VARCHAR}
  601. </select>
  602. <select id="selectDepNoById" resultType="String">
  603. select
  604. dep_no as depNo
  605. from department
  606. where
  607. id=#{id,jdbcType=VARCHAR}
  608. </select>
  609. <select id="selectUserById" parameterType="java.lang.String" resultType="java.lang.Integer">
  610. select
  611. count(0)
  612. from admin
  613. where
  614. department_id=#{id,jdbcType=VARCHAR}
  615. </select>
  616. <!-- 查询当前层级 -->
  617. <select id="selectCurrentDeps" parameterType="java.lang.String" resultMap="BaseResultMap">
  618. select id,name,dep_no,super_id from department where manager_id = #{aid,jdbcType=VARCHAR}
  619. union all
  620. select id,name,dep_no,super_id from department where id = (select department_id from admin where id = #{aid,jdbcType=VARCHAR})
  621. </select>
  622. <!-- 查询下一层级 -->
  623. <select id="selectSubDeps" parameterType="java.lang.String" resultMap="BaseResultMap">
  624. select id,name,dep_no from department where super_id in (#{superIds,jdbcType=VARCHAR})
  625. </select>
  626. <select id="selectBysuperName" resultType="com.goafanti.admin.bo.depCountBo">
  627. select a.id ,a.name ,0 userCount,0 inputCount,0 receiveCount, 0 completeCount, 0 interviewCount
  628. from department a left join department b on a.super_id=b.id where b.name= #{superName,jdbcType=VARCHAR}
  629. </select>
  630. <!-- 查询所有 -->
  631. <select id="selectAllDeps" resultMap="BaseResultMap">
  632. select id,name,dep_no from department
  633. </select>
  634. <select id="getMaxAbbreviation" parameterType="java.lang.String" resultType="java.lang.String">
  635. select max(contract_no) as maxNo from t_order_new
  636. where create_time > '2019-5-31'
  637. and contract_no like concat(#{abbreviation,jdbcType=VARCHAR},'%')
  638. </select>
  639. <select id="getDepAll" resultType="com.goafanti.admin.bo.AdminCustomerBo">
  640. select a.id as aid,a.name as aName,d.id depId,d.name as depName,ifnull(b.userCount,0) as userCount,ifnull(c.timeCount,0) as inputCount,
  641. ifnull(d.timeCount,0) as receiveCount, ifnull(e.completeCount,0)completeCount,ifnull(f.interviewCount,0)interviewCount
  642. from admin a
  643. left join (select aid,count(aid) as userCount from user where aid is not null
  644. and share_type=0 and source !=0 and type=1
  645. group by aid) b on a.id=b.aid
  646. left join (select aid,count(aid) as timeCount from `user` where aid is not null
  647. and share_type=0 and source =1 and type=1
  648. <if test="startTime != null and endTime != null">
  649. and create_time between #{startTime,jdbcType=VARCHAR} and #{endTime,jdbcType=VARCHAR}
  650. </if>
  651. group by aid) c on a.id=c.aid
  652. left join (select aid,count(aid) as timeCount from `user` where aid is not null
  653. and share_type=0 and source =2 and type=1
  654. <if test="startTime != null and endTime != null">
  655. and transfer_time between #{startTime,jdbcType=VARCHAR} and #{endTime,jdbcType=VARCHAR}
  656. </if>
  657. group by aid) d on a.id=d.aid
  658. left join (select x.aid,count(uid) completeCount from (select a.aid,a.uid from user_business a left join `user` b on a.uid=b.id where a.follow_situation=5
  659. <if test="startTime != null and endTime != null">
  660. and a.update_time between #{startTime,jdbcType=VARCHAR} and #{endTime,jdbcType=VARCHAR}
  661. </if>
  662. and b.`type`=1 group by aid,uid)x group by aid)e on a.id=e.aid
  663. left join (select x.aid,count(uid) interviewCount from (select a.aid,a.uid from user_business a left join `user` b on a.uid=b.id where a.follow_situation=1
  664. <if test="startTime != null and endTime != null">
  665. and a.update_time between #{startTime,jdbcType=VARCHAR} and #{endTime,jdbcType=VARCHAR}
  666. </if>
  667. and b.`type`=1 group by aid,uid)x group by aid)f on a.id=f.aid
  668. left join department d on a.department_id=d.id
  669. left join user_role e on a.id=e.uid
  670. left join `role` f on e.rid=f.id
  671. where f.role_name in ('营销员','营销经理')
  672. and a.status='正常'
  673. <if test="depName !=null">
  674. and d.name= #{depName}
  675. </if>
  676. <if test="adminName !=null">
  677. and a.name like concat('%',#{adminName},'%')
  678. </if>
  679. <if test="depId !=null">
  680. and d.id= #{depId}
  681. </if>
  682. </select>
  683. </mapper>