<?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.bonus.boot.manager.basic.dao.PackageTypeDao">
    <insert id="addInfo">
        insert into pm_base_type_package (type_name,package_descri,is_active)
        values (#{typeName},#{packageDescri},'1')
    </insert>

    <update id="updateInfo">
        update pm_base_type_package set type_name = #{typeName},package_descri = #{packageDescri}
        where id = #{id}
    </update>

    <delete id="delById">
        update pm_base_type_package set is_active = '0' where id = #{id}
    </delete>

    <select id="getList" resultType="com.bonus.boot.manager.basic.entity.BaseTypePackageBean">
        select
            id,
            case when type_name = '1' then '标准套餐' when type_name = '2' then '个性化套餐' when type_name = '3' then '职业健康套餐' end as typeName,
            package_descri as packageDescri
        from pm_base_type_package
        where is_active = '1'
        <if test="typeName != null and typeName != ''">
            AND type_name LIKE concat ('%',#{typeName},'%')
        </if>
    </select>

    <select id="getListById" resultType="com.bonus.boot.manager.basic.entity.BaseTypePackageBean">
        select
            id,
            type_name as typeName,
            package_descri as packageDescri
        from pm_base_type_package
        where is_active = '1' and id = #{id}
    </select>
</mapper>

