UserServiceDaoImplMapper.xml 27 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713
  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="userServiceDaoImpl">
  6. <resultMap type="com.java110.entity.user.Cust" id="custMap">
  7. <id column="custId" jdbcType="VARCHAR" property="custId"/>
  8. <result column="name" jdbcType="VARCHAR" property="name"/>
  9. <result column="email" jdbcType="VARCHAR" property="email"/>
  10. <result column="cellphone" jdbcType="VARCHAR" property="cellphone"/>
  11. <result column="realName" jdbcType="VARCHAR" property="realName"/>
  12. <result column="sex" jdbcType="VARCHAR" property="sex"/>
  13. <result column="password" jdbcType="VARCHAR" property="password"/>
  14. <result column="lanId" jdbcType="VARCHAR" property="lanId"/>
  15. <result column="custAdress" jdbcType="VARCHAR" property="custAdress"/>
  16. <result column="custType" jdbcType="VARCHAR" property="custType"/>
  17. <result column="openId" jdbcType="VARCHAR" property="openId"/>
  18. <!-- 一对多关系 -->
  19. <!-- <collection property="stus" resultMap="Student.StudentResult"></collection> -->
  20. <collection property="custAttrs" javaType="com.java110.entity.user.CustAttr">
  21. <id property="custId" column="custId"/>
  22. <result property="attrCd" column="attrCd"/>
  23. <result property="value" column="value"/>
  24. </collection>
  25. </resultMap>
  26. <!--根据用户Id查询用户角色
  27. <select id="findRolesByUserId" resultType="SysRole">
  28. SELECT
  29. r.*
  30. FROM
  31. t_role r,
  32. t_user_role ur
  33. WHERE ur.uid = #{userId}
  34. AND ur.roleId = r.roleId
  35. AND ur.status_cd = '1'
  36. </select>
  37. -->
  38. <!--保存数据至过程表 bo_cust 中 -->
  39. <insert id="saveDataToBoCust" parameterType="com.java110.entity.user.BoCust">
  40. <![CDATA[
  41. insert into bo_cust(boId,custId,name,email,cellphone,realName,sex,password,lanId,custAdress,custType,openId,state)
  42. values(#{boId},#{custId},#{name},#{email},#{cellphone},#{realName},#{sex},#{password},#{lanId},#{custAdress},#{custType},#{openId},#{state})
  43. ]]>
  44. </insert>
  45. <!-- 保存数据至过程表bo_cust_attr 中-->
  46. <insert id="saveDataToBoCustAttr" parameterType="com.java110.entity.user.BoCustAttr">
  47. <![CDATA[
  48. insert into bo_cust_attr(boId,custId,attrCd,value,state)
  49. values(#{boId},#{custId},#{attrCd},#{value},#{state})
  50. ]]>
  51. </insert>
  52. <!-- 保存 实例客户信息 cust -->
  53. <insert id="saveDataToCust" parameterType="com.java110.entity.user.Cust">
  54. <![CDATA[
  55. insert into cust(custId,name,email,cellphone,realName,sex,password,lanId,custAdress,custType,openId,status_cd)
  56. values(#{custId},#{name},#{email},#{cellphone},#{realName},#{sex},#{password},#{lanId},#{custAdress},#{custType},#{openId},#{status_cd})
  57. ]]>
  58. </insert>
  59. <!-- 删除实例客户信息 cust -->
  60. <insert id="deleteDataToCust" parameterType="com.java110.entity.user.Cust">
  61. <![CDATA[
  62. delete * from cust c where c.custId = #{custId}
  63. ]]>
  64. </insert>
  65. <!-- 保存 实例客户属性信息 cust_attr -->
  66. <insert id="saveDataToCustAttr" parameterType="com.java110.entity.user.CustAttr">
  67. <![CDATA[
  68. insert into cust_attr(custId,attrCd,value,status_cd)
  69. values(#{custId},#{attrCd},#{value},#{status_cd})
  70. ]]>
  71. </insert>
  72. <!-- 删除实例客户信息 cust -->
  73. <update id="deleteDataToCustAttr" parameterType="com.java110.entity.user.CustAttr">
  74. delete * from cust_attr ct where 1=1
  75. <if test="custId != null and custId != ''">
  76. and ct.custId = #{custId}
  77. </if>
  78. <if test="attrCd != null and attrCd != ''">
  79. and ct.attrCd = #{attrCd}
  80. </if>
  81. </update>
  82. <!--根据客户ID 查询客户信息,其中包括 cust 和custAttr 数据-->
  83. <select id="queryDataToCust" parameterType="com.java110.entity.user.Cust" resultMap="custMap">
  84. select c.custId,c.name,c.email,c.cellphone,c.realName,c.sex,c.password,c.lanId,c.custAdress,c.custType,c.openId,
  85. ca.custId,ca.attrCd,ca.value
  86. from cust c, cust_attr ca where c.custId= ca.custId
  87. <if test="custId != null and custId != ''">
  88. and c.custId = #{custId}
  89. </if>
  90. <if test="versionId != null and versionId != ''">
  91. and c.versionId = #{versionId}
  92. </if>
  93. and c.status_cd = '0'
  94. </select>
  95. <!-- 查询客户过程数据 -->
  96. <select id="queryBoCust" parameterType="com.java110.entity.user.BoCust" resultType="com.java110.entity.user.BoCust">
  97. select
  98. bc.boId,bc.custId,bc.name,bc.email,bc.cellphone,bc.realName,bc.sex,bc.password,bc.lanId,bc.custAdress,bc.custType,bc.openId,bc.create_dt
  99. from bo_cust bc where 1=1
  100. <if test="boId != null and boId != ''">
  101. and bc.boId = #{boId}
  102. </if>
  103. <if test="custId != null and custId != ''">
  104. and bc.custId = #{custId}
  105. </if>
  106. <if test="versionId != null and versionId != ''">
  107. and c.versionId = #{versionId}
  108. </if>
  109. and bc.state in ('ADD','DEL','KIP')
  110. <if test="create_dt != null and create_dt != ''">
  111. order by bc.create_dt desc
  112. </if>
  113. </select>
  114. <!-- 查询客户属性过程表-->
  115. <select id="queryBoCustAttr" parameterType="com.java110.entity.user.BoCustAttr"
  116. resultType="com.java110.entity.user.BoCustAttr">
  117. select bca.boId,bca.custId,bca.attrCd,bca.value,bca.state,bca.create_dt from bo_cust_attr bca where 1=1
  118. <if test="boId !=null and boId != ''">
  119. and bca.boId = #{boId}
  120. </if>
  121. <if test="custId != null and custId != ''">
  122. and bca.custId = #{custId}
  123. </if>
  124. <if test="versionId != null and versionId != ''">
  125. and bca.versionId = #{versionId}
  126. </if>
  127. <if test="create_dt != null and create_dt != ''">
  128. order by bca.create_dt desc
  129. </if>
  130. </select>
  131. <!-- 查询客户属性信息 -->
  132. <select id="queryDataToCustAttr" parameterType="com.java110.entity.user.CustAttr"
  133. resultType="com.java110.entity.user.CustAttr">
  134. select * from cust_attr ca where 1=1
  135. <if test="custId != null and custId != ''">
  136. and ca.custId = #{custId}
  137. </if>
  138. <if test="versionId != null and versionId != ''">
  139. and ca.versionId = #{versionId}
  140. </if>
  141. <if test="attrCd != null and attrCd != ''">
  142. and ca.attrCd = #{attrCd}
  143. </if>
  144. and status_cd = '0'
  145. </select>
  146. <!-- 保存用户信息 -->
  147. <insert id="saveBusinessUserInfo" parameterType="map">
  148. insert into business_user(b_id,user_id,name,email,address,password,location_cd,age,sex,tel,level_cd,operate)
  149. values(#{bId},#{userId},#{name},#{email},#{address},#{password},#{locationCd},#{age},#{sex},#{tel},#{levelCd},#{operate})
  150. </insert>
  151. <!-- 保存用户属性 -->
  152. <insert id="saveBusinessUserAttr" parameterType="map">
  153. insert into business_user_attr(b_id,user_id,attr_id,spec_cd,value,operate)
  154. values(#{bId},#{userId},#{attrId},#{specCd},#{value},#{operate})
  155. </insert>
  156. <!-- 实例数据 -->
  157. <insert id="saveUserInfoInstance" parameterType="map">
  158. insert into u_user(user_id,name,email,address,password,location_cd,age,sex,tel,level_cd,b_id,status_cd)
  159. select
  160. bu.user_id,bu.name,bu.email,bu.address,bu.password,bu.location_cd,bu.age,bu.sex,bu.tel,bu.level_cd,bu.b_id,'0'
  161. from business_user bu where bu.operate = 'ADD' and bu.b_id=#{b_id}
  162. </insert>
  163. <insert id="saveUserAttrInstance" parameterType="map">
  164. insert into u_user_attr(attr_id,user_id,spec_cd,value,b_id,status_cd)
  165. select bua.attr_id,bua.user_id,bua.spec_cd,bua.value,bua.b_id,'0' from business_user_attr bua where
  166. bua.operate='ADD' and bua.b_id=#{b_id}
  167. </insert>
  168. <update id="updateUserInfoInstance" parameterType="map">
  169. update u_user u set u.status_cd = #{statusCd}
  170. <if test="newBId != null and newBId != ''">
  171. ,u.b_id = #{newBId}
  172. </if>
  173. <if test="name !=null and name != ''">
  174. ,u.name= #{name}
  175. </if>
  176. <if test="email !=null and email != ''">
  177. ,u.email= #{email}
  178. </if>
  179. <if test="address !=null and address != ''">
  180. ,u.address= #{address}
  181. </if>
  182. <if test="password !=null and password != ''">
  183. ,u.password= #{password}
  184. </if>
  185. <if test="locationCd !=null and locationCd != ''">
  186. ,u.location_cd= #{locationCd}
  187. </if>
  188. <if test="age !=null and age != ''">
  189. ,u.age= #{age}
  190. </if>
  191. <if test="sex !=null and sex != ''">
  192. ,u.sex= #{sex}
  193. </if>
  194. <if test="tel !=null and tel != ''">
  195. ,u.tel= #{tel}
  196. </if>
  197. <if test="score !=null and score != ''">
  198. ,u.score= #{score}
  199. </if>
  200. where 1 = 1
  201. <if test="bId != null and bId != ''">
  202. and u.b_id = #{bId}
  203. </if>
  204. <if test="userId != null and userId !=''">
  205. and u.user_id = #{userId}
  206. </if>
  207. <if test="attrId != null and attrId != ''">
  208. and u.attr_id = #{attrId}
  209. </if>
  210. </update>
  211. <update id="updateUserAttrInstance" parameterType="map">
  212. update u_user_attr ua set ua.status_cd = #{statusCd} where 1 = 1
  213. <if test="bId != null and bId != ''">
  214. and ua.b_id = #{bId}
  215. </if>
  216. <if test="userId != null and userId !=''">
  217. and ua.user_id = #{userId}
  218. </if>
  219. </update>
  220. <!-- 查询用户信息 Business -->
  221. <select id="queryBusinessUserInfo" parameterType="map" resultType="map">
  222. select u.user_id,u.name,u.email,u.address,u.password,u.location_cd,
  223. u.age,u.sex,u.tel,u.level_cd,u.b_id,u.operate
  224. from business_user u where 1 = 1
  225. <if test="operate != null and operate != ''">
  226. and u.operate = #{operate}
  227. </if>
  228. <if test="bId != null and bId !=''">
  229. and u.b_id = #{bId}
  230. </if>
  231. <if test="userId != null and userId != ''">
  232. and u.user_id = #{userId}
  233. </if>
  234. </select>
  235. <!-- 查询用户属性信息 Business-->
  236. <select id="queryBusinessUserInfoAttrs" parameterType="map" resultType="map">
  237. select u.attr_id,u.user_id,u.spec_cd,u.value,u.b_id,u.operate
  238. from business_user_attr u where 1 = 1
  239. <if test="operate != null and operate != ''">
  240. and u.operate = #{operate}
  241. </if>
  242. <if test="bId != null and bId !=''">
  243. and u.b_id = #{bId}
  244. </if>
  245. <if test="userId != null and userId != ''">
  246. and u.user_id = #{userId}
  247. </if>
  248. <if test="attrId != null and attrId != ''">
  249. and u.attr_id = #{attrId}
  250. </if>
  251. </select>
  252. <!-- 查询用户信息 -->
  253. <select id="queryUserInfo" parameterType="map" resultType="map">
  254. select u.user_id, u.user_id userId,u.name,u.name
  255. userName,u.email,u.address,u.password,u.location_cd,u.location_cd locationCd,
  256. u.age,u.sex,u.tel,u.level_cd,u.b_id
  257. from u_user u where 1= 1
  258. <if test="bId != null and bId !=''">
  259. and u.b_id = #{bId}
  260. </if>
  261. <if test="userId != null and userId != ''">
  262. and u.user_id = #{userId}
  263. </if>
  264. <if test="statusCd !=null and statusCd != ''">
  265. and u.status_cd = #{statusCd}
  266. </if>
  267. <if test="userIds != null and userIds != null">
  268. and u.user_id in
  269. <foreach collection="userIds" item="item" open="(" close=")" separator=",">
  270. #{item}
  271. </foreach>
  272. </if>
  273. </select>
  274. <!-- 查询用户属性信息 -->
  275. <select id="queryUserInfoAttrs" parameterType="map" resultType="map">
  276. select u.attr_id,u.user_id,u.spec_cd,u.value,u.b_id,
  277. u.attr_id attrId,u.user_id userId,u.spec_cd specCd,u.b_id bId
  278. from u_user_attr u where u.status_cd = '0'
  279. <if test="bId != null and bId !=''">
  280. and u.b_id = #{bId}
  281. </if>
  282. <if test="userId != null and userId != ''">
  283. and u.user_id = #{userId}
  284. </if>
  285. <if test="attrId != null and attrId != ''">
  286. and u.attr_id = #{attrId}
  287. </if>
  288. <if test="specCd != null and specCd != ''">
  289. and u.spec_cd = #{specCd}
  290. </if>
  291. </select>
  292. <!--保存用户地址信息 add by wuxw 2018-06-29 -->
  293. <insert id="saveBusinessUserAddress" parameterType="map">
  294. insert into business_user_address(address_id,b_id,user_id,tel,postal_code,address,is_default,operate)
  295. values(#{addressId},#{bId},#{userId},#{tel},#{postalCode},#{address},#{isDefault},#{operate})
  296. </insert>
  297. <!-- 查询用户地址信息 add by wuxw 2018-06-29-->
  298. <select id="queryBusinessUserAddress" parameterType="map" resultType="map">
  299. select ua.address_id,ua.b_id,ua.user_id,ua.tel,ua.postal_code,ua.address,ua.is_default,ua.operate
  300. from business_user_address ua where 1 = 1
  301. <if test="operate != null and operate != ''">
  302. and ua.operate = #{operate}
  303. </if>
  304. <if test="bId != null and bId !=''">
  305. and ua.b_id = #{bId}
  306. </if>
  307. <if test="userId != null and userId != ''">
  308. and ua.user_id = #{userId}
  309. </if>
  310. </select>
  311. <!-- 保存用户地址 Business 数据到 Instance add by wuxw 2018-06-29 -->
  312. <insert id="saveUserAddressInstance" parameterType="map">
  313. insert into u_user_address(address_id,b_id,user_id,tel,postal_code,address,is_default,status_cd)
  314. select ua.address_id,ua.b_id,ua.user_id,ua.tel,ua.postal_code,ua.address,ua.is_default,'0'
  315. from business_user_address ua where 1 = 1
  316. ua.operate = 'ADD' and ua.b_id=#{b_id}
  317. </insert>
  318. <!-- 作废用户地址信息数据 add by wuxw 2018-06-29-->
  319. <update id="updateUserAddressInstance" parameterType="map">
  320. update u_user_address ua set ua.status_cd = #{statusCd} where 1 = 1
  321. <if test="bId != null and bId != ''">
  322. and ua.b_id = #{bId}
  323. </if>
  324. <if test="userId != null and userId !=''">
  325. and ua.user_id = #{userId}
  326. </if>
  327. <if test="addressId != null and addressId != ''">
  328. and ua.address_id = #{addressId}
  329. </if>
  330. </update>
  331. <!--保存用户打标信息 add by wuxw 2018-06-29 -->
  332. <insert id="saveBusinessUserTag" parameterType="map">
  333. insert into business_user_tag(tag_id,b_id,user_id,tag_cd,remark,operate)
  334. values(#{tagId},#{bId},#{userId},#{tagCd},#{remark},#{operate})
  335. </insert>
  336. <!-- 查询用户地址信息 add by wuxw 2018-06-29-->
  337. <select id="queryBusinessUserTag" parameterType="map" resultType="map">
  338. select ut.tag_id,ut.b_id,ut.user_id,ut.tag_cd,ut.remark,ut.operate
  339. from business_user_tag ut where 1 = 1
  340. <if test="operate != null and operate != ''">
  341. and ut.operate = #{operate}
  342. </if>
  343. <if test="bId != null and bId !=''">
  344. and ut.b_id = #{bId}
  345. </if>
  346. <if test="userId != null and userId != ''">
  347. and ut.user_id = #{userId}
  348. </if>
  349. </select>
  350. <!-- 保存用户地址 Business 数据到 Instance add by wuxw 2018-06-29 -->
  351. <insert id="saveUserTagInstance" parameterType="map">
  352. insert into u_user_tag(tag_id,b_id,user_id,tag_cd,remark,status_cd)
  353. select ut.tag_id,ut.b_id,ut.user_id,ut.tag_cd,ut.remark,'0'
  354. from business_user_tag ut where 1 = 1
  355. ut.operate = 'ADD' and ut.b_id=#{b_id}
  356. </insert>
  357. <!-- 作废用户地址信息数据 add by wuxw 2018-06-29-->
  358. <update id="updateUserTagInstance" parameterType="map">
  359. update u_user_tag ut set ut.status_cd = #{statusCd} where 1 = 1
  360. <if test="bId != null and bId != ''">
  361. and ut.b_id = #{bId}
  362. </if>
  363. <if test="userId != null and userId !=''">
  364. and ut.user_id = #{userId}
  365. </if>
  366. <if test="addressId != null and addressId != ''">
  367. and ut.address_id = #{tagId}
  368. </if>
  369. </update>
  370. <!--保存用户证件信息 add by wuxw 2018-06-29 -->
  371. <insert id="saveBusinessUserCredentials" parameterType="map">
  372. insert into business_user_credentials(credentials_id,b_id,user_id,credentials_cd,value,operate)
  373. values(#{credentialsId},#{bId},#{userId},#{credentialsCd},#{value},#{operate})
  374. </insert>
  375. <!-- 查询用户地址信息 add by wuxw 2018-06-29-->
  376. <select id="queryBusinessUserCredentials" parameterType="map" resultType="map">
  377. select uc.credentials_id,uc.b_id,uc.user_id,uc.credentials_cd,uc.value,uc.operate
  378. from business_user_credentials uc where 1 = 1
  379. <if test="operate != null and operate != ''">
  380. and uc.operate = #{operate}
  381. </if>
  382. <if test="bId != null and bId !=''">
  383. and uc.b_id = #{bId}
  384. </if>
  385. <if test="userId != null and userId != ''">
  386. and uc.user_id = #{userId}
  387. </if>
  388. </select>
  389. <!-- 保存用户地址 Business 数据到 Instance add by wuxw 2018-06-29 -->
  390. <insert id="saveUserCredentialsInstance" parameterType="map">
  391. insert into u_user_credentials(credentials_id,b_id,user_id,credentials_cd,value,status_cd)
  392. select uc.credentials_id,uc.b_id,uc.user_id,uc.credentials_cd,uc.value,'0'
  393. from business_user_credentials uc where 1 = 1
  394. uc.operate = 'ADD' and uc.b_id=#{b_id}
  395. </insert>
  396. <!-- 作废用户地址信息数据 add by wuxw 2018-06-29-->
  397. <update id="updateUserCredentialsInstance" parameterType="map">
  398. update u_user_credentials uc set uc.status_cd = #{statusCd} where 1 = 1
  399. <if test="bId != null and bId != ''">
  400. and uc.b_id = #{bId}
  401. </if>
  402. <if test="userId != null and userId !=''">
  403. and uc.user_id = #{userId}
  404. </if>
  405. <if test="addressId != null and addressId != ''">
  406. and uc.credentials_id = #{credentialsId}
  407. </if>
  408. </update>
  409. <!-- 查询员工总量 -->
  410. <select id="getStaffCount" parameterType="Map" resultType="Map">
  411. select count(1) count
  412. u_user u
  413. left join u_org_staff_rel uosr on u.user_id = uosr.staff_id and uosr.status_cd = '0'
  414. left join u_org uo on uosr.org_id = uo.org_id and uo.status_cd = '0'
  415. where u.level_cd = '01'
  416. <if test="storeId !=null and storeId != ''">
  417. and uosr.store_id = #{storeId}
  418. </if>
  419. <if test="orgId !=null and orgId != ''">
  420. and uosr.org_id = #{orgId}
  421. </if>
  422. and u.status_cd = '0'
  423. <if test="tel !=null and tel != ''">
  424. and u.tel= #{tel}
  425. </if>
  426. <if test="name !=null and name != ''">
  427. and u.name like concat('%',#{name},'%')
  428. </if>
  429. <if test="staffName !=null and staffName != ''">
  430. and u.name like concat('%',#{staffName},'%')
  431. </if>
  432. <if test="staffId != null and staffId !=''">
  433. and uosr.staff_id = #{staffId}
  434. </if>
  435. <if test="orgId !=null and orgId != ''">
  436. and uo.org_id = #{orgId}
  437. </if>
  438. <if test="bId != null and bId !=''">
  439. and u.b_id = #{bId}
  440. </if>
  441. <if test="userIds != null and userIds != null">
  442. and u.user_id in
  443. <foreach collection="userIds" item="item" open="(" close=")" separator=",">
  444. #{item}
  445. </foreach>
  446. </if>
  447. </select>
  448. <!-- 查询员工总量 -->
  449. <select id="getStaffs" parameterType="Map" resultType="Map">
  450. select uo.org_id orgId,uo.org_name,uo.org_name orgName,u.user_id, u.user_id userId,u.name,u.name
  451. userName,u.email,u.address,u.location_cd,u.location_cd locationCd,
  452. u.age,u.sex,u.tel,u.level_cd levelCd,u.b_id,uosr.store_id storeId,uosr.rel_cd relCd
  453. from
  454. u_user u
  455. left join u_org_staff_rel uosr on u.user_id = uosr.staff_id and uosr.status_cd = '0'
  456. left join u_org uo on uosr.org_id = uo.org_id and uo.status_cd = '0'
  457. where u.level_cd = '01'
  458. <if test="storeId !=null and storeId != ''">
  459. and uosr.store_id = #{storeId}
  460. </if>
  461. <if test="orgId !=null and orgId != ''">
  462. and uosr.org_id = #{orgId}
  463. </if>
  464. and u.status_cd = '0'
  465. <if test="tel !=null and tel != ''">
  466. and u.tel= #{tel}
  467. </if>
  468. <if test="name !=null and name != ''">
  469. and u.name like concat('%',#{name},'%')
  470. </if>
  471. <if test="staffName !=null and staffName != ''">
  472. and u.name like concat('%',#{staffName},'%')
  473. </if>
  474. <if test="staffId != null and staffId !=''">
  475. and uosr.staff_id = #{staffId}
  476. </if>
  477. <if test="orgId !=null and orgId != ''">
  478. and uo.org_id = #{orgId}
  479. </if>
  480. <if test="bId != null and bId !=''">
  481. and u.b_id = #{bId}
  482. </if>
  483. <if test="userIds != null and userIds != null">
  484. and u.user_id in
  485. <foreach collection="userIds" item="item" open="(" close=")" separator=",">
  486. #{item}
  487. </foreach>
  488. </if>
  489. order by u.create_time desc
  490. <if test="page != -1 and page != null ">
  491. limit #{page}, #{row}
  492. </if>
  493. </select>
  494. <!-- 查询用户 -->
  495. <select id="getUsers" parameterType="Map" resultType="Map">
  496. select u.user_id, u.user_id userId,u.name,u.name
  497. userName,u.email,u.address,u.password,u.location_cd,u.location_cd locationCd,
  498. u.age,u.sex,u.tel,u.level_cd,u.b_id,u.level_cd levelCd,u.score
  499. from u_user u
  500. <if test="openId != null and openId !=''">
  501. ,u_user_attr ua
  502. </if>
  503. <if test="key != null and key !=''">
  504. ,u_user_attr ub
  505. </if>
  506. <if test="unionId != null and unionId !=''">
  507. ,u_user_attr ua
  508. </if>
  509. where 1= 1
  510. <if test="openId != null and openId != ''">
  511. and u.user_id = ua.user_id
  512. and ua.spec_cd = '100201911001'
  513. and ua.value = #{openId}
  514. and ua.status_cd = '0'
  515. </if>
  516. <if test="unionId != null and unionId != ''">
  517. and u.user_id = ua.user_id
  518. and ua.spec_cd = '100201911002'
  519. and ua.value = #{unionId}
  520. and ua.status_cd = '0'
  521. </if>
  522. <if test="key != null and key != ''">
  523. and u.user_id = ub.user_id
  524. and ub.spec_cd = '100202061602'
  525. and ub.value = #{key}
  526. and ub.status_cd = '0'
  527. </if>
  528. <if test="bId != null and bId !=''">
  529. and u.b_id = #{bId}
  530. </if>
  531. <if test="userId != null and userId != ''">
  532. and u.user_id = #{userId}
  533. </if>
  534. <if test="statusCd !=null and statusCd != ''">
  535. and u.status_cd = #{statusCd}
  536. </if>
  537. <if test="userIds != null and userIds != null">
  538. and u.user_id in
  539. <foreach collection="userIds" item="item" open="(" close=")" separator=",">
  540. #{item}
  541. </foreach>
  542. </if>
  543. <if test="name !=null and name != ''">
  544. and u.name= #{name}
  545. </if>
  546. <if test="userName !=null and userName != ''">
  547. and u.name= #{userName}
  548. </if>
  549. <if test="email !=null and email != ''">
  550. and u.email= #{email}
  551. </if>
  552. <if test="password !=null and password != ''">
  553. and u.password= #{password}
  554. </if>
  555. <if test="locationCd !=null and locationCd != ''">
  556. and u.location_cd= #{locationCd}
  557. </if>
  558. <if test="age !=null and age != ''">
  559. and u.age= #{age}
  560. </if>
  561. <if test="sex !=null and sex != ''">
  562. and u.sex= #{sex}
  563. </if>
  564. <if test="tel !=null and tel != ''">
  565. and u.tel= #{tel}
  566. </if>
  567. <if test="levelCd !=null and levelCd != ''">
  568. and u.level_cd= #{levelCd}
  569. </if>
  570. <if test="levelCds != null">
  571. and u.level_cd in
  572. <foreach collection="levelCds" item="item" open="(" close=")" separator=",">
  573. #{item}
  574. </foreach>
  575. </if>
  576. <if test='userFlag !=null and userFlag =="1"'>
  577. and u.level_cd != '02'
  578. </if>
  579. order by u.create_time desc
  580. <if test="page != -1 and page != null ">
  581. limit #{page}, #{row}
  582. </if>
  583. </select>
  584. <select id="getUserCount" parameterType="Map" resultType="Map">
  585. select count(1) count
  586. from u_user u
  587. <if test="openId != null and openId !=''">
  588. ,u_user_attr ua
  589. </if>
  590. <if test="unionId != null and unionId !=''">
  591. ,u_user_attr ua
  592. </if>
  593. where 1= 1
  594. <if test="openId != null and openId != ''">
  595. and u.user_id = ua.user_id
  596. and ua.spec_cd = '100201911001'
  597. and ua.value = #{openId}
  598. and ua.status_cd = '0'
  599. </if>
  600. <if test="unionId != null and unionId != ''">
  601. and u.user_id = ua.user_id
  602. and ua.spec_cd = '100201911002'
  603. and ua.value = #{unionId}
  604. and ua.status_cd = '0'
  605. </if>
  606. <if test="bId != null and bId !=''">
  607. and u.b_id = #{bId}
  608. </if>
  609. <if test="userId != null and userId != ''">
  610. and u.user_id = #{userId}
  611. </if>
  612. <if test="statusCd !=null and statusCd != ''">
  613. and u.status_cd = #{statusCd}
  614. </if>
  615. <if test="userIds != null and userIds != null">
  616. and u.user_id in
  617. <foreach collection="userIds" item="item" open="(" close=")" separator=",">
  618. #{item}
  619. </foreach>
  620. </if>
  621. </select>
  622. <!-- 查询用户密码 -->
  623. <select id="getUserHasPwd" parameterType="Map" resultType="Map">
  624. select u.user_id, u.user_id userId,u.name,u.name
  625. userName,u.email,u.address,u.password,u.location_cd,u.location_cd locationCd,
  626. u.age,u.sex,u.tel,u.level_cd levelCd,u.b_id,u.password
  627. from u_user u
  628. <if test="openId != null and openId !=''">
  629. ,u_user_attr ua
  630. </if>
  631. <if test="unionId != null and unionId !=''">
  632. ,u_user_attr ua
  633. </if>
  634. where 1= 1
  635. <if test="openId != null and openId != ''">
  636. and u.user_id = ua.user_id
  637. and ua.spec_cd = '100201911001'
  638. and ua.value = #{openId}
  639. and ua.status_cd = '0'
  640. </if>
  641. <if test="unionId != null and unionId != ''">
  642. and u.user_id = ua.user_id
  643. and ua.spec_cd = '100201911002'
  644. and ua.value = #{unionId}
  645. and ua.status_cd = '0'
  646. </if>
  647. <if test="bId != null and bId !=''">
  648. and u.b_id = #{bId}
  649. </if>
  650. <if test="userId != null and userId != ''">
  651. and u.user_id = #{userId}
  652. </if>
  653. <if test="statusCd !=null and statusCd != ''">
  654. and u.status_cd = #{statusCd}
  655. </if>
  656. </select>
  657. </mapper>