AdminMapper.xml 37 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050
  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.AdminMapper">
  4. <resultMap id="BaseResultMap" type="com.goafanti.common.model.Admin">
  5. <id column="id" jdbcType="VARCHAR" property="id" />
  6. <result column="mobile" jdbcType="VARCHAR" property="mobile" />
  7. <result column="name" jdbcType="VARCHAR" property="name" />
  8. <result column="password" jdbcType="VARCHAR" property="password" />
  9. <result column="email" jdbcType="VARCHAR" property="email" />
  10. <result column="create_time" jdbcType="TIMESTAMP" property="createTime" />
  11. <result column="number" jdbcType="INTEGER" property="number" />
  12. <result column="province" jdbcType="VARCHAR" property="province" />
  13. <result column="position" jdbcType="VARCHAR" property="position" />
  14. <result column="superior_id" jdbcType="VARCHAR" property="superiorId" />
  15. <result column="city" jdbcType="VARCHAR" property="city" />
  16. <result column="department_id" jdbcType="VARCHAR" property="departmentId" />
  17. <result column="status" jdbcType="VARCHAR" property="status" />
  18. <result column="user_no" jdbcType="VARCHAR" property="userNo" />
  19. <result column="duty" jdbcType="VARCHAR" property="duty" />
  20. <result column="district" jdbcType="VARCHAR" property="district" />
  21. <result column="head_portrait_url" jdbcType="VARCHAR" property="headPortraitUrl" />
  22. <result column="contact_mobile" jdbcType="VARCHAR" property="contactMobile" />
  23. <result column="last_login_time" jdbcType="TIMESTAMP" property="lastLoginTime" />
  24. <result column="open_id" jdbcType="VARCHAR" property="openId" />
  25. <result column="type" jdbcType="INTEGER" property="type" />
  26. <result column="reviewer" jdbcType="VARCHAR" property="reviewer" />
  27. </resultMap>
  28. <sql id="Base_Column_List">
  29. id, mobile, `name`, `password`, email, create_time, `number`, province, `position`,
  30. superior_id, city, department_id, `status`, user_no, duty, district, head_portrait_url,
  31. contact_mobile, last_login_time, open_id, `type`, reviewer
  32. </sql>
  33. <select id="selectByPrimaryKey" parameterType="java.lang.String" resultMap="BaseResultMap">
  34. select
  35. <include refid="Base_Column_List" />
  36. from admin
  37. where id = #{id,jdbcType=VARCHAR}
  38. </select>
  39. <delete id="deleteByPrimaryKey" parameterType="java.lang.String">
  40. delete from admin
  41. where id = #{id,jdbcType=VARCHAR}
  42. </delete>
  43. <insert id="insert" parameterType="com.goafanti.common.model.Admin">
  44. insert into admin (id, mobile, `name`,
  45. `password`, email, create_time,
  46. `number`, province, `position`,
  47. superior_id, city, department_id,
  48. `status`, user_no, duty,
  49. district, head_portrait_url, contact_mobile,
  50. last_login_time, open_id, `type`,
  51. reviewer)
  52. values (#{id,jdbcType=VARCHAR}, #{mobile,jdbcType=VARCHAR}, #{name,jdbcType=VARCHAR},
  53. #{password,jdbcType=VARCHAR}, #{email,jdbcType=VARCHAR}, #{createTime,jdbcType=TIMESTAMP},
  54. #{number,jdbcType=INTEGER}, #{province,jdbcType=VARCHAR}, #{position,jdbcType=VARCHAR},
  55. #{superiorId,jdbcType=VARCHAR}, #{city,jdbcType=VARCHAR}, #{departmentId,jdbcType=VARCHAR},
  56. #{status,jdbcType=VARCHAR}, #{userNo,jdbcType=VARCHAR}, #{duty,jdbcType=VARCHAR},
  57. #{district,jdbcType=VARCHAR}, #{headPortraitUrl,jdbcType=VARCHAR}, #{contactMobile,jdbcType=VARCHAR},
  58. #{lastLoginTime,jdbcType=TIMESTAMP}, #{openId,jdbcType=VARCHAR}, #{type,jdbcType=INTEGER},
  59. #{reviewer,jdbcType=VARCHAR})
  60. </insert>
  61. <insert id="insertSelective" parameterType="com.goafanti.common.model.Admin">
  62. insert into admin
  63. <trim prefix="(" suffix=")" suffixOverrides=",">
  64. <if test="id != null">
  65. id,
  66. </if>
  67. <if test="mobile != null">
  68. mobile,
  69. </if>
  70. <if test="name != null">
  71. `name`,
  72. </if>
  73. <if test="password != null">
  74. `password`,
  75. </if>
  76. <if test="email != null">
  77. email,
  78. </if>
  79. <if test="createTime != null">
  80. create_time,
  81. </if>
  82. <if test="number != null">
  83. `number`,
  84. </if>
  85. <if test="province != null">
  86. province,
  87. </if>
  88. <if test="position != null">
  89. `position`,
  90. </if>
  91. <if test="superiorId != null">
  92. superior_id,
  93. </if>
  94. <if test="city != null">
  95. city,
  96. </if>
  97. <if test="departmentId != null">
  98. department_id,
  99. </if>
  100. <if test="status != null">
  101. `status`,
  102. </if>
  103. <if test="userNo != null">
  104. user_no,
  105. </if>
  106. <if test="duty != null">
  107. duty,
  108. </if>
  109. <if test="district != null">
  110. district,
  111. </if>
  112. <if test="headPortraitUrl != null">
  113. head_portrait_url,
  114. </if>
  115. <if test="contactMobile != null">
  116. contact_mobile,
  117. </if>
  118. <if test="lastLoginTime != null">
  119. last_login_time,
  120. </if>
  121. <if test="openId != null">
  122. open_id,
  123. </if>
  124. <if test="type != null">
  125. `type`,
  126. </if>
  127. <if test="reviewer != null">
  128. reviewer,
  129. </if>
  130. </trim>
  131. <trim prefix="values (" suffix=")" suffixOverrides=",">
  132. <if test="id != null">
  133. #{id,jdbcType=VARCHAR},
  134. </if>
  135. <if test="mobile != null">
  136. #{mobile,jdbcType=VARCHAR},
  137. </if>
  138. <if test="name != null">
  139. #{name,jdbcType=VARCHAR},
  140. </if>
  141. <if test="password != null">
  142. #{password,jdbcType=VARCHAR},
  143. </if>
  144. <if test="email != null">
  145. #{email,jdbcType=VARCHAR},
  146. </if>
  147. <if test="createTime != null">
  148. #{createTime,jdbcType=TIMESTAMP},
  149. </if>
  150. <if test="number != null">
  151. #{number,jdbcType=INTEGER},
  152. </if>
  153. <if test="province != null">
  154. #{province,jdbcType=VARCHAR},
  155. </if>
  156. <if test="position != null">
  157. #{position,jdbcType=VARCHAR},
  158. </if>
  159. <if test="superiorId != null">
  160. #{superiorId,jdbcType=VARCHAR},
  161. </if>
  162. <if test="city != null">
  163. #{city,jdbcType=VARCHAR},
  164. </if>
  165. <if test="departmentId != null">
  166. #{departmentId,jdbcType=VARCHAR},
  167. </if>
  168. <if test="status != null">
  169. #{status,jdbcType=VARCHAR},
  170. </if>
  171. <if test="userNo != null">
  172. #{userNo,jdbcType=VARCHAR},
  173. </if>
  174. <if test="duty != null">
  175. #{duty,jdbcType=VARCHAR},
  176. </if>
  177. <if test="district != null">
  178. #{district,jdbcType=VARCHAR},
  179. </if>
  180. <if test="headPortraitUrl != null">
  181. #{headPortraitUrl,jdbcType=VARCHAR},
  182. </if>
  183. <if test="contactMobile != null">
  184. #{contactMobile,jdbcType=VARCHAR},
  185. </if>
  186. <if test="lastLoginTime != null">
  187. #{lastLoginTime,jdbcType=TIMESTAMP},
  188. </if>
  189. <if test="openId != null">
  190. #{openId,jdbcType=VARCHAR},
  191. </if>
  192. <if test="type != null">
  193. #{type,jdbcType=INTEGER},
  194. </if>
  195. <if test="reviewer != null">
  196. #{reviewer,jdbcType=VARCHAR},
  197. </if>
  198. </trim>
  199. </insert>
  200. <update id="updateByPrimaryKeySelective" parameterType="com.goafanti.common.model.Admin">
  201. update admin
  202. <set>
  203. <if test="mobile != null">
  204. mobile = #{mobile,jdbcType=VARCHAR},
  205. </if>
  206. <if test="name != null">
  207. `name` = #{name,jdbcType=VARCHAR},
  208. </if>
  209. <if test="password != null">
  210. `password` = #{password,jdbcType=VARCHAR},
  211. </if>
  212. <if test="email != null">
  213. email = #{email,jdbcType=VARCHAR},
  214. </if>
  215. <if test="createTime != null">
  216. create_time = #{createTime,jdbcType=TIMESTAMP},
  217. </if>
  218. <if test="number != null">
  219. `number` = #{number,jdbcType=INTEGER},
  220. </if>
  221. <if test="province != null">
  222. province = #{province,jdbcType=VARCHAR},
  223. </if>
  224. <if test="position != null">
  225. `position` = #{position,jdbcType=VARCHAR},
  226. </if>
  227. <if test="superiorId != null">
  228. superior_id = #{superiorId,jdbcType=VARCHAR},
  229. </if>
  230. <if test="city != null">
  231. city = #{city,jdbcType=VARCHAR},
  232. </if>
  233. <if test="departmentId != null">
  234. department_id = #{departmentId,jdbcType=VARCHAR},
  235. </if>
  236. <if test="status != null">
  237. `status` = #{status,jdbcType=VARCHAR},
  238. </if>
  239. <if test="userNo != null">
  240. user_no = #{userNo,jdbcType=VARCHAR},
  241. </if>
  242. <if test="duty != null">
  243. duty = #{duty,jdbcType=VARCHAR},
  244. </if>
  245. <if test="district != null">
  246. district = #{district,jdbcType=VARCHAR},
  247. </if>
  248. <if test="headPortraitUrl != null">
  249. head_portrait_url = #{headPortraitUrl,jdbcType=VARCHAR},
  250. </if>
  251. <if test="contactMobile != null">
  252. contact_mobile = #{contactMobile,jdbcType=VARCHAR},
  253. </if>
  254. <if test="lastLoginTime != null">
  255. last_login_time = #{lastLoginTime,jdbcType=TIMESTAMP},
  256. </if>
  257. <if test="openId != null">
  258. open_id = #{openId,jdbcType=VARCHAR},
  259. </if>
  260. <if test="type != null">
  261. `type` = #{type,jdbcType=INTEGER},
  262. </if>
  263. <if test="reviewer != null">
  264. reviewer = #{reviewer,jdbcType=VARCHAR},
  265. </if>
  266. </set>
  267. where id = #{id,jdbcType=VARCHAR}
  268. </update>
  269. <update id="updateByPrimaryKey" parameterType="com.goafanti.common.model.Admin">
  270. update admin
  271. set mobile = #{mobile,jdbcType=VARCHAR},
  272. `name` = #{name,jdbcType=VARCHAR},
  273. `password` = #{password,jdbcType=VARCHAR},
  274. email = #{email,jdbcType=VARCHAR},
  275. create_time = #{createTime,jdbcType=TIMESTAMP},
  276. `number` = #{number,jdbcType=INTEGER},
  277. province = #{province,jdbcType=VARCHAR},
  278. `position` = #{position,jdbcType=VARCHAR},
  279. superior_id = #{superiorId,jdbcType=VARCHAR},
  280. city = #{city,jdbcType=VARCHAR},
  281. department_id = #{departmentId,jdbcType=VARCHAR},
  282. `status` = #{status,jdbcType=VARCHAR},
  283. user_no = #{userNo,jdbcType=VARCHAR},
  284. duty = #{duty,jdbcType=VARCHAR},
  285. district = #{district,jdbcType=VARCHAR},
  286. head_portrait_url = #{headPortraitUrl,jdbcType=VARCHAR},
  287. contact_mobile = #{contactMobile,jdbcType=VARCHAR},
  288. last_login_time = #{lastLoginTime,jdbcType=TIMESTAMP},
  289. open_id = #{openId,jdbcType=VARCHAR},
  290. `type` = #{type,jdbcType=INTEGER},
  291. reviewer = #{reviewer,jdbcType=VARCHAR}
  292. where id = #{id,jdbcType=VARCHAR}
  293. </update>
  294. <select id="selectAllAdmin" resultMap="BaseResultMap">
  295. select
  296. <include refid="Base_Column_List" />
  297. from admin
  298. where status !='锁定'
  299. <if test="depId != null">
  300. and department_id = #{depId,jdbcType=VARCHAR}
  301. </if>
  302. </select>
  303. <select id="selectByMobile" parameterType="java.lang.String" resultMap="BaseResultMap">
  304. select
  305. <include refid="Base_Column_List" />
  306. from admin
  307. where mobile = #{mobile,jdbcType=VARCHAR}
  308. </select>
  309. <select id="selectRolesByPrimaryKey" parameterType="java.lang.String" resultType="com.goafanti.common.model.Role">
  310. select r.name, r.id, r.type
  311. from role r
  312. left join user_role ur on ur.rid=r.id
  313. where ur.uid = #{uid,jdbcType=VARCHAR}
  314. </select>
  315. <select id="selectCognizanceConsultant" resultMap="BaseResultMap">
  316. select
  317. <include refid="Base_Column_List" />
  318. from admin
  319. where id <![CDATA[ <> ]]> '1'
  320. </select>
  321. <select id="selectCognizancePrincipal" resultMap="BaseResultMap">
  322. select a.id, a.name, a.position from admin a
  323. INNER JOIN user_role ur on a.id = ur.uid
  324. where ur.rid not in('1','2','3','4','5','6')
  325. group by a.id
  326. </select>
  327. <select id="selectPatentAuthor" resultMap="BaseResultMap">
  328. select a.id, a.name, a.position from admin a
  329. INNER JOIN user_role ur on a.id = ur.uid
  330. where ur.rid not in('1','2','3','4','5','6')
  331. group by a.id
  332. </select>
  333. <select id="selectPatentPrincipal" resultMap="BaseResultMap">
  334. select a.id, a.name, a.position from admin a
  335. INNER JOIN user_role ur on a.id = ur.uid
  336. where ur.rid not in('1','2','3','4','5','6')
  337. group by a.id
  338. </select>
  339. <select id="selectCopyrightConsultant" resultMap="BaseResultMap">
  340. select
  341. <include refid="Base_Column_List" />
  342. from admin
  343. where id <![CDATA[ <> ]]> '1'
  344. </select>
  345. <select id="selectCopyrightPrincipal" resultMap="BaseResultMap">
  346. select a.id, a.name, a.position from admin a
  347. INNER JOIN user_role ur on a.id = ur.uid
  348. where ur.rid not in('1','2','3','4','5','6')
  349. group by a.id
  350. </select>
  351. <select id="selectTechprojectConsultant" resultMap="BaseResultMap">
  352. select
  353. <include refid="Base_Column_List" />
  354. from admin
  355. where id <![CDATA[ <> ]]> '1'
  356. </select>
  357. <select id="selectTechprojectPrincipal" resultMap="BaseResultMap">
  358. select a.id, a.name, a.position from admin a
  359. INNER JOIN user_role ur on a.id = ur.uid
  360. where ur.rid not in('1','2','3','4','5','6')
  361. group by a.id
  362. </select>
  363. <select id="selectRoleByPrimaryKey" parameterType="java.lang.String" resultType="String">
  364. SELECT rid FROM user_role
  365. where uid = #{uid,jdbcType=VARCHAR}
  366. </select>
  367. <select id="selectAccoutManager" resultMap="BaseResultMap">
  368. select a.id, a.name, a.position from admin a
  369. INNER JOIN user_role ur on a.id = ur.uid
  370. where ur.rid = '4'
  371. </select>
  372. <select id="selectTechnician" resultMap="BaseResultMap">
  373. select a.id, a.name, a.position from admin a
  374. INNER JOIN user_role ur on a.id = ur.uid
  375. where ur.rid not in('1','2','3','4')
  376. group by a.id
  377. </select>
  378. <select id="selectSalesman" resultMap="BaseResultMap">
  379. select a.id, a.name, a.position from admin a
  380. INNER JOIN user_role ur on a.id = ur.uid
  381. where ur.rid in ('5', '6')
  382. </select>
  383. <select id="selectContractManager" resultMap="BaseResultMap">
  384. select a.id, a.name, a.position from admin a
  385. INNER JOIN user_role ur on a.id = ur.uid
  386. where ur.rid not in('1','2','3','4')
  387. group by a.id
  388. </select>
  389. <select id="selectTechBroder" resultMap="BaseResultMap">
  390. select
  391. u.rid as rolesId, a.name,a.id, a.position
  392. from user_role u
  393. left join admin a on a.id =u.uid
  394. left join role r on r.id =u.rid
  395. where
  396. r.role_name='技术经纪专员'
  397. </select>
  398. <select id="listAdminSelectBySuperAdmin" resultMap="BaseResultMap">
  399. select
  400. <include refid="Base_Column_List" />
  401. from admin
  402. where id <![CDATA[ <> ]]> '1'
  403. </select>
  404. <select id="listAdminSelectByAreaAdmin" resultMap="BaseResultMap">
  405. select
  406. a.id, a.name, a.mobile,
  407. a.create_time as createTime, a.number, aa.name as superior
  408. from admin a
  409. left join admin_location al on al.admin_id = a.id
  410. left join admin aa on aa.id = a.superior_id
  411. where 1 = 1
  412. <if test="provinceList != null and provinceList.size &gt; 0">
  413. and al.province in
  414. <foreach close=")" collection="provinceList" item="plist" open="(" separator=",">
  415. #{plist}
  416. </foreach>
  417. </if>
  418. <if test="cityList != null and cityList.size &gt; 0">
  419. and al.city in
  420. <foreach close=")" collection="cityList" item="clist" open="(" separator=",">
  421. #{clist}
  422. </foreach>
  423. </if>
  424. </select>
  425. <select id="findAdminListByPage" parameterType="java.lang.String" resultType="com.goafanti.admin.bo.AdminListBo">
  426. select
  427. a.number, a.mobile, a.name,
  428. a.position, a.email, a.id,
  429. a.province,
  430. a.city,
  431. a.create_time as createTime,
  432. aa.name as superior,
  433. a.superior_id as superiorId,
  434. a.department_id as departmentId,
  435. date_format(a.last_login_time,'%Y-%m-%d %H:%i:%S') as lastLoginTime,
  436. dm.name as departmentName
  437. from admin a
  438. left join admin_location al on a.id = al.admin_id
  439. left join admin aa on aa.id = a.superior_id
  440. left join department dm on a.department_id = dm.id
  441. left join user_role x on x.uid=a.id
  442. left join `role` y on x.rid=y.id
  443. where a.id <![CDATA[ <> ]]> '1'
  444. <if test="roleName != null">
  445. where y.role_name= #{roleName,jdbcType=VARCHAR}
  446. </if>
  447. <if test="mobile != null">
  448. and a.mobile = #{mobile,jdbcType=VARCHAR}
  449. </if>
  450. <if test="name != null">
  451. and a.name = #{name,jdbcType=VARCHAR}
  452. </if>
  453. <if test="number != null">
  454. and a.number = #{number,jdbcType=INTEGER}
  455. </if>
  456. <if test="province != null">
  457. and a.province = #{province,jdbcType=VARCHAR}
  458. </if>
  459. order by a.last_login_time ,a.number
  460. <if test="page_sql!=null">
  461. ${page_sql}
  462. </if>
  463. </select>
  464. <select id="findAdminCount" parameterType="java.lang.String" resultType="java.lang.Integer">
  465. select count(1) from admin
  466. where id <![CDATA[ <> ]]> '1'
  467. left join `role` y on x.rid=y.id
  468. where a.id <![CDATA[ <> ]]> '1'
  469. <if test="roleName != null">
  470. where y.role_name= #{roleName,jdbcType=VARCHAR}
  471. </if>
  472. <if test="mobile != null">
  473. and mobile = #{mobile,jdbcType=VARCHAR}
  474. </if>
  475. <if test="name != null">
  476. and name = #{name,jdbcType=VARCHAR}
  477. </if>
  478. <if test="number != null">
  479. and number = #{number,jdbcType=INTEGER}
  480. </if>
  481. <if test="province != null">
  482. and a.province = #{province,jdbcType=VARCHAR}
  483. </if>
  484. </select>
  485. <select id="listAdminByName" parameterType="java.lang.String" resultMap="BaseResultMap">
  486. select id,name from admin where name like concat('%',#{name},'%')
  487. <if test="status==0">
  488. and status= '正常'
  489. </if>
  490. <if test="status==1">
  491. and status= '锁定'
  492. </if>
  493. </select>
  494. <!--*************************************************************************-->
  495. <select id="selectAdminListByPage" parameterType="java.lang.String" resultType="com.goafanti.admin.bo.AdminListBo">
  496. select x.*,y.name as departmentName from(select
  497. <!-- a.user_no as userNo, -->
  498. a.mobile, a.name,
  499. a.position, a.email, a.id,
  500. a.province,
  501. a.city,
  502. a.create_time as createTime,
  503. aa.name as superior,
  504. a.superior_id as superiorId,
  505. a.department_id as departmentId,
  506. a.last_login_time as lastLoginTime,
  507. a.contact_mobile as contactMobile,
  508. a.duty,a.status,
  509. a.type
  510. from admin a
  511. left join admin_location al on a.id = al.admin_id
  512. left join admin aa on aa.id = a.superior_id
  513. left join user_role ur on a.id=ur.uid
  514. left join `role` y on ur.rid=y.id
  515. where a.id <![CDATA[ <> ]]> '1'
  516. <if test="roleName != null">
  517. and y.role_name= #{roleName,jdbcType=VARCHAR}
  518. </if>
  519. <if test="name != null">
  520. and a.name like concat('%',#{name,jdbcType=VARCHAR},'%')
  521. </if>
  522. <if test="departmentId != null">
  523. and a.department_id = #{departmentId,jdbcType=VARCHAR}
  524. </if>
  525. <if test="rid != null">
  526. and ur.rid = #{rid,jdbcType=VARCHAR}
  527. </if>
  528. <if test="duty != null">
  529. and a.duty = #{duty,jdbcType=VARCHAR}
  530. </if>
  531. <if test="position != null">
  532. and a.position = #{position,jdbcType=VARCHAR}
  533. </if>
  534. <if test="status != null">
  535. and a.status = #{status,jdbcType=VARCHAR}
  536. </if>
  537. <if test="mobile != null">
  538. and a.mobile = #{mobile,jdbcType=VARCHAR}
  539. </if>
  540. <if test="superiorId != null">
  541. and a.superior_id = #{superiorId,jdbcType=VARCHAR}
  542. </if>
  543. group by a.id
  544. order by a.last_login_time,a.number )x left join department y on x.departmentId = y.id
  545. <if test="page_sql!=null">
  546. ${page_sql}
  547. </if>
  548. </select>
  549. <select id="selectAdminCount" parameterType="java.lang.String" resultType="java.lang.Integer">
  550. select count(t.counts)
  551. from(select a.id counts from (select a.id from admin a
  552. left join user_role ur on a.id=ur.uid
  553. left join `role` y on ur.rid=y.id
  554. where a.id <![CDATA[ <> ]]> '1'
  555. <if test="roleName != null">
  556. and y.role_name= #{roleName,jdbcType=VARCHAR}
  557. </if>
  558. <if test="name != null">
  559. and a.name like concat('%',#{name,jdbcType=VARCHAR},'%')
  560. </if>
  561. <if test="departmentId != null">
  562. and a.department_id = #{departmentId,jdbcType=VARCHAR}
  563. </if>
  564. <if test="rid != null">
  565. and ur.rid = #{rid,jdbcType=VARCHAR}
  566. </if>
  567. <if test="duty != null">
  568. and a.duty = #{duty,jdbcType=VARCHAR}
  569. </if>
  570. <if test="position != null">
  571. and a.position = #{position,jdbcType=VARCHAR}
  572. </if>
  573. <if test="status != null">
  574. and a.status = #{status,jdbcType=VARCHAR}
  575. </if>
  576. <if test="mobile != null">
  577. and a.mobile = #{mobile,jdbcType=VARCHAR}
  578. </if>
  579. <if test="superiorId != null">
  580. and a.superior_id = #{superiorId,jdbcType=VARCHAR}
  581. </if>
  582. )a
  583. group by a.id)t
  584. </select>
  585. <insert id="insertn" parameterType="com.goafanti.common.model.Admin">
  586. insert into admin (id, mobile, name,
  587. password, email, create_time,
  588. number, province, position, superior_id, city,department_id,status,user_no,duty,district,head_portrait_url,contact_mobile,type)
  589. values (#{id,jdbcType=VARCHAR}, #{mobile,jdbcType=VARCHAR}, #{name,jdbcType=VARCHAR},
  590. #{password,jdbcType=VARCHAR}, #{email,jdbcType=VARCHAR}, #{createTime,jdbcType=TIMESTAMP},
  591. #{number,jdbcType=INTEGER}, #{province,jdbcType=INTEGER}, #{position,jdbcType=VARCHAR},
  592. #{superiorId,jdbcType=VARCHAR}, #{city,jdbcType=INTEGER},#{departmentId,jdbcType=VARCHAR},
  593. #{status,jdbcType=VARCHAR},#{userNo,jdbcType=VARCHAR},#{duty,jdbcType=VARCHAR},#{district,jdbcType=VARCHAR},#{headPortraitUrl,jdbcType=VARCHAR},#{contactMobile,jdbcType=VARCHAR},
  594. #{type})
  595. </insert>
  596. <select id="selectUserNoBySuperiorId" parameterType="java.lang.String" resultType="java.lang.String">
  597. select
  598. user_no as userNo
  599. from admin
  600. where
  601. id=#{superiorId,jdbcType=VARCHAR}
  602. </select>
  603. <select id="selectCountBySuperiorId" parameterType="java.lang.String" resultType="java.lang.Integer">
  604. select
  605. count(1)
  606. from admin
  607. where
  608. superior_id=#{superiorId,jdbcType=VARCHAR}
  609. </select>
  610. <select id="selectIdByUserNo" parameterType="java.lang.String" resultType="java.lang.String">
  611. select
  612. id
  613. from admin
  614. where
  615. user_no=#{UserNo,jdbcType=VARCHAR}
  616. </select>
  617. <select id="selectAllByid" parameterType="java.lang.String" resultType="com.goafanti.common.model.Admin">
  618. select a.id, a.mobile, a.name, a.`password`, a.email, a.create_time as createTime,
  619. a.province, a.`position`,a.reviewer , a.superior_id as superiorId,
  620. a.department_id as departmentId, a.status,a.user_no as userNo,a.duty,a.district,
  621. a.head_portrait_url as headPortraitUrl, a.contact_mobile as contactMobile,
  622. b.name superior,c.name reviewerName,a.type
  623. from admin a left join admin b on a.superior_id =b.id left join admin c on a.reviewer =c.id
  624. where a.id= #{id,jdbcType=VARCHAR}
  625. </select>
  626. <select id="selectNameByid" parameterType="java.lang.String" resultType="java.lang.String">
  627. select
  628. name
  629. from admin
  630. where
  631. id=#{id,jdbcType=VARCHAR}
  632. </select>
  633. <select id="selectRolesByUid" parameterType="java.lang.String" resultType="java.lang.String">
  634. select
  635. r.role_name as roles
  636. from user_role ur
  637. left join role r on r.id = ur.rid
  638. where
  639. uid=#{id,jdbcType=VARCHAR}
  640. </select>
  641. <select id="selectRolesIdByUid" parameterType="java.lang.String" resultType="java.lang.String">
  642. select
  643. rid as rolesId
  644. from user_role
  645. where
  646. uid=#{id,jdbcType=VARCHAR}
  647. </select>
  648. <select id="selectStatusByMobile" parameterType="java.lang.String" resultType="java.lang.String">
  649. select
  650. status
  651. from admin
  652. where
  653. mobile= #{mobile,jdbcType=VARCHAR}
  654. </select>
  655. <delete id="deleteById" parameterType="java.lang.String">
  656. delete from admin
  657. where id = #{id,jdbcType=VARCHAR}
  658. </delete>
  659. <select id="selectIDNBySuperiorId" parameterType="java.lang.String" resultType="com.goafanti.common.model.Admin">
  660. select id, mobile, name,
  661. password, email, create_time as createTime,
  662. province, position,
  663. superior_id as superiorId,department_id as departmentId,
  664. status,user_no as userNo,duty,district,head_portrait_url as headPortraitUrl
  665. from admin
  666. where
  667. superior_id=#{superiorId,jdbcType=VARCHAR}
  668. </select>
  669. <select id="selectUserNoById" resultType="java.lang.String">
  670. select user_no as userNo
  671. from admin
  672. where
  673. id=#{superiorId,jdbcType=VARCHAR}
  674. </select>
  675. <update id="updateByUserNo" parameterType="com.goafanti.common.model.Admin">
  676. update admin
  677. set user_no = #{userNo,jdbcType=VARCHAR}
  678. where
  679. id=#{id,jdbcType=VARCHAR}
  680. </update>
  681. <select id="selectIdBySuperiorId" parameterType="java.lang.String" resultType="java.lang.String">
  682. select id
  683. from admin
  684. where
  685. superior_id=#{superiorId,jdbcType=VARCHAR}
  686. </select>
  687. <select id="selectSubList" parameterType="java.lang.String" resultType="com.goafanti.admin.bo.AdminListBo">
  688. select
  689. a.id,
  690. a.user_no as userNo,
  691. a.mobile,
  692. a.name,
  693. a.position,
  694. b.name as departmentName
  695. from
  696. admin a left join department b on
  697. a.department_id = b.id
  698. where
  699. a.department_id =(
  700. select
  701. department_id
  702. from
  703. admin
  704. where
  705. id = #{adminId,jdbcType=VARCHAR}
  706. )
  707. and a.id <![CDATA[ <> ]]> #{adminId,jdbcType=VARCHAR}
  708. </select>
  709. <select id="selectAdminByRoleId" parameterType="java.lang.String" resultMap="BaseResultMap">
  710. select a.id,a.name from admin a left join user_role b on a.id = b.uid left join role c on b.rid = c.id where c.id = #{roleId,jdbcType=VARCHAR} limit 1
  711. </select>
  712. <select id="selectDepartmentStaff" parameterType="java.lang.String" resultType="com.goafanti.admin.bo.AdminListBo">
  713. select a.id ,a.name,a.password,a.department_id,b.name
  714. from admin a left join department b
  715. on a.department_id= b.id
  716. where 1=1
  717. <if test="departmentId != null and departmentId !='' ">
  718. and a.department_id = #{departmentId,jdbcType=VARCHAR}
  719. </if>
  720. <if test="name != null">
  721. and a.name like concat('%',#{name,jdbcType=VARCHAR},'%')
  722. </if>
  723. </select>
  724. <select id="selectAdminName" parameterType="java.lang.String" resultMap="BaseResultMap">
  725. select a.id, a.name from admin a left join user_role b on a.id=b.uid
  726. left join `role` c on b.rid=c.id
  727. where c.role_name = #{name,jdbcType=VARCHAR}
  728. </select>
  729. <update id="updateLockIds" parameterType="java.lang.String">
  730. update admin set status = '锁定' where id in (${lockIds})
  731. </update>
  732. <!-- 用户是为正常的 -->
  733. <select id="getCountById" parameterType="java.lang.String" resultType="java.lang.Integer">
  734. select count(a.id) from admin a
  735. inner join user_role ur on a.id=ur.uid
  736. where a.id= #{_parameter,jdbcType=VARCHAR} and ( a.status != '注销' or a.status is null)
  737. </select>
  738. <select id="getAdminRoleList" parameterType="java.lang.String" resultMap="BaseResultMap">
  739. select a.id, a.name from admin a left join user_role b on a.id=b.uid
  740. left join `role` c on b.rid=c.id
  741. where c.role_name = #{name,jdbcType=VARCHAR} and a.status='正常'
  742. </select>
  743. <select id="getDeptNameByAid" parameterType="java.lang.String" resultType="com.goafanti.admin.bo.AdminListBo">
  744. select a.id,a.name, d.name as departmentName,a.department_id departmentId,a.email,a.superior_id superiorId,a.open_id openId,
  745. a.reviewer,d.manager_id depManager
  746. from admin a left join department d on a.department_id = d.id
  747. where a.id = #{_parameter,jdbcType=VARCHAR}
  748. </select>
  749. <insert id="addAdminContacts" parameterType="com.goafanti.admin.bo.AdminContacts">
  750. insert into admin_contacts (id,aid,contacts_id)values
  751. (#{id,jdbcType=VARCHAR},#{aid,jdbcType=VARCHAR},#{contactsId,jdbcType=VARCHAR})
  752. </insert>
  753. <select id="frequentContactsList" parameterType="java.lang.String" resultType="com.goafanti.admin.bo.AdminListBo">
  754. select a.id,b.id as contactId,b.name,b.position,b.contact_mobile as contactMobile,c.name as departmentName,y.role_name as roleName
  755. from admin_contacts a left join admin b
  756. on a.contacts_id=b.id left join department c
  757. on c.id=b.department_id left join user_role x on x.uid=b.id
  758. left join `role` y on x.rid=y.id
  759. where b.status ='正常'
  760. <if test="roleName != null">
  761. and y.role_name= #{roleName,jdbcType=VARCHAR}
  762. </if>
  763. <if test="aid != null">
  764. and a.aid= #{aid,jdbcType=VARCHAR}
  765. </if>
  766. <if test="name != null">
  767. and b.name like CONCAT('%',#{name,jdbcType=VARCHAR},'%')
  768. </if>
  769. <if test="deps != null">
  770. and b.department_id in
  771. <foreach close=")" collection="deps" item="depId" open="(" separator=",">
  772. #{depId}
  773. </foreach>
  774. </if>
  775. <if test="page_sql!=null">
  776. ${page_sql}
  777. </if>
  778. </select>
  779. <select id="frequentContactsCount" parameterType="java.lang.String" resultType="java.lang.Integer">
  780. select count(*)
  781. from admin_contacts a left join admin b
  782. on a.contacts_id=b.id
  783. left join user_role x on x.uid=b.id
  784. left join `role` y on x.rid=y.id
  785. where b.status ='正常'
  786. <if test="roleName != null">
  787. and y.role_name= #{roleName,jdbcType=VARCHAR}
  788. </if>
  789. <if test="aid != null">
  790. and a.aid= #{aid,jdbcType=VARCHAR}
  791. </if>
  792. <if test="name != null">
  793. and b.name like CONCAT('%',#{name,jdbcType=VARCHAR},'%')
  794. </if>
  795. <if test="deps != null">
  796. and b.department_id in
  797. <foreach close=")" collection="deps" item="depId" open="(" separator=",">
  798. #{depId}
  799. </foreach>
  800. </if>
  801. </select>
  802. <delete id="deleteFrequentContacts" parameterType="java.lang.String">
  803. delete from admin_contacts
  804. where id = #{id,jdbcType=VARCHAR}
  805. </delete>
  806. <select id="getaidFrequentContacts" resultType="java.lang.String">
  807. select b.id from admin_contacts a left join admin b on a.contacts_id = b.id
  808. where b.status = '正常' and a.aid= #{id,jdbcType=VARCHAR}
  809. </select>
  810. <select id="selectAdminCustomerList" resultType="com.goafanti.admin.bo.AdminCustomerBo">
  811. select a.id as aid,a.name as aName,d.name as depName,ifnull(b.userCount,0) as userCount,ifnull(c.timeCount,0) as inputCount,
  812. ifnull(d.timeCount,0) as receiveCount,ifnull(g.timeCount,0) as signCount from admin a
  813. left join (select aid,count(aid) as userCount from user where aid is not null
  814. and share_type=0 and source in(1,2,3) and type=1 and new_channel=0
  815. group by aid) b on a.id=b.aid
  816. left join (select aid,count(aid) as timeCount from `user` where aid is not null
  817. and share_type in (0,2) and source =1 and type=1 and new_channel=0
  818. <if test="startTime != null and endTime != null">
  819. and transfer_time between #{startTime,jdbcType=VARCHAR} and #{endTime,jdbcType=VARCHAR}
  820. </if>
  821. group by aid) c on a.id=c.aid
  822. left join (select aid,count(aid) as timeCount from `user` where aid is not null
  823. and share_type in (0,2) and source =2 and type=1 and new_channel=0
  824. <if test="startTime != null and endTime != null">
  825. and transfer_time between #{startTime,jdbcType=VARCHAR} and #{endTime,jdbcType=VARCHAR}
  826. </if>
  827. group by aid) d on a.id=d.aid
  828. left join (select aid,count(aid) as timeCount from `user` where aid is not null
  829. and share_type =2 and type=1 and new_channel=0
  830. <if test="startTime != null and endTime != null">
  831. and transfer_time between #{startTime,jdbcType=VARCHAR} and #{endTime,jdbcType=VARCHAR}
  832. </if>
  833. group by aid) g on a.id=g.aid
  834. left join department d on a.department_id=d.id
  835. left join user_role e on a.id=e.uid
  836. left join `role` f on e.rid=f.id
  837. where f.role_name in ('营销员','营销经理')
  838. and a.status='正常'
  839. <if test="depId != null">
  840. and a.department_id = #{depId,jdbcType=VARCHAR}
  841. </if>
  842. <if test="page_sql!=null">
  843. ${page_sql}
  844. </if>
  845. </select>
  846. <select id="selectAdminCustomerCount" parameterType="java.lang.String" resultType="java.lang.Integer">
  847. select count(*) from admin a
  848. left join department d on a.department_id=d.id
  849. left join user_role e on a.id=e.uid
  850. left join `role` f on e.rid=f.id
  851. where f.role_name in ('营销员','营销经理')
  852. and a.status='正常'
  853. <if test="depId != null">
  854. and a.department_id = #{depId,jdbcType=VARCHAR}
  855. </if>
  856. </select>
  857. <select id="selectAdminCustomerDetailList" resultType="com.goafanti.admin.bo.AdminCustomerDetailBo">
  858. select a.id,a.nickname as name,a.source,c.contacts contacts,c.contact_mobile as contactMobile,c.contacts_dep contactsDep,
  859. c.contacts_position contactsPosition, a.create_time as createTime,b.last_follow_time as followTime,c.location_province locationProvince,
  860. c.location_city locationCity,c.location_area locationArea,c.business_scope businessScope , c.intended_project intendedProject
  861. from user a left join (select uid,last_follow_time from user_mid where aid= #{aid}) b on a.id=b.uid
  862. left join organization_identity c on a.id=c.uid
  863. <if test="type==5 or type==6">
  864. left join (select aid,uid from public_release where clock_in =1
  865. and aid= #{aid,jdbcType=VARCHAR}
  866. <if test="startTime != null and endTime != null">
  867. and clock_in_time between #{startTime,jdbcType=VARCHAR} and #{endTime,jdbcType=VARCHAR}
  868. </if>
  869. )e on a.id=e.uid
  870. </if>
  871. where a.type=1 and a.new_channel=0
  872. <if test="type != 5 and type !=6">
  873. and a.aid= #{aid,jdbcType=VARCHAR}
  874. </if>
  875. <if test="type == 5 or type ==6">
  876. and e.aid= #{aid,jdbcType=VARCHAR}
  877. </if>
  878. <if test="type == 0">
  879. and a.share_type = 0
  880. </if>
  881. <if test="type == 1">
  882. and a.share_type = 3
  883. </if>
  884. <if test="type ==0 or type==3 or type==5 or type==7">
  885. and a.channel=0
  886. </if>
  887. <if test="type == 1 or type==4 or type==6">
  888. and a.channel=1
  889. </if>
  890. <if test="type == 2">
  891. and a.share_type=2
  892. </if>
  893. <if test="type == 3 or type==4">
  894. and a.source=1
  895. and a.share_type = 0
  896. </if>
  897. <if test="type==7 ">
  898. and a.share_type = 0
  899. and a.source=2
  900. </if>
  901. <if test="type!=5 and type!=6">
  902. <if test="startTime != null and endTime != null">
  903. and a.transfer_time between #{startTime,jdbcType=VARCHAR} and #{endTime,jdbcType=VARCHAR}
  904. </if>
  905. </if>
  906. <if test="page_sql!=null">
  907. ${page_sql}
  908. </if>
  909. </select>
  910. <select id="selectAdminCustomerDetailCount" parameterType="java.lang.String" resultType="java.lang.Integer">
  911. select count(*)
  912. from user a
  913. <if test="type==5 or type==6">
  914. left join (select aid,uid from public_release where clock_in =1
  915. and aid= #{aid,jdbcType=VARCHAR}
  916. <if test="startTime != null and endTime != null">
  917. and clock_in_time between #{startTime,jdbcType=VARCHAR} and #{endTime,jdbcType=VARCHAR}
  918. </if>
  919. )e on a.id=e.uid
  920. </if>
  921. where a.type=1 and a.new_channel=0
  922. <if test="type != 5 and type !=6">
  923. and a.aid= #{aid,jdbcType=VARCHAR}
  924. </if>
  925. <if test="type == 5 or type ==6">
  926. and e.aid= #{aid,jdbcType=VARCHAR}
  927. </if>
  928. <if test="type == 0">
  929. and a.share_type = 0
  930. </if>
  931. <if test="type == 1">
  932. and a.share_type = 3
  933. </if>
  934. <if test="type ==0 or type==3 or type==5 or type==7">
  935. and a.channel=0
  936. </if>
  937. <if test="type == 1 or type==4 or type==6">
  938. and a.channel=1
  939. </if>
  940. <if test="type == 2">
  941. and a.share_type=2
  942. </if>
  943. <if test="type == 3 or type==4">
  944. and a.source=1
  945. and a.share_type = 0
  946. </if>
  947. <if test="type==7 ">
  948. and a.share_type = 0
  949. and a.source=2
  950. </if>
  951. <if test="type!=5 and type!=6">
  952. <if test="startTime != null and endTime != null">
  953. and a.transfer_time between #{startTime,jdbcType=VARCHAR} and #{endTime,jdbcType=VARCHAR}
  954. </if>
  955. </if>
  956. </select>
  957. <select id="listNameByDepAndName" resultType="java.lang.String">
  958. select a.id from admin a left join user_role b on a.id =b.uid
  959. left join `role` c on b.rid=c.id
  960. where department_id= #{depId}
  961. and c.role_name= #{roleName}
  962. </select>
  963. <select id="selectBySuperId" resultType="java.lang.String">
  964. select id from admin where superior_id= #{aid}
  965. </select>
  966. <select id="selectGetSuper" parameterType="java.lang.String" resultMap="BaseResultMap">
  967. select
  968. <include refid="Base_Column_List" />
  969. from admin
  970. where superior_id= #{aid}
  971. </select>
  972. <select id="selectFinanceAdminByOrderDep" resultType="com.goafanti.common.model.Admin">
  973. select a.finance_id id,b.name from department a left join admin b on a.finance_id=b.id
  974. where a.id= #{orderDep}
  975. </select>
  976. <select id="getPermission" resultType="java.lang.String">
  977. select c.role_type from admin a left join user_role b on a.id=b.uid left join `role` c on b.rid=c.id
  978. where a.id= #{transferId}
  979. </select>
  980. <select id="selectDepIdWithSpuerId" resultType="java.lang.String">
  981. select b.id from admin a right join department b on a.id=b.finance_id
  982. where a.superior_id= #{superId}
  983. </select>
  984. <select id="getAdminRoleListByAid" resultType="java.lang.String">
  985. select c.role_type from admin a left join user_role b on a.id=b.uid
  986. left join role c on b.rid =c.id
  987. where a.id= #{id}
  988. </select>
  989. <select id="selectByOpeid" parameterType="java.lang.String" resultMap="BaseResultMap">
  990. select
  991. <include refid="Base_Column_List" />
  992. from admin
  993. where open_id= #{openid}
  994. </select>
  995. <select id="getFinanceDep" resultType="java.lang.String">
  996. select id from department where finance_id = #{aid}
  997. </select>
  998. <select id="getLowerFinanceDep" resultType="java.lang.String">
  999. select b.id from admin a left join department b on a.id=b.finance_id
  1000. where a.superior_id = #{aid}
  1001. </select>
  1002. </mapper>