AdminMapper.xml 14 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433
  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. </resultMap>
  17. <sql id="Base_Column_List" >
  18. id, mobile, name, password, email, create_time, number, province, position, superior_id,
  19. city
  20. </sql>
  21. <select id="selectByPrimaryKey" resultMap="BaseResultMap" parameterType="java.lang.String" >
  22. select
  23. <include refid="Base_Column_List" />
  24. from admin
  25. where id = #{id,jdbcType=VARCHAR}
  26. </select>
  27. <delete id="deleteByPrimaryKey" parameterType="java.lang.String" >
  28. delete from admin
  29. where id = #{id,jdbcType=VARCHAR}
  30. </delete>
  31. <insert id="insert" parameterType="com.goafanti.common.model.Admin" >
  32. insert into admin (id, mobile, name,
  33. password, email, create_time,
  34. number, province, position, superior_id, city)
  35. values (#{id,jdbcType=VARCHAR}, #{mobile,jdbcType=VARCHAR}, #{name,jdbcType=VARCHAR},
  36. #{password,jdbcType=VARCHAR}, #{email,jdbcType=VARCHAR}, #{createTime,jdbcType=TIMESTAMP},
  37. #{number,jdbcType=INTEGER}, #{province,jdbcType=INTEGER}, #{position,jdbcType=VARCHAR},
  38. #{superiorId,jdbcType=VARCHAR}, #{city,jdbcType=INTEGER}
  39. )
  40. </insert>
  41. <insert id="insertSelective" parameterType="com.goafanti.common.model.Admin" >
  42. insert into admin
  43. <trim prefix="(" suffix=")" suffixOverrides="," >
  44. <if test="id != null" >
  45. id,
  46. </if>
  47. <if test="mobile != null" >
  48. mobile,
  49. </if>
  50. <if test="name != null" >
  51. name,
  52. </if>
  53. <if test="password != null" >
  54. password,
  55. </if>
  56. <if test="email != null" >
  57. email,
  58. </if>
  59. <if test="createTime != null" >
  60. create_time,
  61. </if>
  62. <if test="number != null" >
  63. number,
  64. </if>
  65. <if test="province != null" >
  66. province,
  67. </if>
  68. <if test="position != null" >
  69. position,
  70. </if>
  71. <if test="superiorId != null" >
  72. superior_id,
  73. </if>
  74. <if test="city != null" >
  75. city,
  76. </if>
  77. </trim>
  78. <trim prefix="values (" suffix=")" suffixOverrides="," >
  79. <if test="id != null" >
  80. #{id,jdbcType=VARCHAR},
  81. </if>
  82. <if test="mobile != null" >
  83. #{mobile,jdbcType=VARCHAR},
  84. </if>
  85. <if test="name != null" >
  86. #{name,jdbcType=VARCHAR},
  87. </if>
  88. <if test="password != null" >
  89. #{password,jdbcType=VARCHAR},
  90. </if>
  91. <if test="email != null" >
  92. #{email,jdbcType=VARCHAR},
  93. </if>
  94. <if test="createTime != null" >
  95. #{createTime,jdbcType=TIMESTAMP},
  96. </if>
  97. <if test="number != null" >
  98. #{number,jdbcType=INTEGER},
  99. </if>
  100. <if test="province != null" >
  101. #{province,jdbcType=INTEGER},
  102. </if>
  103. <if test="position != null" >
  104. #{position,jdbcType=VARCHAR},
  105. </if>
  106. <if test="superiorId != null" >
  107. #{superiorId,jdbcType=VARCHAR},
  108. </if>
  109. <if test="city != null" >
  110. #{city,jdbcType=INTEGER},
  111. </if>
  112. </trim>
  113. </insert>
  114. <update id="updateByPrimaryKeySelective" parameterType="com.goafanti.common.model.Admin" >
  115. update admin
  116. <set >
  117. <if test="mobile != null" >
  118. mobile = #{mobile,jdbcType=VARCHAR},
  119. </if>
  120. <if test="name != null" >
  121. name = #{name,jdbcType=VARCHAR},
  122. </if>
  123. <if test="password != null" >
  124. password = #{password,jdbcType=VARCHAR},
  125. </if>
  126. <if test="email != null" >
  127. email = #{email,jdbcType=VARCHAR},
  128. </if>
  129. <if test="createTime != null" >
  130. create_time = #{createTime,jdbcType=TIMESTAMP},
  131. </if>
  132. <if test="number != null" >
  133. number = #{number,jdbcType=INTEGER},
  134. </if>
  135. <if test="province != null" >
  136. province = #{province,jdbcType=INTEGER},
  137. </if>
  138. <if test="position != null" >
  139. position = #{position,jdbcType=VARCHAR},
  140. </if>
  141. <if test="superiorId != null" >
  142. superior_id = #{superiorId,jdbcType=VARCHAR},
  143. </if>
  144. <if test="city != null" >
  145. city = #{city,jdbcType=INTEGER},
  146. </if>
  147. </set>
  148. where id = #{id,jdbcType=VARCHAR}
  149. </update>
  150. <update id="updateByPrimaryKey" parameterType="com.goafanti.common.model.Admin" >
  151. update admin
  152. set mobile = #{mobile,jdbcType=VARCHAR},
  153. name = #{name,jdbcType=VARCHAR},
  154. password = #{password,jdbcType=VARCHAR},
  155. email = #{email,jdbcType=VARCHAR},
  156. create_time = #{createTime,jdbcType=TIMESTAMP},
  157. number = #{number,jdbcType=INTEGER},
  158. province = #{province,jdbcType=INTEGER},
  159. position = #{position,jdbcType=VARCHAR},
  160. superior_id = #{superiorId,jdbcType=VARCHAR},
  161. city = #{city,jdbcType=INTEGER}
  162. where id = #{id,jdbcType=VARCHAR}
  163. </update>
  164. <select id="selectAllAdmin" resultMap="BaseResultMap">
  165. select
  166. <include refid="Base_Column_List" />
  167. from admin
  168. </select>
  169. <select id="selectByMobile" parameterType="java.lang.String" resultMap="BaseResultMap">
  170. select
  171. <include refid="Base_Column_List" />
  172. from admin
  173. where mobile = #{mobile,jdbcType=VARCHAR}
  174. </select>
  175. <select id= "findAdminListByPage" parameterType="java.lang.String" resultType="com.goafanti.admin.bo.AdminListBo" >
  176. select
  177. a.number, a.mobile, a.name,
  178. a.position, a.email, a.id,
  179. a.create_time as createTime, GROUP_CONCAT(DISTINCT(al.province)) AS province,
  180. aa.name as superior, a.superior_id as superiorId
  181. from admin a
  182. left join admin_location al on a.id = al.admin_id
  183. left join admin aa on aa.id = a.superior_id
  184. where a.id <![CDATA[ <> ]]> '1'
  185. <if test = "mobile != null">
  186. and a.mobile = #{mobile,jdbcType=VARCHAR}
  187. </if>
  188. <if test = "name != null">
  189. and a.name = #{name,jdbcType=VARCHAR}
  190. </if>
  191. <if test = "number != null">
  192. and a.number = #{number,jdbcType=INTEGER}
  193. </if>
  194. group by a.id
  195. order by a.number
  196. <if test="page_sql!=null">
  197. ${page_sql}
  198. </if>
  199. </select>
  200. <select id = "findAdminCount" parameterType="java.lang.String" resultType="java.lang.Integer">
  201. select count(1) from admin
  202. where id <![CDATA[ <> ]]> '1'
  203. <if test = "mobile != null">
  204. and mobile = #{mobile,jdbcType=VARCHAR}
  205. </if>
  206. <if test = "name != null">
  207. and name = #{name,jdbcType=VARCHAR}
  208. </if>
  209. <if test = "number != null">
  210. and number = #{number,jdbcType=INTEGER}
  211. </if>
  212. </select>
  213. <select id="selectRolesByPrimaryKey" parameterType="java.lang.String">
  214. select r.name, r.id, r.type
  215. from role r
  216. left join user_role ur on ur.rid=r.id
  217. where ur.uid = #{uid,jdbcType=VARCHAR}
  218. </select>
  219. <select id="selectCognizanceConsultant" resultMap="BaseResultMap" >
  220. select
  221. <include refid="Base_Column_List" />
  222. from admin
  223. where id <![CDATA[ <> ]]> '1'
  224. </select>
  225. <select id="selectCognizancePrincipal" 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')
  229. group by a.id
  230. </select>
  231. <select id="selectPatentAuthor" resultMap="BaseResultMap" >
  232. select a.id, a.name, a.position from admin a
  233. INNER JOIN user_role ur on a.id = ur.uid
  234. where ur.rid not in('1','2','3','4')
  235. group by a.id
  236. </select>
  237. <select id="selectPatentPrincipal" 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="selectCopyrightConsultant" resultMap="BaseResultMap" >
  244. select
  245. <include refid="Base_Column_List" />
  246. from admin
  247. where id <![CDATA[ <> ]]> '1'
  248. </select>
  249. <select id="selectCopyrightPrincipal" 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="selectTechprojectConsultant" resultMap="BaseResultMap" >
  256. select
  257. <include refid="Base_Column_List" />
  258. from admin
  259. where id <![CDATA[ <> ]]> '1'
  260. </select>
  261. <select id="selectTechprojectPrincipal" resultMap="BaseResultMap" >
  262. select a.id, a.name, a.position from admin a
  263. INNER JOIN user_role ur on a.id = ur.uid
  264. where ur.rid not in('1','2','3','4','5','6')
  265. group by a.id
  266. </select>
  267. <select id="selectRoleByPrimaryKey" parameterType="java.lang.String" resultType="String">
  268. SELECT rid FROM user_role
  269. where uid = #{uid,jdbcType=VARCHAR}
  270. </select>
  271. <select id="selectAccoutManager" resultMap="BaseResultMap">
  272. select a.id, a.name, a.position from admin a
  273. INNER JOIN user_role ur on a.id = ur.uid
  274. where ur.rid = '4'
  275. </select>
  276. <select id="selectTechnician" resultMap="BaseResultMap">
  277. select a.id, a.name, a.position from admin a
  278. INNER JOIN user_role ur on a.id = ur.uid
  279. where ur.rid not in('1','2','3','4','5','6')
  280. group by a.id
  281. </select>
  282. <select id="selectSalesman" resultMap="BaseResultMap">
  283. select a.id, a.name, a.position from admin a
  284. INNER JOIN user_role ur on a.id = ur.uid
  285. where ur.rid in ('5', '6')
  286. </select>
  287. <select id="selectContractManager" resultMap="BaseResultMap" >
  288. select a.id, a.name, a.position from admin a
  289. INNER JOIN user_role ur on a.id = ur.uid
  290. where ur.rid not in('1','2','3','4')
  291. group by a.id
  292. </select>
  293. <select id="selectTechBroder" resultMap="BaseResultMap">
  294. select a.id, a.name, a.position from admin a
  295. INNER JOIN user_role ur on a.id = ur.uid
  296. where ur.rid = 7
  297. </select>
  298. <select id="listAdminSelectBySuperAdmin" resultMap="BaseResultMap">
  299. select
  300. <include refid="Base_Column_List" />
  301. from admin
  302. where id <![CDATA[ <> ]]> '1'
  303. </select>
  304. <select id="listAdminSelectByAreaAdmin" resultMap="BaseResultMap">
  305. select
  306. a.id, a.name, a.mobile,
  307. a.create_time as createTime, a.number, aa.name as superior
  308. from admin a
  309. left join admin_location al on al.admin_id = a.id
  310. left join admin aa on aa.id = a.superior_id
  311. where 1 = 1
  312. <if test="provinceList != null">
  313. and al.province in
  314. <foreach collection="provinceList" item="plist" open="(" separator="," close=")">
  315. #{plist}
  316. </foreach>
  317. </if>
  318. <if test = "provinceList != null &amp;&amp; cityList != null">
  319. or
  320. </if>
  321. <if test="cityList != null">
  322. <if test="provinceList == null">
  323. and
  324. </if>
  325. al.city in
  326. <foreach collection="cityList" item="clist" open="(" separator="," close=")">
  327. #{clist}
  328. </foreach>
  329. </if>
  330. </select>
  331. <select id= "findAreaAdminListByPage" parameterType="java.lang.String" resultType="com.goafanti.admin.bo.AdminListBo" >
  332. select
  333. a.number, a.mobile, a.name,
  334. a.position, a.email, a.id,
  335. a.create_time as createTime,
  336. aa.name as superior, GROUP_CONCAT(DISTINCT(al.province)) AS province,
  337. a.superior_id as superiorId
  338. from admin a
  339. left join admin_location al on a.id = al.admin_id
  340. left join admin aa on aa.id = a.superior_id
  341. where 1 =1
  342. <if test = "mobile != null">
  343. and a.mobile = #{mobile,jdbcType=VARCHAR}
  344. </if>
  345. <if test = "name != null">
  346. and a.name = #{name,jdbcType=VARCHAR}
  347. </if>
  348. <if test = "number != null">
  349. and a.number = #{number,jdbcType=INTEGER}
  350. </if>
  351. <if test="provinceList != null">
  352. and al.province in
  353. <foreach collection="provinceList" item="plist" open="(" separator="," close=")">
  354. #{plist}
  355. </foreach>
  356. </if>
  357. <if test = "provinceList != null &amp;&amp; cityList != null">
  358. or
  359. </if>
  360. <if test="cityList != null">
  361. <if test="provinceList == null">
  362. and
  363. </if>
  364. al.city in
  365. <foreach collection="cityList" item="clist" open="(" separator="," close=")">
  366. #{clist}
  367. </foreach>
  368. </if>
  369. group by a.id
  370. order by a.number
  371. <if test="page_sql!=null">
  372. ${page_sql}
  373. </if>
  374. </select>
  375. <select id = "findAreaAdminCount" parameterType="java.lang.String" resultType="java.lang.Integer">
  376. select count(1) from ( select count(1)
  377. from admin a
  378. left join admin_location al on a.id = al.admin_id
  379. where 1 = 1
  380. <if test = "mobile != null">
  381. and a.mobile = #{mobile,jdbcType=VARCHAR}
  382. </if>
  383. <if test = "name != null">
  384. and a.name = #{name,jdbcType=VARCHAR}
  385. </if>
  386. <if test = "number != null">
  387. and a.number = #{number,jdbcType=INTEGER}
  388. </if>
  389. <if test="provinceList != null">
  390. and al.province in
  391. <foreach collection="provinceList" item="plist" open="(" separator="," close=")">
  392. #{plist}
  393. </foreach>
  394. </if>
  395. <if test = "provinceList != null &amp;&amp; cityList != null">
  396. or
  397. </if>
  398. <if test="cityList != null">
  399. <if test="provinceList == null">
  400. and
  401. </if>
  402. al.city in
  403. <foreach collection="cityList" item="clist" open="(" separator="," close=")">
  404. #{clist}
  405. </foreach>
  406. </if>
  407. group by a.id
  408. ) tem
  409. </select>
  410. </mapper>