SysUserMapper.xml 28 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626
  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.dgtly.system.mapper.SysUserMapper">
  6. <resultMap id="SysUserResult" type="SysUser">
  7. <id property="userId" column="user_id" />
  8. <result property="companyId" column="company_id" />
  9. <result property="deptId" column="dept_id" />
  10. <result property="loginName" column="login_name" />
  11. <result property="userName" column="user_name" />
  12. <result property="email" column="email" />
  13. <result property="phonenumber" column="phonenumber" />
  14. <result property="sex" column="sex" />
  15. <result property="avatar" column="avatar" />
  16. <result property="password" column="password" />
  17. <result property="salt" column="salt" />
  18. <result property="idType" column="id_type" />
  19. <result property="idNumber" column="id_number" />
  20. <result property="accountId" column="account_id" />
  21. <result property="isAuthentication" column="is_authentication" />
  22. <result property="personAttestationTime" column="person_attestation_time" />
  23. <result property="receiveUrlMobileNo" column="receive_url_mobile_no" />
  24. <result property="status" column="status" />
  25. <result property="delFlag" column="del_flag" />
  26. <result property="loginIp" column="login_ip" />
  27. <result property="loginDate" column="login_date" />
  28. <result property="createBy" column="create_by" />
  29. <result property="createTime" column="create_time" />
  30. <result property="updateBy" column="update_by" />
  31. <result property="updateTime" column="update_time" />
  32. <result property="remark" column="remark" />
  33. <result property="isConsignee" column="is_consignee" />
  34. <result property="isIndependently" column="is_independently" />
  35. <result property="isSelfDelivery" column="is_self_delivery" />
  36. <result property="isSync" column="is_sync" />
  37. <result property="quit" column="quit" />
  38. <result property="isAuthentication" column="is_authentication" />
  39. <result property="personAttestationTime" column="person_attestation_time" />
  40. <result property="isOrgAuthentication" column="is_org_authentication" />
  41. <result property="orgAttestationTime" column="org_attestation_time" />
  42. <!--<result property="salesLevel" column="sales_level" />-->
  43. <!--<result property="orgName" column="org_name" />-->
  44. <!--<result property="orgCode" column="org_code" />-->
  45. <association property="dept" column="dept_id" javaType="SysDept" resultMap="deptResult" />
  46. <association property="company" column="company_id" javaType="SysCompany" resultMap="companyResult" />
  47. <association property="sysUserExt" column="user_id" javaType="SysUserExt" resultMap="SysUserExtResult" />
  48. <collection property="roles" javaType="java.util.List" resultMap="RoleResult" />
  49. </resultMap>
  50. <resultMap id="deptResult" type="SysDept">
  51. <id property="deptId" column="dept_id" />
  52. <result property="parentId" column="parent_id" />
  53. <result property="deptName" column="dept_name" />
  54. <result property="orderNum" column="order_num" />
  55. <result property="leader" column="leader" />
  56. <result property="status" column="dept_status" />
  57. </resultMap>
  58. <resultMap id="companyResult" type="SysCompany">
  59. <id property="id" column="id" />
  60. <result property="companyName" column="company_name" />
  61. </resultMap>
  62. <resultMap id="RoleResult" type="SysRole">
  63. <id property="roleId" column="role_id" />
  64. <result property="roleName" column="role_name" />
  65. <result property="roleKey" column="role_key" />
  66. <result property="roleSort" column="role_sort" />
  67. <result property="dataScope" column="data_scope" />
  68. <result property="status" column="role_status" />
  69. </resultMap>
  70. <resultMap id="SysUserExtResult" type="SysUserExt" >
  71. <result property="userId" column="user_id" />
  72. <result property="orgCode" column="org_code" />
  73. <result property="salesLevel" column="sales_level" />
  74. <result property="orgName" column="org_name" />
  75. <result property="sapEmployeeId" column="sap_employee_id" />
  76. <result property="bossEmployeeId" column="boss_employee_id" />
  77. <result property="bossName" column="boss_name" />
  78. <result property="customerCode" column="customer_code" />
  79. <result property="isCustomerManager" column="is_customer_manager" />
  80. <result property="postName" column="post_name" />
  81. <result property="postCode" column="post_code" />
  82. <result property="identity" column="identity" />
  83. </resultMap>
  84. <sql id="selectUserVo">
  85. select u.user_id,u.company_id, u.dept_id, u.login_name, u.user_name, u.email, u.avatar, u.phonenumber, u.sex, u.password, u.salt,u.id_type,u.id_number,u.account_id,u.is_authentication,u.receive_url_mobile_no, u.status,
  86. u.del_flag, u.login_ip, u.login_date, u.create_time, u.remark,u.is_consignee,u.person_attestation_time,u.is_independently,u.is_self_delivery,is_sync,
  87. c.company_name,u.quit,
  88. d.dept_id, d.parent_id, d.dept_name, d.order_num, d.leader, d.status as dept_status,
  89. r.role_id, r.role_name, r.role_key, r.role_sort, r.data_scope, r.status as role_status,
  90. suse.sales_level,suse.org_name,suse.org_code,suse.sap_employee_id,suse.boss_employee_id,suse.boss_name,suse.customer_code,suse.is_customer_manager,
  91. suse.post_name,suse.post_code,suse.identity
  92. from sys_user u
  93. left join sys_dept d on u.dept_id = d.dept_id
  94. left join sys_company c on u.company_id = c.id
  95. left join sys_user_role ur on u.user_id = ur.user_id
  96. left join sys_role r on r.role_id = ur.role_id
  97. left join sys_user_ext suse on suse.user_id = u.user_id
  98. </sql>
  99. <select id="selectUserList" parameterType="SysUser" resultMap="SysUserResult">
  100. select u.user_id,u.company_id, u.dept_id, u.login_name, u.user_name,u.id_type,u.id_number,u.account_id,u.is_authentication,u.receive_url_mobile_no, u.email, u.avatar,
  101. u.phonenumber, u.password, u.sex, u.salt, u.status, u.del_flag,u.quit,u.is_independently,u.is_self_delivery,
  102. u.login_ip, u.login_date, u.create_by, u.create_time, u.remark,
  103. d.dept_name, d.leader,
  104. suse.identity,suse.sales_level,suse.org_name,suse.org_code,suse.post_name,suse.is_customer_manager,ce.is_authentication is_org_authentication,ce.org_attestation_time
  105. from sys_user u
  106. left join sys_dept d on u.dept_id = d.dept_id
  107. left join sys_company c on u.company_id = c.id
  108. left join sys_user_ext suse on suse.user_id = u.user_id
  109. LEFT JOIN customers_ext ce ON suse.org_code = ce.chains_code
  110. where u.del_flag = '0'
  111. <if test="loginName != null and loginName != ''">
  112. AND u.login_name like concat('%', #{loginName}, '%')
  113. </if>
  114. <if test="status != null and status != ''">
  115. AND u.status = #{status}
  116. </if>
  117. <if test="sysUserExt != null and sysUserExt.salesLevel !=null
  118. and sysUserExt.salesLevel != ''">
  119. AND suse.sales_level = #{sysUserExt.salesLevel}
  120. </if>
  121. <if test="sysUserExt != null and sysUserExt.orgCode !=null
  122. and sysUserExt.orgCode != ''">
  123. AND suse.org_code = #{sysUserExt.orgCode}
  124. </if>
  125. <if test="sysUserExt != null and sysUserExt.orgName !=null
  126. and sysUserExt.orgName != ''">
  127. AND suse.org_name like concat('%', #{sysUserExt.orgName}, '%')
  128. </if>
  129. <if test="sysUserExt != null and sysUserExt.postName !=null
  130. and sysUserExt.postName != ''">
  131. AND suse.post_name = #{sysUserExt.postName}
  132. </if>
  133. <if test="sysUserExt != null and sysUserExt.identity !=null
  134. and sysUserExt.identity != ''">
  135. AND suse.identity = #{sysUserExt.identity}
  136. </if>
  137. <if test="userName != null and userName != ''">
  138. AND u.user_name like concat('%', #{userName}, '%')
  139. </if>
  140. <if test="phonenumber != null and phonenumber != ''">
  141. AND u.phonenumber like concat('%', #{phonenumber}, '%')
  142. </if>
  143. <if test="params.beginTime != null and params.beginTime != ''"><!-- 开始时间检索 -->
  144. AND date_format(u.create_time,'%y%m%d') &gt;= date_format(#{params.beginTime},'%y%m%d')
  145. </if>
  146. <if test="params.endTime != null and params.endTime != ''"><!-- 结束时间检索 -->
  147. AND date_format(u.create_time,'%y%m%d') &lt;= date_format(#{params.endTime},'%y%m%d')
  148. </if>
  149. <if test="deptId != null and deptId != 0">
  150. AND (u.dept_id = #{deptId} OR u.dept_id IN ( SELECT t.dept_id FROM sys_dept t WHERE FIND_IN_SET (#{deptId},ancestors) ))
  151. </if>
  152. <if test="companyId != null and companyId != 0">
  153. AND u.company_id = #{companyId}
  154. </if>
  155. <if test="isAuthentication != null and isAuthentication != ''">
  156. AND u.is_authentication = #{isAuthentication}
  157. </if>
  158. <if test="isOrgAuthentication != null and isOrgAuthentication != '' and isOrgAuthentication =='1'.toString()">
  159. AND ce.is_authentication = '1'
  160. </if>
  161. <if test="isOrgAuthentication != null and isOrgAuthentication != '' and isOrgAuthentication =='0'.toString()">
  162. AND (ce.is_authentication = '0' or ce.is_authentication is null)
  163. </if>
  164. <!-- 数据范围过滤 -->
  165. ${params.dataScope}
  166. </select>
  167. <select id="selectAllocatedList" parameterType="SysUser" resultMap="SysUserResult">
  168. select distinct u.user_id,u.company_id, u.dept_id,u.id_type,u.id_number,u.account_id,u.is_authentication,u.receive_url_mobile_no, u.login_name, u.user_name, u.email, u.avatar, u.phonenumber, u.status, u.create_time
  169. from sys_user u
  170. left join sys_dept d on u.dept_id = d.dept_id
  171. left join sys_company c on u.company_id = c.id
  172. left join sys_user_role ur on u.user_id = ur.user_id
  173. left join sys_role r on r.role_id = ur.role_id
  174. where u.del_flag = '0' and r.role_id = #{roleId}
  175. <if test="loginName != null and loginName != ''">
  176. AND u.login_name like concat('%', #{loginName}, '%')
  177. </if>
  178. <if test="phonenumber != null and phonenumber != ''">
  179. AND u.phonenumber like concat('%', #{phonenumber}, '%')
  180. </if>
  181. <if test="companyId != null and companyId != ''">
  182. AND u.company_id like #{companyId}
  183. </if>
  184. <!-- 数据范围过滤 -->
  185. ${params.dataScope}
  186. </select>
  187. <select id="selectUnallocatedList" parameterType="SysUser" resultMap="SysUserResult">
  188. select distinct u.user_id,u.company_id,u.id_type,u.id_number,u.account_id,u.is_authentication,u.receive_url_mobile_no, u.dept_id, u.login_name, u.user_name, u.email, u.avatar, u.phonenumber, u.status, u.create_time
  189. from sys_user u
  190. left join sys_dept d on u.dept_id = d.dept_id
  191. left join sys_company c on u.company_id = c.id
  192. left join sys_user_role ur on u.user_id = ur.user_id
  193. left join sys_role r on r.role_id = ur.role_id
  194. where u.del_flag = '0' and (r.role_id != #{roleId} or r.role_id IS NULL)
  195. and u.user_id not in (select u.user_id from sys_user u inner join sys_user_role ur on u.user_id = ur.user_id and ur.role_id = #{roleId})
  196. <if test="loginName != null and loginName != ''">
  197. AND u.login_name like concat('%', #{loginName}, '%')
  198. </if>
  199. <if test="phonenumber != null and phonenumber != ''">
  200. AND u.phonenumber like concat('%', #{phonenumber}, '%')
  201. </if>
  202. <if test="companyId != null and companyId != ''">
  203. AND u.company_id like #{companyId}
  204. </if>
  205. <!-- 数据范围过滤 -->
  206. ${params.dataScope}
  207. </select>
  208. <select id="selectUserByLoginName" parameterType="String" resultMap="SysUserResult">
  209. <include refid="selectUserVo"/>
  210. where u.login_name = #{userName} and u.quit is null GROUP BY login_name
  211. </select>
  212. <select id="selectUserByIsManager" resultType="java.lang.String">
  213. select u.login_name
  214. from sys_user u
  215. left join sys_user_ext suse on suse.user_id = u.user_id
  216. where 1=1
  217. <if test="isCustomerManager !=null ">
  218. and suse.is_customer_manager like concat('%',#{isCustomerManager}, '%')
  219. </if>
  220. and u.quit is null
  221. and u.login_name is not null
  222. </select>
  223. <select id="selectAllUser" parameterType="String" resultMap="SysUserResult">
  224. SELECT
  225. u.user_id,
  226. u.company_id,
  227. u.dept_id,
  228. u.login_name,
  229. u.user_name,
  230. u.email,
  231. u.avatar,
  232. u.phonenumber,
  233. u.sex,
  234. u.PASSWORD,
  235. u.salt,
  236. u.id_type,
  237. u.id_number,
  238. u.account_id,
  239. u.is_authentication,
  240. u.is_independently,
  241. u.is_self_delivery,
  242. u.receive_url_mobile_no,
  243. u.STATUS,
  244. u.del_flag,
  245. u.login_ip,
  246. u.login_date,
  247. u.create_time,
  248. u.remark,
  249. u.is_consignee,
  250. u.person_attestation_time,
  251. is_sync,
  252. u.quit,
  253. suse.sales_level,
  254. suse.org_name,
  255. suse.org_code,
  256. suse.sap_employee_id,
  257. suse.boss_employee_id,
  258. suse.boss_name,
  259. suse.customer_code,
  260. suse.is_customer_manager,
  261. suse.post_name,
  262. suse.post_code,
  263. suse.identity
  264. FROM
  265. sys_user u
  266. LEFT JOIN sys_user_ext suse ON suse.user_id = u.user_id
  267. where suse.is_customer_manager is not null and suse.is_customer_manager !=''
  268. </select>
  269. <select id="selectUserByPhoneNumber" parameterType="String" resultMap="SysUserResult">
  270. <include refid="selectUserVo"/>
  271. where u.phonenumber = #{phonenumber}
  272. </select>
  273. <select id="selectUserByEmail" parameterType="String" resultMap="SysUserResult">
  274. <include refid="selectUserVo"/>
  275. where u.email = #{email}
  276. </select>
  277. <select id="checkLoginNameUnique" resultType="int">
  278. select count(1) from sys_user where login_name=#{loginName}
  279. </select>
  280. <select id="checkPhoneUnique" resultMap="SysUserResult">
  281. select user_id, phonenumber from sys_user where phonenumber=#{phonenumber}
  282. </select>
  283. <select id="checkEmailUnique" resultMap="SysUserResult">
  284. select user_id, email from sys_user where email=#{email}
  285. </select>
  286. <select id="selectUserById" parameterType="Long" resultMap="SysUserResult">
  287. <include refid="selectUserVo"/>
  288. where u.user_id = #{userId}
  289. </select>
  290. <delete id="deleteUserById" parameterType="Long">
  291. delete from sys_user where user_id = #{userId}
  292. </delete>
  293. <delete id="deleteUserByLoginName" parameterType="Long">
  294. delete from sys_user where login_name = #{loginName}
  295. </delete>
  296. <delete id="deleteUserByIds" parameterType="Long">
  297. update sys_user set del_flag = '2' where user_id in
  298. <foreach collection="array" item="userId" open="(" separator="," close=")">
  299. #{userId}
  300. </foreach>
  301. </delete>
  302. <update id="updateUser" parameterType="SysUser">
  303. update sys_user
  304. <set>
  305. <if test="deptId != null and deptId != 0">dept_id = #{deptId},</if>
  306. <if test="loginName != null and loginName != ''">login_name = #{loginName},</if>
  307. <if test="userName != null and userName != ''">user_name = #{userName},</if>
  308. <if test="email != null and email != ''">email = #{email},</if>
  309. <if test="phonenumber != null and phonenumber != ''">phonenumber = #{phonenumber},</if>
  310. <if test="sex != null and sex != ''">sex = #{sex},</if>
  311. <if test="avatar != null and avatar != ''">avatar = #{avatar},</if>
  312. <if test="password != null and password != ''">password = #{password},</if>
  313. <if test="salt != null and salt != ''">salt = #{salt},</if>
  314. <if test="idType != null and idType != ''">id_type = #{idType},</if>
  315. <if test="idNumber != null and idNumber != ''">id_number = #{idNumber},</if>
  316. <if test="accountId != null and accountId != ''">account_id = #{accountId},</if>
  317. <if test="isAuthentication != null and isAuthentication != ''">is_authentication = #{isAuthentication},</if>
  318. <if test="isIndependently != null ">is_independently = #{isIndependently},</if>
  319. <if test="isSelfDelivery !=null">is_self_delivery =#{isSelfDelivery},</if>
  320. <if test="personAttestationTime != null">person_attestation_time = #{personAttestationTime},</if>
  321. <if test="receiveUrlMobileNo != null and receiveUrlMobileNo != ''">receive_url_mobile_no = #{receiveUrlMobileNo},</if>
  322. <if test="status != null and status != ''">status = #{status},</if>
  323. <if test="loginIp != null and loginIp != ''">login_ip = #{loginIp},</if>
  324. <if test="loginDate != null">login_date = #{loginDate},</if>
  325. <if test="updateBy != null and updateBy != ''">update_by = #{updateBy},</if>
  326. <if test="remark != null">remark = #{remark},</if>
  327. <if test="isConsignee != null">is_consignee = #{isConsignee},</if>
  328. <if test="isSync != null">is_sync = #{isSync},</if>
  329. <if test="quit != null">quit = #{quit},</if>
  330. update_time = sysdate()
  331. </set>
  332. where user_id = #{userId}
  333. </update>
  334. <update id="updateUserByLoginName" parameterType="SysUser">
  335. update sys_user
  336. <set>
  337. <if test="deptId != null and deptId != 0">dept_id = #{deptId},</if>
  338. <if test="userName != null and userName != ''">user_name = #{userName},</if>
  339. <if test="email != null and email != ''">email = #{email},</if>
  340. <if test="phonenumber != null and phonenumber != ''">phonenumber = #{phonenumber},</if>
  341. <if test="sex != null and sex != ''">sex = #{sex},</if>
  342. <if test="avatar != null and avatar != ''">avatar = #{avatar},</if>
  343. <if test="password != null and password != ''">password = #{password},</if>
  344. <if test="salt != null and salt != ''">salt = #{salt},</if>
  345. <if test="idType != null and idType != ''">id_type = #{idType},</if>
  346. <if test="idNumber != null and idNumber != ''">id_number = #{idNumber},</if>
  347. <if test="accountId != null and accountId != ''">account_id = #{accountId},</if>
  348. <if test="isAuthentication != null and isAuthentication != ''">is_authentication = #{isAuthentication},</if>
  349. <if test="personAttestationTime != null">person_attestation_time = #{personAttestationTime},</if>
  350. <if test="receiveUrlMobileNo != null and receiveUrlMobileNo != ''">receive_url_mobile_no = #{receiveUrlMobileNo},</if>
  351. <if test="status != null and status != ''">status = #{status},</if>
  352. <if test="loginIp != null and loginIp != ''">login_ip = #{loginIp},</if>
  353. <if test="loginDate != null">login_date = #{loginDate},</if>
  354. <if test="updateBy != null and updateBy != ''">update_by = #{updateBy},</if>
  355. <if test="remark != null">remark = #{remark},</if>
  356. <if test="isConsignee != null">is_consignee = #{isConsignee},</if>
  357. <if test="isSync != null">is_sync = #{isSync},</if>
  358. <if test="isIndependently != null ">is_independently = #{isIndependently},</if>
  359. <if test="isSelfDelivery !=null">is_self_delivery =#{isSelfDelivery},</if>
  360. update_time = sysdate()
  361. </set>
  362. where login_name = #{loginName}
  363. </update>
  364. <update id="updateIsAuthentication" parameterType="String">
  365. update sys_user set is_authentication = #{isAuthentication} ,person_attestation_time = now()
  366. where account_id = #{accountId}
  367. </update>
  368. <update id="changeStatus">
  369. update sys_user set del_flag = #{status}
  370. where company_id = #{companyId}
  371. <if test="status == 0 ">and del_flag = 3 </if>
  372. <if test="status == 3 ">and del_flag = 0 </if>
  373. </update>
  374. <insert id="insertUser" parameterType="SysUser" useGeneratedKeys="true" keyProperty="userId">
  375. <selectKey keyProperty="userId" order="AFTER" resultType="java.lang.Long">
  376. select LAST_INSERT_ID();
  377. </selectKey>
  378. insert into sys_user(
  379. <if test="userId != null and userId != 0">user_id,</if>
  380. <if test="deptId != null and deptId != 0">dept_id,</if>
  381. <if test="companyId != null and companyId != 0">company_id,</if>
  382. <if test="loginName != null and loginName != ''">login_name,</if>
  383. <if test="userName != null and userName != ''">user_name,</if>
  384. <if test="email != null and email != ''">email,</if>
  385. <if test="avatar != null and avatar != ''">avatar,</if>
  386. <if test="phonenumber != null and phonenumber != ''">phonenumber,</if>
  387. <if test="sex != null and sex != ''">sex,</if>
  388. <if test="password != null and password != ''">password,</if>
  389. <if test="salt != null and salt != ''">salt,</if>
  390. <if test="status != null and status != ''">status,</if>
  391. <if test="createBy != null and createBy != ''">create_by,</if>
  392. <if test="remark != null and remark != ''">remark,</if>
  393. create_time
  394. )values(
  395. <if test="userId != null and userId != ''">#{userId},</if>
  396. <if test="deptId != null and deptId != ''">#{deptId},</if>
  397. <if test="companyId != null and companyId != 0">#{companyId},</if>
  398. <if test="loginName != null and loginName != ''">#{loginName},</if>
  399. <if test="userName != null and userName != ''">#{userName},</if>
  400. <if test="email != null and email != ''">#{email},</if>
  401. <if test="avatar != null and avatar != ''">#{avatar},</if>
  402. <if test="phonenumber != null and phonenumber != ''">#{phonenumber},</if>
  403. <if test="sex != null and sex != ''">#{sex},</if>
  404. <if test="password != null and password != ''">#{password},</if>
  405. <if test="salt != null and salt != ''">#{salt},</if>
  406. <if test="status != null and status != ''">#{status},</if>
  407. <if test="createBy != null and createBy != ''">#{createBy},</if>
  408. <if test="remark != null and remark != ''">#{remark},</if>
  409. sysdate()
  410. )
  411. </insert>
  412. <select id="selectAllUserLoginName" resultType="java.lang.String">
  413. select u.login_name
  414. from sys_user u where u.quit is null
  415. </select>
  416. <select id="selectDiyUserLoginName" resultType="java.lang.String">
  417. select distinct(u.login_name)
  418. from sys_user u left join sys_user_ext b on u.user_id = b.user_id where b.post_name='DIY经销商' and u.quit is null
  419. </select>
  420. <insert id="insertUserNoKey" parameterType="SysUser" >
  421. insert into sys_user(
  422. <if test="userId != null and userId != 0">user_id,</if>
  423. <if test="deptId != null and deptId != 0">dept_id,</if>
  424. <if test="loginName != null and loginName != ''">login_name,</if>
  425. <if test="userName != null and userName != ''">user_name,</if>
  426. <if test="email != null and email != ''">email,</if>
  427. <if test="phonenumber != null and phonenumber != ''">phonenumber,</if>
  428. <if test="sex != null and sex != ''">sex,</if>
  429. <if test="password != null and password != ''">password,</if>
  430. <if test="salt != null and salt != ''">salt,</if>
  431. <if test="status != null and status != ''">status,</if>
  432. create_time
  433. )values(
  434. <if test="userId != null and userId != ''">#{userId},</if>
  435. <if test="deptId != null and deptId != ''">#{deptId},</if>
  436. <if test="loginName != null and loginName != ''">#{loginName},</if>
  437. <if test="userName != null and userName != ''">#{userName},</if>
  438. <if test="email != null and email != ''">#{email},</if>
  439. <if test="phonenumber != null and phonenumber != ''">#{phonenumber},</if>
  440. <if test="sex != null and sex != ''">#{sex},</if>
  441. <if test="password != null and password != ''">#{password},</if>
  442. <if test="salt != null and salt != ''">#{salt},</if>
  443. <if test="status != null and status != ''">#{status},</if>
  444. sysdate()
  445. )
  446. </insert>
  447. <select id="selectUserByEmplyeeId" parameterType="String" resultMap="SysUserResult">
  448. <include refid="selectUserVo"/>
  449. where suse.sap_employee_id = #{emplyeeId}
  450. </select>
  451. <select id="selectLoginNamesByCostumerCode" resultType="java.util.Map" parameterType="String">
  452. select sue.org_code customer_code,GROUP_CONCAT(su.login_name SEPARATOR '|') touser from sys_user su
  453. left join sys_user_ext sue on sue.user_id = su.user_id
  454. where sue.org_code in
  455. <foreach collection="array" item="customerCode" open="(" separator="," close=")">
  456. #{customerCode}
  457. </foreach>
  458. and sue.is_customer_manager != 0
  459. GROUP BY sue.org_code
  460. </select>
  461. <select id="selectLoginNamesByOrgCodeSelf" resultType="java.util.Map" parameterType="String">
  462. select sue.org_code customer_code,GROUP_CONCAT(su.login_name SEPARATOR '|') touser from sys_user su
  463. left join sys_user_ext sue on sue.user_id = su.user_id
  464. where 1=1
  465. and sue.org_code =#{customerCode}
  466. and sue.is_customer_manager in ('1','2','3')
  467. and sue.is_customer_manager != 0
  468. and su.quit is null
  469. and su.del_flag = 0
  470. GROUP BY sue.org_code
  471. </select>
  472. <select id="selectLoginNameByCustomerCode" resultType="java.lang.String">
  473. SELECT
  474. u.login_name
  475. FROM
  476. order_sales_sum_tuc_customer c
  477. LEFT JOIN sys_user_ext e ON e.sap_employee_id = c.emp_id
  478. LEFT JOIN sys_user u ON u.user_id = e.user_id
  479. WHERE
  480. c.customer_id =#{customerId}
  481. and u.quit is null
  482. and u.del_flag = 0
  483. GROUP BY
  484. u.user_id limit 1
  485. </select>
  486. <select id="selectLoginNamesByCustomerModelVO" resultType="java.util.Map" parameterType="String">
  487. select DISTINCT sue.org_code customer_code,GROUP_CONCAT(su.login_name SEPARATOR '|') touser from sys_user su
  488. left join sys_user_ext sue on sue.user_id = su.user_id
  489. where 1=1
  490. <if test="customerCode !=null and customerCode !='' ">
  491. and sue.org_code =#{customerCode}
  492. </if>
  493. <if test="customerType !=null and customerType !='' and customerType =='D9' ">
  494. and sue.identity in ('1')
  495. </if>
  496. <if test="customerType !=null and customerType !='' and customerType =='Y9' ">
  497. and sue.identity in ('2')
  498. </if>
  499. and sue.is_customer_manager != 0
  500. GROUP BY sue.org_code
  501. </select>
  502. <select id="selectLoginNamesByCostumerCode1" resultType="java.util.Map" parameterType="String">
  503. select DISTINCT sue.org_code customer_code,GROUP_CONCAT(su.login_name SEPARATOR '|') touser from sys_user su
  504. left join sys_user_ext sue on sue.user_id = su.user_id
  505. where sue.org_code in
  506. <foreach collection="array" item="customerCode" open="(" separator="," close=")">
  507. #{customerCode}
  508. </foreach>
  509. GROUP BY sue.org_code
  510. </select>
  511. <select id="selectLoginNamesByEmployeeCode" resultType="Map" parameterType="String">
  512. select DISTINCT sue.sap_employee_id employee_code,GROUP_CONCAT(su.login_name SEPARATOR '|') touser ,sue.org_code from sys_user su
  513. left join sys_user_ext sue on sue.user_id = su.user_id
  514. where sue.sap_employee_id in
  515. <foreach collection="array" item="employeeCode" open="(" separator="," close=")">
  516. #{employeeCode}
  517. </foreach>
  518. GROUP BY sue.sap_employee_id
  519. </select>
  520. <select id="selectUserByOrgCode" resultMap="SysUserResult" >
  521. SELECT
  522. u.user_id,
  523. u.user_name,
  524. u.is_consignee,
  525. u.is_independently,
  526. u.is_self_delivery,
  527. v.sap_employee_id,
  528. v.is_customer_manager,
  529. v.org_code
  530. FROM
  531. sys_user u
  532. LEFT JOIN sys_user_ext v ON u.user_id = v.user_id
  533. WHERE
  534. v.org_code =#{orgCode} and u.quit is null
  535. and v.is_customer_manager !='0' and v.is_customer_manager !='8'
  536. </select>
  537. <select id="getCustomNameByCode" resultType="java.lang.String" >
  538. select customer_name from order_sales_sum_tuc_customer where customer_id=#{code} limit 1
  539. </select>
  540. <select id="selectSyncDateUser" resultType="java.lang.String" >
  541. select GROUP_CONCAT(su.login_name SEPARATOR '|') touser from sys_user su
  542. left join sys_user_sync_data sus on sus.user_id = su.user_id where sus.type = #{type}
  543. </select>
  544. <insert id="insertUserRole">
  545. insert into sys_user_role (user_id,role_id) select ${userId},${roleId} from dual where not exists ( select 1 from sys_user_role where user_id = #{userId} and role_id = #{roleId} )
  546. </insert>
  547. <delete id="deleteByLoginName" parameterType="int">
  548. delete from sys_user_author_rel where user_id = (
  549. select user_id from sys_user where 1=1
  550. <if test="loginName !=null and loginName !='' ">
  551. and login_name=#{loginName}
  552. </if>
  553. )
  554. </delete>
  555. <select id="selectUser" parameterType="SysUser" resultMap="SysUserResult">
  556. select u.user_id,u.company_id, u.dept_id, u.login_name, u.user_name,u.id_type,u.id_number,u.account_id,u.is_authentication,u.receive_url_mobile_no, u.email, u.avatar,
  557. u.phonenumber, u.password, u.sex, u.salt, u.status, u.del_flag,
  558. u.login_ip, u.login_date, u.create_by, u.create_time, u.remark,u.quit
  559. from sys_user u where quit is null
  560. </select>
  561. <select id="sendmailUnionUser" resultType="com.dgtly.system.domain.UserVO" >
  562. select u.user_name as userName,u.phonenumber,u.login_name as loginName
  563. from sys_user u LEFT JOIN sys_user_ext e on e.user_id =u.user_id WHERE
  564. ( u.phonenumber, u.user_name ) IN (
  565. SELECT
  566. phonenumber,
  567. user_name
  568. FROM
  569. sys_user where del_flag=0 and quit is null
  570. GROUP BY
  571. phonenumber,
  572. user_name
  573. HAVING
  574. count(*) > 1) and u.del_flag=0 and u.quit is null
  575. and e.is_customer_manager is null order by user_name
  576. </select>
  577. </mapper>