<?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.process.mapper.BizProcessMapper">

    <resultMap type="cn.ezhizao.project.business.process.domain.BizProcess" id="BizProcessResult">
        <id column="id" property="id"/>
    </resultMap>


    <select id="getList" parameterType="BizProcess" resultMap="BizProcessResult">
        SELECT * FROM biz_process
        <trim prefix=" WHERE" suffix="" suffixOverrides="AND">
            deleted = 0
            <if test="processCode != null  and processCode != ''"> AND process_code LIKE concat('%', #{processCode}, '%')</if>
            <if test="processAlias != null  and processAlias != ''"> AND process_alias LIKE concat('%', #{processAlias}, '%')</if>
            <if test="status != null  and status != ''"> AND status = #{status}</if>
        </trim>
    </select>
    <select id="getFilterList" parameterType="BizProcess" resultMap="BizProcessResult">
        SELECT * FROM biz_process
        <trim prefix=" WHERE" suffix="" suffixOverrides="AND">
            deleted = 0 and id not in (select process_id from biz_dept_process where dept_id = #{deptId} and deleted = 0)
            <if test="processCode != null  and processCode != ''"> AND process_code LIKE concat('%', #{processCode}, '%')</if>
            <if test="processAlias != null  and processAlias != ''"> AND process_alias LIKE concat('%', #{processAlias}, '%')</if>
            <if test="status != null  and status != ''"> AND status = #{status}</if>
        </trim>
    </select>


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