<?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.starry.admin.modules.system.mapper.SysTenantPackageMapper">
    <resultMap type="com.starry.admin.modules.system.entity.SysTenantPackageEntity" id="SysTenantPackageResult">
        <result property="packageId" column="package_id"/>
        <result property="packageName" column="package_name"/>
        <result property="menuIds" column="menu_ids"/>
        <result property="status" column="status"/>
        <result property="remarks" column="remarks"/>
        <result property="updatedTime" column="updated_time"/>
        <result property="updatedBy" column="updated_by"/>
        <result property="createdTime" column="created_time"/>
        <result property="createdBy" column="created_by"/>
        <result property="deleted" column="deleted"/>
        <result property="version" column="version"/>
    </resultMap>

    <sql id="selectSysTenantPackageVo">
        select package_id,
               package_name,
               menu_ids,
               status,
               remarks,
               updated_time,
               updated_by,
               created_time,
               created_by,
               deleted
        from sys_tenant_package
    </sql>

    <select id="selectSysTenantPackageList" resultMap="SysTenantPackageResult">
        <include refid="selectSysTenantPackageVo"/>
        <where>
            deleted = 0
        </where>
        <if test="vo.packageName != null and vo.packageName != ''">
            AND package_name like concat('%', #{vo.packageName}, '%')
        </if>
        <if test="vo.status != null and vo.status != ''">
            AND status = #{vo.status}
        </if>
    </select>

    <select id="selectSysTenantPackageByPackageId" parameterType="String" resultMap="SysTenantPackageResult">
        <include refid="selectSysTenantPackageVo"/>
        where package_id = #{packageId}
    </select>

    <select id="getSimpleList" resultType="com.starry.admin.modules.system.vo.SimplePackage">
        select package_id as id, package_name as name
        from sys_tenant_package
        where deleted = 0
          and status = '0'
    </select>
</mapper>