<?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.com.countrygarden.bi.main.dao.marketing.CommOperationHistoryMapper">
  <resultMap id="BaseResultMap" type="cn.com.countrygarden.bi.main.model.marketing.CommOperationHistory">
    <!--
      WARNING - @mbg.generated
    -->
    <id column="id" jdbcType="INTEGER" property="id" />
    <result column="comm_id" jdbcType="INTEGER" property="commId" />
    <result column="comment" jdbcType="VARCHAR" property="comment" />
    <result column="content" jdbcType="VARCHAR" property="content" />
    <result column="name" jdbcType="VARCHAR" property="name" />
    <result column="gmt_create" jdbcType="TIMESTAMP" property="gmtCreate" />
    <result column="create_by" jdbcType="VARCHAR" property="createBy" />
  </resultMap>

  <select id="search" parameterType="Map" resultMap="BaseResultMap">
    SELECT id, comm_id, comment, content, name, gmt_create, create_by
    FROM comm_operation_history AS o
    <where>
      <if test="commId > 0">
        AND o.comm_id = #{commId, jdbcType = INTEGER}
      </if>
    </where>
    ORDER BY id DESC
  </select>

  <select id="sumProjectByStatusAndTime" resultType="java.lang.Integer">
    <![CDATA[
      SELECT COUNT(DISTINCT comm_id)
      FROM comm_operation_history
      WHERE gmt_create>=#{startDate} AND gmt_create<=#{endDate} AND name=#{statusName}
    ]]>
  </select>
</mapper>