<?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.matrix.system.common.dao.BusParameterSettingsDao"> 
 | 
    <!-- 定义BusParameterSettings 的复杂关联map --> 
 | 
    <resultMap type="com.matrix.system.common.bean.BusParameterSettings" id="BusParameterSettingsMap"> 
 | 
        <id property="paramId" column="param_id"/> 
 | 
        <result property="paramCode" column="param_code"/> 
 | 
        <result property="paramValue" column="param_value"/> 
 | 
        <result property="paramValue1" column="param_value1"/> 
 | 
        <result property="paramValue2" column="param_value2"/> 
 | 
        <result property="paramValue3" column="param_value3"/> 
 | 
        <result property="companyId" column="company_id"/> 
 | 
        <result property="shopId" column="shop_id"/> 
 | 
    </resultMap> 
 | 
  
 | 
  
 | 
    <!-- 定义BusParameterSettings 的简单map  ,本map不添加其他的关联属性 --> 
 | 
    <resultMap type="com.matrix.system.common.bean.BusParameterSettings" id="BusParameterSettingsSimpleMap"> 
 | 
        <id property="paramId" column="param_id"/> 
 | 
        <result property="paramCode" column="param_code"/> 
 | 
        <result property="paramValue" column="param_value"/> 
 | 
        <result property="paramValue1" column="param_value1"/> 
 | 
        <result property="paramValue2" column="param_value2"/> 
 | 
        <result property="paramValue3" column="param_value3"/> 
 | 
        <result property="companyId" column="company_id"/> 
 | 
        <result property="shopId" column="shop_id"/> 
 | 
    </resultMap> 
 | 
  
 | 
  
 | 
    <!--  插入方法   --> 
 | 
    <insert id="insert" parameterType="com.matrix.system.common.bean.BusParameterSettings" 
 | 
            useGeneratedKeys="true" keyProperty="paramId"> 
 | 
        INSERT INTO bus_parameter_settings ( 
 | 
            param_id, 
 | 
            param_code, 
 | 
            param_value, 
 | 
            param_value1, 
 | 
            param_value2, 
 | 
            param_value3, 
 | 
            company_id, 
 | 
            shop_id 
 | 
        ) 
 | 
    VALUES ( 
 | 
            #{paramId}, 
 | 
            #{paramCode}, 
 | 
            #{paramValue}, 
 | 
            #{paramValue1}, 
 | 
            #{paramValue2}, 
 | 
            #{paramValue3}, 
 | 
            #{companyId}, 
 | 
            #{shopId} 
 | 
    ) 
 | 
    </insert> 
 | 
  
 | 
  
 | 
    <!--  批量插入   --> 
 | 
    <insert id="batchInsert" parameterType="java.util.List"> 
 | 
        INSERT INTO bus_parameter_settings ( 
 | 
        param_id, 
 | 
        param_code, 
 | 
        param_value, 
 | 
        param_value1, 
 | 
        param_value2, 
 | 
        param_value3, 
 | 
        company_id, 
 | 
        shop_id 
 | 
        ) 
 | 
        VALUES 
 | 
        <foreach collection="list" item="item" index="index" separator=",">( 
 | 
            #{item.paramId}, 
 | 
            #{item.paramCode}, 
 | 
            #{item.paramValue}, 
 | 
            #{item.paramValue1}, 
 | 
            #{item.paramValue2}, 
 | 
            #{item.paramValue3}, 
 | 
            #{item.companyId}, 
 | 
            #{item.shopId} 
 | 
            ) 
 | 
        </foreach> 
 | 
    </insert> 
 | 
  
 | 
  
 | 
    <!--  根据Map更新 部分更新   --> 
 | 
    <update id="updateByMap" parameterType="java.util.HashMap"> 
 | 
        UPDATE bus_parameter_settings 
 | 
        <set> 
 | 
            <if test="_parameter.containsKey('paramCode')"> 
 | 
                param_code = #{paramCode}, 
 | 
            </if> 
 | 
            <if test="_parameter.containsKey('paramValue')"> 
 | 
                param_value = #{paramValue}, 
 | 
            </if> 
 | 
            <if test="_parameter.containsKey('paramValue1')"> 
 | 
                param_value1 = #{paramValue1}, 
 | 
            </if> 
 | 
            <if test="_parameter.containsKey('paramValue2')"> 
 | 
                param_value2 = #{paramValue2}, 
 | 
            </if> 
 | 
            <if test="_parameter.containsKey('paramValue3')"> 
 | 
                param_value3 = #{paramValue3}, 
 | 
            </if> 
 | 
            <if test="_parameter.containsKey('companyId')"> 
 | 
                company_id = #{companyId}, 
 | 
            </if> 
 | 
            <if test="_parameter.containsKey('shopId')"> 
 | 
                shop_id = #{shopId}, 
 | 
            </if> 
 | 
        </set> 
 | 
        WHERE param_id=#{paramId} 
 | 
    </update> 
 | 
  
 | 
  
 | 
    <!--  根据对象更新 部分更新   --> 
 | 
    <update id="updateByModel" parameterType="Long"> 
 | 
        UPDATE bus_parameter_settings 
 | 
        <set> 
 | 
            <if test="(paramCode!=null and paramCode!='') or (paramCode!='' and paramCode==0)"> 
 | 
                param_code = #{paramCode}, 
 | 
            </if> 
 | 
            <if test="(paramValue!=null and paramValue!='') or (paramValue!='' and paramValue==0)"> 
 | 
                param_value = #{paramValue}, 
 | 
            </if> 
 | 
            <if test="(paramValue1!=null and paramValue1!='') or (paramValue1!='' and paramValue1==0)"> 
 | 
                param_value1 = #{paramValue1}, 
 | 
            </if> 
 | 
            <if test="(paramValue2!=null and paramValue2!='') or (paramValue2!='' and paramValue2==0)"> 
 | 
                param_value2 = #{paramValue2}, 
 | 
            </if> 
 | 
            <if test="(paramValue3!=null and paramValue3!='') or (paramValue3!='' and paramValue3==0)"> 
 | 
                param_value3 = #{paramValue3}, 
 | 
            </if> 
 | 
            <if test="(companyId!=null and companyId!='') "> 
 | 
                company_id = #{companyId} 
 | 
            </if> 
 | 
             <if test="(shopId!=null and shopId!='') "> 
 | 
                 shop_id = #{shopId} 
 | 
            </if> 
 | 
        </set> 
 | 
        WHERE param_id=#{paramId} 
 | 
    </update> 
 | 
  
 | 
    <update id="updateParams" parameterType="java.util.List"> 
 | 
        <foreach collection="list" index="index" item="item" separator=";"> 
 | 
            UPDATE bus_parameter_settings 
 | 
            <set> 
 | 
                <if test="(item.paramValue!=null ) "> 
 | 
                    param_value = #{item.paramValue}, 
 | 
                </if> 
 | 
                <if test="(item.paramValue1!=null) "> 
 | 
                    param_value1 = #{item.paramValue1}, 
 | 
                </if> 
 | 
                <if test="(item.paramValue2!=null) "> 
 | 
                    param_value2 = #{item.paramValue2}, 
 | 
                </if> 
 | 
                <if test="(item.paramValue3!=null ) "> 
 | 
                    param_value3 = #{item.paramValue3}, 
 | 
                </if> 
 | 
                <if test="(item.shopId!=null ) "> 
 | 
                    shop_id = #{item.shopId}, 
 | 
                </if> 
 | 
            </set> 
 | 
            where param_code = #{item.paramCode} and company_id = #{companyId} 
 | 
        </foreach> 
 | 
    </update> 
 | 
  
 | 
  
 | 
    <!-- 批量删除 --> 
 | 
    <delete id="deleteByIds" parameterType="java.util.List"> 
 | 
        delete from bus_parameter_settings where param_id in 
 | 
        <foreach collection="list" index="index" item="item" open="(" 
 | 
                 separator="," close=")"> 
 | 
            #{item} 
 | 
        </foreach> 
 | 
    </delete> 
 | 
  
 | 
    <!-- 根据id删除--> 
 | 
    <delete id="deleteById" parameterType="Long"> 
 | 
        DELETE FROM bus_parameter_settings 
 | 
        where  param_id=#{paramId}  
 | 
    </delete> 
 | 
  
 | 
    <!-- 根据对象删除--> 
 | 
    <delete id="deleteByModel" parameterType="Long"> 
 | 
        DELETE FROM bus_parameter_settings 
 | 
        where 1=1 
 | 
        <if test="record!=null"> 
 | 
            <if test="(record.paramId!=null and record.paramId!='') or (record.paramId!='' and record.paramId==0)"> 
 | 
                and param_id = #{record.paramId} 
 | 
            </if> 
 | 
            <if test="(record.paramCode!=null and record.paramCode!='') or (record.paramCode!='' and record.paramCode==0)"> 
 | 
                and param_code = #{record.paramCode} 
 | 
            </if> 
 | 
            <if test="(record.paramValue!=null and record.paramValue!='') or (record.paramValue!='' and record.paramValue==0)"> 
 | 
                and param_value = #{record.paramValue} 
 | 
            </if> 
 | 
            <if test="(record.paramValue1!=null and record.paramValue1!='') or (record.paramValue1!='' and record.paramValue1==0)"> 
 | 
                and param_value1 = #{record.paramValue1} 
 | 
            </if> 
 | 
            <if test="(record.paramValue2!=null and record.paramValue2!='') or (record.paramValue2!='' and record.paramValue2==0)"> 
 | 
                and param_value2 = #{record.paramValue2} 
 | 
            </if> 
 | 
            <if test="(record.paramValue3!=null and record.paramValue3!='') or (record.paramValue3!='' and record.paramValue3==0)"> 
 | 
                and param_value3 = #{record.paramValue3} 
 | 
            </if> 
 | 
            <if test="(record.companyId!=null and record.companyId!='') "> 
 | 
                and company_id = #{record.companyId} 
 | 
            </if> 
 | 
            <if test="(record.shopId!=null and record.shopId!='') "> 
 | 
                and shop_id = #{record.shopId} 
 | 
            </if> 
 | 
        </if> 
 | 
    </delete> 
 | 
  
 | 
  
 | 
    <!-- 分页查询 --> 
 | 
    <select id="selectInPage" resultMap="BusParameterSettingsMap"> 
 | 
        select 
 | 
        param_id, 
 | 
        param_code, 
 | 
        param_value, 
 | 
        param_value1, 
 | 
        param_value2, 
 | 
        param_value3, 
 | 
        company_id, 
 | 
        shop_id 
 | 
        from bus_parameter_settings 
 | 
        where 1=1 
 | 
        <if test="record!=null"> 
 | 
            <if test="(record.paramId!=null and record.paramId!='') or (record.paramId!='' and record.paramId==0)"> 
 | 
                and param_id = #{record.paramId} 
 | 
            </if> 
 | 
            <if test="(record.paramCode!=null and record.paramCode!='') or (record.paramCode!='' and record.paramCode==0)"> 
 | 
                and param_code = #{record.paramCode} 
 | 
            </if> 
 | 
            <if test="(record.paramValue!=null and record.paramValue!='') or (record.paramValue!='' and record.paramValue==0)"> 
 | 
                and param_value = #{record.paramValue} 
 | 
            </if> 
 | 
            <if test="(record.paramValue1!=null and record.paramValue1!='') or (record.paramValue1!='' and record.paramValue1==0)"> 
 | 
                and param_value1 = #{record.paramValue1} 
 | 
            </if> 
 | 
            <if test="(record.paramValue2!=null and record.paramValue2!='') or (record.paramValue2!='' and record.paramValue2==0)"> 
 | 
                and param_value2 = #{record.paramValue2} 
 | 
            </if> 
 | 
            <if test="(record.paramValue3!=null and record.paramValue3!='') or (record.paramValue3!='' and record.paramValue3==0)"> 
 | 
                and param_value3 = #{record.paramValue3} 
 | 
            </if> 
 | 
            <if test="(record.companyId!=null and record.companyId!='') "> 
 | 
                and company_id = #{record.companyId} 
 | 
            </if> 
 | 
            <if test="(record.shopId!=null and record.shopId!='') "> 
 | 
                and shop_id = #{record.shopId} 
 | 
            </if> 
 | 
        </if> 
 | 
        <if test="pageVo !=null"><!-- 判断pageVo对象是否为空 --> 
 | 
            <if test="pageVo.sort !=null  and pageVo.order !=null"> 
 | 
                order by 
 | 
                ${pageVo.sort} ${pageVo.order} 
 | 
            </if> 
 | 
            <if test="pageVo.offset >=0  and pageVo.limit >0"> 
 | 
                limit 
 | 
                #{pageVo.offset},#{pageVo.limit} 
 | 
            </if> 
 | 
        </if> 
 | 
    </select> 
 | 
  
 | 
    <!-- 查询总条数 --> 
 | 
    <select id="selectTotalRecord" parameterType="long" resultType="java.lang.Integer"> 
 | 
        select count(*) 
 | 
        from bus_parameter_settings 
 | 
        where 1=1 
 | 
        <if test="record!=null"> 
 | 
            <if test="(record.paramId!=null and record.paramId!='') or (record.paramId!='' and record.paramId==0)"> 
 | 
                and param_id = #{record.paramId} 
 | 
            </if> 
 | 
            <if test="(record.paramCode!=null and record.paramCode!='') or (record.paramCode!='' and record.paramCode==0)"> 
 | 
                and param_code = #{record.paramCode} 
 | 
            </if> 
 | 
            <if test="(record.paramValue!=null and record.paramValue!='') or (record.paramValue!='' and record.paramValue==0)"> 
 | 
                and param_value = #{record.paramValue} 
 | 
            </if> 
 | 
            <if test="(record.paramValue1!=null and record.paramValue1!='') or (record.paramValue1!='' and record.paramValue1==0)"> 
 | 
                and param_value1 = #{record.paramValue1} 
 | 
            </if> 
 | 
            <if test="(record.paramValue2!=null and record.paramValue2!='') or (record.paramValue2!='' and record.paramValue2==0)"> 
 | 
                and param_value2 = #{record.paramValue2} 
 | 
            </if> 
 | 
            <if test="(record.paramValue3!=null and record.paramValue3!='') or (record.paramValue3!='' and record.paramValue3==0)"> 
 | 
                and param_value3 = #{record.paramValue3} 
 | 
            </if> 
 | 
            <if test="(record.companyId!=null and record.companyId!='') "> 
 | 
                and company_id = #{record.companyId} 
 | 
            </if> 
 | 
  
 | 
            <if test="(record.shopId!=null and record.shopId!='') "> 
 | 
                and shop_id = #{record.shopId} 
 | 
            </if> 
 | 
        </if> 
 | 
    </select> 
 | 
  
 | 
    <!-- 根据id查询--> 
 | 
    <select id="selectById" resultMap="BusParameterSettingsMap"> 
 | 
        select  
 | 
            param_id, 
 | 
            param_code, 
 | 
            param_value, 
 | 
            param_value1, 
 | 
            param_value2, 
 | 
            param_value3, 
 | 
            company_id, 
 | 
            shop_id 
 | 
        from bus_parameter_settings 
 | 
        where  param_id=#{paramId}  
 | 
    </select> 
 | 
  
 | 
  
 | 
    <!-- 根据id 锁表查询--> 
 | 
    <select id="selectForUpdate" resultMap="BusParameterSettingsMap"> 
 | 
        select  
 | 
            param_id, 
 | 
            param_code, 
 | 
            param_value, 
 | 
            param_value1, 
 | 
            param_value2, 
 | 
            param_value3, 
 | 
            company_id, 
 | 
            shop_id 
 | 
        from bus_parameter_settings 
 | 
        where  param_id=#{param_id}  
 | 
        for update 
 | 
    </select> 
 | 
  
 | 
  
 | 
    <!-- 根据对象查询--> 
 | 
    <select id="selectByModel" resultMap="BusParameterSettingsMap"> 
 | 
        select 
 | 
        param_id, 
 | 
        param_code, 
 | 
        param_value, 
 | 
        param_value1, 
 | 
        param_value2, 
 | 
        param_value3, 
 | 
        company_id, 
 | 
        shop_id 
 | 
        from bus_parameter_settings 
 | 
        where 1=1 
 | 
        <if test="record!=null"> 
 | 
            <if test="(record.paramId!=null and record.paramId!='') or (record.paramId!='' and record.paramId==0)"> 
 | 
                and param_id = #{record.paramId} 
 | 
            </if> 
 | 
            <if test="(record.paramCode!=null and record.paramCode!='') or (record.paramCode!='' and record.paramCode==0)"> 
 | 
                and param_code = #{record.paramCode} 
 | 
            </if> 
 | 
            <if test="(record.paramValue!=null and record.paramValue!='') or (record.paramValue!='' and record.paramValue==0)"> 
 | 
                and param_value = #{record.paramValue} 
 | 
            </if> 
 | 
            <if test="(record.paramValue1!=null and record.paramValue1!='') or (record.paramValue1!='' and record.paramValue1==0)"> 
 | 
                and param_value1 = #{record.paramValue1} 
 | 
            </if> 
 | 
            <if test="(record.paramValue2!=null and record.paramValue2!='') or (record.paramValue2!='' and record.paramValue2==0)"> 
 | 
                and param_value2 = #{record.paramValue2} 
 | 
            </if> 
 | 
            <if test="(record.paramValue3!=null and record.paramValue3!='') or (record.paramValue3!='' and record.paramValue3==0)"> 
 | 
                and param_value3 = #{record.paramValue3} 
 | 
            </if> 
 | 
            <if test="(record.companyId!=null and record.companyId!='') "> 
 | 
                and company_id = #{record.companyId} 
 | 
            </if> 
 | 
  
 | 
            <if test="(record.shopId!=null and record.shopId!='') "> 
 | 
                and shop_id = #{record.shopId} 
 | 
            </if> 
 | 
        </if> 
 | 
    </select> 
 | 
  
 | 
    <select id="selectByCodes" resultMap="BusParameterSettingsMap"> 
 | 
  
 | 
        select * from bus_parameter_settings where company_id=#{companyId} and  shop_id=#{shopId} 
 | 
        and param_code in 
 | 
        <foreach collection="list" index="index" item="item" open="(" 
 | 
                 separator="," close=")"> 
 | 
            #{item} 
 | 
        </foreach> 
 | 
    </select> 
 | 
  
 | 
    <select id="selectByCode" resultMap="BusParameterSettingsMap"> 
 | 
         select * from bus_parameter_settings where 
 | 
         param_code=#{code} 
 | 
         and company_id=#{companyId} and  shop_id=#{shopId} 
 | 
    </select> 
 | 
    <select id="selectCompanyParamByCode" resultMap="BusParameterSettingsMap"> 
 | 
         select * from bus_parameter_settings where 
 | 
         param_code=#{code} 
 | 
         and company_id=#{companyId} 
 | 
    </select> 
 | 
</mapper> 
 |