ProductLimitUserHelpMapper.xml 2.75 KB
<?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.yoho.activity.dal.ProductLimitUserHelpMapper">
  <resultMap id="BaseResultMap" type="com.yoho.activity.dal.model.LimitProductHelpUser">
    <id column="id" jdbcType="INTEGER" property="id" />
    <result column="user_id" property="userId" jdbcType="INTEGER"  />
    <result column="help_user_id" property="helpUserId" jdbcType="VARCHAR"  />
    <result column="help_user_name" property="helpUserName" jdbcType="VARCHAR"  />
    <result column="help_user_img_url" property="helpUserImgUrl" jdbcType="VARCHAR"  />
    <result column="limit_product_code" property="limitProductCode" jdbcType="VARCHAR"  />
    <result column="is_share" property="isShare" jdbcType="VARCHAR"  />
    <result column="create_time" property="createTime" jdbcType="INTEGER"  />
  </resultMap>
  <sql id="Base_Column_List" >
    id, user_id, help_user_id,help_user_name,help_user_img_url,limit_product_code,is_share,create_time
  </sql>

  <select id="selectHelpInfo" resultMap="BaseResultMap">
    select
    <include refid="Base_Column_List" />
    from limit_product_help_user
    where user_id = #{userId,jdbcType=INTEGER}
    and limit_product_code = #{limitProductCode,jdbcType=VARCHAR}
  </select>

  <insert id="addHelpUserInfo" parameterType="com.yoho.activity.dal.model.LimitProductHelpUser">
    insert into limit_product_help_user (user_id, help_user_id,help_user_name,help_user_img_url,limit_product_code,create_time)
    values (#{userId,jdbcType=INTEGER}, #{helpUserId,jdbcType=VARCHAR}, #{helpUserName,jdbcType=VARCHAR},
      #{helpUserImgUrl,jdbcType=VARCHAR}, #{limitProductCode,jdbcType=VARCHAR}, #{createTime,jdbcType=INTEGER}
      )
  </insert>

  <insert id="addShareInfo" parameterType="com.yoho.activity.dal.model.LimitProductHelpUser">
    insert into limit_product_help_user (user_id,limit_product_code,is_share,create_time)
    values (#{userId,jdbcType=INTEGER}, #{limitProductCode,jdbcType=VARCHAR}, #{isShare,jdbcType=VARCHAR},
    #{createTime,jdbcType=INTEGER}
      )
  </insert>

  <select id="selectHelpInfoByUidAndCode" resultMap="BaseResultMap">
    select
    <include refid="Base_Column_List" />
    from limit_product_help_user
    where user_id in
    <foreach collection="list" item="item" open="(" close=")" separator=",">
      #{item}
    </foreach>
    and limit_product_code = #{limitProductCode,jdbcType=VARCHAR}
  </select>

  <select id="selectExistHelpInfo" resultType="java.lang.Integer">
    select count(1) FROM limit_product_help_user
    where user_id = #{userId,jdbcType=INTEGER} AND help_user_id =  #{helpUserId,jdbcType=VARCHAR} AND limit_product_code = #{limitProductCode,jdbcType=VARCHAR}
  </select>
</mapper>