AdminMapper.xml 37 KB

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