AdminMapper.xml 9.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293
  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="VARCHAR" />
  13. <result column="position" property="position" jdbcType="VARCHAR" />
  14. </resultMap>
  15. <sql id="Base_Column_List" >
  16. id, mobile, name, password, email, create_time, number, province, position
  17. </sql>
  18. <select id="selectByPrimaryKey" resultMap="BaseResultMap" parameterType="java.lang.String" >
  19. select
  20. <include refid="Base_Column_List" />
  21. from admin
  22. where id = #{id,jdbcType=VARCHAR}
  23. </select>
  24. <delete id="deleteByPrimaryKey" parameterType="java.lang.String" >
  25. delete from admin
  26. where id = #{id,jdbcType=VARCHAR}
  27. </delete>
  28. <insert id="insert" parameterType="com.goafanti.common.model.Admin" >
  29. insert into admin (id, mobile, name,
  30. password, email, create_time,
  31. number, province, position)
  32. values (#{id,jdbcType=VARCHAR}, #{mobile,jdbcType=VARCHAR}, #{name,jdbcType=VARCHAR},
  33. #{password,jdbcType=VARCHAR}, #{email,jdbcType=VARCHAR}, #{createTime,jdbcType=TIMESTAMP},
  34. #{number,jdbcType=INTEGER}, #{province,jdbcType=VARCHAR}, #{position,jdbcType=VARCHAR}
  35. )
  36. </insert>
  37. <insert id="insertSelective" parameterType="com.goafanti.common.model.Admin" >
  38. insert into admin
  39. <trim prefix="(" suffix=")" suffixOverrides="," >
  40. <if test="id != null" >
  41. id,
  42. </if>
  43. <if test="mobile != null" >
  44. mobile,
  45. </if>
  46. <if test="name != null" >
  47. name,
  48. </if>
  49. <if test="password != null" >
  50. password,
  51. </if>
  52. <if test="email != null" >
  53. email,
  54. </if>
  55. <if test="createTime != null" >
  56. create_time,
  57. </if>
  58. <if test="number != null" >
  59. number,
  60. </if>
  61. <if test="province != null" >
  62. province,
  63. </if>
  64. <if test="position != null" >
  65. position,
  66. </if>
  67. </trim>
  68. <trim prefix="values (" suffix=")" suffixOverrides="," >
  69. <if test="id != null" >
  70. #{id,jdbcType=VARCHAR},
  71. </if>
  72. <if test="mobile != null" >
  73. #{mobile,jdbcType=VARCHAR},
  74. </if>
  75. <if test="name != null" >
  76. #{name,jdbcType=VARCHAR},
  77. </if>
  78. <if test="password != null" >
  79. #{password,jdbcType=VARCHAR},
  80. </if>
  81. <if test="email != null" >
  82. #{email,jdbcType=VARCHAR},
  83. </if>
  84. <if test="createTime != null" >
  85. #{createTime,jdbcType=TIMESTAMP},
  86. </if>
  87. <if test="number != null" >
  88. #{number,jdbcType=INTEGER},
  89. </if>
  90. <if test="province != null" >
  91. #{province,jdbcType=VARCHAR},
  92. </if>
  93. <if test="position != null" >
  94. #{position,jdbcType=VARCHAR},
  95. </if>
  96. </trim>
  97. </insert>
  98. <update id="updateByPrimaryKeySelective" parameterType="com.goafanti.common.model.Admin" >
  99. update admin
  100. <set >
  101. <if test="mobile != null" >
  102. mobile = #{mobile,jdbcType=VARCHAR},
  103. </if>
  104. <if test="name != null" >
  105. name = #{name,jdbcType=VARCHAR},
  106. </if>
  107. <if test="password != null" >
  108. password = #{password,jdbcType=VARCHAR},
  109. </if>
  110. <if test="email != null" >
  111. email = #{email,jdbcType=VARCHAR},
  112. </if>
  113. <if test="createTime != null" >
  114. create_time = #{createTime,jdbcType=TIMESTAMP},
  115. </if>
  116. <if test="number != null" >
  117. number = #{number,jdbcType=INTEGER},
  118. </if>
  119. <if test="province != null" >
  120. province = #{province,jdbcType=VARCHAR},
  121. </if>
  122. <if test="position != null" >
  123. position = #{position,jdbcType=VARCHAR},
  124. </if>
  125. </set>
  126. where id = #{id,jdbcType=VARCHAR}
  127. </update>
  128. <update id="updateByPrimaryKey" parameterType="com.goafanti.common.model.Admin" >
  129. update admin
  130. set mobile = #{mobile,jdbcType=VARCHAR},
  131. name = #{name,jdbcType=VARCHAR},
  132. password = #{password,jdbcType=VARCHAR},
  133. email = #{email,jdbcType=VARCHAR},
  134. create_time = #{createTime,jdbcType=TIMESTAMP},
  135. number = #{number,jdbcType=INTEGER},
  136. province = #{province,jdbcType=VARCHAR},
  137. position = #{position,jdbcType=VARCHAR}
  138. where id = #{id,jdbcType=VARCHAR}
  139. </update>
  140. <select id="selectAllAdmin" resultMap="BaseResultMap">
  141. select
  142. <include refid="Base_Column_List" />
  143. from admin
  144. </select>
  145. <select id="selectByMobile" parameterType="java.lang.String" resultMap="BaseResultMap">
  146. select
  147. <include refid="Base_Column_List" />
  148. from admin
  149. where mobile = #{mobile,jdbcType=VARCHAR}
  150. </select>
  151. <select id= "findAdminListByPage" parameterType="java.lang.String" resultMap="BaseResultMap" >
  152. select
  153. <include refid="Base_Column_List" />
  154. from admin
  155. where id <![CDATA[ <> ]]> '1'
  156. <if test = "province != null">
  157. and province = #{province,jdbcType=VARCHAR}
  158. </if>
  159. <if test = "mobile != null">
  160. and mobile = #{mobile,jdbcType=VARCHAR}
  161. </if>
  162. <if test = "name != null">
  163. and name = #{name,jdbcType=VARCHAR}
  164. </if>
  165. <if test = "number != null">
  166. and number = #{number,jdbcType=INTEGER}
  167. </if>
  168. order by number
  169. <if test="page_sql!=null">
  170. ${page_sql}
  171. </if>
  172. </select>
  173. <select id = "findAdminCount" parameterType="java.lang.String" resultType="java.lang.Integer">
  174. select count(1) from admin
  175. where id <![CDATA[ <> ]]> '1'
  176. <if test = "province != null">
  177. and province = #{province,jdbcType=VARCHAR}
  178. </if>
  179. <if test = "mobile != null">
  180. and mobile = #{mobile,jdbcType=VARCHAR}
  181. </if>
  182. <if test = "name != null">
  183. and name = #{name,jdbcType=VARCHAR}
  184. </if>
  185. <if test = "number != null">
  186. and number = #{number,jdbcType=INTEGER}
  187. </if>
  188. </select>
  189. <select id="selectRolesByPrimaryKey" parameterType="java.lang.String">
  190. select r.name, r.id, r.type
  191. from role r
  192. left join user_role ur on ur.rid=r.id
  193. where ur.uid = #{uid,jdbcType=VARCHAR}
  194. </select>
  195. <select id="selectCognizanceConsultant" resultMap="BaseResultMap" >
  196. select
  197. <include refid="Base_Column_List" />
  198. from admin
  199. where id <![CDATA[ <> ]]> '1'
  200. </select>
  201. <select id="selectCognizancePrincipal" resultMap="BaseResultMap" >
  202. select a.id, a.name, a.position from admin a
  203. INNER JOIN user_role ur on a.id = ur.uid
  204. where ur.rid not in('1','2','3','4')
  205. group by a.id
  206. </select>
  207. <select id="selectPatentAuthor" resultMap="BaseResultMap" >
  208. select a.id, a.name, a.position from admin a
  209. INNER JOIN user_role ur on a.id = ur.uid
  210. where ur.rid not in('1','2','3','4')
  211. group by a.id
  212. </select>
  213. <select id="selectPatentPrincipal" 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="selectCopyrightConsultant" resultMap="BaseResultMap" >
  220. select
  221. <include refid="Base_Column_List" />
  222. from admin
  223. where id <![CDATA[ <> ]]> '1'
  224. </select>
  225. <select id="selectCopyrightPrincipal" 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="selectTechprojectConsultant" resultMap="BaseResultMap" >
  232. select
  233. <include refid="Base_Column_List" />
  234. from admin
  235. where id <![CDATA[ <> ]]> '1'
  236. </select>
  237. <select id="selectTechprojectPrincipal" 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="selectRoleByPrimaryKey" parameterType="java.lang.String" resultType="String">
  244. SELECT rid FROM user_role
  245. where uid = #{uid,jdbcType=VARCHAR}
  246. </select>
  247. <select id="selectAccoutManager" resultMap="BaseResultMap">
  248. select a.id, a.name, a.position from admin a
  249. INNER JOIN user_role ur on a.id = ur.uid
  250. where ur.rid = '4'
  251. </select>
  252. <select id="selectTechnician" resultMap="BaseResultMap">
  253. select a.id, a.name, a.position from admin a
  254. INNER JOIN user_role ur on a.id = ur.uid
  255. where ur.rid not in('1','2','3','4','5','6')
  256. group by a.id
  257. </select>
  258. <select id="selectSalesman" resultMap="BaseResultMap">
  259. select a.id, a.name, a.position from admin a
  260. INNER JOIN user_role ur on a.id = ur.uid
  261. where ur.rid in ('5', '6')
  262. </select>
  263. <select id="selectContractManager" resultMap="BaseResultMap" >
  264. select a.id, a.name, a.position from admin a
  265. INNER JOIN user_role ur on a.id = ur.uid
  266. where ur.rid not in('1','2','3','4')
  267. group by a.id
  268. </select>
  269. <select id="selectTechBroder" resultMap="BaseResultMap">
  270. select a.id, a.name, a.position from admin a
  271. INNER JOIN user_role ur on a.id = ur.uid
  272. where ur.rid = 7
  273. </select>
  274. </mapper>