| | |
| | | <mapper namespace="com.oying.modules.system.mapper.UserMapper"> |
| | | <resultMap id="BaseResultMap" type="com.oying.modules.system.domain.User"> |
| | | <id column="user_user_id" property="id"/> |
| | | <result column="user_dept_id" property="deptId"/> |
| | | <result column="user_username" property="username"/> |
| | | <result column="user_user_type" property="userType"/> |
| | | <result column="user_openid" property="openid"/> |
| | |
| | | <result column="user_update_by" property="updateBy"/> |
| | | <result column="user_create_time" property="createTime"/> |
| | | <result column="user_update_time" property="updateTime"/> |
| | | <association property="dept" javaType="com.oying.modules.system.domain.Dept"> |
| | | <id column="dept_id" property="id"/> |
| | | <result column="dept_name" property="name"/> |
| | | </association> |
| | | <collection property="jobs" ofType="com.oying.modules.system.domain.Job"> |
| | | <id column="job_id" property="id"/> |
| | | <result column="job_name" property="name"/> |
| | | </collection> |
| | | <collection property="roles" ofType="com.oying.modules.system.domain.Role"> |
| | | <id column="role_id" property="id"/> |
| | | <result column="role_name" property="name"/> |
| | |
| | | </resultMap> |
| | | |
| | | <sql id="Base_Column_List"> |
| | | u.user_id as user_user_id, u.dept_id as user_dept_id, u.username as user_username, |
| | | u.user_id as user_user_id, u.username as user_username, |
| | | u.user_type as user_user_type,u.openid as user_openid, |
| | | u.nick_name as user_nick_name, u.email as user_email, u.phone as user_phone, |
| | | u.gender as user_gender, u.avatar_name as user_avatar_name, u.avatar_path as user_avatar_path, |
| | | u.enabled as user_enabled, u.pwd_reset_time as user_pwd_reset_time, u.create_by as user_create_by, |
| | | u.update_by as user_update_by, u.create_time as user_create_time, u.update_time as user_update_time, |
| | | d.dept_id as dept_id, d.name as dept_name |
| | | </sql> |
| | | |
| | | <sql id="Job_Column_List"> |
| | | j.job_id as job_id, j.name as job_name |
| | | u.update_by as user_update_by, u.create_time as user_create_time, u.update_time as user_update_time |
| | | </sql> |
| | | |
| | | <sql id="Role_Column_List"> |
| | | r.role_id as role_id, r.name as role_name, r.level as role_level, r.data_scope as role_data_scope |
| | | </sql> |
| | | |
| | | <sql id="Whrer_Sql"> |
| | | <sql id="Where_Sql"> |
| | | <where> |
| | | <if test="criteria.id != null"> |
| | | and u.user_id = #{criteria.id} |
| | |
| | | <if test="criteria.enabled != null"> |
| | | and u.enabled = #{criteria.enabled} |
| | | </if> |
| | | <if test="criteria.deptIds != null and criteria.deptIds.size() != 0"> |
| | | and u.dept_id in |
| | | <foreach collection="criteria.deptIds" item="deptId" open="(" separator="," close=")"> |
| | | #{deptId} |
| | | <if test="criteria.userTypes != null and criteria.userTypes.size() != 0"> |
| | | and u.user_type in |
| | | <foreach collection="criteria.userTypes" item="userType" open="(" separator="," close=")"> |
| | | #{userType} |
| | | </foreach> |
| | | </if> |
| | | <if test="criteria.blurry != null and criteria.blurry != ''"> |
| | |
| | | |
| | | <select id="findAll" resultMap="BaseResultMap"> |
| | | select u.*, |
| | | <include refid="Job_Column_List"/>, |
| | | <include refid="Role_Column_List"/> |
| | | from ( |
| | | select |
| | | <include refid="Base_Column_List"/> |
| | | from sys_user u |
| | | left join sys_dept d on u.dept_id = d.dept_id |
| | | <include refid="Whrer_Sql"/> |
| | | <include refid="Where_Sql"/> |
| | | order by u.user_id desc |
| | | <if test="criteria.offset != null"> |
| | | limit #{criteria.offset}, #{criteria.size} |
| | | </if> |
| | | ) u |
| | | left join sys_users_jobs suj on u.user_user_id = suj.user_id |
| | | left join sys_job j on suj.job_id = j.job_id |
| | | left join sys_users_roles sur on u.user_user_id = sur.user_id |
| | | left join sys_role r on sur.role_id = r.role_id |
| | | order by u.user_user_id desc |
| | |
| | | <select id="countAll" resultType="java.lang.Long"> |
| | | select count(*) |
| | | from sys_user u |
| | | <include refid="Whrer_Sql"/> |
| | | <include refid="Where_Sql"/> |
| | | </select> |
| | | |
| | | <select id="findByUsername" resultMap="BaseResultMap"> |
| | |
| | | u.password user_password, u.is_admin user_is_admin, |
| | | <include refid="Base_Column_List"/> |
| | | from sys_user u |
| | | left join sys_dept d on u.dept_id = d.dept_id |
| | | where u.username = #{username} |
| | | </select> |
| | | |
| | |
| | | u.password user_password, u.is_admin user_is_admin, |
| | | <include refid="Base_Column_List"/> |
| | | from sys_user u |
| | | left join sys_dept d on u.dept_id = d.dept_id |
| | | where u.openid = #{openid} |
| | | </select> |
| | | |
| | |
| | | group by u.user_id |
| | | </select> |
| | | |
| | | <select id="findByRoleDeptId" resultType="com.oying.modules.system.domain.User"> |
| | | SELECT u.* FROM sys_user u, sys_users_roles r, sys_roles_depts d |
| | | WHERE u.user_id = r.user_id AND r.role_id = d.role_id AND d.dept_id = #{deptId} |
| | | group by u.user_id |
| | | </select> |
| | | |
| | | <select id="findByMenuId" resultType="com.oying.modules.system.domain.User"> |
| | | SELECT u.user_id as id, u.username FROM sys_user u, sys_users_roles ur, sys_roles_menus rm |
| | | WHERE u.user_id = ur.user_id AND ur.role_id = rm.role_id AND rm.menu_id = #{menuId} |
| | |
| | | WHERE u.user_id = j.user_id AND j.job_id IN |
| | | <foreach collection="jobIds" item="jobId" open="(" separator="," close=")"> |
| | | #{jobId} |
| | | </foreach> |
| | | </select> |
| | | |
| | | <select id="countByDepts" resultType="int"> |
| | | SELECT count(*) FROM sys_user u |
| | | WHERE u.dept_id IN |
| | | <foreach collection="deptIds" item="deptId" open="(" separator="," close=")"> |
| | | #{deptId} |
| | | </foreach> |
| | | </select> |
| | | |