From 2873f1cd6ea6caac062740e05994a1f0a880ffde Mon Sep 17 00:00:00 2001 From: xiangpei <xiangpei@timesnew.cn> Date: 星期二, 12 三月 2024 11:27:20 +0800 Subject: [PATCH] 一个用户只能是一个部门的管理员、创建随机试卷的时候人员只能选当前部门的人,试卷增加部门id --- src/main/resources/mapper/UserMapper.xml | 47 ++++++++++++++++++++++++++++++++++++++++------- 1 files changed, 40 insertions(+), 7 deletions(-) diff --git a/src/main/resources/mapper/UserMapper.xml b/src/main/resources/mapper/UserMapper.xml index c9c344a..2afc008 100644 --- a/src/main/resources/mapper/UserMapper.xml +++ b/src/main/resources/mapper/UserMapper.xml @@ -23,7 +23,7 @@ </resultMap> <sql id="Base_Column_List"> id, user_uuid, user_name, password, real_name, age, sex, birth_day, user_level, phone, - role, status, image_path, create_time, modify_time, last_active_time, deleted, wx_open_id + role, status, image_path, create_time, modify_time, last_active_time, deleted, wx_open_id, dept_admin </sql> <select id="selectByPrimaryKey" parameterType="java.lang.Integer" resultMap="BaseResultMap"> select @@ -220,6 +220,9 @@ <if test="wxOpenId != null"> wx_open_id = #{wxOpenId,jdbcType=VARCHAR}, </if> + <if test="deptAdmin != null"> + dept_admin = #{deptAdmin}, + </if> </set> where id = #{id,jdbcType=INTEGER} </update> @@ -241,7 +244,8 @@ modify_time = #{modifyTime,jdbcType=TIMESTAMP}, last_active_time = #{lastActiveTime,jdbcType=TIMESTAMP}, deleted = #{deleted,jdbcType=BIT}, - wx_open_id = #{wxOpenId,jdbcType=VARCHAR} + wx_open_id = #{wxOpenId,jdbcType=VARCHAR}, + dept_admin = #{deptAdmin} where id = #{id,jdbcType=INTEGER} </update> @@ -251,6 +255,12 @@ select <include refid="Base_Column_List"/> from t_user where deleted=0 + </select> + + <select id="getUserByLevel" resultMap="BaseResultMap"> + select + id,real_name + from t_user where deleted=0 and user_level = #{userLevel} </select> <select id="getUserById" resultMap="BaseResultMap"> @@ -265,6 +275,13 @@ <include refid="Base_Column_List"/> from t_user where deleted=0 and user_name=#{value} limit 1 + </select> + + <select id="getUserByRealName" resultMap="BaseResultMap"> + select + <include refid="Base_Column_List"/> + from t_user + where deleted=0 and real_name = #{realName} </select> <select id="getUserByUserNamePwd" resultMap="BaseResultMap"> @@ -318,7 +335,7 @@ <where> and deleted=0 <if test="userName != null and userName != ''"> - and user_name like concat('%',#{userName},'%') + and real_name like concat('%',#{userName},'%') </if> <if test="role != null "> and role= #{role} @@ -339,12 +356,12 @@ <insert id="insertUsers" parameterType="java.util.List" useGeneratedKeys="true" keyProperty="id"> insert into t_user - (user_uuid,user_name,password,real_name,age,last_active_time) + (user_uuid,user_name,password,real_name,last_active_time,role,status,user_level,deleted) values - <foreach collection="list" item="item" index="index" + <foreach collection="list" item="item" separator=","> - (#{item.userUuid},#{item.userName},#{item.password},#{item.realName},#{item.age}, - #{item.lastActiveTime}) + (#{item.userUuid,jdbcType=VARCHAR},#{item.userName,jdbcType=VARCHAR},#{item.password,jdbcType=VARCHAR},#{item.realName,jdbcType=VARCHAR}, + #{item.lastActiveTime},#{item.role},#{item.status},#{item.userLevel},0) </foreach> </insert> @@ -410,5 +427,21 @@ limit 1 </select> + <select id="selectByIdName" resultMap="BaseResultMap"> + select + <include refid="Base_Column_List" /> + from t_user + <where> + and deleted=0 and id = #{id} + <if test="userName != null and userName != ''"> + and user_name like concat('%',#{userName},"%") + </if> + </where> + </select> + + + <update id="updateDeptAdmin"> + UPDATE t_user SET dept_admin = #{deptAdmin} WHERE id = #{id} AND deleted = 0 + </update> </mapper> -- Gitblit v1.8.0