|
@@ -3,24 +3,22 @@
|
|
<mapper namespace="cn.com.ctop.common.module.mapper.SysUserMapper">
|
|
<mapper namespace="cn.com.ctop.common.module.mapper.SysUserMapper">
|
|
|
|
|
|
<select id="selectAllUser" resultType="org.jeecg.common.system.entity.SysUser">
|
|
<select id="selectAllUser" resultType="org.jeecg.common.system.entity.SysUser">
|
|
- select * from sys_user
|
|
|
|
- </select>
|
|
|
|
|
|
+ select *
|
|
|
|
+ from sys_user
|
|
|
|
+ </select>
|
|
|
|
|
|
<!-- 根据用户名查询 -->
|
|
<!-- 根据用户名查询 -->
|
|
<!-- 修改前的版本select * from sys_user where username = #{username} and del_flag = 0 -->
|
|
<!-- 修改前的版本select * from sys_user where username = #{username} and del_flag = 0 -->
|
|
<select id="getUserByName" resultType="org.jeecg.common.system.entity.SysUser">
|
|
<select id="getUserByName" resultType="org.jeecg.common.system.entity.SysUser">
|
|
|
|
|
|
- SELECT
|
|
|
|
- t2.*,
|
|
|
|
- t4.role_name
|
|
|
|
- FROM
|
|
|
|
- sys_user t2
|
|
|
|
- LEFT JOIN sys_user_role t3 ON t2.id = t3.user_id
|
|
|
|
- LEFT JOIN sys_role t4 ON t3.role_id = t4.id
|
|
|
|
- WHERE
|
|
|
|
- t2.username = #{username}
|
|
|
|
- AND t2.del_flag = 0
|
|
|
|
- </select>
|
|
|
|
|
|
+ SELECT t2.*,
|
|
|
|
+ t4.role_name
|
|
|
|
+ FROM sys_user t2
|
|
|
|
+ LEFT JOIN sys_user_role t3 ON t2.id = t3.user_id
|
|
|
|
+ LEFT JOIN sys_role t4 ON t3.role_id = t4.id
|
|
|
|
+ WHERE t2.username = #{username}
|
|
|
|
+ AND t2.del_flag = 0
|
|
|
|
+ </select>
|
|
|
|
|
|
<!-- 根据部门Id查询 -->
|
|
<!-- 根据部门Id查询 -->
|
|
<select id="getUserByDepId" resultType="org.jeecg.common.system.entity.SysUser">
|
|
<select id="getUserByDepId" resultType="org.jeecg.common.system.entity.SysUser">
|
|
@@ -64,41 +62,46 @@
|
|
|
|
|
|
<!-- 修改用户部门code -->
|
|
<!-- 修改用户部门code -->
|
|
<update id="updateUserDepart">
|
|
<update id="updateUserDepart">
|
|
- UPDATE sys_user SET org_code = #{orgCode} where username = #{username}
|
|
|
|
- </update>
|
|
|
|
|
|
+ UPDATE sys_user
|
|
|
|
+ SET org_code = #{orgCode}
|
|
|
|
+ where username = #{username}
|
|
|
|
+ </update>
|
|
|
|
|
|
<!-- 根据手机号查询 -->
|
|
<!-- 根据手机号查询 -->
|
|
<select id="getUserByPhone" resultType="org.jeecg.common.system.entity.SysUser">
|
|
<select id="getUserByPhone" resultType="org.jeecg.common.system.entity.SysUser">
|
|
- select * from sys_user where phone = #{phone} and del_flag = 0
|
|
|
|
- </select>
|
|
|
|
|
|
+ select *
|
|
|
|
+ from sys_user
|
|
|
|
+ where phone = #{phone}
|
|
|
|
+ and del_flag = 0
|
|
|
|
+ </select>
|
|
|
|
|
|
<!-- 根据realname查询 -->
|
|
<!-- 根据realname查询 -->
|
|
<select id="getUserByRealName" resultType="org.jeecg.common.system.entity.SysUser">
|
|
<select id="getUserByRealName" resultType="org.jeecg.common.system.entity.SysUser">
|
|
- select * from sys_user where realname = #{realname} and del_flag = 0 limit 1
|
|
|
|
|
|
+ select *
|
|
|
|
+ from sys_user
|
|
|
|
+ where realname = #{realname}
|
|
|
|
+ and del_flag = 0 limit 1
|
|
</select>
|
|
</select>
|
|
|
|
|
|
<!-- 根据邮箱查询用户信息 -->
|
|
<!-- 根据邮箱查询用户信息 -->
|
|
<select id="getUserByEmail" resultType="org.jeecg.common.system.entity.SysUser">
|
|
<select id="getUserByEmail" resultType="org.jeecg.common.system.entity.SysUser">
|
|
- select * from sys_user where email = #{email} and del_flag = 0
|
|
|
|
- </select>
|
|
|
|
|
|
+ select *
|
|
|
|
+ from sys_user
|
|
|
|
+ where email = #{email}
|
|
|
|
+ and del_flag = 0
|
|
|
|
+ </select>
|
|
<select id="queryRoleCode" parameterType="Object" resultType="java.util.Map">
|
|
<select id="queryRoleCode" parameterType="Object" resultType="java.util.Map">
|
|
-SELECT
|
|
|
|
- role_code roleCode,
|
|
|
|
- role_name roleName,
|
|
|
|
- id roleId
|
|
|
|
- FROM
|
|
|
|
- sys_role
|
|
|
|
- WHERE
|
|
|
|
- id = (
|
|
|
|
- SELECT
|
|
|
|
- t2.role_id
|
|
|
|
- FROM
|
|
|
|
- sys_user t1
|
|
|
|
- LEFT JOIN sys_user_role t2 ON t1.id = t2.user_id
|
|
|
|
- WHERE
|
|
|
|
- t1.id = #{userId,jdbcType=VARCHAR}
|
|
|
|
- )
|
|
|
|
-</select>
|
|
|
|
|
|
+ SELECT role_code roleCode,
|
|
|
|
+ role_name roleName,
|
|
|
|
+ id roleId
|
|
|
|
+ FROM sys_role
|
|
|
|
+ WHERE id = (
|
|
|
|
+ SELECT t2.role_id
|
|
|
|
+ FROM sys_user t1
|
|
|
|
+ LEFT JOIN sys_user_role t2 ON t1.id = t2.user_id
|
|
|
|
+ WHERE t1.id = #{userId,jdbcType=VARCHAR}
|
|
|
|
+ )
|
|
|
|
+ </select>
|
|
<select id="getAllUser" resultType="cn.com.ctop.common.module.vo.SysUserVo">
|
|
<select id="getAllUser" resultType="cn.com.ctop.common.module.vo.SysUserVo">
|
|
SELECT
|
|
SELECT
|
|
t1.id userId,
|
|
t1.id userId,
|
|
@@ -152,34 +155,29 @@ SELECT
|
|
|
|
|
|
</select>
|
|
</select>
|
|
<select id="getAllSale" resultType="cn.com.ctop.common.module.vo.SysUserVo">
|
|
<select id="getAllSale" resultType="cn.com.ctop.common.module.vo.SysUserVo">
|
|
- SELECT
|
|
|
|
- t2.id userId,
|
|
|
|
- t2.username userName,
|
|
|
|
- t2.realname realName,
|
|
|
|
- t4.role_name AS roleName
|
|
|
|
- FROM
|
|
|
|
- user_company t1
|
|
|
|
- LEFT JOIN sys_user t2 ON t1.user_id = t2.id
|
|
|
|
- LEFT JOIN sys_user_role t3 ON t2.id = t3.user_id
|
|
|
|
- LEFT JOIN sys_role t4 ON t3.role_id = t4.id
|
|
|
|
- WHERE
|
|
|
|
- t4.role_name LIKE '%销售%';
|
|
|
|
|
|
+ SELECT t2.id userId,
|
|
|
|
+ t2.username userName,
|
|
|
|
+ t2.realname realName,
|
|
|
|
+ t4.role_name AS roleName
|
|
|
|
+ FROM user_company t1
|
|
|
|
+ LEFT JOIN sys_user t2 ON t1.user_id = t2.id
|
|
|
|
+ LEFT JOIN sys_user_role t3 ON t2.id = t3.user_id
|
|
|
|
+ LEFT JOIN sys_role t4 ON t3.role_id = t4.id
|
|
|
|
+ WHERE t4.role_name LIKE '%销售%';
|
|
</select>
|
|
</select>
|
|
|
|
|
|
|
|
|
|
<select id="getAllSalesByCompanyId" resultType="cn.com.ctop.common.module.vo.SysUserVo">
|
|
<select id="getAllSalesByCompanyId" resultType="cn.com.ctop.common.module.vo.SysUserVo">
|
|
- SELECT
|
|
|
|
- t2.id userId,
|
|
|
|
- t2.username userName,
|
|
|
|
- t2.realname realName,
|
|
|
|
- t4.role_name AS roleName
|
|
|
|
- FROM
|
|
|
|
- user_company t1
|
|
|
|
- LEFT JOIN sys_user t2 ON t1.user_id = t2.id
|
|
|
|
- LEFT JOIN sys_user_role t3 ON t2.id = t3.user_id
|
|
|
|
- LEFT JOIN sys_role t4 ON t3.role_id = t4.id
|
|
|
|
- WHERE t1.company_id = #{companyId}
|
|
|
|
- and t4.role_name LIKE '%销售%';
|
|
|
|
|
|
+ SELECT t2.id userId,
|
|
|
|
+ t2.username userName,
|
|
|
|
+ t2.realname realName,
|
|
|
|
+ t4.role_name AS roleName
|
|
|
|
+ FROM user_company t1
|
|
|
|
+ LEFT JOIN sys_user t2 ON t1.user_id = t2.id
|
|
|
|
+ LEFT JOIN sys_user_role t3 ON t2.id = t3.user_id
|
|
|
|
+ LEFT JOIN sys_role t4 ON t3.role_id = t4.id
|
|
|
|
+ WHERE t1.company_id = #{companyId}
|
|
|
|
+ and t4.role_name LIKE '%销售%';
|
|
</select>
|
|
</select>
|
|
<!-- 根据 orgCode 查询用户,包括子部门下的用户 -->
|
|
<!-- 根据 orgCode 查询用户,包括子部门下的用户 -->
|
|
<select id="getUserByOrgCode" resultType="cn.com.ctop.common.module.model.SysUserSysDepartModel">
|
|
<select id="getUserByOrgCode" resultType="cn.com.ctop.common.module.model.SysUserSysDepartModel">
|
|
@@ -223,30 +221,34 @@ SELECT
|
|
|
|
|
|
<!-- 查询被逻辑删除的用户 -->
|
|
<!-- 查询被逻辑删除的用户 -->
|
|
<select id="selectLogicDeleted" resultType="org.jeecg.common.system.entity.SysUser">
|
|
<select id="selectLogicDeleted" resultType="org.jeecg.common.system.entity.SysUser">
|
|
- SELECT * FROM sys_user ${ew.customSqlSegment}
|
|
|
|
- </select>
|
|
|
|
|
|
+ SELECT *
|
|
|
|
+ FROM sys_user ${ew.customSqlSegment}
|
|
|
|
+ </select>
|
|
|
|
|
|
<!-- 更新被逻辑删除的用户 -->
|
|
<!-- 更新被逻辑删除的用户 -->
|
|
<update id="revertLogicDeleted">
|
|
<update id="revertLogicDeleted">
|
|
- UPDATE
|
|
|
|
- sys_user
|
|
|
|
- SET
|
|
|
|
- del_flag = 0,
|
|
|
|
- update_by = #{entity.updateBy},
|
|
|
|
- update_time = #{entity.updateTime}
|
|
|
|
- WHERE
|
|
|
|
- del_flag = 1
|
|
|
|
- AND id IN (${userIds})
|
|
|
|
- </update>
|
|
|
|
|
|
+ UPDATE
|
|
|
|
+ sys_user
|
|
|
|
+ SET del_flag = 0,
|
|
|
|
+ update_by = #{entity.updateBy},
|
|
|
|
+ update_time = #{entity.updateTime}
|
|
|
|
+ WHERE del_flag = 1
|
|
|
|
+ AND id IN (${userIds})
|
|
|
|
+ </update>
|
|
|
|
|
|
<!-- 彻底删除被逻辑删除的用户 -->
|
|
<!-- 彻底删除被逻辑删除的用户 -->
|
|
<delete id="deleteLogicDeleted">
|
|
<delete id="deleteLogicDeleted">
|
|
- DELETE FROM sys_user WHERE del_flag = 1 AND id IN (${userIds})
|
|
|
|
- </delete>
|
|
|
|
|
|
+ DELETE
|
|
|
|
+ FROM sys_user
|
|
|
|
+ WHERE del_flag = 1
|
|
|
|
+ AND id IN (${userIds})
|
|
|
|
+ </delete>
|
|
|
|
|
|
<!-- 更新空字符串为null -->
|
|
<!-- 更新空字符串为null -->
|
|
<update id="updateNullByEmptyString">
|
|
<update id="updateNullByEmptyString">
|
|
- UPDATE sys_user SET ${fieldName} = NULL WHERE ${fieldName} = ''
|
|
|
|
|
|
+ UPDATE sys_user
|
|
|
|
+ SET ${fieldName} = NULL
|
|
|
|
+ WHERE ${fieldName} = ''
|
|
</update>
|
|
</update>
|
|
|
|
|
|
<!-- 通过多个部门IDS,查询部门下的用户信息 -->
|
|
<!-- 通过多个部门IDS,查询部门下的用户信息 -->
|
|
@@ -266,26 +268,31 @@ SELECT
|
|
|
|
|
|
<select id="selectUserByAccount" resultType="com.alibaba.fastjson.JSONObject">
|
|
<select id="selectUserByAccount" resultType="com.alibaba.fastjson.JSONObject">
|
|
SELECT *
|
|
SELECT *
|
|
- FROM sys_user t1
|
|
|
|
- INNER JOIN ctop_user_allocation t2 ON t1.id = t2.user_id
|
|
|
|
|
|
+ FROM sys_user t1
|
|
|
|
+ INNER JOIN ctop_user_allocation t2 ON t1.id = t2.user_id
|
|
WHERE t2.account_id = #{accountId}
|
|
WHERE t2.account_id = #{accountId}
|
|
</select>
|
|
</select>
|
|
<select id="selectAllDesigner" resultType="org.jeecg.common.system.entity.SysUser">
|
|
<select id="selectAllDesigner" resultType="org.jeecg.common.system.entity.SysUser">
|
|
- select user.realname,user.id,role.role_name from sys_user_role userRole left join sys_user user on userRole.user_id = user.id
|
|
|
|
- left join sys_role role on userRole.role_id = role.id
|
|
|
|
- where role.role_code in ('plane','plan','shot','clip','designTeamLeader')
|
|
|
|
- and user.status = 1
|
|
|
|
|
|
+ select user.realname, user.id, role.role_name
|
|
|
|
+ from sys_user_role userRole
|
|
|
|
+ left join sys_user user
|
|
|
|
+ on userRole.user_id = user.id
|
|
|
|
+ left join sys_role role on userRole.role_id = role.id
|
|
|
|
+ where role.role_code in ('plane'
|
|
|
|
+ , 'plan'
|
|
|
|
+ , 'shot'
|
|
|
|
+ , 'clip'
|
|
|
|
+ , 'designTeamLeader')
|
|
|
|
+ and user.status = 1
|
|
</select>
|
|
</select>
|
|
<select id="getDesignerTeamLeaderBy" resultType="org.jeecg.common.system.entity.SysUser">
|
|
<select id="getDesignerTeamLeaderBy" resultType="org.jeecg.common.system.entity.SysUser">
|
|
- SELECT
|
|
|
|
- user2.realname,user2.id
|
|
|
|
|
|
+ SELECT user2.realname,
|
|
|
|
+ user2.id
|
|
FROM sys_user user2
|
|
FROM sys_user user2
|
|
- LEFT JOIN sys_user_role userRole ON user2.id = userRole.user_id
|
|
|
|
- LEFT JOIN sys_role role ON userRole.role_id = role.id
|
|
|
|
- WHERE
|
|
|
|
- user2.org_code = #{orgCode}
|
|
|
|
- AND
|
|
|
|
- role.role_code = 'designTeamLeader'
|
|
|
|
|
|
+ LEFT JOIN sys_user_role userRole ON user2.id = userRole.user_id
|
|
|
|
+ LEFT JOIN sys_role role ON userRole.role_id = role.id
|
|
|
|
+ WHERE user2.org_code = #{orgCode}
|
|
|
|
+ AND role.role_code = 'designTeamLeader'
|
|
</select>
|
|
</select>
|
|
|
|
|
|
<!-- 查询用户列表-->
|
|
<!-- 查询用户列表-->
|
|
@@ -341,21 +348,103 @@ SELECT
|
|
</select>
|
|
</select>
|
|
|
|
|
|
|
|
|
|
-
|
|
|
|
-
|
|
|
|
<!-- 修改用户 设计组长姓名 -->
|
|
<!-- 修改用户 设计组长姓名 -->
|
|
<update id="updUserDesignLeaderById">
|
|
<update id="updUserDesignLeaderById">
|
|
- UPDATE sys_user SET design_team_leader_name = #{designTeamLeaderName} WHERE id = #{userId}
|
|
|
|
|
|
+ UPDATE sys_user
|
|
|
|
+ SET design_team_leader_name = #{designTeamLeaderName}
|
|
|
|
+ WHERE id = #{userId}
|
|
</update>
|
|
</update>
|
|
|
|
|
|
<select id="getUserIdsByLeaderId" resultType="java.lang.String">
|
|
<select id="getUserIdsByLeaderId" resultType="java.lang.String">
|
|
- select id from sys_user
|
|
|
|
|
|
+ select id
|
|
|
|
+ from sys_user
|
|
where leader_id = #{leaderId}
|
|
where leader_id = #{leaderId}
|
|
</select>
|
|
</select>
|
|
|
|
|
|
<select id="getDepart" resultType="com.alibaba.fastjson.JSONObject">
|
|
<select id="getDepart" resultType="com.alibaba.fastjson.JSONObject">
|
|
- select * from sys_manager_company
|
|
|
|
|
|
+ select *
|
|
|
|
+ from sys_manager_company
|
|
where id = #{companyId}
|
|
where id = #{companyId}
|
|
</select>
|
|
</select>
|
|
|
|
|
|
|
|
+
|
|
|
|
+ <select id="getQuarterlyChangeRoleOperators" resultType="com.alibaba.fastjson.JSONObject">
|
|
|
|
+ SELECT
|
|
|
|
+ t1.user_id as 'userId',
|
|
|
|
+ t2.realname,
|
|
|
|
+ t.role_name as 'roleName',
|
|
|
|
+ t.role_code as 'roleCode',
|
|
|
|
+ DATE_FORMAT(t3.create_time, '%Y-%m-%d %H:%i:%s') as 'upTime'
|
|
|
|
+ FROM `sys_role` t
|
|
|
|
+ LEFT JOIN sys_user_role t1 ON t.id = t1.role_id
|
|
|
|
+ LEFT JOIN sys_user t2 ON t1.user_id = t2.id
|
|
|
|
+ LEFT JOIN sys_role_change_record t3 ON t1.user_id = t3.user_id
|
|
|
|
+ LEFT JOIN ctop_user_allocation t4 ON t1.user_id = t4.user_id
|
|
|
|
+ WHERE t.role_code in
|
|
|
|
+ <foreach collection="roleCode" item="roleCode" separator="," open="(" close=")">
|
|
|
|
+ #{roleCode}
|
|
|
|
+ </foreach>
|
|
|
|
+ <if test="userId != null and userId != ''">
|
|
|
|
+ AND t1.user_id =#{userId}
|
|
|
|
+ </if>
|
|
|
|
+ AND t1.user_id is not null
|
|
|
|
+ AND t3.create_time >=#{startDate}
|
|
|
|
+ AND t3.create_time <=#{endDate}
|
|
|
|
+ AND t4.media_id = #{mediaId}
|
|
|
|
+ GROUP BY t1.user_id
|
|
|
|
+ </select>
|
|
|
|
+
|
|
|
|
+ <select id="getQuarterlyOnJobOperators" resultType="com.alibaba.fastjson.JSONObject">
|
|
|
|
+ SELECT
|
|
|
|
+ t1.user_id as 'userId',
|
|
|
|
+ t2.realname,
|
|
|
|
+ t.role_code as 'roleCode',
|
|
|
|
+ t.role_name as 'roleName'
|
|
|
|
+ FROM `sys_role` t
|
|
|
|
+ LEFT JOIN sys_user_role t1 ON t.id = t1.role_id
|
|
|
|
+ LEFT JOIN sys_user t2 ON t1.user_id = t2.id
|
|
|
|
+ LEFT JOIN ctop_user_allocation t3 ON t1.user_id = t3.user_id
|
|
|
|
+ WHERE t.role_code in
|
|
|
|
+ <foreach collection="roleCode" item="roleCode" separator="," open="(" close=")">
|
|
|
|
+ #{roleCode}
|
|
|
|
+ </foreach>
|
|
|
|
+ <if test="userId != null and userId != ''">
|
|
|
|
+ AND t1.user_id =#{userId}
|
|
|
|
+ </if>
|
|
|
|
+ AND t2.status=1
|
|
|
|
+ AND t1.user_id is not null
|
|
|
|
+ <if test="changeRoleUserIds != null and changeRoleUserIds.size() > 0">
|
|
|
|
+ AND t1.user_id not in
|
|
|
|
+ <foreach collection="changeRoleUserIds" item="user" separator="," open="(" close=")">
|
|
|
|
+ #{user.userId}
|
|
|
|
+ </foreach>
|
|
|
|
+ </if>
|
|
|
|
+ AND t3.media_id = #{mediaId}
|
|
|
|
+ GROUP BY t1.user_id
|
|
|
|
+ </select>
|
|
|
|
+
|
|
|
|
+ <select id="getQuarterlyOffJobOperators" resultType="com.alibaba.fastjson.JSONObject">
|
|
|
|
+ SELECT
|
|
|
|
+ t1.user_id as 'userId',
|
|
|
|
+ t2.realname,
|
|
|
|
+ t.role_name as 'roleName',
|
|
|
|
+ t.role_code as 'roleCode',
|
|
|
|
+ frozen_time as 'quitTime'
|
|
|
|
+ FROM `sys_role` t
|
|
|
|
+ LEFT JOIN sys_user_role t1 ON t.id = t1.role_id
|
|
|
|
+ LEFT JOIN sys_user t2 ON t1.user_id = t2.id
|
|
|
|
+ LEFT JOIN ctop_user_allocation t3 ON t1.user_id = t3.user_id
|
|
|
|
+ WHERE t.role_code in
|
|
|
|
+ <foreach collection="roleCode" item="roleCode" separator="," open="(" close=")">
|
|
|
|
+ #{roleCode}
|
|
|
|
+ </foreach>
|
|
|
|
+ <if test="userId != null and userId != ''">
|
|
|
|
+ AND t1.user_id =#{userId}
|
|
|
|
+ </if>
|
|
|
|
+ AND t2.status= 2
|
|
|
|
+ AND frozen_time >=#{startDate}
|
|
|
|
+ AND frozen_time <=#{endDate}
|
|
|
|
+ AND t3.media_id = #{mediaId}
|
|
|
|
+ GROUP BY t1.user_id
|
|
|
|
+ </select>
|
|
</mapper>
|
|
</mapper>
|