<?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.ibs.list.mapper.SysGroupBusinessMapper">
    
    <resultMap type="SysGroupBusiness" id="SysGroupBusinessResult">
        <result property="id"    column="id"    />
        <result property="groupId"    column="group_id"    />
        <result property="custId"    column="cust_id"    />
        <result property="custName"    column="cust_name"    />
        <result property="custIdc"    column="cust_idc"    />
        <result property="deptId"    column="dept_id"    />
        <result property="userId"    column="user_id"    />
        <result property="createBy"    column="create_by"    />
        <result property="createTime"    column="create_time"    />
        <result property="updateBy"    column="update_by"    />
        <result property="updateTime"    column="update_time"    />
        <result property="remark"    column="remark"    />
        <result property="delFlag"    column="del_flag"    />
        <result property="pushStatus"    column="push_status"    />
        <result property="custPhone"    column="cust_phone"    />
        <result property="gridName1"    column="grid_name1"    />
        <result property="userName"    column="user_name"    />
        <result property="custIsn"    column="cust_isn"    />
        <result property="deptName"    column="dept_name"    />
        <result property="gridName2"    column="grid_name2"    />
        <result property="lpName"    column="lp_name"    />
        <result property="socialCreditCode"    column="social_credit_code"    />
    </resultMap>

    <sql id="selectSysGroupBusinessVo">
        select id, group_id, cust_id, cust_name, cust_idc, dept_id, user_id, create_by, create_time, update_by, update_time, remark, del_flag, push_status, cust_phone, grid_name1, user_name, cust_isn, dept_name, grid_name2, lp_name, social_credit_code from sys_group_business
    </sql>

    <select id="selectSysGroupBusinessList" parameterType="SysGroupBusiness" resultMap="SysGroupBusinessResult">
        <include refid="selectSysGroupBusinessVo"/>
        <where>  
            <if test="groupId != null  and groupId != ''"> and group_id = #{groupId}</if>
            <if test="custId != null  and custId != ''"> and cust_id = #{custId}</if>
            <if test="custName != null  and custName != ''"> and cust_name like concat('%', #{custName}, '%')</if>
            <if test="custIdc != null  and custIdc != ''"> and cust_idc = #{custIdc}</if>
            <if test="deptId != null "> and dept_id = #{deptId}</if>
            <if test="userId != null "> and user_id = #{userId}</if>
            <if test="pushStatus != null  and pushStatus != ''"> and push_status = #{pushStatus}</if>
            <if test="custPhone != null  and custPhone != ''"> and cust_phone = #{custPhone}</if>
            <if test="gridName1 != null  and gridName1 != ''"> and grid_name1 = #{gridName1}</if>
            <if test="userName != null  and userName != ''"> and user_name like concat('%', #{userName}, '%')</if>
            <if test="custIsn != null  and custIsn != ''"> and cust_isn = #{custIsn}</if>
            <if test="deptName != null  and deptName != ''"> and dept_name like concat('%', #{deptName}, '%')</if>
            <if test="gridName2 != null  and gridName2 != ''"> and grid_name2 = #{gridName2}</if>
            <if test="lpName != null  and lpName != ''"> and lp_name like concat('%', #{lpName}, '%')</if>
            <if test="socialCreditCode != null  and socialCreditCode != ''"> and social_credit_code = #{socialCreditCode}</if>
        </where>
    </select>
    
    <select id="selectSysGroupBusinessById" parameterType="Long" resultMap="SysGroupBusinessResult">
        <include refid="selectSysGroupBusinessVo"/>
        where id = #{id}
    </select>

    <insert id="insertSysGroupBusiness" parameterType="SysGroupBusiness" useGeneratedKeys="true" keyProperty="id">
        insert into sys_group_business
        <trim prefix="(" suffix=")" suffixOverrides=",">
            <if test="groupId != null">group_id,</if>
            <if test="custId != null">cust_id,</if>
            <if test="custName != null">cust_name,</if>
            <if test="custIdc != null">cust_idc,</if>
            <if test="deptId != null">dept_id,</if>
            <if test="userId != null">user_id,</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>
            <if test="remark != null">remark,</if>
            <if test="delFlag != null">del_flag,</if>
            <if test="pushStatus != null">push_status,</if>
            <if test="custPhone != null">cust_phone,</if>
            <if test="gridName1 != null">grid_name1,</if>
            <if test="userName != null">user_name,</if>
            <if test="custIsn != null">cust_isn,</if>
            <if test="deptName != null">dept_name,</if>
            <if test="gridName2 != null">grid_name2,</if>
            <if test="lpName != null">lp_name,</if>
            <if test="socialCreditCode != null">social_credit_code,</if>
         </trim>
        <trim prefix="values (" suffix=")" suffixOverrides=",">
            <if test="groupId != null">#{groupId},</if>
            <if test="custId != null">#{custId},</if>
            <if test="custName != null">#{custName},</if>
            <if test="custIdc != null">#{custIdc},</if>
            <if test="deptId != null">#{deptId},</if>
            <if test="userId != null">#{userId},</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>
            <if test="remark != null">#{remark},</if>
            <if test="delFlag != null">#{delFlag},</if>
            <if test="pushStatus != null">#{pushStatus},</if>
            <if test="custPhone != null">#{custPhone},</if>
            <if test="gridName1 != null">#{gridName1},</if>
            <if test="userName != null">#{userName},</if>
            <if test="custIsn != null">#{custIsn},</if>
            <if test="deptName != null">#{deptName},</if>
            <if test="gridName2 != null">#{gridName2},</if>
            <if test="lpName != null">#{lpName},</if>
            <if test="socialCreditCode != null">#{socialCreditCode},</if>
         </trim>
    </insert>

    <update id="updateSysGroupBusiness" parameterType="SysGroupBusiness">
        update sys_group_business
        <trim prefix="SET" suffixOverrides=",">
            <if test="groupId != null">group_id = #{groupId},</if>
            <if test="custId != null">cust_id = #{custId},</if>
            <if test="custName != null">cust_name = #{custName},</if>
            <if test="custIdc != null">cust_idc = #{custIdc},</if>
            <if test="deptId != null">dept_id = #{deptId},</if>
            <if test="userId != null">user_id = #{userId},</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>
            <if test="remark != null">remark = #{remark},</if>
            <if test="delFlag != null">del_flag = #{delFlag},</if>
            <if test="pushStatus != null">push_status = #{pushStatus},</if>
            <if test="custPhone != null">cust_phone = #{custPhone},</if>
            <if test="gridName1 != null">grid_name1 = #{gridName1},</if>
            <if test="userName != null">user_name = #{userName},</if>
            <if test="custIsn != null">cust_isn = #{custIsn},</if>
            <if test="deptName != null">dept_name = #{deptName},</if>
            <if test="gridName2 != null">grid_name2 = #{gridName2},</if>
            <if test="lpName != null">lp_name = #{lpName},</if>
            <if test="socialCreditCode != null">social_credit_code = #{socialCreditCode},</if>
        </trim>
        where id = #{id}
    </update>

    <delete id="deleteSysGroupBusinessById" parameterType="Long">
        delete from sys_group_business where id = #{id}
    </delete>

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