<?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.pj.tb_goods_type.TbGoodsTypeMapper">




	<!-- ================================== 查询相关 ================================== -->
	<!-- select id, name, sort, no, create_time, create_by, create_name, update_time, update_by, update_name, delete_status, parent_id from tb_goods_type  -->
	
	<!-- 通用映射：自动模式 -->
	<resultMap id="model" autoMapping="true" type="com.pj.tb_goods_type.TbGoodsType"></resultMap>
	
	<!-- 公共查询sql片段 -->
	<sql id="select_sql">
		select * 
		from tb_goods_type 
	</sql>

	<insert id="addGoodsToGoodsType">
		insert into tb_goods_type_goods_relation
		(goods_id,goods_type_id)
		values(
		<if  test="goodsId!=null and goodsId!=''"> #{goodsId},</if>
		<if  test="goodsTypeId!=null and goodsTypeId!=''">  #{goodsTypeId}</if>
		)
	</insert>

	<delete id="delGoodsFromGoodsType">
		delete from  tb_goods_type_goods_relation
		<where>
			<if  test="goodsId!=null and goodsId!=''"> goods_id=#{goodsId}</if>
			<if  test="goodsTypeId!=null and goodsTypeId!=''"> and goods_type_id=#{goodsTypeId}</if>
		</where>
	</delete>
	<!-- 查集合 - 根据条件（参数为空时代表忽略指定条件） [G] -->
	<select id="getList" resultMap="model">
		<include refid="select_sql"></include>
<!--		<where>-->
<!--			<if test=' this.has("id") '> and id = #{id} </if>-->
<!--			<if test=' this.has("name") '> and name = #{name} </if>-->
<!--			<if test=' this.has("sort") '> and sort = #{sort} </if>-->
<!--			<if test=' this.has("no") '> and no = #{no} </if>-->
<!--			<if test=' this.has("createTime") '> and create_time = #{createTime} </if>-->
<!--			<if test=' this.has("createBy") '> and create_by = #{createBy} </if>-->
<!--			<if test=' this.has("createName") '> and create_name = #{createName} </if>-->
<!--			<if test=' this.has("updateTime") '> and update_time = #{updateTime} </if>-->
<!--			<if test=' this.has("updateBy") '> and update_by = #{updateBy} </if>-->
<!--			<if test=' this.has("updateName") '> and update_name = #{updateName} </if>-->
<!--			<if test=' this.has("deleteStatus") '> and delete_status = #{deleteStatus} </if>-->
<!--			<if test=' this.has("parentId") '> and parent_id = #{parentId} </if>-->
<!--		</where>-->
<!--		order by-->
<!--		<choose>-->
<!--			<when test='sortType == 1'> id desc </when>-->
<!--			<when test='sortType == 2'> name desc </when>-->
<!--			<when test='sortType == 3'> sort desc </when>-->
<!--			<when test='sortType == 4'> no desc </when>-->
<!--			<when test='sortType == 5'> create_time desc </when>-->
<!--			<when test='sortType == 6'> create_by desc </when>-->
<!--			<when test='sortType == 7'> create_name desc </when>-->
<!--			<when test='sortType == 8'> update_time desc </when>-->
<!--			<when test='sortType == 9'> update_by desc </when>-->
<!--			<when test='sortType == 10'> update_name desc </when>-->
<!--			<when test='sortType == 11'> delete_status desc </when>-->
<!--			<when test='sortType == 12'> parent_id desc </when>-->
<!--			<otherwise> id asc </otherwise>-->
<!--		</choose>-->
	</select>
	
	
	
	
	
	
	
	
	

</mapper>
