AdminMapper.xml 15 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440
  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. </set>
  158. where id = #{id,jdbcType=VARCHAR}
  159. </update>
  160. <update id="updateByPrimaryKey" parameterType="com.goafanti.common.model.Admin" >
  161. update admin
  162. set mobile = #{mobile,jdbcType=VARCHAR},
  163. name = #{name,jdbcType=VARCHAR},
  164. password = #{password,jdbcType=VARCHAR},
  165. email = #{email,jdbcType=VARCHAR},
  166. create_time = #{createTime,jdbcType=TIMESTAMP},
  167. number = #{number,jdbcType=INTEGER},
  168. province = #{province,jdbcType=INTEGER},
  169. position = #{position,jdbcType=VARCHAR},
  170. superior_id = #{superiorId,jdbcType=VARCHAR},
  171. city = #{city,jdbcType=INTEGER},
  172. department_id = #{departmentId,jdbcType=VARCHAR}
  173. where id = #{id,jdbcType=VARCHAR}
  174. </update>
  175. <select id="selectAllAdmin" resultMap="BaseResultMap">
  176. select
  177. <include refid="Base_Column_List" />
  178. from admin
  179. </select>
  180. <select id="selectByMobile" parameterType="java.lang.String" resultMap="BaseResultMap">
  181. select
  182. <include refid="Base_Column_List" />
  183. from admin
  184. where mobile = #{mobile,jdbcType=VARCHAR}
  185. </select>
  186. <select id="selectRolesByPrimaryKey" parameterType="java.lang.String">
  187. select r.name, r.id, r.type
  188. from role r
  189. left join user_role ur on ur.rid=r.id
  190. where ur.uid = #{uid,jdbcType=VARCHAR}
  191. </select>
  192. <select id="selectCognizanceConsultant" resultMap="BaseResultMap" >
  193. select
  194. <include refid="Base_Column_List" />
  195. from admin
  196. where id <![CDATA[ <> ]]> '1'
  197. </select>
  198. <select id="selectCognizancePrincipal" resultMap="BaseResultMap" >
  199. select a.id, a.name, a.position from admin a
  200. INNER JOIN user_role ur on a.id = ur.uid
  201. where ur.rid not in('1','2','3','4','5','6')
  202. group by a.id
  203. </select>
  204. <select id="selectPatentAuthor" resultMap="BaseResultMap" >
  205. select a.id, a.name, a.position from admin a
  206. INNER JOIN user_role ur on a.id = ur.uid
  207. where ur.rid not in('1','2','3','4','5','6')
  208. group by a.id
  209. </select>
  210. <select id="selectPatentPrincipal" resultMap="BaseResultMap" >
  211. select a.id, a.name, a.position from admin a
  212. INNER JOIN user_role ur on a.id = ur.uid
  213. where ur.rid not in('1','2','3','4','5','6')
  214. group by a.id
  215. </select>
  216. <select id="selectCopyrightConsultant" resultMap="BaseResultMap" >
  217. select
  218. <include refid="Base_Column_List" />
  219. from admin
  220. where id <![CDATA[ <> ]]> '1'
  221. </select>
  222. <select id="selectCopyrightPrincipal" resultMap="BaseResultMap" >
  223. select a.id, a.name, a.position from admin a
  224. INNER JOIN user_role ur on a.id = ur.uid
  225. where ur.rid not in('1','2','3','4','5','6')
  226. group by a.id
  227. </select>
  228. <select id="selectTechprojectConsultant" resultMap="BaseResultMap" >
  229. select
  230. <include refid="Base_Column_List" />
  231. from admin
  232. where id <![CDATA[ <> ]]> '1'
  233. </select>
  234. <select id="selectTechprojectPrincipal" resultMap="BaseResultMap" >
  235. select a.id, a.name, a.position from admin a
  236. INNER JOIN user_role ur on a.id = ur.uid
  237. where ur.rid not in('1','2','3','4','5','6')
  238. group by a.id
  239. </select>
  240. <select id="selectRoleByPrimaryKey" parameterType="java.lang.String" resultType="String">
  241. SELECT rid FROM user_role
  242. where uid = #{uid,jdbcType=VARCHAR}
  243. </select>
  244. <select id="selectAccoutManager" resultMap="BaseResultMap">
  245. select a.id, a.name, a.position from admin a
  246. INNER JOIN user_role ur on a.id = ur.uid
  247. where ur.rid = '4'
  248. </select>
  249. <select id="selectTechnician" 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')
  253. group by a.id
  254. </select>
  255. <select id="selectSalesman" resultMap="BaseResultMap">
  256. select a.id, a.name, a.position from admin a
  257. INNER JOIN user_role ur on a.id = ur.uid
  258. where ur.rid in ('5', '6')
  259. </select>
  260. <select id="selectContractManager" resultMap="BaseResultMap" >
  261. select a.id, a.name, a.position from admin a
  262. INNER JOIN user_role ur on a.id = ur.uid
  263. where ur.rid not in('1','2','3','4')
  264. group by a.id
  265. </select>
  266. <select id="selectTechBroder" resultMap="BaseResultMap">
  267. select a.id, a.name, a.position from admin a
  268. INNER JOIN user_role ur on a.id = ur.uid
  269. where ur.rid = 7
  270. </select>
  271. <select id="listAdminSelectBySuperAdmin" resultMap="BaseResultMap">
  272. select
  273. <include refid="Base_Column_List" />
  274. from admin
  275. where id <![CDATA[ <> ]]> '1'
  276. </select>
  277. <select id="listAdminSelectByAreaAdmin" resultMap="BaseResultMap">
  278. select
  279. a.id, a.name, a.mobile,
  280. a.create_time as createTime, a.number, aa.name as superior
  281. from admin a
  282. left join admin_location al on al.admin_id = a.id
  283. left join admin aa on aa.id = a.superior_id
  284. where 1 = 1
  285. <if test="provinceList != null and provinceList.size > 0">
  286. and al.province in
  287. <foreach collection="provinceList" item="plist" open="(" separator="," close=")">
  288. #{plist}
  289. </foreach>
  290. </if>
  291. <if test="cityList != null and cityList.size > 0">
  292. and al.city in
  293. <foreach collection="cityList" item="clist" open="(" separator="," close=")">
  294. #{clist}
  295. </foreach>
  296. </if>
  297. </select>
  298. <select id= "findAdminListByPage" parameterType="java.lang.String" resultType="com.goafanti.admin.bo.AdminListBo" >
  299. select
  300. a.number, a.mobile, a.name,
  301. a.position, a.email, a.id,
  302. a.create_time as createTime, GROUP_CONCAT(DISTINCT(al.province)) AS province,
  303. aa.name as superior, a.superior_id as superiorId
  304. from admin a
  305. left join admin_location al on a.id = al.admin_id
  306. left join admin aa on aa.id = a.superior_id
  307. where a.id <![CDATA[ <> ]]> '1'
  308. <if test = "mobile != null">
  309. and a.mobile = #{mobile,jdbcType=VARCHAR}
  310. </if>
  311. <if test = "name != null">
  312. and a.name = #{name,jdbcType=VARCHAR}
  313. </if>
  314. <if test = "number != null">
  315. and a.number = #{number,jdbcType=INTEGER}
  316. </if>
  317. group by a.id
  318. order by a.number
  319. <if test="page_sql!=null">
  320. ${page_sql}
  321. </if>
  322. </select>
  323. <select id= "findAreaAdminListByPage" parameterType="java.lang.String" resultType="com.goafanti.admin.bo.AdminListBo" >
  324. select
  325. a.number, a.mobile, a.name,
  326. a.position, a.email, a.id,
  327. a.create_time as createTime,
  328. aa.name as superior, GROUP_CONCAT(DISTINCT(al.province)) AS province,
  329. a.superior_id as superiorId
  330. from admin a
  331. left join admin_location al on a.id = al.admin_id
  332. left join admin aa on aa.id = a.superior_id
  333. where 1 =1
  334. <if test = "mobile != null">
  335. and a.mobile = #{mobile,jdbcType=VARCHAR}
  336. </if>
  337. <if test = "name != null">
  338. and a.name = #{name,jdbcType=VARCHAR}
  339. </if>
  340. <if test = "number != null">
  341. and a.number = #{number,jdbcType=INTEGER}
  342. </if>
  343. <if test="provinceList != null">
  344. and al.province in
  345. <foreach collection="provinceList" item="plist" open="(" separator="," close=")">
  346. #{plist}
  347. </foreach>
  348. </if>
  349. <if test = "provinceList != null and cityList != null">
  350. or
  351. </if>
  352. <if test="cityList != null">
  353. <if test="provinceList == null">
  354. and
  355. </if>
  356. al.city in
  357. <foreach collection="cityList" item="clist" open="(" separator="," close=")">
  358. #{clist}
  359. </foreach>
  360. </if>
  361. group by a.id
  362. order by a.number
  363. <if test="page_sql!=null">
  364. ${page_sql}
  365. </if>
  366. </select>
  367. <select id = "findAdminCount" parameterType="java.lang.String" resultType="java.lang.Integer">
  368. select count(1) from admin
  369. where id <![CDATA[ <> ]]> '1'
  370. <if test = "mobile != null">
  371. and mobile = #{mobile,jdbcType=VARCHAR}
  372. </if>
  373. <if test = "name != null">
  374. and name = #{name,jdbcType=VARCHAR}
  375. </if>
  376. <if test = "number != null">
  377. and number = #{number,jdbcType=INTEGER}
  378. </if>
  379. </select>
  380. <select id = "findAreaAdminCount" parameterType="java.lang.String" resultType="java.lang.Integer">
  381. select count(distinct(a.number))
  382. from admin a
  383. left join admin_location al on a.id = al.admin_id
  384. where 1 = 1
  385. <if test = "mobile != null">
  386. and a.mobile = #{mobile,jdbcType=VARCHAR}
  387. </if>
  388. <if test = "name != null">
  389. and a.name = #{name,jdbcType=VARCHAR}
  390. </if>
  391. <if test = "number != null">
  392. and a.number = #{number,jdbcType=INTEGER}
  393. </if>
  394. <if test="provinceList != null">
  395. and al.province in
  396. <foreach collection="provinceList" item="plist" open="(" separator="," close=")">
  397. #{plist}
  398. </foreach>
  399. </if>
  400. <if test = "provinceList != null &amp;&amp; cityList != null">
  401. or
  402. </if>
  403. <if test="cityList != null">
  404. <if test="provinceList == null">
  405. and
  406. </if>
  407. al.city in
  408. <foreach collection="cityList" item="clist" open="(" separator="," close=")">
  409. #{clist}
  410. </foreach>
  411. </if>
  412. </select>
  413. <select id="listAdminByName" parameterType="java.lang.String" resultMap="BaseResultMap">
  414. select id,name from admin where name like concat('%',#{name},'%')
  415. </select>
  416. </mapper>