AdminMapper.xml 14 KB

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