<?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.project.tb_account.TbAccountMapper">



	<!-- ================================== 查询相关 ================================== -->
	<!-- select id, customer_id, account_no, lock_money, act_money, total_money, status, create_time from tb_account  -->
	
	<!-- 通用映射：手动模式 -->
	<resultMap id="model" type="com.pj.project.tb_account.TbAccount">
		<result property="id" column="id" />
		<result property="customerId" column="customer_id" />
		<result property="accountNo" column="account_no" />
		<result property="lockMoney" column="lock_money" />
		<result property="actMoney" column="act_money" />
		<result property="totalMoney" column="total_money" />
		<result property="status" column="status" />
		<result property="createTime" column="create_time" />
	</resultMap>
	
	<!-- 公共查询sql片段 -->
	<sql id="select_sql">
		select * 
		from tb_account 
	</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("customerId") '> and customer_id = #{customerId} </if>
			<if test=' this.has("accountNo") '> and account_no = #{accountNo} </if>
			<if test=' this.has("lockMoney") '> and lock_money = #{lockMoney} </if>
			<if test=' this.has("actMoney") '> and act_money = #{actMoney} </if>
			<if test=' this.has("totalMoney") '> and total_money = #{totalMoney} </if>
			<if test=' this.has("status") '> and status = #{status} </if>
			<if test=' this.has("createTime") '> and create_time = #{createTime} </if>
		</where>
		order by
		<choose>
			<when test='sortType == 1'> id desc </when>
			<when test='sortType == 2'> customer_id desc </when>
			<when test='sortType == 3'> account_no desc </when>
			<when test='sortType == 4'> lock_money desc </when>
			<when test='sortType == 5'> act_money desc </when>
			<when test='sortType == 6'> total_money desc </when>
			<when test='sortType == 7'> status desc </when>
			<when test='sortType == 8'> create_time desc </when>
			<otherwise> id desc </otherwise>
		</choose>
	</select>
	
	
	
	
	
	
	
	
	

</mapper>
