<?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_item_rules.TbItemRulesMapper">




	<!-- ================================== 查询相关 ================================== -->
	<!-- select id, goods_codes, create_time, update_by, update_by_name, update_time, update_by_id, fee_type, percent, fee_money from tb_item_rules  -->

	<!-- 通用映射：自动模式 -->
	<resultMap id="model" autoMapping="true" type="com.pj.tb_item_rules.TbItemRules"></resultMap>

	<!-- 公共查询sql片段 -->
	<sql id="select_sql">
		select *
		from tb_item_rules
	</sql>


	<!-- 查集合 - 根据条件（参数为空时代表忽略指定条件） [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("goodsCodes") '> and goods_codes = #{goodsCodes} </if>
			<if test=' this.has("updateBy") '> and update_by = #{updateBy} </if>
			<if test=' this.has("updateByName") '> and update_by_name = #{updateByName} </if>
			<if test=' this.has("updateById") '> and update_by_id = #{updateById} </if>
			<if test=' this.has("feeType") '> and fee_type = #{feeType} </if>
			<if test=' this.has("percent") '> and percent = #{percent} </if>
			<if test=' this.has("feeMoney") '> and fee_money = #{feeMoney} </if>
			<if test=' this.has("itemId") '> and item_id = #{itemId} </if>
		</where>
		order by
		<choose>
			<when test='sortType == 1'> id desc </when>
			<when test='sortType == 2'> goods_codes desc </when>
			<when test='sortType == 3'> create_time desc </when>
			<when test='sortType == 4'> update_by desc </when>
			<when test='sortType == 5'> update_by_name desc </when>
			<when test='sortType == 6'> update_time desc </when>
			<when test='sortType == 7'> update_by_id desc </when>
			<when test='sortType == 8'> fee_type desc </when>
			<when test='sortType == 9'> percent desc </when>
			<when test='sortType == 10'> fee_money desc </when>
			<otherwise> id desc </otherwise>
		</choose>
	</select>


	<select id="getAllList" resultType="com.pj.tb_item_rules.TbItemRulesVo">
		select i.name,i.company_name,r.*
		from tb_fee_item i
		left join tb_item_rules r on i.id = r.item_id
	</select>







</mapper>
