<?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="cn.pluss.platform.mapper.OfficialActivityMapper">

    <!-- 通用查询映射结果 -->
    <resultMap id="BaseResultMap" type="cn.pluss.platform.entity.OfficialActivity">
        <id column="id" property="id" />
        <result column="officName" property="officName" />
        <result column="officTitle" property="officTitle" />
        <result column="officContent" property="officContent" />
        <result column="officImgUrl" property="officImgUrl" />
        <result column="toImgUrl" property="toImgUrl" />
        <result column="startTime" property="startTime" />
        <result column="endTime" property="endTime" />
        <result column="status" property="status" />
        <result column="remark" property="remark" />
        <result column="createTime" property="createTime" />
        <result column="createBy" property="createBy" />
        <result column="updateTime" property="updateTime" />
        <result column="officRule" property="officRule"/>
        <result column="officDetailImgUrl" property="officDetailImgUrl"/>
        <result column="activityGroupNo" property="activityGroupNo"/>
        <result column="groupBy" property="groupBy"/>
        <result column="actType" property="actType"/>
        <result column="roleType" property="roleType"/>
    </resultMap>



    <update id="updateActivityStatus" parameterType="java.util.Date">
        UPDATE tb_pluss_official_activity
        SET `status` = '3'
        WHERE
        id IN (
        SELECT id FROM(
        SELECT
        id
        FROM
        tb_pluss_official_activity
        WHERE
        endTime <![CDATA[<=]]> #{dateTime} AND `status` = '2' ) a )
    </update>


    <select id="getListByRole" resultType="cn.pluss.platform.entity.OfficialActivity" parameterType="cn.pluss.platform.entity.OfficialActivity">
        select * from tb_pluss_official_activity
        <where>
            <if test="status != null and status != ''">
                and status = #{status}
            </if>
            <if test="activityGroupNo != null and activityGroupNo != ''">
                and activityGroupNo = #{activityGroupNo}
            </if>
            <if test="actType != null and actType != ''">
                and actType = #{actType}
            </if>
            <if test="commonType != null or roleType != null ">
                and (
                <if test="commonType != null and commonType != ''">
                    roleType = #{commonType}
                </if>
                <if test="roleType != null and roleType != ''">
                    or roleType = #{roleType}
                </if>
                )
            </if>
            order by createTime desc
        </where>
    </select>
</mapper>
