MYSQL查询用户下多个角色信息

    <resultMap id="baseBeanUser" type="com.aisino.guard.vo.system.TUserVoOut">
        <id column="id" property="id"/>
        <result column="name" property="name"/>
        <result column="actualName" property="actualName"/>
        <result column="ipNum" property="ipNum"/>
        <result column="intime" property="intime"/>
        <result column="departmentName" property="departmentName"/>
        <result column="departmentId" property="departmentId"/>
        <collection
                property="roleNameLst"
                columnPrefix="r_"
                ofType="com.aisino.guard.entity.system.TRole"
        >
            <id column="id" property="id"/>
            <result column="name" property="name"/>
            <result column="deleted" property="deleted"/>
        </collection>
    </resultMap>

    <select id="queryUserPageLst" resultMap="baseBeanUser">
        select
            u.id as id,
            u.name as name,
            u.actual_name as actualName,
            u.ip_num as ipNum,
            u.intime as intime,
            u.department_id as departmentId,
            d.name as departmentName,
            r.id r_id,
            r.name r_name
        from
            t_user as u
        left join t_department as d
        on u.department_id = d.id
        left join t_user_role_rel as usrel
        on  u.id = usrel.ref_user_id
        left join t_role as r
        on r.id = usrel.ref_role_id
        <where>
            u.deleted = ${@com.aisino.guard.vo.system.TUserVO@DELTED_FLAG_N}
            <if test="param.name != null">
                AND p.name = #{param.name}
            </if>
            <if test="param.actualName != null">
                AND u.actual_name = #{param.actualName}
            </if>
            <if test="param.departmentId != null">
                AND u.department_id = #{param.departmentId}
            </if>
        </where>
    </select>

 

转载于:https://www.cnblogs.com/it-way/p/11199495.html

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值