GiantEnterpriseMapper.xml 3.5 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.ruoyi.web.controller.business.mapper.GiantEnterpriseMapper">

    <resultMap type="GiantEnterprise" id="GiantEnterpriseResult">
        <result property="id" column="id"/>
        <result property="enterpriseName" column="enterprise_name"/>
        <result property="creditCode" column="credit_code"/>
        <result property="year" column="year"/>
        <result property="num" column="num"/>
        <result property="createTime" column="create_time"/>
    </resultMap>

    <sql id="selectGiantEnterpriseVo">
        select id, enterprise_name, credit_code, year, num, create_time from giant_enterprise
    </sql>

    <select id="selectGiantEnterpriseById" parameterType="Long" resultMap="GiantEnterpriseResult">
        <include refid="selectGiantEnterpriseVo"/>
        where id = #{id}
    </select>

    <select id="selectGiantEnterpriseList" parameterType="GiantEnterprise" resultMap="GiantEnterpriseResult">
        <include refid="selectGiantEnterpriseVo"/>
        <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>
            <if test="year != null "> and year = #{year}</if>
            <if test="num != null  and num != ''"> and num = #{num}</if>
        </where>
    </select>

    <insert id="insertGiantEnterprise" parameterType="GiantEnterprise" useGeneratedKeys="true" keyProperty="id">
        insert into giant_enterprise
        <trim prefix="(" suffix=")" suffixOverrides=",">
            <if test="enterpriseName != null and enterpriseName != ''">enterprise_name,</if>
            <if test="creditCode != null and creditCode != ''">credit_code,</if>
            <if test="year != null">year,</if>
            <if test="num != null and num != ''">num,</if>
            <if test="createTime != null">create_time,</if>
        </trim>
        <trim prefix="values (" suffix=")" suffixOverrides=",">
            <if test="enterpriseName != null and enterpriseName != ''">#{enterpriseName},</if>
            <if test="creditCode != null and creditCode != ''">#{creditCode},</if>
            <if test="year != null">#{year},</if>
            <if test="num != null and num != ''">#{num},</if>
            <if test="createTime != null">#{createTime},</if>
        </trim>
    </insert>

    <update id="updateGiantEnterprise" parameterType="GiantEnterprise">
        update giant_enterprise
        <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="year != null">year = #{year},</if>
            <if test="num != null and num != ''">num = #{num},</if>
            <if test="createTime != null">create_time = #{createTime},</if>
        </trim>
        where id = #{id}
    </update>

    <delete id="deleteGiantEnterpriseById" parameterType="Long">
        delete from giant_enterprise where id = #{id}
    </delete>

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