<?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.pcloud.book.book.dao.impl.BookLabelDaoImpl">

	<resultMap id="BaseResultMap" type="com.pcloud.book.book.entity.BookLabel">
		<id column="id" property="id" jdbcType="BIGINT" />
		<result column="name" property="name" jdbcType="VARCHAR" />
		<result column="type" property="type" jdbcType="INTEGER" />
	</resultMap>

	<sql id="Base_Column_List">
		id,`name`,`type`
	</sql>

	<select id="getListByType" parameterType="integer" resultMap="BaseResultMap">
		SELECT 
			<include refid="Base_Column_List"/>
		FROM 
			book_label
		where type=#{type}
	</select>

	<!--获取全部-->
	<select id="getAll" resultMap="BaseResultMap">
		select <include refid="Base_Column_List"/>
		from book_label
	</select>

	<!--根据id查询map-->
	<select id="getMapByIds" parameterType="list" resultMap="BaseResultMap">
		select <include refid="Base_Column_List"/>
		from book_label
		where id in
		<foreach collection="list" item="item" open="(" separator="," close=")">
			#{item}
		</foreach>
	</select>

	<select id="getByNameType" resultType="long" parameterType="map">
		SELECT id FROM book_label
		WHERE `name`= #{name}
		AND type = #{type}
		LIMIT 1
	</select>
</mapper>