2024-12-13 15:27:59 +08:00
|
|
|
|
<?xml version="1.0" encoding="UTF-8"?>
|
|
|
|
|
|
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
|
|
|
|
|
|
<mapper namespace="com.electromagnetic.industry.software.manage.mapper.UserMapper">
|
2024-12-13 16:12:27 +08:00
|
|
|
|
<resultMap id="UserResultMap" type="com.electromagnetic.industry.software.manage.pojo.models.User">
|
|
|
|
|
|
<id column="id" jdbcType="BIGINT" property="id"/>
|
|
|
|
|
|
<result column="user_id" jdbcType="VARCHAR" property="userId"/>
|
|
|
|
|
|
<result column="user_name" jdbcType="VARCHAR" property="userName"/>
|
|
|
|
|
|
<result column="work_number" jdbcType="VARCHAR" property="workNumber"/>
|
|
|
|
|
|
<result column="mobile" jdbcType="VARCHAR" property="mobile"/>
|
|
|
|
|
|
<result column="user_dept" jdbcType="VARCHAR" property="userDept"/>
|
|
|
|
|
|
<result column="user_title" jdbcType="VARCHAR" property="userTitle"/>
|
2025-01-08 15:49:01 +08:00
|
|
|
|
<result column="user_account" jdbcType="VARCHAR" property="userAccount"/>
|
2024-12-13 16:12:27 +08:00
|
|
|
|
<result column="user_pwd" jdbcType="VARCHAR" property="userPwd"/>
|
|
|
|
|
|
<result column="join_time" jdbcType="TIMESTAMP" property="joinTime"/>
|
|
|
|
|
|
<result column="is_published" jdbcType="TINYINT" property="isPublished"/>
|
2024-12-26 15:03:57 +08:00
|
|
|
|
<result column="is_activated" jdbcType="TINYINT" property="isActivated"/>
|
2024-12-13 16:12:27 +08:00
|
|
|
|
<result column="salt" jdbcType="VARCHAR" property="salt"/>
|
|
|
|
|
|
<result column="user_status" jdbcType="VARCHAR" property="userStatus"/>
|
|
|
|
|
|
<result column="internship_end_date" jdbcType="DATE" property="internshipEndDate"/>
|
2025-01-02 14:46:17 +08:00
|
|
|
|
<result column="admin_type" jdbcType="VARCHAR" property="adminType"/>
|
2024-12-13 16:12:27 +08:00
|
|
|
|
<result column="creator" jdbcType="VARCHAR" property="creator"/>
|
|
|
|
|
|
<result column="creator_name" jdbcType="VARCHAR" property="creatorName"/>
|
|
|
|
|
|
<result column="gmt_create" jdbcType="TIMESTAMP" property="gmtCreate"/>
|
|
|
|
|
|
<result column="modifier" jdbcType="VARCHAR" property="modifier"/>
|
|
|
|
|
|
<result column="modifier_name" jdbcType="VARCHAR" property="modifierName"/>
|
|
|
|
|
|
<result column="gmt_modified" jdbcType="TIMESTAMP" property="gmtModified"/>
|
|
|
|
|
|
<result column="effect_flag" jdbcType="TINYINT" property="effectFlag"/>
|
|
|
|
|
|
</resultMap>
|
2024-12-13 15:27:59 +08:00
|
|
|
|
|
2024-12-13 16:12:27 +08:00
|
|
|
|
<sql id="selectUserVo">
|
|
|
|
|
|
select user_id,
|
|
|
|
|
|
user_name,
|
|
|
|
|
|
work_number,
|
|
|
|
|
|
mobile,
|
|
|
|
|
|
user_dept,
|
|
|
|
|
|
user_title,
|
2025-01-08 15:49:01 +08:00
|
|
|
|
user_account,
|
2024-12-13 16:12:27 +08:00
|
|
|
|
user_pwd,
|
|
|
|
|
|
join_time,
|
|
|
|
|
|
is_published,
|
2024-12-26 15:03:57 +08:00
|
|
|
|
is_activated,
|
2024-12-13 16:12:27 +08:00
|
|
|
|
salt,
|
|
|
|
|
|
user_status,
|
|
|
|
|
|
internship_end_date,
|
2025-01-02 14:46:17 +08:00
|
|
|
|
admin_type,
|
2024-12-13 16:12:27 +08:00
|
|
|
|
creator,
|
|
|
|
|
|
creator_name,
|
|
|
|
|
|
gmt_create,
|
|
|
|
|
|
modifier,
|
|
|
|
|
|
modifier_name,
|
|
|
|
|
|
gmt_modified,
|
|
|
|
|
|
effect_flag
|
|
|
|
|
|
from ed_users
|
|
|
|
|
|
</sql>
|
2024-12-13 15:27:59 +08:00
|
|
|
|
|
2024-12-13 16:12:27 +08:00
|
|
|
|
<insert id="insert" parameterType="com.electromagnetic.industry.software.manage.pojo.models.User">
|
|
|
|
|
|
insert into ed_users(
|
2024-12-13 15:27:59 +08:00
|
|
|
|
<if test="userId != null and userId !='' ">user_id,</if>
|
|
|
|
|
|
<if test="userName != null and userName !='' ">user_name,</if>
|
|
|
|
|
|
<if test="workNumber != null and workNumber !='' ">work_number,</if>
|
|
|
|
|
|
<if test="mobile != null and mobile !='' ">mobile,</if>
|
|
|
|
|
|
<if test="userDept != null and userDept !='' ">user_dept,</if>
|
|
|
|
|
|
<if test="userTitle != null and userTitle !='' ">user_title,</if>
|
2025-01-08 15:49:01 +08:00
|
|
|
|
<if test="userAccount != null and userAccount !='' ">user_account,</if>
|
2024-12-13 15:27:59 +08:00
|
|
|
|
<if test="userPwd != null and userPwd !='' ">user_pwd,</if>
|
|
|
|
|
|
<if test="joinTime != null">join_time,</if>
|
|
|
|
|
|
<if test="isPublished != null">is_published,</if>
|
2024-12-26 15:03:57 +08:00
|
|
|
|
<if test="isActivated != null">is_activated,</if>
|
2024-12-13 15:27:59 +08:00
|
|
|
|
<if test="salt != null and salt !='' ">salt,</if>
|
|
|
|
|
|
<if test="userStatus != null and userStatus !='' ">user_status,</if>
|
|
|
|
|
|
<if test="internshipEndDate != null">internship_end_date,</if>
|
|
|
|
|
|
<if test="creator != null and creator !='' ">creator,</if>
|
|
|
|
|
|
<if test="creatorName != null and creatorName !='' ">creator_name,</if>
|
|
|
|
|
|
gmt_create,
|
|
|
|
|
|
effect_flag)
|
2024-12-13 16:12:27 +08:00
|
|
|
|
values (
|
2024-12-13 15:27:59 +08:00
|
|
|
|
<if test="userId != null and userId !='' ">#{userId},</if>
|
|
|
|
|
|
<if test="userName != null and userName !='' ">#{userName},</if>
|
|
|
|
|
|
<if test="workNumber != null and workNumber !='' ">#{workNumber},</if>
|
|
|
|
|
|
<if test="mobile != null and mobile !='' ">#{mobile},</if>
|
|
|
|
|
|
<if test="userDept != null and userDept !='' ">#{userDept},</if>
|
|
|
|
|
|
<if test="userTitle != null and userTitle !='' ">#{userTitle},</if>
|
2025-01-08 15:49:01 +08:00
|
|
|
|
<if test="userAccount != null and userAccount !='' ">#{userAccount},</if>
|
2024-12-13 15:27:59 +08:00
|
|
|
|
<if test="userPwd != null and userPwd !='' ">#{userPwd},</if>
|
|
|
|
|
|
<if test="joinTime != null">#{joinTime},</if>
|
|
|
|
|
|
<if test="isPublished != null">#{isPublished},</if>
|
2024-12-26 15:03:57 +08:00
|
|
|
|
<if test="isActivated != null">#{isActivated},</if>
|
2024-12-13 15:27:59 +08:00
|
|
|
|
<if test="salt != null and salt !='' ">#{salt},</if>
|
|
|
|
|
|
<if test="userStatus != null and userStatus !='' ">#{userStatus},</if>
|
|
|
|
|
|
<if test="internshipEndDate != null">#{internshipEndDate},</if>
|
|
|
|
|
|
<if test="creator != null and creator !='' ">#{creator},</if>
|
|
|
|
|
|
<if test="creatorName != null and creatorName !='' ">#{creatorName},</if>
|
|
|
|
|
|
now(),
|
|
|
|
|
|
1
|
2024-12-13 16:12:27 +08:00
|
|
|
|
)
|
|
|
|
|
|
</insert>
|
|
|
|
|
|
<update id="modify" parameterType="com.electromagnetic.industry.software.manage.pojo.models.User">
|
|
|
|
|
|
update ed_users
|
|
|
|
|
|
<set>
|
|
|
|
|
|
<if test="userId != null and userId != ''">user_id = #{userId},</if>
|
|
|
|
|
|
<if test="userName != null and userName != ''">user_name = #{userName},</if>
|
|
|
|
|
|
<if test="workNumber != null and workNumber != ''">work_number = #{workNumber},</if>
|
|
|
|
|
|
<if test="mobile != null and mobile != ''">mobile = #{mobile},</if>
|
|
|
|
|
|
<if test="userDept != null and userDept != ''">user_dept = #{userDept},</if>
|
|
|
|
|
|
<if test="userTitle != null and userTitle != ''">user_title = #{userTitle},</if>
|
2025-01-08 15:49:01 +08:00
|
|
|
|
<if test="userAccount != null and userAccount != ''">user_account = #{userAccount},</if>
|
2024-12-13 16:12:27 +08:00
|
|
|
|
<if test="joinTime != null">join_time = #{joinTime},</if>
|
|
|
|
|
|
<if test="userStatus != null and userStatus != ''">user_status = #{userStatus},</if>
|
2024-12-26 15:03:57 +08:00
|
|
|
|
<if test="isActivated != null and isActivated != ''">is_activated = #{isActivated},</if>
|
2024-12-26 15:18:46 +08:00
|
|
|
|
<if test="userPwd != null and userPwd != ''">user_pwd = #{userPwd},</if>
|
2024-12-13 16:12:27 +08:00
|
|
|
|
internship_end_date = #{internshipEndDate},
|
|
|
|
|
|
<if test="modifier != null and modifier != ''">modifier = #{modifier},</if>
|
|
|
|
|
|
<if test="modifierName != null and modifierName != ''">modifier_name = #{modifierName},</if>
|
|
|
|
|
|
gmt_modified=now()
|
|
|
|
|
|
</set>
|
|
|
|
|
|
where user_id= #{userId}
|
|
|
|
|
|
</update>
|
2024-12-13 15:27:59 +08:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
<update id="publish" parameterType="com.electromagnetic.industry.software.manage.pojo.other.PublishParam">
|
|
|
|
|
|
update ed_users
|
|
|
|
|
|
<trim prefix="SET" suffixOverrides=",">
|
|
|
|
|
|
is_published = 1,
|
|
|
|
|
|
<if test="modifier != null and modifier != ''">modifier = #{modifier},</if>
|
|
|
|
|
|
<if test="modifierName != null and modifierName != ''">modifier_name = #{modifierName},</if>
|
|
|
|
|
|
gmt_modified = now()
|
|
|
|
|
|
</trim>
|
|
|
|
|
|
where user_id IN
|
|
|
|
|
|
<foreach collection="userIds" item="userId" open="(" separator="," close=")">
|
|
|
|
|
|
#{userId}
|
|
|
|
|
|
</foreach>
|
|
|
|
|
|
</update>
|
|
|
|
|
|
|
2024-12-13 16:12:27 +08:00
|
|
|
|
<select id="search" parameterType="com.electromagnetic.industry.software.manage.pojo.other.SearchKeyWords"
|
|
|
|
|
|
resultMap="UserResultMap">
|
2024-12-13 15:27:59 +08:00
|
|
|
|
SELECT *
|
|
|
|
|
|
FROM ed_users
|
|
|
|
|
|
<where>
|
|
|
|
|
|
<!-- 条件 1:按用户名或工号搜索 -->
|
|
|
|
|
|
<if test="keyWord != null and keyWord != ''">
|
|
|
|
|
|
(user_name LIKE CONCAT('%', #{keyWord}, '%') OR work_number LIKE CONCAT('%', #{keyWord}, '%'))
|
|
|
|
|
|
</if>
|
|
|
|
|
|
|
|
|
|
|
|
<!-- 条件 2:按用户状态搜索 -->
|
|
|
|
|
|
<if test="userStatus != null and userStatus != ''">
|
|
|
|
|
|
<choose>
|
|
|
|
|
|
<when test="userStatus != 'all'">
|
|
|
|
|
|
AND user_status = #{userStatus}
|
|
|
|
|
|
</when>
|
|
|
|
|
|
</choose>
|
|
|
|
|
|
</if>
|
|
|
|
|
|
|
|
|
|
|
|
<!-- 条件 3:按发布状态搜索 -->
|
|
|
|
|
|
<if test="isPublished != null and isPublished != ''">
|
|
|
|
|
|
<choose>
|
|
|
|
|
|
<when test="isPublished != 'all'">
|
|
|
|
|
|
AND is_published = CAST(#{isPublished} AS SIGNED)
|
|
|
|
|
|
</when>
|
|
|
|
|
|
</choose>
|
|
|
|
|
|
</if>
|
2024-12-26 15:03:57 +08:00
|
|
|
|
|
|
|
|
|
|
<!-- 条件 4:按激活状态搜索 -->
|
|
|
|
|
|
<if test="isActivated != null and isActivated != ''">
|
|
|
|
|
|
<choose>
|
|
|
|
|
|
<when test="isActivated != 'all'">
|
|
|
|
|
|
AND is_activated = CAST(#{isActivated} AS SIGNED)
|
|
|
|
|
|
</when>
|
|
|
|
|
|
</choose>
|
|
|
|
|
|
</if>
|
2024-12-13 15:27:59 +08:00
|
|
|
|
and effect_flag=1
|
|
|
|
|
|
</where>
|
|
|
|
|
|
|
|
|
|
|
|
<!-- 动态排序条件 -->
|
|
|
|
|
|
<choose>
|
|
|
|
|
|
<when test="gmtCreate == 'asc' or gmtCreate == 'desc'">
|
|
|
|
|
|
ORDER BY gmt_create ${gmtCreate}
|
|
|
|
|
|
</when>
|
|
|
|
|
|
<when test="joinTime == 'asc' or joinTime == 'desc'">
|
|
|
|
|
|
ORDER BY join_time ${joinTime}
|
|
|
|
|
|
</when>
|
|
|
|
|
|
<when test="internEndDate == 'asc' or internEndDate == 'desc'">
|
|
|
|
|
|
ORDER BY internship_end_date ${internEndDate}
|
|
|
|
|
|
</when>
|
|
|
|
|
|
</choose>
|
|
|
|
|
|
LIMIT #{pageSize} OFFSET #{pageIndex}
|
|
|
|
|
|
</select>
|
|
|
|
|
|
|
2024-12-13 16:12:27 +08:00
|
|
|
|
<select id="getTotalCount" parameterType="com.electromagnetic.industry.software.manage.pojo.other.SearchKeyWords"
|
|
|
|
|
|
resultType="Integer">
|
2024-12-13 15:27:59 +08:00
|
|
|
|
SELECT COUNT(*)
|
|
|
|
|
|
FROM ed_users
|
|
|
|
|
|
<where>
|
|
|
|
|
|
<!-- 条件 1:按用户名或工号搜索 -->
|
|
|
|
|
|
<if test="keyWord != null and keyWord != ''">
|
|
|
|
|
|
(user_name LIKE CONCAT('%', #{keyWord}, '%') OR work_number LIKE CONCAT('%', #{keyWord}, '%'))
|
|
|
|
|
|
</if>
|
|
|
|
|
|
|
|
|
|
|
|
<!-- 条件 2:按用户状态搜索 -->
|
|
|
|
|
|
<if test="userStatus != null and userStatus != ''">
|
|
|
|
|
|
<choose>
|
|
|
|
|
|
<when test="userStatus != 'all'">
|
|
|
|
|
|
AND user_status = #{userStatus}
|
|
|
|
|
|
</when>
|
|
|
|
|
|
</choose>
|
|
|
|
|
|
</if>
|
|
|
|
|
|
|
|
|
|
|
|
<!-- 条件 3:按发布状态搜索 -->
|
|
|
|
|
|
<if test="isPublished != null and isPublished != ''">
|
|
|
|
|
|
<choose>
|
|
|
|
|
|
<when test="isPublished != 'all'">
|
|
|
|
|
|
AND is_published = #{isPublished}
|
|
|
|
|
|
</when>
|
|
|
|
|
|
</choose>
|
|
|
|
|
|
</if>
|
2024-12-26 15:03:57 +08:00
|
|
|
|
|
|
|
|
|
|
<!-- 条件 4:按激活状态搜索 -->
|
|
|
|
|
|
<if test="isActivated != null and isActivated != ''">
|
|
|
|
|
|
<choose>
|
|
|
|
|
|
<when test="isActivated != 'all'">
|
|
|
|
|
|
AND is_activated = CAST(#{isActivated} AS SIGNED)
|
|
|
|
|
|
</when>
|
|
|
|
|
|
</choose>
|
|
|
|
|
|
</if>
|
2024-12-13 15:27:59 +08:00
|
|
|
|
and effect_flag=1
|
|
|
|
|
|
</where>
|
|
|
|
|
|
|
|
|
|
|
|
<!-- 动态排序条件 -->
|
|
|
|
|
|
<choose>
|
|
|
|
|
|
<when test="gmtCreate == 'asc' or gmtCreate == 'desc'">
|
|
|
|
|
|
ORDER BY gmt_create ${gmtCreate}
|
|
|
|
|
|
</when>
|
|
|
|
|
|
<when test="joinTime == 'asc' or joinTime == 'desc'">
|
|
|
|
|
|
ORDER BY join_time ${joinTime}
|
|
|
|
|
|
</when>
|
|
|
|
|
|
<when test="internEndDate == 'asc' or internEndDate == 'desc'">
|
|
|
|
|
|
ORDER BY internship_end_date ${internEndDate}
|
|
|
|
|
|
</when>
|
|
|
|
|
|
</choose>
|
|
|
|
|
|
</select>
|
|
|
|
|
|
|
|
|
|
|
|
<select id="selectUserByWorkNumber" parameterType="String" resultMap="UserResultMap">
|
2024-12-13 16:12:27 +08:00
|
|
|
|
<include refid="selectUserVo"/>
|
2024-12-13 15:27:59 +08:00
|
|
|
|
where work_number = #{workNumber}
|
2024-12-13 16:12:27 +08:00
|
|
|
|
</select>
|
2024-12-13 15:27:59 +08:00
|
|
|
|
|
|
|
|
|
|
<select id="getSingleUser" parameterType="String" resultMap="UserResultMap">
|
2024-12-13 16:12:27 +08:00
|
|
|
|
<include refid="selectUserVo"/>
|
2024-12-13 15:27:59 +08:00
|
|
|
|
where user_id = #{userId}
|
|
|
|
|
|
</select>
|
|
|
|
|
|
|
|
|
|
|
|
<update id="deleteUser" parameterType="com.electromagnetic.industry.software.manage.pojo.other.UserDeleteKeyWords">
|
|
|
|
|
|
update ed_users
|
|
|
|
|
|
<set>
|
|
|
|
|
|
effect_flag=0,
|
|
|
|
|
|
modifier=#{modifier},
|
|
|
|
|
|
modifier_name=#{modifierName},
|
|
|
|
|
|
gmt_modified = now()
|
|
|
|
|
|
</set>
|
|
|
|
|
|
where user_id = #{userId}
|
|
|
|
|
|
</update>
|
2024-12-18 17:08:43 +08:00
|
|
|
|
|
2024-12-26 15:03:57 +08:00
|
|
|
|
<select id="selectUserRoles" parameterType="String" resultType="String">
|
2024-12-27 10:27:21 +08:00
|
|
|
|
select r.role_name
|
|
|
|
|
|
from ed_role r
|
2025-04-17 17:20:19 +08:00
|
|
|
|
where r.id in (select ur.role_id
|
2025-04-18 10:42:21 +08:00
|
|
|
|
from ed_users u
|
|
|
|
|
|
left join ed_user_role ur on u.user_id = ur.user_id
|
|
|
|
|
|
where u.user_id = #{userId})
|
2024-12-26 15:03:57 +08:00
|
|
|
|
</select>
|
|
|
|
|
|
|
2024-12-13 15:27:59 +08:00
|
|
|
|
</mapper>
|