<?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.jumeirah.common.mapper.MerchantUserPermissionMapper">
    <!-- 通用查询结果列 -->
    <sql id="Base_Column_List">

                                id, user_id, permission_id, state, remark, position_name, version, create_time, update_time

    </sql>

    <select id="getPermissionCodesByUserId" resultType="java.lang.String">

        SELECT
            mp.CODE
        FROM
            merchant_user_permission mup
            INNER JOIN merchant_permission mp ON mp.id = mup.permission_id
        WHERE
            mup.user_id = #{userId}

    </select>

    <select id="getMerchantUserPermissionById" resultType="com.jumeirah.common.param.MerchantUserPermissionQueryVo">
        select
        <include refid="Base_Column_List"/>
        from merchant_user_permission where id = #{id}
    </select>

    <select id="getMerchantUserPermissionPageList"
            parameterType="com.jumeirah.common.param.MerchantUserPermissionPageParam"
            resultType="com.jumeirah.common.param.MerchantUserPermissionQueryVo">
        select
        <include refid="Base_Column_List"/>
        from merchant_user_permission
    </select>
</mapper>
