SysUserMapper.xml 27 KB

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