SysUserMapper.xml 3.02 KB
Newer Older
qinhu's avatar
1  
qinhu committed
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84
<?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="cn.wise.sc.cement.business.mapper.SysUserMapper">


    <sql id="where">
        <where>
            <if test="params.status != null ">
                and su.status = #{params.status}
            </if>
            <if test="params.groupId != null">
                and su.group_id = #{params.groupId}
            </if>
            <if test="params.name != null and params.name != ''">
                and su.name like concat('%', #{params.name}, '%')
            </if>
        </where>
    </sql>

    <select id="getPage" resultType="cn.wise.sc.cement.business.model.vo.UserVo">
        SELECT su.*, sg.name as groupName, sp.name as postName
        FROM sys_user su
        left join sys_group sg on sg.id = su.group_id
        left join sys_post sp on sp.id = su.post_id
        <include refid="where"/>
        ORDER BY su.create_time DESC
    </select>


    <select id="getById" resultType="cn.wise.sc.cement.business.model.vo.UserVo">
        SELECT su.*, sg.name as groupName, sp.name as postName,
        sr.id as roleId, sr.name as roleName
        FROM sys_user su
        left join sys_group sg on sg.id = su.group_id
        left join sys_post sp on sp.id = su.post_id
        left join sys_role_user sru on sru.user_id = su.id
        left join sys_role sr on sr.id = sru.role_id
        where su.id = #{id}
    </select>

    <insert id="saveUserRoles">
        insert into sys_role_user(role_id, user_id) values
            (#{roleId}, #{userId})
    </insert>


    <!--    <select id="exportList" resultType="java.util.HashMap">-->
    <!--        SELECT-->
    <!--        su.id as 序号,-->
    <!--        su.username as 用户账号,-->
    <!--        su.name as 真实姓名,-->
    <!--        (-->
    <!--        CASE su.sex-->
    <!--        WHEN 0 THEN '女'-->
    <!--        ELSE '男'-->
    <!--        END-->
    <!--        )as 性别,-->
    <!--        su.group_id as 组别id,-->
    <!--        su.post_id as 职务id,-->
    <!--        su.wx_id as 微信号,-->
    <!--        su.qualifications as 职称,-->
    <!--        (-->
    <!--        CASE su.status-->
    <!--        WHEN 0 THEN '禁用'-->
    <!--        ELSE '启用'-->
    <!--        END-->
    <!--        )as 状态,-->
    <!--        su.work_year as 工作年限,-->
    <!--        su.phone as 手机号,-->
    <!--        su.fax as 传真,-->
    <!--        su.major as 专业,-->
    <!--        su.email as 邮箱,-->
    <!--        su.technology_date as 从事本技术领域日期,-->
    <!--        su.technology_year as 从事本技术领域年限,-->
    <!--        su.education as 文化程度,-->
    <!--        su.create_time as 创建时间,-->
    <!--        su.update_time as 修改时间,-->
    <!--        su.remark as 备注-->
    <!--        FROM sys_user su-->
    <!--        <include refid="where" />-->
    <!--        ORDER BY su.id ASC-->
    <!--    </select>-->

</mapper>