From 3e11f3d28421cf9401bb42e68ed49e118e0ce5dc Mon Sep 17 00:00:00 2001
From: ZQN <364596817@qq.com>
Date: 星期一, 24 六月 2024 16:40:08 +0800
Subject: [PATCH] 用户导入

---
 project-system/src/main/resources/mapper/system/SysUserMapper.xml |   46 ++++++++++++++++++++++++++++++++++++++--------
 1 files changed, 38 insertions(+), 8 deletions(-)

diff --git a/project-system/src/main/resources/mapper/system/SysUserMapper.xml b/project-system/src/main/resources/mapper/system/SysUserMapper.xml
index a28c496..42e47cc 100644
--- a/project-system/src/main/resources/mapper/system/SysUserMapper.xml
+++ b/project-system/src/main/resources/mapper/system/SysUserMapper.xml
@@ -9,6 +9,7 @@
         <result property="deptId"       column="dept_id"      />
         <result property="userName"     column="user_name"    />
         <result property="nickName"     column="nick_name"    />
+        <result property="userType"     column="user_type"    />
         <result property="email"        column="email"        />
         <result property="phonenumber"  column="phonenumber"  />
         <result property="wxOpenid"  column="wx_openid"  />
@@ -52,7 +53,7 @@
     </resultMap>
 
 	<sql id="selectUserVo">
-        select u.user_id, u.dept_id, u.user_name, u.nick_name, u.email,  u.phonenumber,u.wx_openid,u.sex, u.avatar,
+        select u.user_id, u.dept_id, u.user_name, u.nick_name,u.user_type, u.email,  u.phonenumber,u.wx_openid,u.sex, u.avatar,
                u.password, u.status, u.del_flag, u.login_ip, u.login_date, u.create_by, u.create_time, u.update_by, u.update_time,
                u.remark,u.birthday,u.province,u.city,u.area,
         d.dept_id, d.parent_id, d.ancestors, d.dept_name, d.order_num, d.leader, d.status as dept_status,
@@ -64,7 +65,7 @@
     </sql>
 
     <select id="selectUserList" parameterType="SysUser" resultMap="SysUserResult">
-		select u.user_id, u.dept_id, u.nick_name, u.user_name, u.email, u.avatar, u.phonenumber, u.sex, u.status, u.del_flag,
+		select u.user_id, u.dept_id, u.nick_name, u.user_name,u.user_type, u.email, u.avatar, u.phonenumber, u.sex, u.status, u.del_flag,
 		       u.login_ip, u.login_date, u.create_by, u.create_time, u.remark,d.dept_name, d.leader
 		from sys_user u
 		left join sys_dept d on u.dept_id = d.dept_id
@@ -91,7 +92,9 @@
 			AND (u.dept_id = #{deptId} OR u.dept_id IN ( SELECT t.dept_id FROM sys_dept t WHERE find_in_set(#{deptId}, ancestors) ))
 		</if>
 		<!-- 鏁版嵁鑼冨洿杩囨护 -->
-		${params.dataScope}
+		<if test="params != null and params.dataScope != null and params.dataScope != ''">
+			AND ${params.dataScope}
+		</if>
 	</select>
 
 	<select id="selectAllocatedList" parameterType="SysUser" resultMap="SysUserResult">
@@ -108,7 +111,9 @@
 			AND u.phonenumber like concat('%', #{phonenumber}, '%')
 		</if>
 		<!-- 鏁版嵁鑼冨洿杩囨护 -->
-		${params.dataScope}
+		<if test="params != null and params.dataScope != null and params.dataScope != ''">
+			AND ${params.dataScope}
+		</if>
 	</select>
 
 	<select id="selectUnallocatedList" parameterType="SysUser" resultMap="SysUserResult">
@@ -126,7 +131,9 @@
 			AND u.phonenumber like concat('%', #{phonenumber}, '%')
 		</if>
 		<!-- 鏁版嵁鑼冨洿杩囨护 -->
-		${params.dataScope}
+		<if test="params != null and params.dataScope != null and params.dataScope != ''">
+			AND ${params.dataScope}
+		</if>
 	</select>
 
 	<select id="selectUserByUserName" parameterType="String" resultMap="SysUserResult">
@@ -157,6 +164,7 @@
  			<if test="deptId != null and deptId != 0">dept_id,</if>
  			<if test="userName != null and userName != ''">user_name,</if>
  			<if test="nickName != null and nickName != ''">nick_name,</if>
+ 			<if test="userType != null and userType != ''">user_type,</if>
  			<if test="email != null and email != ''">email,</if>
  			<if test="avatar != null and avatar != ''">avatar,</if>
  			<if test="phonenumber != null and phonenumber != ''">phonenumber,</if>
@@ -164,6 +172,7 @@
  			<if test="password != null and password != ''">password,</if>
  			<if test="status != null and status != ''">status,</if>
  			<if test="createBy != null and createBy != ''">create_by,</if>
+ 			<if test="recommendUser != null and recommendUser != ''">recommend_user,</if>
  			<if test="remark != null and remark != ''">remark,</if>
  			create_time
  		)values(
@@ -171,6 +180,7 @@
  			<if test="deptId != null and deptId != ''">#{deptId},</if>
  			<if test="userName != null and userName != ''">#{userName},</if>
  			<if test="nickName != null and nickName != ''">#{nickName},</if>
+			<if test="userType != null and userType != ''">#{userType},</if>
  			<if test="email != null and email != ''">#{email},</if>
  			<if test="avatar != null and avatar != ''">#{avatar},</if>
  			<if test="phonenumber != null and phonenumber != ''">#{phonenumber},</if>
@@ -178,6 +188,7 @@
  			<if test="password != null and password != ''">#{password},</if>
  			<if test="status != null and status != ''">#{status},</if>
  			<if test="createBy != null and createBy != ''">#{createBy},</if>
+			<if test="recommendUser != null and recommendUser != ''">#{recommendUser},</if>
  			<if test="remark != null and remark != ''">#{remark},</if>
  			sysdate()
  		)
@@ -189,6 +200,7 @@
  			<if test="deptId != null and deptId != 0">dept_id = #{deptId},</if>
  			<if test="userName != null and userName != ''">user_name = #{userName},</if>
  			<if test="nickName != null and nickName != ''">nick_name = #{nickName},</if>
+ 			<if test="userType != null and userType != ''">user_type = #{userType},</if>
  			<if test="email != null ">email = #{email},</if>
  			<if test="phonenumber != null ">phonenumber = #{phonenumber},</if>
  			<if test="sex != null and sex != ''">sex = #{sex},</if>
@@ -198,6 +210,7 @@
  			<if test="loginIp != null and loginIp != ''">login_ip = #{loginIp},</if>
  			<if test="loginDate != null">login_date = #{loginDate},</if>
  			<if test="updateBy != null and updateBy != ''">update_by = #{updateBy},</if>
+ 			<if test="recommendUser != null and recommendUser != ''">recommend_user = #{recommendUser},</if>
  			<if test="remark != null">remark = #{remark},</if>
  			update_time = sysdate()
  		</set>
@@ -213,19 +226,36 @@
 	</update>
 
 	<update id="resetUserPwd" parameterType="SysUser">
- 		update sys_user set password = #{password}, remark = #{remark} where user_name = #{userName}
+ 		update sys_user set password = #{password}, recommend_user = #{recommendUser} where user_name = #{userName}
+	</update>
+
+	<update id="resetPhone" parameterType="SysUser">
+		update sys_user set phonenumber = #{phone}, user_name = #{phone} where user_id = #{userId}
 	</update>
 
 	<delete id="deleteUserById" parameterType="Long">
- 		update sys_user set del_flag = '2' where user_id = #{userId}
+ 		update sys_user set del_flag = '1' where user_id = #{userId}
  	</delete>
 
  	<delete id="deleteUserByIds" parameterType="Long">
- 		update sys_user set del_flag = '2' where user_id in
+ 		update sys_user set del_flag = '1' where user_id in
  		<foreach collection="array" item="userId" open="(" separator="," close=")">
  			#{userId}
         </foreach>
  	</delete>
 
 
+	<select id="getPhonesByRoleKey"  resultType="String">
+		select u.phonenumber
+			from sys_user u
+			join sys_user_role ur on u.user_id = ur.user_id
+			join sys_role r on r.role_id = ur.role_id
+			join sys_user_dept ud on u.user_id = ud.user_id
+		where
+		  u.user_type != '02'
+		  and u.status='0'
+		  and r.role_key = #{roleKey}
+		  and ud.dept_id = #{deptId}
+	</select>
+
 </mapper>

--
Gitblit v1.9.1