<?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.project.zcustom.mapper.basics.PlatBasicsCompanyMapper">
    
    <resultMap type="PlatBasicsCompany" id="PlatBasicsCompanyResult">
        <result property="id"    column="id"    />
        <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"    />
        <result property="appOrg"    column="app_org"    />
        <result property="companyName"    column="company_name"    />
        <result property="activeUserNum"    column="active_user_num"    />
    </resultMap>

    <sql id="selectPlatBasicsCompanyVo">
        select id, del_flag, create_by, create_time, update_by, update_time, app_org, company_name, active_user_num from large_plat_basics_company
    </sql>

    <select id="selectPlatBasicsCompanyList" parameterType="PlatBasicsCompany" resultMap="PlatBasicsCompanyResult">
        <include refid="selectPlatBasicsCompanyVo"/>
        <where>  
            <if test="appOrg != null  and appOrg != ''"> and app_org = #{appOrg}</if>
            <if test="companyName != null  and companyName != ''"> and company_name like concat('%', #{companyName}, '%')</if>
            <if test="activeUserNum != null "> and active_user_num = #{activeUserNum}</if>
        </where>
    </select>
    
    <select id="selectPlatBasicsCompanyById" parameterType="Long" resultMap="PlatBasicsCompanyResult">
        <include refid="selectPlatBasicsCompanyVo"/>
        where id = #{id}
    </select>

    <insert id="insertPlatBasicsCompany" parameterType="PlatBasicsCompany" useGeneratedKeys="true" keyProperty="id">
        insert into large_plat_basics_company
        <trim prefix="(" suffix=")" suffixOverrides=",">
            <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>
            <if test="appOrg != null">app_org,</if>
            <if test="companyName != null">company_name,</if>
            <if test="activeUserNum != null">active_user_num,</if>
         </trim>
        <trim prefix="values (" suffix=")" suffixOverrides=",">
            <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>
            <if test="appOrg != null">#{appOrg},</if>
            <if test="companyName != null">#{companyName},</if>
            <if test="activeUserNum != null">#{activeUserNum},</if>
         </trim>
    </insert>

    <update id="updatePlatBasicsCompany" parameterType="PlatBasicsCompany">
        update large_plat_basics_company
        <trim prefix="SET" suffixOverrides=",">
            <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>
            <if test="appOrg != null">app_org = #{appOrg},</if>
            <if test="companyName != null">company_name = #{companyName},</if>
            <if test="activeUserNum != null">active_user_num = #{activeUserNum},</if>
        </trim>
        where id = #{id}
    </update>

    <delete id="deletePlatBasicsCompanyById" parameterType="Long">
        delete from large_plat_basics_company where id = #{id}
    </delete>

    <delete id="deletePlatBasicsCompanyByIds" parameterType="String">
        delete from large_plat_basics_company where id in 
        <foreach item="id" collection="array" open="(" separator="," close=")">
            #{id}
        </foreach>
    </delete>
    <delete id="reallyDeleteByWrapper">
        DELETE FROM large_plat_basics_company ${ew.customSqlSegment}
    </delete>
</mapper>