WarningCompanyMapper.xml 3.04 KB
<?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.credit.cy.business.mapper.WarningCompanyMapper">
    
    <resultMap type="WarningCompany" id="WarningCompanyResult">
        <result property="wcId"    column="wc_id"    />
        <result property="enterpriseName"    column="enterprise_name"    />
        <result property="creditCode"    column="credit_code"    />
        <result property="createTime"    column="create_time"    />
    </resultMap>

    <sql id="selectWarningCompanyVo">
        select wc_id, enterprise_name, credit_code, create_time from warning_company
    </sql>

    <select id="selectWarningCompanyList" parameterType="WarningCompany" resultMap="WarningCompanyResult">
        <include refid="selectWarningCompanyVo"/>
        <where>  
            <if test="enterpriseName != null  and enterpriseName != ''"> and enterprise_name like concat('%', #{enterpriseName}, '%')</if>
            <if test="creditCode != null  and creditCode != ''"> and credit_code = #{creditCode}</if>
        </where>
    </select>
    
    <select id="selectWarningCompanyByWcId" parameterType="Long" resultMap="WarningCompanyResult">
        <include refid="selectWarningCompanyVo"/>
        where wc_id = #{wcId}
    </select>
        
    <insert id="insertWarningCompany" parameterType="WarningCompany">
        insert into warning_company
        <trim prefix="(" suffix=")" suffixOverrides=",">
            <if test="wcId != null">wc_id,</if>
            <if test="enterpriseName != null and enterpriseName != ''">enterprise_name,</if>
            <if test="creditCode != null and creditCode != ''">credit_code,</if>
            <if test="createTime != null">create_time,</if>
         </trim>
        <trim prefix="values (" suffix=")" suffixOverrides=",">
            <if test="wcId != null">#{wcId},</if>
            <if test="enterpriseName != null and enterpriseName != ''">#{enterpriseName},</if>
            <if test="creditCode != null and creditCode != ''">#{creditCode},</if>
            <if test="createTime != null">#{createTime},</if>
         </trim>
    </insert>

    <update id="updateWarningCompany" parameterType="WarningCompany">
        update warning_company
        <trim prefix="SET" suffixOverrides=",">
            <if test="enterpriseName != null and enterpriseName != ''">enterprise_name = #{enterpriseName},</if>
            <if test="creditCode != null and creditCode != ''">credit_code = #{creditCode},</if>
            <if test="createTime != null">create_time = #{createTime},</if>
        </trim>
        where wc_id = #{wcId}
    </update>

    <delete id="deleteWarningCompanyByWcId" parameterType="Long">
        delete from warning_company where wc_id = #{wcId}
    </delete>

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

</mapper>