SysUserCQuery.xml 10.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211
  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.bowintek.smartsearch.mapper.SysUserCQuery">
  4. <select id="selectUserByAccount" resultType="com.bowintek.smartsearch.vo.user.UserModel">
  5. select us.userId,us.name,us.loginId,us.recordStatus,us.createTime,us.createBy,us.updateTime,us.updateBy,us.userTypeId from sys_user us
  6. where RecordStatus=1 and us.loginId = #{account} and lower(us.password)=lower(#{password})
  7. </select>
  8. <select id="selectUserByUserID" resultType="com.bowintek.smartsearch.vo.user.UserModel">
  9. select us.userId,us.name,us.loginId,us.recordStatus,us.createTime,us.createBy,us.updateTime,us.updateBy,us.userTypeId from sys_user us
  10. where RecordStatus=1 and us.userId = #{userId}
  11. </select>
  12. <select id="selectUserList" resultType="java.util.HashMap">
  13. select us.*,dic.Name as UserTypeName ,urole.roleName from sys_user us
  14. left join sys_dictionary_item dic on dic.Value = us.UserTypeID and dic.DictionaryCode='UserType'
  15. left join (
  16. select usr.UserID, group_concat(sr.Name) roleName from sys_user_sys_role usr
  17. inner join sys_role sr on usr.RoleID = sr.RoleID
  18. group by usr.UserID
  19. ) urole on us.UserID=urole.UserID
  20. where 1=1
  21. <if test="username != null and username != ''">
  22. and us.Name like Concat('%',#{username},'%')
  23. </if>
  24. <if test="loginid != null and loginid != ''">
  25. and us.loginid like Concat('%',#{loginid},'%')
  26. </if>
  27. <if test="recordStatu != null">
  28. and us.RecordStatus =#{recordStatu}
  29. </if>
  30. <if test="userType != null">
  31. and us.UserTypeID =#{userType}
  32. </if>
  33. order by createTime desc
  34. </select>
  35. <select id="selectUserDataRange" resultType="java.util.HashMap">
  36. select mu.MenuNo,MIN(datarange.DataRangeID) as DataRangeID,0 as OrderNo
  37. from sys_user_sys_role userrole
  38. inner join sys_role_datarange datarange on userrole.RoleID=datarange.RoleID
  39. inner join sys_menu mu on datarange.FunctionCode = mu.FunctionCode
  40. where userrole.UserID=#{userID}
  41. group by mu.MenuNo
  42. union all
  43. select distinct menu.MenuNo,MIN(role.DefaultDataRange) as DataRangeID,1 as OrderNo
  44. from sys_menu menu
  45. inner join sys_role_sys_function_code rolecode on menu.FunctionCode=rolecode.FunctionCode
  46. inner join sys_user_sys_role userrole on rolecode.RoleID=userrole.RoleID
  47. inner join sys_role role on userrole.RoleID=role.RoleID
  48. where userrole.UserID=#{userID}
  49. group by menu.MenuNo
  50. </select>
  51. <select id="selectUserInfo" resultType="com.bowintek.smartsearch.vo.user.UserInfoModel">
  52. select us.userId,us.name,us.loginID
  53. ,us.userTypeID
  54. from sys_user us
  55. where us.userId = #{userId}
  56. </select>
  57. <select id="selectUserMenuList" resultType="com.bowintek.smartsearch.model.SysMenu">
  58. select distinct mu.menuNo,mu.orderNo,mu.menuName,mu.icon,mu.viewPath,mu.url,mu.parentMenuNo,mu.isTopMenu,mu.isVisible,mu.isLeaf,mu.functionCode
  59. from sys_menu mu
  60. inner join (
  61. with recursive type_cte as (
  62. select MenuNo,MenuName,ParentMenuNo from sys_menu where MenuNo in(
  63. select m.MenuNo from sys_menu m
  64. inner join sys_function_code fc on m.FunctionCode = fc.FunctionCode
  65. inner join sys_role_sys_function_code rfc on fc.FunctionCode = rfc.FunctionCode
  66. inner join sys_user_sys_role ur on rfc.RoleID = ur.RoleID
  67. where 1=1 and ur.userID=#{userID}
  68. )
  69. union all
  70. select t.MenuNo,concat(type_cte2.MenuName,'>',t.MenuName),t.ParentMenuNo
  71. from sys_menu t
  72. inner join type_cte type_cte2 on t.MenuNo = type_cte2.ParentMenuNo
  73. )
  74. select
  75. MenuNo, MenuName, ParentMenuNo
  76. from type_cte
  77. ) mu2 on mu.MenuNo = mu2.MenuNo or (mu.ParentMenuNo = mu2.MenuNo and mu.IsVisible=0)
  78. where mu.recordStatus=1
  79. order by mu.orderNo
  80. </select>
  81. <select id="selectUserShortcutMenuList" resultType="com.bowintek.smartsearch.model.SysMenu">
  82. select distinct mu.menuNo,mu.orderNo,mu.menuName,mu.icon,mu.viewPath,mu2.url,mu.parentMenuNo,mu.isTopMenu,mu.isVisible,mu.isLeaf,mu.functionCode,mu.shortcutIcon
  83. from sys_menu mu
  84. inner join (
  85. with recursive type_cte as (
  86. select m.menuNo,m.menuName,m.parentMenuNo,m.url,m.orderNo
  87. from sys_menu m
  88. inner join sys_function_code fc on m.FunctionCode = fc.FunctionCode
  89. inner join sys_role_sys_function_code rfc on fc.FunctionCode = rfc.FunctionCode
  90. inner join sys_user_sys_role ur on rfc.RoleID = ur.RoleID
  91. inner join sys_role_sys_menu_shortcut rms on rms.MenuNo = m.MenuNo and rms.RoleID = ur.RoleID
  92. where 1=1 and ur.userID=#{userID} group by m.menuNo,m.menuName,m.parentMenuNo,m.url
  93. union all
  94. select type_cte2.menuNo,concat(t.menuName,'>',type_cte2.menuName),t.parentMenuNo, case when locate(t.url,type_cte2.url)=1 then type_cte2.url else concat(t.url,type_cte2.url) end,concat(t.orderNo,type_cte2.orderNo)
  95. from sys_menu t
  96. inner join type_cte type_cte2 on t.MenuNo = type_cte2.ParentMenuNo
  97. )
  98. select
  99. MenuNo, MenuName, ParentMenuNo,url,orderNo
  100. from type_cte
  101. ) mu2 on mu.MenuNo = mu2.MenuNo or (mu.ParentMenuNo = mu2.MenuNo and mu.IsVisible=0)
  102. where mu.recordStatus=1 and mu2.ParentMenuNo is null
  103. order by mu.orderNo
  104. </select>
  105. <select id="selectUserByLoginID" resultType="com.bowintek.smartsearch.vo.user.UserModel">
  106. select us.userId,us.name,us.loginId from sys_user us where us.loginID = #{loginID}
  107. </select>
  108. <select id="selectUserCollege" resultType="java.lang.String">
  109. select CollegeID from sys_user_cf_college where userID= #{userID}
  110. union
  111. select CollegeID from cf_teacher where userID= #{userID}
  112. </select>
  113. <select id="selectUserMajor" resultType="java.lang.String">
  114. select MajorID from sys_user_cf_major where userID= #{userID}
  115. union
  116. select mj.MajorID from
  117. (
  118. select CollegeID from sys_user_cf_college where userID= #{userID}
  119. union
  120. select CollegeID from cf_teacher where userID= #{userID}
  121. ) t
  122. inner join cf_major mj on t.CollegeID = mj.CollegeID
  123. where (select count(1) as count from sys_user_cf_major where userID= #{userID}) = 0
  124. </select>
  125. <select id="selectUserMajorGrade" resultType="java.lang.String">
  126. select MajorGradeID from sys_user_cf_major_grade where userID= #{userID}
  127. union
  128. select mg.MajorGradeID from
  129. (
  130. select CollegeID from sys_user_cf_college where userID= #{userID}
  131. union
  132. select CollegeID from cf_teacher where userID= #{userID}
  133. ) t
  134. inner join cf_major mj on t.CollegeID = mj.CollegeID
  135. inner join cf_major_grade mg on mg.MajorID = mj.MajorID
  136. where (select count(1) as count from sys_user_cf_major_grade where userID= #{userID}) = 0
  137. </select>
  138. <select id="selectUserMajorClass" resultType="java.lang.String">
  139. select MajorClassID from sys_user_cf_major_class where userID= #{userID}
  140. union
  141. select mc.MajorClassID from
  142. (
  143. select CollegeID from sys_user_cf_college where userID= #{userID}
  144. union
  145. select CollegeID from cf_teacher where userID= #{userID}
  146. ) t
  147. inner join cf_major mj on t.CollegeID = mj.CollegeID
  148. inner join cf_major_grade mg on mg.MajorID = mj.MajorID
  149. inner join cf_major_class mc on mg.MajorGradeID = mc.MajorGradeID
  150. where (select count(1) as count from sys_user_cf_major_class where userID= #{userID}) = 0
  151. </select>
  152. <insert id="insertUser" parameterType="java.util.List">
  153. insert into Sys_User(UserID, UserTypeID,LoginID,Password,Name,RecordStatus,CreateBy,CreateTime,UpdateBy,UpdateTime)
  154. values
  155. <foreach collection="dataList" item="item" separator=",">
  156. (#{item.userID},#{item.userTypeID},#{item.loginID},#{item.password},#{item.name},#{item.recordStatus},#{item.createBy},#{item.createTime},null,null)
  157. </foreach>
  158. </insert>
  159. <insert id="insertUserRole" parameterType="java.util.List">
  160. insert into sys_user_sys_role(UserID, RoleID)
  161. values
  162. <foreach collection="dataList" item="item" separator=",">
  163. (#{item.userID},#{item.roleID})
  164. </foreach>
  165. </insert>
  166. <update id="batchUpdateStudentUserID">
  167. <foreach collection="dataList" item="item" separator=";">
  168. update
  169. `cf_student`
  170. set
  171. `userID` = #{item.userID},
  172. `updateBy` = #{updateBy},
  173. `updateTime` = sysdate()
  174. where
  175. studentID = #{item.studentID}
  176. and userID is null
  177. </foreach>
  178. </update>
  179. <select id="selectUserPerms" resultType="java.lang.String">
  180. select fc.functionCode
  181. from sys_function_code fc
  182. inner join sys_role_sys_function_code rfc on fc.FunctionCode = rfc.FunctionCode
  183. inner join sys_user_sys_role ur on rfc.RoleID = ur.RoleID
  184. where 1=1 and ur.userID=#{userID}
  185. </select>
  186. <delete id="deleteUserRoleByUserId">
  187. delete from sys_user_sys_role where 1=1
  188. and userID in
  189. <foreach collection="userIDList" item="userID" index="index" open="(" close=")" separator=",">
  190. #{userID}
  191. </foreach>
  192. </delete>
  193. </mapper>