<?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.ytpm.lemonios.dao.DitchMapper">
    <insert id="insertOne" keyProperty="ditchId" useGeneratedKeys="true">
        insert into yt_ditch
        (
            ditch_id,
            ditch_name,
            user_id,
            app_type,
            app_id,
            is_delete,
            create_time
        )
        values
            (
                #{ditchId},
                #{ditchName},
                #{userId},
                #{appType},
                #{appId},
                #{isDelete},
                #{createTime}
            )
    </insert>
    <select id="ditchList" resultType="com.ytpm.agent.view.AgentDitchView">
        select
        ditch_id, ditch_name, create_time
        from yt_ditch
        <where>
            user_id = #{userId}
            and is_delete=0
        </where>
    </select>
    <select id="ditchListForIos" resultType="com.ytpm.agent.view.AgentDitchView">
        select
        ditch_id, ditch_name, create_time
        from yt_ditch
        <where>
            app_id = #{appId}
            and is_delete=0
        </where>
    </select>
    <select id="selectById" resultType="com.ytpm.agent.model.YtDitch">
        select
            ditch_id, ditch_name, user_id, is_delete, create_time
        from yt_ditch
        where ditch_id = #{ditchId}
    </select>
</mapper>