<?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.xhpc.activity.mapper.XhpcActivityImgMapper">
  <resultMap id="BaseResultMap" type="com.xhpc.activity.domain.XhpcActivityImgDomain">
    <id column="activity_img_id" jdbcType="BIGINT" property="activityImgId" />
    <result column="activity_type" jdbcType="VARCHAR" property="activityType" />
    <result column="activity_id" jdbcType="INTEGER" property="activityId" />
    <result column="img_name" jdbcType="VARCHAR" property="imgName" />
    <result column="img_url" jdbcType="VARCHAR" property="imgUrl" />
    <result column="del_flag" jdbcType="SMALLINT" property="delFlag" />
    <result column="create_by" jdbcType="VARCHAR" property="createBy" />
    <result column="create_time" jdbcType="TIMESTAMP" property="createTime" />
  </resultMap>
  <sql id="Base_Column_List">
    activity_img_id, activity_type, activity_id, img_name, img_url, del_flag, create_by, 
    create_time
  </sql>


  <select id="selectListByActivityId" resultMap="BaseResultMap">
    select
    <include refid="Base_Column_List" />
    from xhpc_activity_img
    where del_flag = 0 and activity_type=#{activityType} and activity_id=#{activityId}
  </select>


  <update id="deleteLogicByActivityId">
    update xhpc_activity_img set del_flag=2
    where activity_type=#{activityType} and activity_id=#{activityId}
  </update>


  <select id="selectByPrimaryKey" parameterType="java.lang.Long" resultMap="BaseResultMap">
    select 
    <include refid="Base_Column_List" />
    from xhpc_activity_img
    where activity_img_id = #{activityImgId,jdbcType=BIGINT}
  </select>


  <update id="deleteLogicByPrimaryKey" parameterType="java.lang.Long">
    update xhpc_activity_img set del_flag=2
    where activity_img_id = #{activityImgId,jdbcType=BIGINT}
  </update>


  <delete id="deleteByPrimaryKey" parameterType="java.lang.Long">
    delete from xhpc_activity_img
    where activity_img_id = #{activityImgId,jdbcType=BIGINT}
  </delete>


  <insert id="insert" keyColumn="activity_img_id" keyProperty="activityImgId" parameterType="com.xhpc.activity.domain.XhpcActivityImgDomain" useGeneratedKeys="true">
    insert into xhpc_activity_img (activity_type, activity_id, img_name, 
      img_url, del_flag, create_by, 
      create_time)
    values (#{activityType,jdbcType=VARCHAR}, #{activityId,jdbcType=INTEGER}, #{imgName,jdbcType=VARCHAR}, 
      #{imgUrl,jdbcType=VARCHAR}, 0, #{createBy,jdbcType=VARCHAR},
      sysdate())
  </insert>


  <update id="updateByPrimaryKey" parameterType="com.xhpc.activity.domain.XhpcActivityImgDomain">
    update xhpc_activity_img
    set activity_type = #{activityType,jdbcType=VARCHAR},
      activity_id = #{activityId,jdbcType=INTEGER},
      img_name = #{imgName,jdbcType=VARCHAR},
      img_url = #{imgUrl,jdbcType=VARCHAR},
      create_by = #{createBy,jdbcType=VARCHAR},
      create_time = sysdate()
    where activity_img_id = #{activityImgId,jdbcType=BIGINT}
  </update>

</mapper>