<?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="org.springblade.modules.guosen.activity.mapper.ActivityMapper">

    <!-- 通用查询映射结果 -->
    <resultMap id="activityResultMap" type="org.springblade.modules.guosen.activity.vo.ActivityVO">
        <result column="id" property="id"/>
        <result column="create_user" property="createUser"/>
        <result column="create_dept" property="createDept"/>
        <result column="create_time" property="createTime"/>
        <result column="update_user" property="updateUser"/>
        <result column="update_time" property="updateTime"/>
        <result column="status" property="status"/>
        <result column="is_deleted" property="isDeleted"/>
        <result column="name" property="name"/>
        <result column="begin_time" property="beginTime"/>
        <result column="end_time" property="endTime"/>
        <result column="description" property="description"/>
        <result column="introduction" property="introduction"/>
        <result column="ads" property="ads"/>
        <result column="cover" property="cover"/>
        <result column="reward" property="reward"/>
        <result column="allmoods" property="allmoods"/>
        <result column="activity_status" property="activityStatus"/>
        <result column="gross_profit_rate" property="grossProfitRate"/>
    </resultMap>


    <select id="selectActivityPage" resultMap="activityResultMap">
        select * from cyzh_activity where is_deleted = 0
    </select>

    <select id="selectPageWithTag" resultType="org.springblade.modules.guosen.activity.vo.ActivityVO">
        select a.*,GROUP_CONCAT(c.name) as tags
        from cyzh_activity as a
        left join cyzh_activity_tag as b on a.id = b.activity_id
        left join cyzh_tag as c on b.tag_id = c.id
        where a.is_deleted = 0 and a.enable=1
        <if test="activity!=null">
            <if test="activity.name != null and activity.name != ''">
               and a.name like concat('%',#{activity.name},'%')
            </if>
        </if>
        group by a.id
    </select>



</mapper>
