<?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.system.mapper.house.BusinessEntityInfoMapper">
    <resultMap id="BaseResultMap" type="com.ruoyi.system.domain.house.BusinessEntityInfo">
        <id column="id" property="id" jdbcType="VARCHAR"/>
        <result column="house_resource_id" property="houseResourceId" jdbcType="VARCHAR"/>
        <result column="name" property="name" jdbcType="VARCHAR"/>
        <result column="nature" property="nature" jdbcType="VARCHAR"/>
        <result column="social_credit_code" property="socialCreditCode" jdbcType="VARCHAR"/>
        <result column="principal" property="principal" jdbcType="VARCHAR"/>
        <result column="principal_tel" property="principalTel" jdbcType="VARCHAR"/>
        <result column="business" property="business" jdbcType="VARCHAR"/>
        <result column="worker_number" property="workerNumber" jdbcType="INTEGER"/>
        <result column="registered_address" property="registeredAddress" jdbcType="VARCHAR"/>
        <result column="industry_classification" property="industryClassification" jdbcType="VARCHAR"/>
    </resultMap>

    <insert id="insertBusinessEntityInfo" parameterType="com.ruoyi.system.domain.house.BusinessEntityInfo">
        INSERT INTO business_entity_info (
            id, house_resource_id, name, nature, social_credit_code,
            principal, principal_tel, business, worker_number, registered_address, industry_classification
        ) VALUES (
                     #{id}, #{houseResourceId}, #{name}, #{nature}, #{socialCreditCode},
                     #{principal}, #{principalTel}, #{business}, #{workerNumber}, #{registeredAddress}, #{industryClassification}
                 )
    </insert>

    <select id="selectBusinessEntityInfoById" resultMap="BaseResultMap">
        SELECT * FROM business_entity_info WHERE id = #{id}
    </select>

    <update id="updateBusinessEntityInfo" parameterType="com.ruoyi.system.domain.house.BusinessEntityInfo">
        UPDATE business_entity_info
        <set>
            <if test="houseResourceId != null">house_resource_id=#{houseResourceId},</if>
            <if test="name != null">name=#{name},</if>
            <if test="nature != null">nature=#{nature},</if>
            <if test="socialCreditCode != null">social_credit_code=#{socialCreditCode},</if>
            <if test="principal != null">principal=#{principal},</if>
            <if test="principalTel != null">principal_tel=#{principalTel},</if>
            <if test="business != null">business=#{business},</if>
            <if test="workerNumber != null">worker_number=#{workerNumber},</if>
            <if test="registeredAddress != null">registered_address=#{registeredAddress},</if>
            <if test="industryClassification != null">industry_classification=#{industryClassification},</if>
        </set>
        WHERE id=#{id}
    </update>

    <delete id="deleteBusinessEntityInfoById">
        DELETE FROM business_entity_info WHERE id = #{id}
    </delete>

    <select id="selectAllBusinessEntityInfos" resultMap="BaseResultMap">
        SELECT * FROM business_entity_info
    </select>

    <delete id="deleteByHouseResourceId">
        DELETE FROM business_entity_info WHERE house_resource_id = #{houseResourceId}
    </delete>

    <select id="selectAllBusinessEntityInfosByHouseResourceId"
            resultType="com.ruoyi.system.domain.house.BusinessEntityInfo">
        SELECT * FROM business_entity_info WHERE house_resource_id = #{houseResourceId}
    </select>
</mapper>