From d272e9a407a5d028b336256d77b72a606f673c9d Mon Sep 17 00:00:00 2001
From: java110 <928255095@qq.com>
Date: 星期一, 22 五月 2023 13:52:30 +0800
Subject: [PATCH] optimize

---
 java110-db/src/main/resources/mapper/user/UserV1ServiceDaoImplMapper.xml |   57 +++++++++++++++++++++++++++++++++++++++++++++++++--------
 1 files changed, 49 insertions(+), 8 deletions(-)

diff --git a/java110-db/src/main/resources/mapper/user/UserV1ServiceDaoImplMapper.xml b/java110-db/src/main/resources/mapper/user/UserV1ServiceDaoImplMapper.xml
index 5f670ba..cbd8759 100644
--- a/java110-db/src/main/resources/mapper/user/UserV1ServiceDaoImplMapper.xml
+++ b/java110-db/src/main/resources/mapper/user/UserV1ServiceDaoImplMapper.xml
@@ -7,11 +7,9 @@
 
     <!-- 淇濆瓨鐢ㄦ埛淇℃伅 add by wuxw 2018-07-03 -->
     <insert id="saveUserInfo" parameterType="Map">
-        insert into u_user(
-        address,sex,user_id,level_cd,location_cd,score,password,name,tel,b_id,email,age
-        ) values (
-        #{address},#{sex},#{userId},#{levelCd},#{locationCd},#{score},#{password},#{name},#{tel},#{bId},#{email},#{age}
-        )
+        insert into u_user(address, sex, user_id, level_cd, location_cd, score, password, name, tel, b_id, email, age)
+        values (#{address}, #{sex}, #{userId}, #{levelCd}, #{locationCd}, #{score}, #{password}, #{name}, #{tel},
+                #{bId}, #{email}, #{age})
     </insert>
 
 
@@ -98,9 +96,7 @@
         <if test="tel !=null and tel != ''">
             , t.tel= #{tel}
         </if>
-        <if test="email !=null and email != ''">
-            , t.email= #{email}
-        </if>
+        , t.email= #{email}
         <if test="age !=null and age != ''">
             , t.age= #{age}
         </if>
@@ -162,4 +158,49 @@
 
     </select>
 
+    <select id="queryStaffsNoInOrgCount" parameterType="Map" resultType="Map">
+        select count(DISTINCT t.user_id) count
+        from u_user t
+        inner join s_store_user su on t.user_id = su.user_id and su.status_cd = '0'
+        LEFT JOIN u_org_staff_rel osr on su.user_id = osr.staff_id and osr.status_cd = '0'
+        where t.level_cd = '01'
+        and su.store_id = #{storeId}
+        and (osr.org_id != #{orgId} or osr.org_id is null)
+        <if test="staffName !=null and staffName != ''">
+            and t.name like concat('%', #{staffName},'%')
+        </if>
+        <if test="orgIds != null and orgIds.length > 0">
+            and osr.org_id in
+            <foreach collection="orgIds" item="item" open="(" close=")" separator=",">
+                #{item}
+            </foreach>
+        </if>
+
+    </select>
+
+    <select id="queryStaffsNoInOrg" parameterType="Map" resultType="Map">
+        select DISTINCT t.address,t.sex,t.status_cd,t.status_cd statusCd,t.user_id,t.user_id
+        userId,t.level_cd,t.level_cd
+        levelCd,t.location_cd,t.location_cd locationCd,t.score,t.name,t.tel,t.b_id,t.b_id
+        bId,t.email,t.age,t.create_time
+        from u_user t
+        inner join s_store_user su on t.user_id = su.user_id and su.status_cd = '0'
+        LEFT JOIN u_org_staff_rel osr on su.user_id = osr.staff_id and osr.status_cd = '0'
+        where t.level_cd = '01'
+        and su.store_id = #{storeId}
+        and (osr.org_id != #{orgId} or osr.org_id is null)
+        <if test="staffName !=null and staffName != ''">
+            and t.name like concat('%', #{staffName},'%')
+        </if>
+        <if test="orgIds != null and orgIds.length > 0">
+            and osr.org_id in
+            <foreach collection="orgIds" item="item" open="(" close=")" separator=",">
+                #{item}
+            </foreach>
+        </if>
+        order by t.create_time desc
+        <if test="page != -1 and page != null ">
+            limit #{page}, #{row}
+        </if>
+    </select>
 </mapper>

--
Gitblit v1.8.0