<?xml version="1.0" encoding="UTF-8" ?>
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "mybatis-3-mapper.dtd" >
<mapper namespace="com.pcloud.book.group.dao.impl.GroupQrcodeStyleDaoImpl" >
  <resultMap id="BaseResultMap" type="com.pcloud.book.group.entity.GroupQrcodeStyle" >
    <id column="QRCODE_STYLE_ID" property="qrcodeStyleId" jdbcType="BIGINT" />
    <result column="book_group_id" property="bookGroupId" jdbcType="BIGINT" />
    <result column="LOGO_URL" property="logoUrl" jdbcType="BIGINT" />
    <result column="OLD_RED_COLOR" property="oldRedColor" jdbcType="BIGINT" />
    <result column="OLD_GREEN_COLOR" property="oldGreenColor" jdbcType="BIGINT" />
    <result column="OLD_BLUE_COLOR" property="oldBlueColor" jdbcType="BIGINT" />
    <result column="NEW_RED_COLOR" property="newRedColor" jdbcType="BIGINT" />
    <result column="NEW_GREEN_COLOR" property="newGreenColor" jdbcType="BIGINT" />
    <result column="NEW_BLUE_COLOR" property="newBlueColor" jdbcType="BIGINT" />
    <result column="ON_COLOR" property="onColor" jdbcType="VARCHAR" />
    <result column="STYLE_TYPE" property="styleType" jdbcType="BIGINT" />
  </resultMap>
  
	<sql id="Base_Column_List" >
	    QRCODE_STYLE_ID, book_group_id, LOGO_URL, OLD_RED_COLOR, OLD_GREEN_COLOR,OLD_BLUE_COLOR, 
	    NEW_RED_COLOR, NEW_GREEN_COLOR, NEW_BLUE_COLOR, ON_COLOR,STYLE_TYPE
	</sql>
  
	<!-- 删除二维码关联的样式 -->
	<delete id="delQrcodeStyle" parameterType="Long">
		delete from
		group_qrcode_style
		where book_group_id=#{bookGroupId}
	</delete>
  
    <!-- 添加二维码标签关联 -->
     <insert id="insert" parameterType="com.pcloud.book.group.entity.GroupQrcodeStyle" useGeneratedKeys="true" keyProperty="qrcodeStyleId" >
	    insert into group_qrcode_style (book_group_id, LOGO_URL, OLD_RED_COLOR, OLD_GREEN_COLOR,
	      OLD_BLUE_COLOR, NEW_RED_COLOR, NEW_GREEN_COLOR, 
	      NEW_BLUE_COLOR, ON_COLOR,STYLE_TYPE)
	    values (#{bookGroupId,jdbcType=BIGINT}, #{logoUrl,jdbcType=BIGINT}, #{oldRedColor,jdbcType=BIGINT}, 
	      #{oldGreenColor,jdbcType=BIGINT}, #{oldBlueColor,jdbcType=BIGINT}, 
	      #{newRedColor,jdbcType=BIGINT}, #{newGreenColor,jdbcType=BIGINT}, 
	      #{newBlueColor,jdbcType=BIGINT}, #{onColor,jdbcType=VARCHAR},#{styleType,jdbcType=BIGINT}
	     )
     </insert>
     
    <!-- 获取二维码关联标签 -->
    <select id="getQrcodeStyleByBookGroupId" resultMap="BaseResultMap" parameterType="java.lang.Long" >
		SELECT
			QRCODE_STYLE_ID,
			book_group_id,
			LOGO_URL,
			OLD_RED_COLOR,
			OLD_GREEN_COLOR,
			OLD_BLUE_COLOR,
			NEW_RED_COLOR,
			NEW_GREEN_COLOR,
			NEW_BLUE_COLOR,
			ON_COLOR,
			STYLE_TYPE
		FROM
		group_qrcode_style
		WHERE
		book_group_id = #{bookGroupId,jdbcType=BIGINT}
		limit 1
    </select>
  
  
</mapper>