<?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="cn.ezhizao.project.business.account.mapper.BizAccountMapper">

    <resultMap type="cn.ezhizao.project.business.account.domain.BizAccount" id="BizAccountResult">
        <id column="id" property="id"/>
    </resultMap>


    <select id="getList" parameterType="BizAccount" resultMap="BizAccountResult">
        SELECT * FROM biz_account
        <trim prefix=" WHERE" suffix="" suffixOverrides="AND">
            deleted = 0
            and tenant_id = #{tenantId}
            <if test="keyword != null  and keyword != ''"> AND (name like concat('%', #{keyword}, '%') or account_num like concat('%', #{keyword}, '%') or account_open like concat('%', #{keyword}, '%')) </if>
            <if test="name != null  and name != ''"> AND name like concat('%', #{name}, '%')</if>
            <if test="accountNum != null  and accountNum != ''"> AND account_num = #{accountNum}</if>
            <if test="accountOpen != null  and accountOpen != ''"> AND account_open like concat('%', #{accountOpen}, '%')</if>
        </trim>
    </select>

    <delete id="physicalDelete">
        DELETE FROM biz_account
        <trim prefix=" WHERE" suffix="" suffixOverrides="AND">
            <if test="id != null">
                id = #{id} AND
            </if>
       <!-- 删除条件为其他外键可以在这里加 -->
        </trim>
    </delete>
</mapper>
