ExampleSysUserMapper.xml 7.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243
  1. <?xml version="1.0" encoding="UTF-8"?>
  2. <!DOCTYPE mapper
  3. PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
  4. "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
  5. <mapper namespace="com.sundata.example.mapper.ExampleSysUserMapper">
  6. <sql id="Base_Column_List">
  7. account,psw,cnname,email,orgcode,loginname,
  8. (select orgname from sys_organization a where a.orgcode=sys_user.orgcode) as orgname,
  9. mobile,tel,userState,logOn,creattime,modifypwdate,certtype,certno,tellerid,admpost,
  10. partypost,busipost,admorg
  11. </sql>
  12. <!-- 插入记录 -->
  13. <insert id="insert">
  14. insert into
  15. sys_user(account,cnname,psw,email,mobile,tel,userState,orgcode,logOn,creattime,modifypwdate
  16. ,certtype,certno,tellerid,admpost,partypost,busipost,admorg,loginname)
  17. values(#{account},#{cnname},#{psw},#{email},#{mobile},#{tel},#{userState},
  18. #{orgcode},#{logOn},#{creattime},#{modifypwdate},#{certtype},#{certno},#{tellerid},#{admpost},
  19. #{partypost},#{busipost},#{admorg},#{loginname})
  20. </insert>
  21. <!-- 根据id,修改记录 -->
  22. <update id="update">
  23. update sys_user set
  24. cnname=#{cnname},
  25. email=#{email},
  26. mobile=#{mobile},
  27. tel=#{tel},
  28. userState=#{userState},
  29. orgcode=#{orgcode},
  30. logOn=#{logOn},
  31. certtype=#{certtype},
  32. certno=#{certno},
  33. tellerid=#{tellerid},
  34. admpost=#{admpost},
  35. partypost=#{partypost},
  36. busipost=#{busipost},
  37. admorg=#{admorg}
  38. where account=#{account}
  39. </update>
  40. <!-- 根据loginname,修改记录,不修改机构 -->
  41. <update id="updateByLoginname">
  42. update sys_user set
  43. cnname=#{cnname},
  44. email=#{email},
  45. mobile=#{mobile},
  46. tel=#{tel},
  47. userState=#{userState},
  48. logOn=#{logOn},
  49. certtype=#{certtype},
  50. certno=#{certno},
  51. tellerid=#{tellerid},
  52. admpost=#{admpost},
  53. partypost=#{partypost},
  54. busipost=#{busipost},
  55. admorg=#{admorg}
  56. where loginname=#{loginname}
  57. </update>
  58. <!-- 修改记录,只修改只不为空的字段 -->
  59. <update id="updateNotEmpty">
  60. update sys_user set
  61. <trim suffixOverrides=",">
  62. <if test="cnname != null and cnname != '' ">
  63. cnname=#{cnname},
  64. </if>
  65. <if test="psw != null and psw != '' ">
  66. psw=#{psw},
  67. </if>
  68. <if test="email != null and email != '' ">
  69. email=#{email},
  70. </if>
  71. <if test="mobile != null ">
  72. mobile=#{mobile},
  73. </if>
  74. <if test="tel != null ">
  75. tel=#{tel},
  76. </if>
  77. <if test="userState != null ">
  78. userState=#{userState},
  79. </if>
  80. <if test="orgcode != null ">
  81. orgcode=#{orgcode},
  82. </if>
  83. <if test="logOn != null ">
  84. logOn=#{logOn},
  85. </if>
  86. </trim>
  87. where account=#{account}
  88. </update>
  89. <update id="updateNotEmptyByloginname">
  90. update sys_user set
  91. <trim suffixOverrides=",">
  92. <if test="cnname != null and cnname != '' ">
  93. cnname=#{cnname},
  94. </if>
  95. <if test="psw != null and psw != '' ">
  96. psw=#{psw},
  97. </if>
  98. <if test="email != null and email != '' ">
  99. email=#{email},
  100. </if>
  101. <if test="mobile != null ">
  102. mobile=#{mobile},
  103. </if>
  104. <if test="tel != null ">
  105. tel=#{tel},
  106. </if>
  107. <if test="userState != null ">
  108. userState=#{userState},
  109. </if>
  110. <if test="orgcode != null ">
  111. orgcode=#{orgcode},
  112. </if>
  113. <if test="logOn != null ">
  114. logOn=#{logOn},
  115. </if>
  116. </trim>
  117. where loginname=#{loginname}
  118. </update>
  119. <!-- 删除记录 -->
  120. <delete id="delete">
  121. delete from sys_user where account in
  122. <foreach item="item" index="index" collection="account.split(',')" open="(" separator="," close=")">
  123. #{item}
  124. </foreach>
  125. </delete>
  126. <!-- 根据id查询 系统用户 -->
  127. <select id="queryOne" resultType="com.sundata.example.model.ExampleSysUserModel">
  128. select
  129. <include refid="Base_Column_List" />
  130. from sys_user where account = #{account}
  131. </select>
  132. <select id="queryByloginname" resultType="com.sundata.example.model.ExampleSysUserModel">
  133. select
  134. <include refid="Base_Column_List" />
  135. from sys_user where loginname=#{loginname}
  136. <if test="orgcode != null and orgcode !=''">
  137. and orgcode in (
  138. <foreach item="item" index="index" collection="orgcode.split(',')" open="" separator="," close="">
  139. #{item}
  140. </foreach> )
  141. </if>
  142. </select>
  143. <select id="queryPage" resultType="com.sundata.example.model.ExampleSysUserModel">
  144. <![CDATA[select
  145. max(psw) as pws,max(cnname) as cnname,max(email) as email,max(loginname) as loginname,
  146. case when count(1)>1 then '多个机构' else max(orgname) end as orgname,
  147. max(mobile) as mobile,max(tel) as tel,min(userState) as userState,max(logOn) as logOn,max(creattime) as creattime,
  148. max(modifypwdate) as modifypwdate,max(certtype) as certtype,max(certno) as certno,max(tellerid) as tellerid,
  149. max(admpost) as admpost,max(partypost) as partypost,max(busipost) as busipost,max(admorg) as admorg,
  150. (CASE WHEN max(cnname)='test3' THEN 'checked' ELSE '' END ) checked,
  151. ]]>
  152. <if test="dbtype == 'ora' ">
  153. listagg(account,',') within group(order by loginname) as account,listagg(u.orgcode,',') within group(order by loginname) as orgcode
  154. </if>
  155. <if test="dbtype == 'mysql' ">
  156. group_concat(account) as account,group_concat(u.orgcode) as orgcode
  157. </if>
  158. <if test="dbtype == 'db2' ">
  159. listagg(account,',') as account,listagg(u.orgcode,',') as orgcode
  160. </if>
  161. from sys_user u
  162. left join sys_organization a on a.orgcode=u.orgcode
  163. <where>
  164. <if test="cnname != null and cnname != ''">
  165. and cnname like concat('%',concat(#{cnname},'%'))
  166. </if>
  167. <if test="orgcode != null and orgcode !=''">
  168. and u.orgcode in (
  169. select underorg from sys_orgrelational where orgcode=#{orgcode}
  170. )
  171. </if>
  172. <if test="logOn != null">
  173. and logOn = #{logOn}
  174. </if>
  175. <if test="userState != null">
  176. <if test="userState == '_check'">
  177. and userState != 'RESIGN'
  178. </if>
  179. <if test="userState != '_check'">
  180. and userState = #{userState}
  181. </if>
  182. </if>
  183. <if test="loginname != null and loginname !=''">
  184. and loginname like concat('%',concat(#{loginname},'%'))
  185. </if>
  186. </where>
  187. group by loginname
  188. <if test="ordercol != null and ordercol !=''">
  189. ORDER BY ${ordercol} ${soertype}
  190. </if>
  191. </select>
  192. <select id="getRoleUsersqueryPage" resultType="com.sundata.example.model.ExampleSysUserModel">
  193. select t.*,r.orgname from sys_user t left join sys_organization r on t.orgcode = r.orgcode
  194. where account
  195. <if test="canselect!=null">
  196. not
  197. </if>
  198. <![CDATA[
  199. in (select account from sys_user_role where roleid=#{roleid})
  200. and t.ORGCODE in (select org.ORGCODE from sys_organization org
  201. inner join SYS_ROLE role on roleid=#{roleid}
  202. where (role.LOWORGTYPE is null or role.LOWORGTYPE='' or role.LOWORGTYPE >= org.orgtype)
  203. AND (role.highorgtype IS NULL or role.highorgtype='' or role.highorgtype <= org.orgtype)
  204. AND org.orgcode in (select UNDERORG from SYS_ORGRELATIONAL where ORGCODE=role.orgcode))
  205. ]]>
  206. order by t.loginname
  207. </select>
  208. <select id="queryAllRole" resultType="String">
  209. select roleid from SYS_USER_ROLE where account=#{account}
  210. </select>
  211. <!-- 查询用户可配置的角色列表 -->
  212. <select id="getUserDataList" resultType="com.sundata.example.model.ExampleSysRoleModel">
  213. <![CDATA[
  214. SELECT a.roleid,a.rolename,a.remark,a.creattime ,
  215. (CASE WHEN b.ROLEID IS NOT NULL THEN 'checked' ELSE '' END ) checked
  216. FROM SYS_ROLE a
  217. inner join SYS_ORGANIZATION org on org.ORGCODE=#{orgcode,jdbcType=VARCHAR}
  218. LEFT JOIN SYS_USER_ROLE b ON a.ROLEID=b.ROLEID AND b.ACCOUNT=#{account,jdbcType=VARCHAR}
  219. WHERE a.ORGCODE IN (SELECT c.ORGCODE FROM SYS_ORGRELATIONAL c WHERE c.UNDERORG=#{orgcode,jdbcType=VARCHAR} )
  220. AND (a.loworgtype IS NULL or a.loworgtype='' or a.loworgtype >= org.orgtype)
  221. AND (a.highorgtype IS NULL or a.highorgtype='' or a.highorgtype <= org.orgtype)
  222. ]]>
  223. </select>
  224. </mapper>