<?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.mall.mapper.MallAppCompanyMapper">

    <resultMap type="MallAppCompany" id="MallAppCompanyResult">
        <result property="companyId"    column="company_id"    />
        <result property="sysUserId"    column="sys_user_id"    />
        <result property="companyName"    column="company_name"    />
        <result property="companyPhone"    column="company_phone"    />
        <result property="companyAccount"    column="company_account"    />
        <result property="companyPassword"    column="company_password"    />
        <result property="companyBusinessBegin"    column="company_business_begin"    />
        <result property="companyBusinessEnd"    column="company_business_end"    />
        <result property="provinceId"    column="province_id"    />
        <result property="provinceName"    column="province_name"    />
        <result property="cityId"    column="city_id"    />
        <result property="cityName"    column="city_name"    />
        <result property="areaId"    column="area_id"    />
        <result property="areaName"    column="area_name"    />
        <result property="address"    column="address"    />
        <result property="longitude"    column="longitude"    />
        <result property="latitude"    column="latitude"    />
        <result property="companyStatus"    column="company_status"    />
        <result property="createAt"    column="create_at"    />
        <result property="updateAt"    column="update_at"    />
        <result property="delFlag"    column="del_flag"    />
    </resultMap>

    <sql id="selectMallAppCompanyVo">
        select company_id, sys_user_id, company_name, company_phone, company_account, company_password, company_business_begin, company_business_end, province_id, province_name, city_id, city_name, area_id, area_name, address, longitude, latitude, company_status, create_at, update_at, del_flag from mall_app_company
    </sql>

    <select id="selectMallAppCompanyList" parameterType="MallAppCompany" resultMap="MallAppCompanyResult">
        <include refid="selectMallAppCompanyVo"/>
        <where>
            <if test="sysUserId != null "> and sys_user_id = #{sysUserId}</if>
            <if test="companyName != null  and companyName != ''"> and company_name like concat('%', #{companyName}, '%')</if>
            <if test="companyPhone != null  and companyPhone != ''"> and company_phone like concat('%', #{companyPhone}, '%')</if>
            <if test="companyAccount != null  and companyAccount != ''"> and company_account = #{companyAccount}</if>
            <if test="companyPassword != null  and companyPassword != ''"> and company_password = #{companyPassword}</if>
            <if test="companyBusinessBegin != null  and companyBusinessBegin != ''"> and company_business_begin = #{companyBusinessBegin}</if>
            <if test="companyBusinessEnd != null  and companyBusinessEnd != ''"> and company_business_end = #{companyBusinessEnd}</if>
            <if test="provinceId != null "> and province_id = #{provinceId}</if>
            <if test="provinceName != null  and provinceName != ''"> and province_name like concat('%', #{provinceName}, '%')</if>
            <if test="cityId != null "> and city_id = #{cityId}</if>
            <if test="cityName != null  and cityName != ''"> and city_name like concat('%', #{cityName}, '%')</if>
            <if test="areaId != null "> and area_id = #{areaId}</if>
            <if test="areaName != null  and areaName != ''"> and area_name like concat('%', #{areaName}, '%')</if>
            <if test="address != null  and address != ''"> and address = #{address}</if>
            <if test="longitude != null  and longitude != ''"> and longitude = #{longitude}</if>
            <if test="latitude != null  and latitude != ''"> and latitude = #{latitude}</if>
            <if test="companyStatus != null "> and company_status = #{companyStatus}</if>
            <if test="createAt != null  and createAt != ''"> and create_at = #{createAt}</if>
            <if test="updateAt != null  and updateAt != ''"> and update_at = #{updateAt}</if>
            <if test="delFlag != null "> and del_flag = #{delFlag}</if>
        </where>
    </select>

    <select id="selectMallAppCompanyByCompanyId" parameterType="Long" resultMap="MallAppCompanyResult">
        <include refid="selectMallAppCompanyVo"/>
        where company_id = #{companyId}
    </select>

    <insert id="insertMallAppCompany" parameterType="MallAppCompany" useGeneratedKeys="true" keyProperty="companyId">
        insert into mall_app_company
        <trim prefix="(" suffix=")" suffixOverrides=",">
            <if test="sysUserId != null">sys_user_id,</if>
            <if test="companyName != null">company_name,</if>
            <if test="companyPhone != null">company_phone,</if>
            <if test="companyAccount != null">company_account,</if>
            <if test="companyPassword != null">company_password,</if>
            <if test="companyBusinessBegin != null">company_business_begin,</if>
            <if test="companyBusinessEnd != null">company_business_end,</if>
            <if test="provinceId != null">province_id,</if>
            <if test="provinceName != null">province_name,</if>
            <if test="cityId != null">city_id,</if>
            <if test="cityName != null">city_name,</if>
            <if test="areaId != null">area_id,</if>
            <if test="areaName != null">area_name,</if>
            <if test="address != null">address,</if>
            <if test="longitude != null">longitude,</if>
            <if test="latitude != null">latitude,</if>
            <if test="companyStatus != null">company_status,</if>
            <if test="createAt != null">create_at,</if>
            <if test="updateAt != null">update_at,</if>
            <if test="delFlag != null">del_flag,</if>
         </trim>
        <trim prefix="values (" suffix=")" suffixOverrides=",">
            <if test="sysUserId != null">#{sysUserId},</if>
            <if test="companyName != null">#{companyName},</if>
            <if test="companyPhone != null">#{companyPhone},</if>
            <if test="companyAccount != null">#{companyAccount},</if>
            <if test="companyPassword != null">#{companyPassword},</if>
            <if test="companyBusinessBegin != null">#{companyBusinessBegin},</if>
            <if test="companyBusinessEnd != null">#{companyBusinessEnd},</if>
            <if test="provinceId != null">#{provinceId},</if>
            <if test="provinceName != null">#{provinceName},</if>
            <if test="cityId != null">#{cityId},</if>
            <if test="cityName != null">#{cityName},</if>
            <if test="areaId != null">#{areaId},</if>
            <if test="areaName != null">#{areaName},</if>
            <if test="address != null">#{address},</if>
            <if test="longitude != null">#{longitude},</if>
            <if test="latitude != null">#{latitude},</if>
            <if test="companyStatus != null">#{companyStatus},</if>
            <if test="createAt != null">#{createAt},</if>
            <if test="updateAt != null">#{updateAt},</if>
            <if test="delFlag != null">#{delFlag},</if>
         </trim>
    </insert>

    <update id="updateMallAppCompany" parameterType="MallAppCompany">
        update mall_app_company
        <trim prefix="SET" suffixOverrides=",">
            <if test="sysUserId != null">sys_user_id = #{sysUserId},</if>
            <if test="companyName != null">company_name = #{companyName},</if>
            <if test="companyPhone != null">company_phone = #{companyPhone},</if>
            <if test="companyAccount != null">company_account = #{companyAccount},</if>
            <if test="companyPassword != null">company_password = #{companyPassword},</if>
            <if test="companyBusinessBegin != null">company_business_begin = #{companyBusinessBegin},</if>
            <if test="companyBusinessEnd != null">company_business_end = #{companyBusinessEnd},</if>
            <if test="provinceId != null">province_id = #{provinceId},</if>
            <if test="provinceName != null">province_name = #{provinceName},</if>
            <if test="cityId != null">city_id = #{cityId},</if>
            <if test="cityName != null">city_name = #{cityName},</if>
            <if test="areaId != null">area_id = #{areaId},</if>
            <if test="areaName != null">area_name = #{areaName},</if>
            <if test="address != null">address = #{address},</if>
            <if test="longitude != null">longitude = #{longitude},</if>
            <if test="latitude != null">latitude = #{latitude},</if>
            <if test="companyStatus != null">company_status = #{companyStatus},</if>
            <if test="createAt != null">create_at = #{createAt},</if>
            <if test="updateAt != null">update_at = #{updateAt},</if>
            <if test="delFlag != null">del_flag = #{delFlag},</if>
        </trim>
        where company_id = #{companyId}
    </update>

    <delete id="deleteMallAppCompanyByCompanyId" parameterType="Long">
        delete from mall_app_company where company_id = #{companyId}
    </delete>

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