<?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.ruoyi.invest.mapper.TProjectChannelMapper">
    
    <resultMap type="TProjectChannel" id="TProjectChannelResult">
        <result property="id"    column="id"    />
        <result property="channelName"    column="channel_name"    />
        <result property="channelCode"    column="channel_code"    />
        <result property="channelType"    column="channel_type"    />
        <result property="channelGroup"    column="channel_group"    />
        <result property="channelBlurb"    column="channel_blurb"    />
        <result property="contacts"    column="contacts"    />
        <result property="telephone"    column="telephone"    />
        <result property="channelCity"    column="channel_city"    />
        <result property="address"    column="address"    />
        <result property="channelHead"    column="channel_head"    />
        <result property="status"    column="status"    />
        <result property="mark"    column="mark"    />
        <result property="delFlag"    column="del_flag"    />
        <result property="createBy"    column="create_by"    />
        <result property="createTime"    column="create_time"    />
        <result property="updateBy"    column="update_by"    />
        <result property="updateTime"    column="update_time"    />
    </resultMap>

    <sql id="selectTProjectChannelVo">
        select id, channel_name, channel_code, channel_type, channel_group, channel_blurb, contacts, telephone, channel_city,address, channel_head, status, mark, del_flag, create_by, create_time, update_by, update_time from t_project_channel
    </sql>

    <select id="selectTProjectChannelList" parameterType="TProjectChannel" resultMap="TProjectChannelResult">
        <include refid="selectTProjectChannelVo"/>
        <where>
            del_flag = 0
            <if test="channelName != null  and channelName != ''"> and channel_name like concat('%', #{channelName}, '%')</if>
            <if test="channelCode != null  and channelCode != ''"> and channel_code like concat('%', #{channelCode}, '%')</if>
            <if test="channelGroup != null  and channelGroup != ''"> and channel_group = #{channelGroup}</if>
            <if test="channelType != null  and channelType != ''"> and channel_type = #{channelType}</if>
            <if test="contacts != null  and contacts != ''"> and contacts like concat('%', #{contacts}, '%')</if>
            <if test="telephone != null  and telephone != ''"> and telephone like concat('%', #{telephone}, '%')</if>
            <if test="channelHead != null  and channelHead != ''"> and channel_head like concat('%', #{channelHead}, '%')</if>
            <if test="status != null  and status != ''"> and status = #{status}</if>
            <if test="notStatus != null  and notStatus != ''"> and status != #{notStatus}</if>
        </where>
    </select>
    
    <select id="selectTProjectChannelById" parameterType="String" resultMap="TProjectChannelResult">
        <include refid="selectTProjectChannelVo"/>
        where id = #{id}
    </select>
        
    <insert id="insertTProjectChannel" parameterType="TProjectChannel">
        insert into t_project_channel
        <trim prefix="(" suffix=")" suffixOverrides=",">
            <if test="id != null">id,</if>
            <if test="channelName != null">channel_name,</if>
            <if test="channelCode != null">channel_code,</if>
            <if test="channelType != null">channel_type,</if>
            <if test="channelGroup != null">channel_group,</if>
            <if test="channelBlurb != null">channel_blurb,</if>
            <if test="contacts != null">contacts,</if>
            <if test="telephone != null">telephone,</if>
            <if test="channelCity != null">channel_city,</if>
            <if test="address != null">address,</if>
            <if test="channelHead != null">channel_head,</if>
            <if test="status != null">status,</if>
            <if test="mark != null">mark,</if>
            <if test="delFlag != null">del_flag,</if>
            <if test="createBy != null">create_by,</if>
            <if test="createTime != null">create_time,</if>
            <if test="updateBy != null">update_by,</if>
            <if test="updateTime != null">update_time,</if>
         </trim>
        <trim prefix="values (" suffix=")" suffixOverrides=",">
            <if test="id != null">#{id},</if>
            <if test="channelName != null">#{channelName},</if>
            <if test="channelCode != null">#{channelCode},</if>
            <if test="channelType != null">#{channelType},</if>
            <if test="channelGroup != null">#{channelGroup},</if>
            <if test="channelBlurb != null">#{channelBlurb},</if>
            <if test="contacts != null">#{contacts},</if>
            <if test="telephone != null">#{telephone},</if>
            <if test="channelCity != null">#{channelCity},</if>
            <if test="address != null">#{address},</if>
            <if test="channelHead != null">#{channelHead},</if>
            <if test="status != null">#{status},</if>
            <if test="mark != null">#{mark},</if>
            <if test="delFlag != null">#{delFlag},</if>
            <if test="createBy != null">#{createBy},</if>
            <if test="createTime != null">#{createTime},</if>
            <if test="updateBy != null">#{updateBy},</if>
            <if test="updateTime != null">#{updateTime},</if>
         </trim>
    </insert>

    <update id="updateTProjectChannel" parameterType="TProjectChannel">
        update t_project_channel
        <trim prefix="SET" suffixOverrides=",">
            <if test="channelName != null">channel_name = #{channelName},</if>
            <if test="channelCode != null">channel_code = #{channelCode},</if>
            <if test="channelType != null">channel_type = #{channelType},</if>
            <if test="channelGroup != null">channel_group = #{channelGroup},</if>
            <if test="channelBlurb != null">channel_blurb = #{channelBlurb},</if>
            <if test="contacts != null">contacts = #{contacts},</if>
            <if test="telephone != null">telephone = #{telephone},</if>
            <if test="channelCity != null">channel_city = #{channelCity},</if>
            <if test="address != null">address = #{address},</if>
            <if test="channelHead != null">channel_head = #{channelHead},</if>
            <if test="status != null">status = #{status},</if>
            <if test="mark != null">mark = #{mark},</if>
            <if test="delFlag != null">del_flag = #{delFlag},</if>
            <if test="createBy != null">create_by = #{createBy},</if>
            <if test="createTime != null">create_time = #{createTime},</if>
            <if test="updateBy != null">update_by = #{updateBy},</if>
            <if test="updateTime != null">update_time = #{updateTime},</if>
        </trim>
        where id = #{id}
    </update>

    <delete id="deleteTProjectChannelById" parameterType="String">
        delete from t_project_channel where id = #{id}
    </delete>

    <delete id="deleteTProjectChannelByIds" parameterType="String">
        delete from t_project_channel where id in 
        <foreach item="id" collection="array" open="(" separator="," close=")">
            #{id}
        </foreach>
    </delete>

    <update id="updateTProjectChannelByIds" parameterType="String">
        update t_project_channel
        set del_flag = 1
        where id in
        <foreach item="id" collection="array" open="(" separator="," close=")">
            #{id}
        </foreach>
    </update>

    <select id="selectTProjectChannelCode" parameterType="String" resultType="java.lang.Integer">
        select count(*) from t_project_channel
        where channel_code like concat('%', #{year}, '%')
    </select>


</mapper>