<?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.dgtly.system.mapper.SysCompanyMapper">
    
    <resultMap type="SysCompany" id="SysCompanyResult">
        <result property="id"    column="id"    />
        <result property="company"    column="company"    />
        <result property="authorizeId"    column="authorize_id"    />
        <result property="status"    column="status"    />
        <result property="createTime"    column="create_time"    />
    </resultMap>

    <sql id="selectSysCompanyVo">
        select id, company,authorize_id,status,create_time from sys_company
    </sql>

    <select id="selectSysCompanyList" parameterType="SysCompany" resultMap="SysCompanyResult">
        <include refid="selectSysCompanyVo"/>
        <where>  
            <if test="company != null  and company != ''"> and company = #{company}</if>
        </where>
    </select>
    
    <select id="selectSysCompanyById" parameterType="Long" resultMap="SysCompanyResult">
        <include refid="selectSysCompanyVo"/>
        where id = #{id}
    </select>
        
    <insert id="insertSysCompany" parameterType="SysCompany" useGeneratedKeys="true" keyProperty="id">
        insert into sys_company
        <trim prefix="(" suffix=")" suffixOverrides=",">
            <if test="company != null  and company != ''">company,</if>
            <if test="authorizeId != null">authorize_id,</if>
            <if test="createTime != null ">create_time,</if>
         </trim>
        <trim prefix="values (" suffix=")" suffixOverrides=",">
            <if test="company != null  and company != ''">#{company},</if>
            <if test="authorizeId != null">#{authorizeId},</if>
            <if test="createTime != null ">#{createTime},</if>
         </trim>
    </insert>

    <update id="updateSysCompany" parameterType="SysCompany">
        update sys_company
        <trim prefix="SET" suffixOverrides=",">
            <if test="status != null">status = #{status},</if>
            <if test="company != null  and company != ''">company = #{company},</if>
            <if test="createTime != null ">create_time = #{createTime},</if>
        </trim>
        where id = #{id}
    </update>

    <delete id="deleteSysCompanyById" parameterType="Long">
        delete from sys_company where id = #{id}
    </delete>

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