<?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.fs.company.mapper.CompanyMoneyLogsMapper">
    
    <resultMap type="CompanyMoneyLogs" id="CompanyMoneyLogsResult">
        <result property="logsId"    column="logs_id"    />
        <result property="companyId"    column="company_id"    />
        <result property="money"    column="money"    />
        <result property="balance"    column="balance"    />
        <result property="remark"    column="remark"    />
        <result property="createTime"    column="create_time"    />
        <result property="logsType"    column="logs_type"    />
        <result property="businessId"    column="business_id"    />
    </resultMap>

    <sql id="selectCompanyMoneyLogsVo">
        select logs_id, company_id, money,balance, remark, create_time,logs_type,business_id from company_money_logs
    </sql>

    <select id="selectCompanyMoneyLogsList" parameterType="CompanyMoneyLogs" resultMap="CompanyMoneyLogsResult">
        <include refid="selectCompanyMoneyLogsVo"/>
        <where>  
            <if test="companyId != null "> and company_id = #{companyId}</if>
            <if test="money != null "> and money = #{money}</if>
        </where>
    </select>
    
    <select id="selectCompanyMoneyLogsById" parameterType="Long" resultMap="CompanyMoneyLogsResult">
        <include refid="selectCompanyMoneyLogsVo"/>
        where logs_id = #{logsId}
    </select>
        
    <insert id="insertCompanyMoneyLogs" parameterType="CompanyMoneyLogs" useGeneratedKeys="true" keyProperty="logsId">
        insert into company_money_logs
        <trim prefix="(" suffix=")" suffixOverrides=",">
            <if test="companyId != null">company_id,</if>
            <if test="money != null">money,</if>
            <if test="balance != null">balance,</if>
            <if test="remark != null">remark,</if>
            <if test="createTime != null">create_time,</if>
            <if test="logsType != null">logs_type,</if>
            <if test="businessId != null">business_id,</if>
         </trim>
        <trim prefix="values (" suffix=")" suffixOverrides=",">
            <if test="companyId != null">#{companyId},</if>
            <if test="money != null">#{money},</if>
            <if test="balance != null">#{balance},</if>
            <if test="remark != null">#{remark},</if>
            <if test="createTime != null">#{createTime},</if>
            <if test="logsType != null">#{logsType},</if>
            <if test="businessId != null">#{businessId},</if>
         </trim>
    </insert>

    <update id="updateCompanyMoneyLogs" parameterType="CompanyMoneyLogs">
        update company_money_logs
        <trim prefix="SET" suffixOverrides=",">
            <if test="companyId != null">company_id = #{companyId},</if>
            <if test="money != null">money = #{money},</if>
            <if test="balance != null">balance = #{balance},</if>
            <if test="remark != null">remark = #{remark},</if>
            <if test="createTime != null">create_time = #{createTime},</if>
            <if test="logsType != null">logs_type = #{logsType},</if>
            <if test="businessId != null">business_id = #{businessId},</if>
        </trim>
        where logs_id = #{logsId}
    </update>

    <delete id="deleteCompanyMoneyLogsById" parameterType="Long">
        delete from company_money_logs where logs_id = #{logsId}
    </delete>

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