AdminMapper.xml 18 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527
  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" property="id" jdbcType="VARCHAR" />
  6. <result column="mobile" property="mobile" jdbcType="VARCHAR" />
  7. <result column="name" property="name" jdbcType="VARCHAR" />
  8. <result column="password" property="password" jdbcType="VARCHAR" />
  9. <result column="email" property="email" jdbcType="VARCHAR" />
  10. <result column="create_time" property="createTime" jdbcType="TIMESTAMP" />
  11. <result column="number" property="number" jdbcType="INTEGER" />
  12. <result column="province" property="province" jdbcType="INTEGER" />
  13. <result column="position" property="position" jdbcType="VARCHAR" />
  14. <result column="superior_id" property="superiorId" jdbcType="VARCHAR" />
  15. <result column="city" property="city" jdbcType="INTEGER" />
  16. <result column="department_id" property="departmentId" jdbcType="VARCHAR"/>
  17. </resultMap>
  18. <sql id="Base_Column_List" >
  19. id, mobile, name, password, email, create_time, number, province, position, superior_id,
  20. city,department_id
  21. </sql>
  22. <select id="selectByPrimaryKey" resultMap="BaseResultMap" parameterType="java.lang.String" >
  23. select
  24. <include refid="Base_Column_List" />
  25. from admin
  26. where id = #{id,jdbcType=VARCHAR}
  27. </select>
  28. <delete id="deleteByPrimaryKey" parameterType="java.lang.String" >
  29. delete from admin
  30. where id = #{id,jdbcType=VARCHAR}
  31. </delete>
  32. <insert id="insert" parameterType="com.goafanti.common.model.Admin" >
  33. insert into admin (id, mobile, name,
  34. password, email, create_time,
  35. number, province, position, superior_id, city,department_id)
  36. values (#{id,jdbcType=VARCHAR}, #{mobile,jdbcType=VARCHAR}, #{name,jdbcType=VARCHAR},
  37. #{password,jdbcType=VARCHAR}, #{email,jdbcType=VARCHAR}, #{createTime,jdbcType=TIMESTAMP},
  38. #{number,jdbcType=INTEGER}, #{province,jdbcType=INTEGER}, #{position,jdbcType=VARCHAR},
  39. #{superiorId,jdbcType=VARCHAR}, #{city,jdbcType=INTEGER},#{departmentId,jdbcType=VARCHAR}
  40. )
  41. </insert>
  42. <insert id="insertSelective" parameterType="com.goafanti.common.model.Admin" >
  43. insert into admin
  44. <trim prefix="(" suffix=")" suffixOverrides="," >
  45. <if test="id != null" >
  46. id,
  47. </if>
  48. <if test="mobile != null" >
  49. mobile,
  50. </if>
  51. <if test="name != null" >
  52. name,
  53. </if>
  54. <if test="password != null" >
  55. password,
  56. </if>
  57. <if test="email != null" >
  58. email,
  59. </if>
  60. <if test="createTime != null" >
  61. create_time,
  62. </if>
  63. <if test="number != null" >
  64. number,
  65. </if>
  66. <if test="province != null" >
  67. province,
  68. </if>
  69. <if test="position != null" >
  70. position,
  71. </if>
  72. <if test="superiorId != null" >
  73. superior_id,
  74. </if>
  75. <if test="city != null" >
  76. city,
  77. </if>
  78. <if test="departmentId != null">
  79. department_id,
  80. </if>
  81. </trim>
  82. <trim prefix="values (" suffix=")" suffixOverrides="," >
  83. <if test="id != null" >
  84. #{id,jdbcType=VARCHAR},
  85. </if>
  86. <if test="mobile != null" >
  87. #{mobile,jdbcType=VARCHAR},
  88. </if>
  89. <if test="name != null" >
  90. #{name,jdbcType=VARCHAR},
  91. </if>
  92. <if test="password != null" >
  93. #{password,jdbcType=VARCHAR},
  94. </if>
  95. <if test="email != null" >
  96. #{email,jdbcType=VARCHAR},
  97. </if>
  98. <if test="createTime != null" >
  99. #{createTime,jdbcType=TIMESTAMP},
  100. </if>
  101. <if test="number != null" >
  102. #{number,jdbcType=INTEGER},
  103. </if>
  104. <if test="province != null" >
  105. #{province,jdbcType=INTEGER},
  106. </if>
  107. <if test="position != null" >
  108. #{position,jdbcType=VARCHAR},
  109. </if>
  110. <if test="superiorId != null" >
  111. #{superiorId,jdbcType=VARCHAR},
  112. </if>
  113. <if test="city != null" >
  114. #{city,jdbcType=INTEGER},
  115. </if>
  116. <if test="departmentId != null">
  117. #{departmentId,jdbcType=VARCHAR},
  118. </if>
  119. </trim>
  120. </insert>
  121. <update id="updateByPrimaryKeySelective" parameterType="com.goafanti.common.model.Admin" >
  122. update admin
  123. <set >
  124. <if test="mobile != null" >
  125. mobile = #{mobile,jdbcType=VARCHAR},
  126. </if>
  127. <if test="name != null" >
  128. name = #{name,jdbcType=VARCHAR},
  129. </if>
  130. <if test="password != null" >
  131. password = #{password,jdbcType=VARCHAR},
  132. </if>
  133. <if test="email != null" >
  134. email = #{email,jdbcType=VARCHAR},
  135. </if>
  136. <if test="createTime != null" >
  137. create_time = #{createTime,jdbcType=TIMESTAMP},
  138. </if>
  139. <if test="number != null" >
  140. number = #{number,jdbcType=INTEGER},
  141. </if>
  142. <if test="province != null" >
  143. province = #{province,jdbcType=INTEGER},
  144. </if>
  145. <if test="position != null" >
  146. position = #{position,jdbcType=VARCHAR},
  147. </if>
  148. <if test="superiorId != null" >
  149. superior_id = #{superiorId,jdbcType=VARCHAR},
  150. </if>
  151. <if test="city != null" >
  152. city = #{city,jdbcType=INTEGER},
  153. </if>
  154. <if test="departmentId != null">
  155. department_id = #{departmentId,jdbcType=VARCHAR},
  156. </if>
  157. <if test="status != null">
  158. status = #{status,jdbcType=VARCHAR},
  159. </if>
  160. <if test="userNo != null">
  161. user_no = #{userNo,jdbcType=VARCHAR},
  162. </if>
  163. <if test="duty != null">
  164. duty = #{duty,jdbcType=VARCHAR},
  165. </if>
  166. <if test="district != null">
  167. district = #{district,jdbcType=VARCHAR},
  168. </if>
  169. <if test="headPortraitUrl != null">
  170. head_portrait_url = #{headPortraitUrl,jdbcType=VARCHAR},
  171. </if>
  172. </set>
  173. where id = #{id,jdbcType=VARCHAR}
  174. </update>
  175. <update id="updateByPrimaryKey" parameterType="com.goafanti.common.model.Admin" >
  176. update admin
  177. set mobile = #{mobile,jdbcType=VARCHAR},
  178. name = #{name,jdbcType=VARCHAR},
  179. password = #{password,jdbcType=VARCHAR},
  180. email = #{email,jdbcType=VARCHAR},
  181. create_time = #{createTime,jdbcType=TIMESTAMP},
  182. number = #{number,jdbcType=INTEGER},
  183. province = #{province,jdbcType=INTEGER},
  184. position = #{position,jdbcType=VARCHAR},
  185. superior_id = #{superiorId,jdbcType=VARCHAR},
  186. city = #{city,jdbcType=INTEGER},
  187. department_id = #{departmentId,jdbcType=VARCHAR}
  188. where id = #{id,jdbcType=VARCHAR}
  189. </update>
  190. <select id="selectAllAdmin" resultMap="BaseResultMap">
  191. select
  192. <include refid="Base_Column_List" />
  193. from admin
  194. </select>
  195. <select id="selectByMobile" parameterType="java.lang.String" resultMap="BaseResultMap">
  196. select
  197. <include refid="Base_Column_List" />
  198. from admin
  199. where mobile = #{mobile,jdbcType=VARCHAR}
  200. </select>
  201. <select id="selectRolesByPrimaryKey" parameterType="java.lang.String">
  202. select r.name, r.id, r.type
  203. from role r
  204. left join user_role ur on ur.rid=r.id
  205. where ur.uid = #{uid,jdbcType=VARCHAR}
  206. </select>
  207. <select id="selectCognizanceConsultant" resultMap="BaseResultMap" >
  208. select
  209. <include refid="Base_Column_List" />
  210. from admin
  211. where id <![CDATA[ <> ]]> '1'
  212. </select>
  213. <select id="selectCognizancePrincipal" resultMap="BaseResultMap" >
  214. select a.id, a.name, a.position from admin a
  215. INNER JOIN user_role ur on a.id = ur.uid
  216. where ur.rid not in('1','2','3','4','5','6')
  217. group by a.id
  218. </select>
  219. <select id="selectPatentAuthor" resultMap="BaseResultMap" >
  220. select a.id, a.name, a.position from admin a
  221. INNER JOIN user_role ur on a.id = ur.uid
  222. where ur.rid not in('1','2','3','4','5','6')
  223. group by a.id
  224. </select>
  225. <select id="selectPatentPrincipal" resultMap="BaseResultMap" >
  226. select a.id, a.name, a.position from admin a
  227. INNER JOIN user_role ur on a.id = ur.uid
  228. where ur.rid not in('1','2','3','4','5','6')
  229. group by a.id
  230. </select>
  231. <select id="selectCopyrightConsultant" resultMap="BaseResultMap" >
  232. select
  233. <include refid="Base_Column_List" />
  234. from admin
  235. where id <![CDATA[ <> ]]> '1'
  236. </select>
  237. <select id="selectCopyrightPrincipal" resultMap="BaseResultMap" >
  238. select a.id, a.name, a.position from admin a
  239. INNER JOIN user_role ur on a.id = ur.uid
  240. where ur.rid not in('1','2','3','4','5','6')
  241. group by a.id
  242. </select>
  243. <select id="selectTechprojectConsultant" resultMap="BaseResultMap" >
  244. select
  245. <include refid="Base_Column_List" />
  246. from admin
  247. where id <![CDATA[ <> ]]> '1'
  248. </select>
  249. <select id="selectTechprojectPrincipal" resultMap="BaseResultMap" >
  250. select a.id, a.name, a.position from admin a
  251. INNER JOIN user_role ur on a.id = ur.uid
  252. where ur.rid not in('1','2','3','4','5','6')
  253. group by a.id
  254. </select>
  255. <select id="selectRoleByPrimaryKey" parameterType="java.lang.String" resultType="String">
  256. SELECT rid FROM user_role
  257. where uid = #{uid,jdbcType=VARCHAR}
  258. </select>
  259. <select id="selectAccoutManager" resultMap="BaseResultMap">
  260. select a.id, a.name, a.position from admin a
  261. INNER JOIN user_role ur on a.id = ur.uid
  262. where ur.rid = '4'
  263. </select>
  264. <select id="selectTechnician" resultMap="BaseResultMap">
  265. select a.id, a.name, a.position from admin a
  266. INNER JOIN user_role ur on a.id = ur.uid
  267. where ur.rid not in('1','2','3','4')
  268. group by a.id
  269. </select>
  270. <select id="selectSalesman" resultMap="BaseResultMap">
  271. select a.id, a.name, a.position from admin a
  272. INNER JOIN user_role ur on a.id = ur.uid
  273. where ur.rid in ('5', '6')
  274. </select>
  275. <select id="selectContractManager" resultMap="BaseResultMap" >
  276. select a.id, a.name, a.position from admin a
  277. INNER JOIN user_role ur on a.id = ur.uid
  278. where ur.rid not in('1','2','3','4')
  279. group by a.id
  280. </select>
  281. <select id="selectTechBroder" resultMap="BaseResultMap">
  282. select a.id, a.name, a.position from admin a
  283. INNER JOIN user_role ur on a.id = ur.uid
  284. where ur.rid = 7
  285. </select>
  286. <select id="listAdminSelectBySuperAdmin" resultMap="BaseResultMap">
  287. select
  288. <include refid="Base_Column_List" />
  289. from admin
  290. where id <![CDATA[ <> ]]> '1'
  291. </select>
  292. <select id="listAdminSelectByAreaAdmin" resultMap="BaseResultMap">
  293. select
  294. a.id, a.name, a.mobile,
  295. a.create_time as createTime, a.number, aa.name as superior
  296. from admin a
  297. left join admin_location al on al.admin_id = a.id
  298. left join admin aa on aa.id = a.superior_id
  299. where 1 = 1
  300. <if test="provinceList != null and provinceList.size > 0">
  301. and al.province in
  302. <foreach collection="provinceList" item="plist" open="(" separator="," close=")">
  303. #{plist}
  304. </foreach>
  305. </if>
  306. <if test="cityList != null and cityList.size > 0">
  307. and al.city in
  308. <foreach collection="cityList" item="clist" open="(" separator="," close=")">
  309. #{clist}
  310. </foreach>
  311. </if>
  312. </select>
  313. <select id= "findAdminListByPage" parameterType="java.lang.String" resultType="com.goafanti.admin.bo.AdminListBo" >
  314. select
  315. a.number, a.mobile, a.name,
  316. a.position, a.email, a.id,
  317. a.province,
  318. a.city,
  319. a.create_time as createTime,
  320. aa.name as superior,
  321. a.superior_id as superiorId,
  322. a.department_id as departmentId,
  323. dm.name as departmentName
  324. from admin a
  325. left join admin_location al on a.id = al.admin_id
  326. left join admin aa on aa.id = a.superior_id
  327. left join department_management dm on a.department_id = dm.id
  328. where a.id <![CDATA[ <> ]]> '1'
  329. <if test = "mobile != null">
  330. and a.mobile = #{mobile,jdbcType=VARCHAR}
  331. </if>
  332. <if test = "name != null">
  333. and a.name = #{name,jdbcType=VARCHAR}
  334. </if>
  335. <if test = "number != null">
  336. and a.number = #{number,jdbcType=INTEGER}
  337. </if>
  338. <if test = "province != null">
  339. and a.province = #{province,jdbcType=VARCHAR}
  340. </if>
  341. order by a.number
  342. <if test="page_sql!=null">
  343. ${page_sql}
  344. </if>
  345. </select>
  346. <select id = "findAdminCount" parameterType="java.lang.String" resultType="java.lang.Integer">
  347. select count(1) from admin
  348. where id <![CDATA[ <> ]]> '1'
  349. <if test = "mobile != null">
  350. and mobile = #{mobile,jdbcType=VARCHAR}
  351. </if>
  352. <if test = "name != null">
  353. and name = #{name,jdbcType=VARCHAR}
  354. </if>
  355. <if test = "number != null">
  356. and number = #{number,jdbcType=INTEGER}
  357. </if>
  358. <if test = "province != null">
  359. and a.province = #{province,jdbcType=VARCHAR}
  360. </if>
  361. </select>
  362. <select id="listAdminByName" parameterType="java.lang.String" resultMap="BaseResultMap">
  363. select id,name from admin where name like concat('%',#{name},'%')
  364. </select>
  365. <!--*************************************************************************-->
  366. <select id= "selectAdminListByPage" parameterType="java.lang.String" resultType="com.goafanti.admin.bo.AdminListBo" >
  367. select x.*,y.name as departmentName from(select
  368. a.user_no as userNo, a.mobile, a.name,
  369. a.position, a.email, a.id,
  370. a.province,
  371. a.city,
  372. a.create_time as createTime,
  373. aa.name as superior,
  374. a.superior_id as superiorId,
  375. a.department_id as departmentId,
  376. a.duty,a.status
  377. from admin a
  378. left join admin_location al on a.id = al.admin_id
  379. left join admin aa on aa.id = a.superior_id
  380. left join user_role ur on a.id=ur.uid
  381. where a.id <![CDATA[ <> ]]> '1'
  382. and (a.status !='注销' or a.status is null)
  383. <if test = "name != null">
  384. and a.name = #{name,jdbcType=VARCHAR}
  385. </if>
  386. <if test = "departmentId != null">
  387. and a.department_id = #{departmentId,jdbcType=VARCHAR}
  388. </if>
  389. <if test = "rid != null">
  390. and ur.rid = #{rid,jdbcType=VARCHAR}
  391. </if>
  392. <if test = "duty != null">
  393. and a.duty = #{duty,jdbcType=VARCHAR}
  394. </if>
  395. <if test = "position != null">
  396. and a.position = #{position,jdbcType=VARCHAR}
  397. </if>
  398. <if test = "status != null">
  399. and a.status = #{status,jdbcType=VARCHAR}
  400. </if>
  401. <if test = "mobile != null">
  402. and a.mobile = #{mobile,jdbcType=VARCHAR}
  403. </if>
  404. <if test = "superiorId != null">
  405. and a.superior_id = #{superiorId,jdbcType=VARCHAR}
  406. </if>
  407. group by a.id
  408. order by a.number )x left join department_management y on x.departmentId = y.id
  409. <if test="page_sql!=null">
  410. ${page_sql}
  411. </if>
  412. </select>
  413. <select id = "selectAdminCount" parameterType="java.lang.String" resultType="java.lang.Integer">
  414. select count(t.counts)
  415. from(select a.id counts from (select a.id from admin a
  416. left join user_role ur on a.id=ur.uid
  417. where a.id <![CDATA[ <> ]]> '1'
  418. and (a.status != '注销' or a.status is null)
  419. <if test = "name != null">
  420. and a.name = #{name,jdbcType=VARCHAR}
  421. </if>
  422. <if test = "departmentId != null">
  423. and a.department_id = #{departmentId,jdbcType=VARCHAR}
  424. </if>
  425. <if test = "rid != null">
  426. and ur.rid = #{rid,jdbcType=VARCHAR}
  427. </if>
  428. <if test = "duty != null">
  429. and a.duty = #{duty,jdbcType=VARCHAR}
  430. </if>
  431. <if test = "position != null">
  432. and a.position = #{position,jdbcType=VARCHAR}
  433. </if>
  434. <if test = "status != null">
  435. and a.status = #{status,jdbcType=VARCHAR}
  436. </if>
  437. <if test = "mobile != null">
  438. and a.mobile = #{mobile,jdbcType=VARCHAR}
  439. </if>
  440. <if test = "superiorId != null">
  441. and a.superior_id = #{superiorId,jdbcType=VARCHAR}
  442. </if>
  443. )a
  444. group by a.id)t
  445. </select>
  446. <insert id="insertn" parameterType="com.goafanti.common.model.Admin" >
  447. insert into admin (id, mobile, name,
  448. password, email, create_time,
  449. number, province, position, superior_id, city,department_id,status,user_no,duty,district,head_portrait_url)
  450. values (#{id,jdbcType=VARCHAR}, #{mobile,jdbcType=VARCHAR}, #{name,jdbcType=VARCHAR},
  451. #{password,jdbcType=VARCHAR}, #{email,jdbcType=VARCHAR}, #{createTime,jdbcType=TIMESTAMP},
  452. #{number,jdbcType=INTEGER}, #{province,jdbcType=INTEGER}, #{position,jdbcType=VARCHAR},
  453. #{superiorId,jdbcType=VARCHAR}, #{city,jdbcType=INTEGER},#{departmentId,jdbcType=VARCHAR},
  454. #{status,jdbcType=VARCHAR},#{userNo,jdbcType=VARCHAR},#{duty,jdbcType=VARCHAR},#{district,jdbcType=VARCHAR},#{headPortraitUrl,jdbcType=VARCHAR}
  455. )
  456. </insert>
  457. <select id="selectUserNoBySuperiorId" parameterType="java.lang.String" resultType="java.lang.String">
  458. select
  459. user_no as userNo
  460. from admin
  461. where
  462. id=#{superiorId,jdbcType=VARCHAR}
  463. </select>
  464. <select id="selectCountBySuperiorId" parameterType="java.lang.String" resultType="java.lang.Integer">
  465. select
  466. count(1)
  467. from admin
  468. where
  469. superior_id=#{superiorId,jdbcType=VARCHAR}
  470. </select>
  471. <select id="selectIdByUserNo" parameterType="java.lang.String" resultType="java.lang.String">
  472. select
  473. id
  474. from admin
  475. where
  476. user_no=#{UserNo,jdbcType=VARCHAR}
  477. </select>
  478. <select id= "selectAllByid" parameterType="java.lang.String" resultType="com.goafanti.common.model.Admin" >
  479. select
  480. id, mobile, name,
  481. password, email, create_time as createTime,
  482. province, position,
  483. superior_id as superiorId,department_id as departmentId,
  484. status,user_no as userNo,duty,district,head_portrait_url as headPortraitUrl
  485. from admin
  486. where
  487. id=#{id,jdbcType=VARCHAR}
  488. </select>
  489. <select id= "selectNameByid" parameterType="java.lang.String" resultType="java.lang.String" >
  490. select
  491. name
  492. from admin
  493. where
  494. id=#{id,jdbcType=VARCHAR}
  495. </select>
  496. <select id= "selectRolesByUid" parameterType="java.lang.String" resultType="java.lang.String">
  497. select
  498. r.role_name as roles
  499. from user_role ur
  500. left join role r on r.id = ur.rid
  501. where
  502. uid=#{id,jdbcType=VARCHAR}
  503. </select>
  504. </mapper>