<?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.zxdmy.excite.system.mapper.cloud.role.CloudRoleMapper">

    <!-- 通用查询映射结果 -->
    <resultMap id="BaseResultMap" type="com.zxdmy.excite.system.entity.cloud.role.CloudRole">
        <id column="id" property="id" />
        <result column="role_name" property="roleName" />
        <result column="role_upload" property="roleUpload" />
        <result column="role_down" property="roleDown" />
        <result column="role_delete" property="roleDelete" />
        <result column="create_time" property="createTime" />
        <result column="creator_id" property="creatorId" />
        <result column="creator_name" property="creatorName" />
        <result column="delete_time" property="deleteTime" />
        <result column="delete_id" property="deleteId" />
        <result column="delete_name" property="deleteName" />
    </resultMap>

    <!-- 通用查询结果列 -->
    <sql id="Base_Column_List">
        id, role_name, role_upload, role_down,role_delete, create_time, creator_id, creator_name, delete_time, delete_id, delete_name
    </sql>


    <select id="queryByPage" resultType="com.zxdmy.excite.system.entity.vo.role.RoleVo" >
        select <include refid="Base_Column_List"/>
        from cloud_role
        <trim prefix="WHERE" prefixOverrides="AND">
            delete_time is null
            <if test="data.roleName != null and data.roleName != ''">
                AND role_name LIKE CONCAT('%' ,#{data.roleName}, '%')
            </if>
        </trim>
        LIMIT #{page},#{size};
    </select>

    <select id="queryByPageCount" resultType="java.lang.Integer">
        select count(*)
        from cloud_role
        <trim prefix="WHERE" prefixOverrides="AND">
            <if test="data.roleName != null and data.roleName != ''">
                AND role_name LIKE CONCAT('%' ,#{data.roleName}, '%')
            </if>
        </trim>
    </select>

    <select id="getData" resultType="com.zxdmy.excite.system.entity.vo.role.RoleVo" >
        select <include refid="Base_Column_List"/>
        from cloud_role
        <trim prefix="WHERE" prefixOverrides="AND">
            <if test="data.roleName != null and data.roleName != ''">
                AND role_name = #{data.roleName}
            </if>
        </trim>
    </select>


    <select id="queryByData" resultType="com.zxdmy.excite.system.entity.vo.role.RoleVo" >
        select <include refid="Base_Column_List"/>
        from cloud_role
        <trim prefix="WHERE" prefixOverrides="AND">
            delete_time is null
        </trim>
    </select>
</mapper>
