<?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.willalp.app.mapper.HsAppHomeDataMapper">
    <resultMap type="com.willalp.app.domain.HsAppHomeData" id="HsAppHomeDataResult">
        <result property="homeContentId" column="home_content_id"/>
        <result property="homeParentId" column="home_parent_id"/>
        <result property="text" column="text"/>
        <result property="link" column="link"/>
        <result property="imgPath" column="img_path"/>
        <result property="homeGroupType" column="home_group_type"/>
        <result property="isDelete" column="is_delete"/>
        <result property="createBy" column="create_by"/>
        <result property="createTime" column="create_time"/>
        <result property="updateBy" column="update_by"/>
        <result property="updateTime" column="update_time"/>
        <result property="remark" column="remark"/>
    </resultMap>

    <sql id="selectHsAppHomeDataVo">
        select home_content_id,
               home_parent_id,
               text,
               link,
               img_path,
               home_group_type,
               is_delete,
               create_by,
               create_time,
               update_by,
               update_time,
               remark
        from hs_app_home_data
    </sql>

    <select id="selectHsAppHomeDataList" parameterType="HsAppHomeData" resultMap="HsAppHomeDataResult">
        <include refid="selectHsAppHomeDataVo"/>
        <where>
            is_delete = 0
            <if test="homeParentId != null">
                  and home_parent_id = #{homeParentId}
            </if>
            <if test="text != null  and text != ''">
                  and text = #{text}
            </if>
            <if test="link != null  and link != ''">
                  and link = #{link}
            </if>
            <if test="imgPath != null  and imgPath != ''">
                  and img_path = #{imgPath}
            </if>
            <if test="homeGroupType != null">
                  and home_group_type = #{homeGroupType}
            </if>
        </where>
        order by update_time desc
    </select>
    <select id="selectAppConfigVo" flushCache="true" resultType="com.willalp.app.domain.vo.HsAppHomeDataVo">
        SELECT home_content_id,
        home_parent_id,
        `text`,
        img_path,
        `link`,
        home_group_type,
        update_time
        FROM hs_app_home_data hahd
        <where>
            hahd.is_delete = 0
            AND home_content_id = #{homeId,jdbcType=BIGINT}
                              OR
            hahd.is_delete = 0 and home_parent_id = #{homeId,jdbcType=BIGINT}
        </where>
    </select>
</mapper>
