AdminMapper.xml 37 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037
  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 status='正常' and name like concat('%',#{name},'%')
  487. </select>
  488. <!--*************************************************************************-->
  489. <select id="selectAdminListByPage" parameterType="java.lang.String" resultType="com.goafanti.admin.bo.AdminListBo">
  490. select x.*,y.name as departmentName from(select
  491. <!-- a.user_no as userNo, -->
  492. a.mobile, a.name,
  493. a.position, a.email, a.id,
  494. a.province,
  495. a.city,
  496. a.create_time as createTime,
  497. aa.name as superior,
  498. a.superior_id as superiorId,
  499. a.department_id as departmentId,
  500. a.last_login_time as lastLoginTime,
  501. a.contact_mobile as contactMobile,
  502. a.duty,a.status
  503. from admin a
  504. left join admin_location al on a.id = al.admin_id
  505. left join admin aa on aa.id = a.superior_id
  506. left join user_role ur on a.id=ur.uid
  507. left join `role` y on ur.rid=y.id
  508. where a.id <![CDATA[ <> ]]> '1'
  509. <if test="roleName != null">
  510. and y.role_name= #{roleName,jdbcType=VARCHAR}
  511. </if>
  512. <if test="name != null">
  513. and a.name like concat('%',#{name,jdbcType=VARCHAR},'%')
  514. </if>
  515. <if test="departmentId != null">
  516. and a.department_id = #{departmentId,jdbcType=VARCHAR}
  517. </if>
  518. <if test="rid != null">
  519. and ur.rid = #{rid,jdbcType=VARCHAR}
  520. </if>
  521. <if test="duty != null">
  522. and a.duty = #{duty,jdbcType=VARCHAR}
  523. </if>
  524. <if test="position != null">
  525. and a.position = #{position,jdbcType=VARCHAR}
  526. </if>
  527. <if test="status != null">
  528. and a.status = #{status,jdbcType=VARCHAR}
  529. </if>
  530. <if test="mobile != null">
  531. and a.mobile = #{mobile,jdbcType=VARCHAR}
  532. </if>
  533. <if test="superiorId != null">
  534. and a.superior_id = #{superiorId,jdbcType=VARCHAR}
  535. </if>
  536. group by a.id
  537. order by a.last_login_time,a.number )x left join department y on x.departmentId = y.id
  538. <if test="page_sql!=null">
  539. ${page_sql}
  540. </if>
  541. </select>
  542. <select id="selectAdminCount" parameterType="java.lang.String" resultType="java.lang.Integer">
  543. select count(t.counts)
  544. from(select a.id counts from (select a.id from admin a
  545. left join user_role ur on a.id=ur.uid
  546. left join `role` y on ur.rid=y.id
  547. where a.id <![CDATA[ <> ]]> '1'
  548. <if test="roleName != null">
  549. and y.role_name= #{roleName,jdbcType=VARCHAR}
  550. </if>
  551. <if test="name != null">
  552. and a.name like concat('%',#{name,jdbcType=VARCHAR},'%')
  553. </if>
  554. <if test="departmentId != null">
  555. and a.department_id = #{departmentId,jdbcType=VARCHAR}
  556. </if>
  557. <if test="rid != null">
  558. and ur.rid = #{rid,jdbcType=VARCHAR}
  559. </if>
  560. <if test="duty != null">
  561. and a.duty = #{duty,jdbcType=VARCHAR}
  562. </if>
  563. <if test="position != null">
  564. and a.position = #{position,jdbcType=VARCHAR}
  565. </if>
  566. <if test="status != null">
  567. and a.status = #{status,jdbcType=VARCHAR}
  568. </if>
  569. <if test="mobile != null">
  570. and a.mobile = #{mobile,jdbcType=VARCHAR}
  571. </if>
  572. <if test="superiorId != null">
  573. and a.superior_id = #{superiorId,jdbcType=VARCHAR}
  574. </if>
  575. )a
  576. group by a.id)t
  577. </select>
  578. <insert id="insertn" parameterType="com.goafanti.common.model.Admin">
  579. insert into admin (id, mobile, name,
  580. password, email, create_time,
  581. number, province, position, superior_id, city,department_id,status,user_no,duty,district,head_portrait_url,contact_mobile,type)
  582. values (#{id,jdbcType=VARCHAR}, #{mobile,jdbcType=VARCHAR}, #{name,jdbcType=VARCHAR},
  583. #{password,jdbcType=VARCHAR}, #{email,jdbcType=VARCHAR}, #{createTime,jdbcType=TIMESTAMP},
  584. #{number,jdbcType=INTEGER}, #{province,jdbcType=INTEGER}, #{position,jdbcType=VARCHAR},
  585. #{superiorId,jdbcType=VARCHAR}, #{city,jdbcType=INTEGER},#{departmentId,jdbcType=VARCHAR},
  586. #{status,jdbcType=VARCHAR},#{userNo,jdbcType=VARCHAR},#{duty,jdbcType=VARCHAR},#{district,jdbcType=VARCHAR},#{headPortraitUrl,jdbcType=VARCHAR},#{contactMobile,jdbcType=VARCHAR},
  587. #{type})
  588. </insert>
  589. <select id="selectUserNoBySuperiorId" parameterType="java.lang.String" resultType="java.lang.String">
  590. select
  591. user_no as userNo
  592. from admin
  593. where
  594. id=#{superiorId,jdbcType=VARCHAR}
  595. </select>
  596. <select id="selectCountBySuperiorId" parameterType="java.lang.String" resultType="java.lang.Integer">
  597. select
  598. count(1)
  599. from admin
  600. where
  601. superior_id=#{superiorId,jdbcType=VARCHAR}
  602. </select>
  603. <select id="selectIdByUserNo" parameterType="java.lang.String" resultType="java.lang.String">
  604. select
  605. id
  606. from admin
  607. where
  608. user_no=#{UserNo,jdbcType=VARCHAR}
  609. </select>
  610. <select id="selectAllByid" parameterType="java.lang.String" resultType="com.goafanti.common.model.Admin">
  611. select a.id, a.mobile, a.name, a.`password`, a.email, a.create_time as createTime,
  612. a.province, a.`position`,a.reviewer , a.superior_id as superiorId,
  613. a.department_id as departmentId, a.status,a.user_no as userNo,a.duty,a.district,
  614. a.head_portrait_url as headPortraitUrl, a.contact_mobile as contactMobile,
  615. b.name superior,c.name reviewerName
  616. from admin a left join admin b on a.superior_id =b.id left join admin c on a.reviewer =c.id
  617. where a.id= #{id,jdbcType=VARCHAR}
  618. </select>
  619. <select id="selectNameByid" parameterType="java.lang.String" resultType="java.lang.String">
  620. select
  621. name
  622. from admin
  623. where
  624. id=#{id,jdbcType=VARCHAR}
  625. </select>
  626. <select id="selectRolesByUid" parameterType="java.lang.String" resultType="java.lang.String">
  627. select
  628. r.role_name as roles
  629. from user_role ur
  630. left join role r on r.id = ur.rid
  631. where
  632. uid=#{id,jdbcType=VARCHAR}
  633. </select>
  634. <select id="selectRolesIdByUid" parameterType="java.lang.String" resultType="java.lang.String">
  635. select
  636. rid as rolesId
  637. from user_role
  638. where
  639. uid=#{id,jdbcType=VARCHAR}
  640. </select>
  641. <select id="selectStatusByMobile" parameterType="java.lang.String" resultType="java.lang.String">
  642. select
  643. status
  644. from admin
  645. where
  646. mobile= #{mobile,jdbcType=VARCHAR}
  647. </select>
  648. <delete id="deleteById" parameterType="java.lang.String">
  649. delete from admin
  650. where id = #{id,jdbcType=VARCHAR}
  651. </delete>
  652. <select id="selectIDNBySuperiorId" parameterType="java.lang.String" resultType="com.goafanti.common.model.Admin">
  653. select id, mobile, name,
  654. password, email, create_time as createTime,
  655. province, position,
  656. superior_id as superiorId,department_id as departmentId,
  657. status,user_no as userNo,duty,district,head_portrait_url as headPortraitUrl
  658. from admin
  659. where
  660. superior_id=#{superiorId,jdbcType=VARCHAR}
  661. </select>
  662. <select id="selectUserNoById" resultType="java.lang.String">
  663. select user_no as userNo
  664. from admin
  665. where
  666. id=#{superiorId,jdbcType=VARCHAR}
  667. </select>
  668. <update id="updateByUserNo" parameterType="com.goafanti.common.model.Admin">
  669. update admin
  670. set user_no = #{userNo,jdbcType=VARCHAR}
  671. where
  672. id=#{id,jdbcType=VARCHAR}
  673. </update>
  674. <select id="selectIdBySuperiorId" parameterType="java.lang.String" resultType="java.lang.String">
  675. select id
  676. from admin
  677. where
  678. superior_id=#{superiorId,jdbcType=VARCHAR}
  679. </select>
  680. <select id="selectSubList" parameterType="java.lang.String" resultType="com.goafanti.admin.bo.AdminListBo">
  681. select
  682. a.id,
  683. a.user_no as userNo,
  684. a.mobile,
  685. a.name,
  686. a.position,
  687. b.name as departmentName
  688. from
  689. admin a left join department b on
  690. a.department_id = b.id
  691. where
  692. a.department_id =(
  693. select
  694. department_id
  695. from
  696. admin
  697. where
  698. id = #{adminId,jdbcType=VARCHAR}
  699. )
  700. and a.id <![CDATA[ <> ]]> #{adminId,jdbcType=VARCHAR}
  701. </select>
  702. <select id="selectAdminByRoleId" parameterType="java.lang.String" resultMap="BaseResultMap">
  703. 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
  704. </select>
  705. <select id="selectDepartmentStaff" parameterType="java.lang.String" resultType="com.goafanti.admin.bo.AdminListBo">
  706. select a.id ,a.name,a.password,a.department_id,b.name
  707. from admin a left join department b
  708. on a.department_id= b.id
  709. where 1=1
  710. <if test="departmentId != null and departmentId !='' ">
  711. and a.department_id = #{departmentId,jdbcType=VARCHAR}
  712. </if>
  713. <if test="name != null">
  714. and a.name like concat('%',#{name,jdbcType=VARCHAR},'%')
  715. </if>
  716. </select>
  717. <select id="selectAdminName" parameterType="java.lang.String" resultMap="BaseResultMap">
  718. select a.id, a.name from admin a left join user_role b on a.id=b.uid
  719. left join `role` c on b.rid=c.id
  720. where c.role_name = #{name,jdbcType=VARCHAR}
  721. </select>
  722. <update id="updateLockIds" parameterType="java.lang.String">
  723. update admin set status = '锁定' where id in (${lockIds})
  724. </update>
  725. <!-- 用户是为正常的 -->
  726. <select id="getCountById" parameterType="java.lang.String" resultType="java.lang.Integer">
  727. select count(a.id) from admin a
  728. inner join user_role ur on a.id=ur.uid
  729. where a.id= #{_parameter,jdbcType=VARCHAR} and ( a.status != '注销' or a.status is null)
  730. </select>
  731. <select id="getAdminRoleList" parameterType="java.lang.String" resultMap="BaseResultMap">
  732. select a.id, a.name from admin a left join user_role b on a.id=b.uid
  733. left join `role` c on b.rid=c.id
  734. where c.role_name = #{name,jdbcType=VARCHAR} and a.status='正常'
  735. </select>
  736. <select id="getDeptNameByAid" parameterType="java.lang.String" resultType="com.goafanti.admin.bo.AdminListBo">
  737. select a.id,a.name, d.name as departmentName,a.department_id departmentId,a.email,a.superior_id superiorId,a.open_id openId,
  738. a.reviewer,d.manager_id depManager
  739. from admin a left join department d on a.department_id = d.id
  740. where a.id = #{_parameter,jdbcType=VARCHAR}
  741. </select>
  742. <insert id="addAdminContacts" parameterType="com.goafanti.admin.bo.AdminContacts">
  743. insert into admin_contacts (id,aid,contacts_id)values
  744. (#{id,jdbcType=VARCHAR},#{aid,jdbcType=VARCHAR},#{contactsId,jdbcType=VARCHAR})
  745. </insert>
  746. <select id="frequentContactsList" parameterType="java.lang.String" resultType="com.goafanti.admin.bo.AdminListBo">
  747. 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
  748. from admin_contacts a left join admin b
  749. on a.contacts_id=b.id left join department c
  750. on c.id=b.department_id left join user_role x on x.uid=b.id
  751. left join `role` y on x.rid=y.id
  752. where b.status ='正常'
  753. <if test="roleName != null">
  754. and y.role_name= #{roleName,jdbcType=VARCHAR}
  755. </if>
  756. <if test="aid != null">
  757. and a.aid= #{aid,jdbcType=VARCHAR}
  758. </if>
  759. <if test="name != null">
  760. and b.name like CONCAT('%',#{name,jdbcType=VARCHAR},'%')
  761. </if>
  762. <if test="depId != null">
  763. and b.department_id= #{depId,jdbcType=VARCHAR}
  764. </if>
  765. <if test="page_sql!=null">
  766. ${page_sql}
  767. </if>
  768. </select>
  769. <select id="frequentContactsCount" parameterType="java.lang.String" resultType="java.lang.Integer">
  770. select count(*)
  771. from admin_contacts a left join admin b
  772. on a.contacts_id=b.id
  773. left join user_role x on x.uid=b.id
  774. left join `role` y on x.rid=y.id
  775. where b.status ='正常'
  776. <if test="roleName != null">
  777. and y.role_name= #{roleName,jdbcType=VARCHAR}
  778. </if>
  779. <if test="aid != null">
  780. and a.aid= #{aid,jdbcType=VARCHAR}
  781. </if>
  782. <if test="name != null">
  783. and b.name like CONCAT('%',#{name,jdbcType=VARCHAR},'%')
  784. </if>
  785. <if test="depId != null">
  786. and b.department_id= #{depId,jdbcType=VARCHAR}
  787. </if>
  788. </select>
  789. <delete id="deleteFrequentContacts" parameterType="java.lang.String">
  790. delete from admin_contacts
  791. where id = #{id,jdbcType=VARCHAR}
  792. </delete>
  793. <select id="getaidFrequentContacts" resultType="java.lang.String">
  794. select b.id from admin_contacts a left join admin b on a.contacts_id = b.id
  795. where b.status = '正常' and a.aid= #{id,jdbcType=VARCHAR}
  796. </select>
  797. <select id="selectAdminCustomerList" resultType="com.goafanti.admin.bo.AdminCustomerBo">
  798. 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,
  799. ifnull(d.timeCount,0) as receiveCount,ifnull(g.timeCount,0) as signCount from admin a
  800. left join (select aid,count(aid) as userCount from user where aid is not null
  801. and share_type=0 and source !=0 and type=1
  802. group by aid) b on a.id=b.aid
  803. left join (select aid,count(aid) as timeCount from `user` where aid is not null
  804. and share_type in (0,2) and source =1 and type=1
  805. <if test="startTime != null and endTime != null">
  806. and transfer_time between #{startTime,jdbcType=VARCHAR} and #{endTime,jdbcType=VARCHAR}
  807. </if>
  808. group by aid) c on a.id=c.aid
  809. left join (select aid,count(aid) as timeCount from `user` where aid is not null
  810. and share_type in (0,2) and source =2 and type=1
  811. <if test="startTime != null and endTime != null">
  812. and transfer_time between #{startTime,jdbcType=VARCHAR} and #{endTime,jdbcType=VARCHAR}
  813. </if>
  814. group by aid) d on a.id=d.aid
  815. left join (select aid,count(aid) as timeCount from `user` where aid is not null
  816. and share_type =2 and type=1
  817. <if test="startTime != null and endTime != null">
  818. and transfer_time between #{startTime,jdbcType=VARCHAR} and #{endTime,jdbcType=VARCHAR}
  819. </if>
  820. group by aid) g on a.id=g.aid
  821. left join department d on a.department_id=d.id
  822. left join user_role e on a.id=e.uid
  823. left join `role` f on e.rid=f.id
  824. where f.role_name in ('营销员','营销经理')
  825. and a.status='正常'
  826. <if test="depId != null">
  827. and a.department_id = #{depId,jdbcType=VARCHAR}
  828. </if>
  829. <if test="page_sql!=null">
  830. ${page_sql}
  831. </if>
  832. </select>
  833. <select id="selectAdminCustomerCount" parameterType="java.lang.String" resultType="java.lang.Integer">
  834. select count(*) from admin a
  835. left join department d on a.department_id=d.id
  836. left join user_role e on a.id=e.uid
  837. left join `role` f on e.rid=f.id
  838. where f.role_name in ('营销员','营销经理')
  839. and a.status='正常'
  840. <if test="depId != null">
  841. and a.department_id = #{depId,jdbcType=VARCHAR}
  842. </if>
  843. </select>
  844. <select id="selectAdminCustomerDetailList" resultType="com.goafanti.admin.bo.AdminCustomerDetailBo">
  845. select a.id,a.nickname as name,a.source,c.contacts contacts,c.contact_mobile as contactMobile,c.contacts_dep contactsDep,
  846. c.contacts_position contactsPosition, a.create_time as createTime,b.last_follow_time as followTime,c.location_province locationProvince,
  847. c.location_city locationCity,c.location_area locationArea,c.business_scope businessScope , c.intended_project intendedProject
  848. from user a left join (select uid,last_follow_time from user_mid where aid= #{aid}) b on a.id=b.uid
  849. left join organization_identity c on a.id=c.uid
  850. <if test="type==5 or type==6">
  851. left join (select aid,uid from public_release where clock_in =1
  852. and aid= #{aid,jdbcType=VARCHAR}
  853. <if test="startTime != null and endTime != null">
  854. and clock_in_time between #{startTime,jdbcType=VARCHAR} and #{endTime,jdbcType=VARCHAR}
  855. </if>
  856. )e on a.id=e.uid
  857. </if>
  858. where a.type=1
  859. <if test="type != 5 and type !=6">
  860. and a.aid= #{aid,jdbcType=VARCHAR}
  861. </if>
  862. <if test="type == 5 or type ==6">
  863. and e.aid= #{aid,jdbcType=VARCHAR}
  864. </if>
  865. <if test="type == 0">
  866. and a.share_type = 0
  867. </if>
  868. <if test="type == 1">
  869. and a.share_type = 3
  870. </if>
  871. <if test="type ==0 or type==3 or type==5 or type==7">
  872. and a.channel=0
  873. </if>
  874. <if test="type == 1 or type==4 or type==6">
  875. and a.channel=1
  876. </if>
  877. <if test="type == 2">
  878. and a.share_type=2
  879. </if>
  880. <if test="type == 3 or type==4">
  881. and a.source=1
  882. and a.share_type = 0
  883. </if>
  884. <if test="type==7 ">
  885. and a.share_type = 0
  886. and a.source=2
  887. </if>
  888. <if test="type!=5 and type!=6">
  889. <if test="startTime != null and endTime != null">
  890. and a.transfer_time between #{startTime,jdbcType=VARCHAR} and #{endTime,jdbcType=VARCHAR}
  891. </if>
  892. </if>
  893. <if test="page_sql!=null">
  894. ${page_sql}
  895. </if>
  896. </select>
  897. <select id="selectAdminCustomerDetailCount" parameterType="java.lang.String" resultType="java.lang.Integer">
  898. select count(*)
  899. from user a
  900. <if test="type==5 or type==6">
  901. left join (select aid,uid from public_release where clock_in =1
  902. and aid= #{aid,jdbcType=VARCHAR}
  903. <if test="startTime != null and endTime != null">
  904. and clock_in_time between #{startTime,jdbcType=VARCHAR} and #{endTime,jdbcType=VARCHAR}
  905. </if>
  906. )e on a.id=e.uid
  907. </if>
  908. where a.type=1
  909. <if test="type != 5 and type !=6">
  910. and a.aid= #{aid,jdbcType=VARCHAR}
  911. </if>
  912. <if test="type == 5 or type ==6">
  913. and e.aid= #{aid,jdbcType=VARCHAR}
  914. </if>
  915. <if test="type == 0">
  916. and a.share_type = 0
  917. </if>
  918. <if test="type == 1">
  919. and a.share_type = 3
  920. </if>
  921. <if test="type ==0 or type==3 or type==5 or type==7">
  922. and a.channel=0
  923. </if>
  924. <if test="type == 1 or type==4 or type==6">
  925. and a.channel=1
  926. </if>
  927. <if test="type == 2">
  928. and a.share_type=2
  929. </if>
  930. <if test="type == 3 or type==4">
  931. and a.source=1
  932. and a.share_type = 0
  933. </if>
  934. <if test="type==7 ">
  935. and a.share_type = 0
  936. and a.source=2
  937. </if>
  938. <if test="type!=5 and type!=6">
  939. <if test="startTime != null and endTime != null">
  940. and a.transfer_time between #{startTime,jdbcType=VARCHAR} and #{endTime,jdbcType=VARCHAR}
  941. </if>
  942. </if>
  943. </select>
  944. <select id="listNameByDepAndName" resultType="java.lang.String">
  945. select a.id from admin a left join user_role b on a.id =b.uid
  946. left join `role` c on b.rid=c.id
  947. where department_id= #{depId}
  948. and c.role_name= #{roleName}
  949. </select>
  950. <select id="selectBySuperId" resultType="java.lang.String">
  951. select id from admin where superior_id= #{aid}
  952. </select>
  953. <select id="selectGetSuper" parameterType="java.lang.String" resultMap="BaseResultMap">
  954. select
  955. <include refid="Base_Column_List" />
  956. from admin
  957. where superior_id= #{aid}
  958. </select>
  959. <select id="selectFinanceAdminByOrderDep" resultType="com.goafanti.common.model.Admin">
  960. select a.finance_id id,b.name from department a left join admin b on a.finance_id=b.id
  961. where a.id= #{orderDep}
  962. </select>
  963. <select id="getPermission" resultType="java.lang.String">
  964. 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
  965. where a.id= #{transferId}
  966. </select>
  967. <select id="selectDepIdWithSpuerId" resultType="java.lang.String">
  968. select b.id from admin a right join department b on a.id=b.finance_id
  969. where a.superior_id= #{superId}
  970. </select>
  971. <select id="getAdminRoleListByAid" resultType="java.lang.String">
  972. select c.role_type from admin a left join user_role b on a.id=b.uid
  973. left join role c on b.rid =c.id
  974. where a.id= #{id}
  975. </select>
  976. <select id="selectByOpeid" parameterType="java.lang.String" resultMap="BaseResultMap">
  977. select
  978. <include refid="Base_Column_List" />
  979. from admin
  980. where open_id= #{openid}
  981. </select>
  982. <select id="getFinanceDep" resultType="java.lang.String">
  983. select id from department where finance_id = #{aid}
  984. </select>
  985. <select id="getLowerFinanceDep" resultType="java.lang.String">
  986. select b.id from admin a left join department b on a.id=b.finance_id
  987. where a.superior_id = #{aid}
  988. </select>
  989. </mapper>