美文网首页
后台→xxMapper.xml中传参

后台→xxMapper.xml中传参

作者: 墨色尘埃 | 来源:发表于2017-12-17 15:15 被阅读0次

    前面了解到前端(或者利用postman通过url模拟)→后台传参数,control类方法中如何接收,那么又该怎么将参数传递给xxMapper.xml中呢,可见mybatis多参数传递到Mapper.xml中一文。

    只要定义了这个属性名,那么就能成功传递
    ① String name
    ② Map<String,String> map:这里就是key
    ③ Object object:对象中有这个属性名
    ④ @Param("name") String name:属性名为双引号里的

    OverViewMapper

    @Mapper
    public interface OverViewMapper {
    
        int deleteByPrimaryKey(String enterpriseId);
    
        int insert(OverView record);
    
        int insertSelective(OverView record);
    
        OverView selectByPrimaryKey(String enterpriseId);
    
        int updateByPrimaryKeySelective(OverView record);
    
        int updateByPrimaryKey(OverView record);
    
        //
        List<EnterpriseBaseExtra> list(@Param("extraSql") String extraSql);
    
        List<Map<String, Object>> detail(@Param("enterpriseId") String enterpriseId);
    
        List<DynaTableField> tableName(@Param("dynaKey") String dynaKey);
    
        List<LinkedHashMap<String, Object>> overViewDetail(@Param("startTime") String startTime,
                                                           @Param("endTime") String endTime,
                                                           @Param("dynaKey") String dynaKey,
                                                           @Param("tableName") String tableName);
    
    
    }
    

    OverViewMapper.xml

    <?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.jsptpd.gayg.modules.cloud.dao.OverViewMapper">
        <resultMap id="BaseResultMap" type="com.jsptpd.gayg.modules.cloud.model.OverView">
            <id column="ENTERPRISE_ID" jdbcType="VARCHAR" property="enterpriseId"/>
            <result column="ENTERPRISE_NAME" jdbcType="VARCHAR" property="enterpriseName"/>
            <result column="ENTERPRISE_USCC" jdbcType="VARCHAR" property="enterpriseUscc"/>
            <result column="GD_INFO" jdbcType="VARCHAR" property="gdInfo"/>
            <result column="HG_CODE" jdbcType="VARCHAR" property="hgCode"/>
            <result column="ESTABLISH_DATE" jdbcType="DATE" property="establishDate"/>
            <result column="REGIST_CAPITAL" jdbcType="DECIMAL" property="registCapital"/>
            <result column="ENTERPRISE_ADDRESS" jdbcType="VARCHAR" property="enterpriseAddress"/>
            <result column="ENTERPRISE_SCOPE" jdbcType="VARCHAR" property="enterpriseScope"/>
            <result column="LEGAL_NAME" jdbcType="VARCHAR" property="legalName"/>
            <result column="CONTACT_PHONE" jdbcType="VARCHAR" property="contactPhone"/>
            <result column="IS_INVEST" jdbcType="INTEGER" property="isInvest"/>
            <result column="PARK_TYPE" jdbcType="INTEGER" property="parkType"/>
            <result column="WORKSHOP_POS" jdbcType="VARCHAR" property="workshopPos"/>
            <result column="WORKSHOP_AREA" jdbcType="DECIMAL" property="workshopArea"/>
            <result column="INDUSTRY_CLASS" jdbcType="INTEGER" property="industryClass"/>
            <result column="INDUSTRY_CATEGORY" jdbcType="INTEGER" property="industryCategory"/>
            <result column="TRIAL_TIME" jdbcType="DATE" property="trialTime"/>
            <result column="INVEST_TIME" jdbcType="DATE" property="investTime"/>
            <result column="PRODUCT_TIME" jdbcType="DATE" property="productTime"/>
            <result column="BUSI_INFO" jdbcType="INTEGER" property="busiInfo"/>
    
            <result column="ZSYZDW_AMOUNT" jdbcType="DECIMAL" property="zsyzdwAmount"/>
            <result column="SJWZ_AMOUNT" jdbcType="DECIMAL" property="sjwzAmount"/>
            <result column="SUBSIDY_URL" jdbcType="VARCHAR" property="subsidyUrl"/>
            <result column="GYSZ_TOTAL" jdbcType="DECIMAL" property="gyszTotal"/>
            <result column="ZYYW_INCOME" jdbcType="DECIMAL" property="zyywIncome"/>
            <result column="QIYE_REPORT" jdbcType="DECIMAL" property="qiyeReport"/>
            <result column="TAX_FIGURES" jdbcType="DECIMAL" property="taxFigures"/>
            <result column="GDZCTZ_AMOUNT" jdbcType="DECIMAL" property="gdzctzAmount"/>
            <result column="JNSS_AMOUNT" jdbcType="DECIMAL" property="jnssAmount"/>
            <result column="G_TAX" jdbcType="DECIMAL" property="gTax"/>
            <result column="D_TAX" jdbcType="DECIMAL" property="dTax"/>
            <result column="E_TAX" jdbcType="DECIMAL" property="eTax"/>
            <result column="P_TAX" jdbcType="DECIMAL" property="pTax"/>
            <result column="IN_OUT_TOTAL" jdbcType="DECIMAL" property="inOutTotal"/>
            <result column="EMPLOY_NUM" jdbcType="INTEGER" property="employNum"/>
            <result column="SBJN_NUM" jdbcType="INTEGER" property="sbjnNum"/>
            <result column="SBJN_AMOUNT" jdbcType="VARCHAR" property="sbjnAmount"/>
            <result column="WATER_SIZE" jdbcType="DECIMAL" property="waterSize"/>
            <result column="WATER_AMOUNT" jdbcType="VARCHAR" property="waterAmount"/>
            <result column="ELE_SIZE" jdbcType="DOUBLE" property="eleSize"/>
            <result column="ELE_AMOUNT" jdbcType="VARCHAR" property="eleAmount"/>
            <result column="YKT_NUM" jdbcType="INTEGER" property="yktNum"/>
            <result column="YKT_PERSONS" jdbcType="INTEGER" property="yktPersons"/>
    
            <result column="ENTERPRISE_TYPE" jdbcType="VARCHAR" property="enterpriseType"/>
            <result column="REMARK" jdbcType="VARCHAR" property="remark"/>
            <result column="STATUS" jdbcType="INTEGER" property="status"/>
            <result column="OPERATOR" jdbcType="VARCHAR" property="operator"/>
            <result column="OPERATE_TIME" jdbcType="TIMESTAMP" property="operateTime"/>
    
        </resultMap>
    
    
        <resultMap id="DynaResultMap" type="com.jsptpd.gayg.modules.cloud.model.DynaTableField">
            <id column="ID" jdbcType="INTEGER" property="id"/>
            <result column="DYNA_KEY" jdbcType="VARCHAR" property="dynaKey"/>
            <result column="TABLE_NAME" jdbcType="VARCHAR" property="tableName"/>
            <result column="FIELD_NAME" jdbcType="VARCHAR" property="fieldName"/>
            <result column="FIELD_CN_NAME" jdbcType="VARCHAR" property="fieldCnName"/>
            <result column="FIELD_ORDER" jdbcType="INTEGER" property="fieldOrder"/>
        </resultMap>
    
    
        <sql id="Base_Column_List">
            ENTERPRISE_ID, ENTERPRISE_NAME, ZSYZDW_AMOUNT, SJWZ_AMOUNT, SUBSIDY_URL, GYSZ_TOTAL,
            ZYYW_INCOME, QIYE_REPORT, TAX_FIGURES, GDZCTZ_AMOUNT, JNSS_AMOUNT, G_TAX, D_TAX,
            E_TAX, P_TAX, IN_OUT_TOTAL, EMPLOY_NUM, SBJN_NUM, SBJN_AMOUNT, WATER_SIZE, WATER_AMOUNT,
            ELE_SIZE, ELE_AMOUNT, YKT_NUM, YKT_PERSONS
        </sql>
        <select id="selectByPrimaryKey" parameterType="java.lang.String" resultMap="BaseResultMap">
            select
            <include refid="Base_Column_List"/>
            from t_enterprise_extra_info
            where ENTERPRISE_ID = #{enterpriseId,jdbcType=VARCHAR} AND status=101001
        </select>
        <delete id="deleteByPrimaryKey" parameterType="java.lang.String">
            delete from t_enterprise_extra_info
            where ENTERPRISE_ID = #{enterpriseId,jdbcType=VARCHAR} AND status=101001
        </delete>
        <insert id="insert" parameterType="com.jsptpd.gayg.modules.cloud.model.OverView">
            insert into t_enterprise_extra_info (ENTERPRISE_ID, ENTERPRISE_NAME, ZSYZDW_AMOUNT,
            SJWZ_AMOUNT, SUBSIDY_URL, GYSZ_TOTAL,
            ZYYW_INCOME, QIYE_REPORT, TAX_FIGURES,
            GDZCTZ_AMOUNT, JNSS_AMOUNT, G_TAX,
            D_TAX, E_TAX, P_TAX, IN_OUT_TOTAL,
            EMPLOY_NUM, SBJN_NUM, SBJN_AMOUNT,
            WATER_SIZE, WATER_AMOUNT, ELE_SIZE,
            ELE_AMOUNT, YKT_NUM, YKT_PERSONS
            )
            VALUES (#{enterpriseId,jdbcType=VARCHAR}, #{enterpriseName,jdbcType=VARCHAR}, #{zsyzdwAmount,jdbcType=DECIMAL},
            #{sjwzAmount,jdbcType=DECIMAL}, #{subsidyUrl,jdbcType=VARCHAR}, #{gyszTotal,jdbcType=DECIMAL},
            #{zyywIncome,jdbcType=DECIMAL}, #{qiyeReport,jdbcType=DECIMAL}, #{taxFigures,jdbcType=DECIMAL},
            #{gdzctzAmount,jdbcType=DECIMAL}, #{jnssAmount,jdbcType=DECIMAL}, #{gTax,jdbcType=DECIMAL},
            #{dTax,jdbcType=DECIMAL}, #{eTax,jdbcType=DECIMAL}, #{pTax,jdbcType=DECIMAL}, #{inOutTotal,jdbcType=DECIMAL},
            #{employNum,jdbcType=INTEGER}, #{sbjnNum,jdbcType=INTEGER}, #{sbjnAmount,jdbcType=VARCHAR},
            #{waterSize,jdbcType=DECIMAL}, #{waterAmount,jdbcType=VARCHAR}, #{eleSize,jdbcType=DOUBLE},
            #{eleAmount,jdbcType=VARCHAR}, #{yktNum,jdbcType=INTEGER}, #{yktPersons,jdbcType=INTEGER}
            )
        </insert>
        <insert id="insertSelective" parameterType="com.jsptpd.gayg.modules.cloud.model.OverView">
            insert into t_enterprise_extra_info
            <trim prefix="(" suffix=")" suffixOverrides=",">
                <if test="enterpriseId != null">
                    ENTERPRISE_ID,
                </if>
                <if test="enterpriseName != null">
                    ENTERPRISE_NAME,
                </if>
                <if test="zsyzdwAmount != null">
                    ZSYZDW_AMOUNT,
                </if>
                <if test="sjwzAmount != null">
                    SJWZ_AMOUNT,
                </if>
                <if test="subsidyUrl != null">
                    SUBSIDY_URL,
                </if>
                <if test="gyszTotal != null">
                    GYSZ_TOTAL,
                </if>
                <if test="zyywIncome != null">
                    ZYYW_INCOME,
                </if>
                <if test="qiyeReport != null">
                    QIYE_REPORT,
                </if>
                <if test="taxFigures != null">
                    TAX_FIGURES,
                </if>
                <if test="gdzctzAmount != null">
                    GDZCTZ_AMOUNT,
                </if>
                <if test="jnssAmount != null">
                    JNSS_AMOUNT,
                </if>
                <if test="gTax != null">
                    G_TAX,
                </if>
                <if test="dTax != null">
                    D_TAX,
                </if>
                <if test="eTax != null">
                    E_TAX,
                </if>
                <if test="pTax != null">
                    P_TAX,
                </if>
                <if test="inOutTotal != null">
                    IN_OUT_TOTAL,
                </if>
                <if test="employNum != null">
                    EMPLOY_NUM,
                </if>
                <if test="sbjnNum != null">
                    SBJN_NUM,
                </if>
                <if test="sbjnAmount != null">
                    SBJN_AMOUNT,
                </if>
                <if test="waterSize != null">
                    WATER_SIZE,
                </if>
                <if test="waterAmount != null">
                    WATER_AMOUNT,
                </if>
                <if test="eleSize != null">
                    ELE_SIZE,
                </if>
                <if test="eleAmount != null">
                    ELE_AMOUNT,
                </if>
                <if test="yktNum != null">
                    YKT_NUM,
                </if>
                <if test="yktPersons != null">
                    YKT_PERSONS,
                </if>
            </trim>
            <trim prefix="values (" suffix=")" suffixOverrides=",">
                <if test="enterpriseId != null">
                    #{enterpriseId,jdbcType=VARCHAR},
                </if>
                <if test="enterpriseName != null">
                    #{enterpriseName,jdbcType=VARCHAR},
                </if>
                <if test="zsyzdwAmount != null">
                    #{zsyzdwAmount,jdbcType=DECIMAL},
                </if>
                <if test="sjwzAmount != null">
                    #{sjwzAmount,jdbcType=DECIMAL},
                </if>
                <if test="subsidyUrl != null">
                    #{subsidyUrl,jdbcType=VARCHAR},
                </if>
                <if test="gyszTotal != null">
                    #{gyszTotal,jdbcType=DECIMAL},
                </if>
                <if test="zyywIncome != null">
                    #{zyywIncome,jdbcType=DECIMAL},
                </if>
                <if test="qiyeReport != null">
                    #{qiyeReport,jdbcType=DECIMAL},
                </if>
                <if test="taxFigures != null">
                    #{taxFigures,jdbcType=DECIMAL},
                </if>
                <if test="gdzctzAmount != null">
                    #{gdzctzAmount,jdbcType=DECIMAL},
                </if>
                <if test="jnssAmount != null">
                    #{jnssAmount,jdbcType=DECIMAL},
                </if>
                <if test="gTax != null">
                    #{gTax,jdbcType=DECIMAL},
                </if>
                <if test="dTax != null">
                    #{dTax,jdbcType=DECIMAL},
                </if>
                <if test="eTax != null">
                    #{eTax,jdbcType=DECIMAL},
                </if>
                <if test="pTax != null">
                    #{pTax,jdbcType=DECIMAL},
                </if>
                <if test="inOutTotal != null">
                    #{inOutTotal,jdbcType=DECIMAL},
                </if>
                <if test="employNum != null">
                    #{employNum,jdbcType=INTEGER},
                </if>
                <if test="sbjnNum != null">
                    #{sbjnNum,jdbcType=INTEGER},
                </if>
                <if test="sbjnAmount != null">
                    #{sbjnAmount,jdbcType=VARCHAR},
                </if>
                <if test="waterSize != null">
                    #{waterSize,jdbcType=DECIMAL},
                </if>
                <if test="waterAmount != null">
                    #{waterAmount,jdbcType=VARCHAR},
                </if>
                <if test="eleSize != null">
                    #{eleSize,jdbcType=DOUBLE},
                </if>
                <if test="eleAmount != null">
                    #{eleAmount,jdbcType=VARCHAR},
                </if>
                <if test="yktNum != null">
                    #{yktNum,jdbcType=INTEGER},
                </if>
                <if test="yktPersons != null">
                    #{yktPersons,jdbcType=INTEGER},
                </if>
            </trim>
        </insert>
        <update id="updateByPrimaryKeySelective" parameterType="com.jsptpd.gayg.modules.cloud.model.OverView">
            update t_enterprise_extra_info
            <set>
                <if test="enterpriseName != null">
                    ENTERPRISE_NAME = #{enterpriseName,jdbcType=VARCHAR},
                </if>
                <if test="zsyzdwAmount != null">
                    ZSYZDW_AMOUNT = #{zsyzdwAmount,jdbcType=DECIMAL},
                </if>
                <if test="sjwzAmount != null">
                    SJWZ_AMOUNT = #{sjwzAmount,jdbcType=DECIMAL},
                </if>
                <if test="subsidyUrl != null">
                    SUBSIDY_URL = #{subsidyUrl,jdbcType=VARCHAR},
                </if>
                <if test="gyszTotal != null">
                    GYSZ_TOTAL = #{gyszTotal,jdbcType=DECIMAL},
                </if>
                <if test="zyywIncome != null">
                    ZYYW_INCOME = #{zyywIncome,jdbcType=DECIMAL},
                </if>
                <if test="qiyeReport != null">
                    QIYE_REPORT = #{qiyeReport,jdbcType=DECIMAL},
                </if>
                <if test="taxFigures != null">
                    TAX_FIGURES = #{taxFigures,jdbcType=DECIMAL},
                </if>
                <if test="gdzctzAmount != null">
                    GDZCTZ_AMOUNT = #{gdzctzAmount,jdbcType=DECIMAL},
                </if>
                <if test="jnssAmount != null">
                    JNSS_AMOUNT = #{jnssAmount,jdbcType=DECIMAL},
                </if>
                <if test="gTax != null">
                    G_TAX = #{gTax,jdbcType=DECIMAL},
                </if>
                <if test="dTax != null">
                    D_TAX = #{dTax,jdbcType=DECIMAL},
                </if>
                <if test="eTax != null">
                    E_TAX = #{eTax,jdbcType=DECIMAL},
                </if>
                <if test="pTax != null">
                    P_TAX = #{pTax,jdbcType=DECIMAL},
                </if>
                <if test="inOutTotal != null">
                    IN_OUT_TOTAL = #{inOutTotal,jdbcType=DECIMAL},
                </if>
                <if test="employNum != null">
                    EMPLOY_NUM = #{employNum,jdbcType=INTEGER},
                </if>
                <if test="sbjnNum != null">
                    SBJN_NUM = #{sbjnNum,jdbcType=INTEGER},
                </if>
                <if test="sbjnAmount != null">
                    SBJN_AMOUNT = #{sbjnAmount,jdbcType=VARCHAR},
                </if>
                <if test="waterSize != null">
                    WATER_SIZE = #{waterSize,jdbcType=DECIMAL},
                </if>
                <if test="waterAmount != null">
                    WATER_AMOUNT = #{waterAmount,jdbcType=VARCHAR},
                </if>
                <if test="eleSize != null">
                    ELE_SIZE = #{eleSize,jdbcType=DOUBLE},
                </if>
                <if test="eleAmount != null">
                    ELE_AMOUNT = #{eleAmount,jdbcType=VARCHAR},
                </if>
                <if test="yktNum != null">
                    YKT_NUM = #{yktNum,jdbcType=INTEGER},
                </if>
                <if test="yktPersons != null">
                    YKT_PERSONS = #{yktPersons,jdbcType=INTEGER},
                </if>
            </set>
            where ENTERPRISE_ID = #{enterpriseId,jdbcType=VARCHAR} AND status=101001
        </update>
        <update id="updateByPrimaryKey" parameterType="com.jsptpd.gayg.modules.cloud.model.OverView">
            update t_enterprise_extra_info
            set ENTERPRISE_NAME = #{enterpriseName,jdbcType=VARCHAR},
            ZSYZDW_AMOUNT = #{zsyzdwAmount,jdbcType=DECIMAL},
            SJWZ_AMOUNT = #{sjwzAmount,jdbcType=DECIMAL},
            SUBSIDY_URL = #{subsidyUrl,jdbcType=VARCHAR},
            GYSZ_TOTAL = #{gyszTotal,jdbcType=DECIMAL},
            ZYYW_INCOME = #{zyywIncome,jdbcType=DECIMAL},
            QIYE_REPORT = #{qiyeReport,jdbcType=DECIMAL},
            TAX_FIGURES = #{taxFigures,jdbcType=DECIMAL},
            GDZCTZ_AMOUNT = #{gdzctzAmount,jdbcType=DECIMAL},
            JNSS_AMOUNT = #{jnssAmount,jdbcType=DECIMAL},
            G_TAX = #{gTax,jdbcType=DECIMAL},
            D_TAX = #{dTax,jdbcType=DECIMAL},
            E_TAX = #{eTax,jdbcType=DECIMAL},
            P_TAX = #{pTax,jdbcType=DECIMAL},
            IN_OUT_TOTAL = #{inOutTotal,jdbcType=DECIMAL},
            EMPLOY_NUM = #{employNum,jdbcType=INTEGER},
            SBJN_NUM = #{sbjnNum,jdbcType=INTEGER},
            SBJN_AMOUNT = #{sbjnAmount,jdbcType=VARCHAR},
            WATER_SIZE = #{waterSize,jdbcType=DECIMAL},
            WATER_AMOUNT = #{waterAmount,jdbcType=VARCHAR},
            ELE_SIZE = #{eleSize,jdbcType=DOUBLE},
            ELE_AMOUNT = #{eleAmount,jdbcType=VARCHAR},
            YKT_NUM = #{yktNum,jdbcType=INTEGER},
            YKT_PERSONS = #{yktPersons,jdbcType=INTEGER}
            where ENTERPRISE_ID = #{enterpriseId,jdbcType=VARCHAR} AND status=101001
        </update>
    
        <!--获取企业全景信息接口-->
        <select id="list" parameterType="java.lang.String" resultMap="BaseResultMap">
            <!--<select id="list" parameterType="java.lang.String" resultType="java.util.LinkedHashMap">-->
            SELECT u.*,c.*
            FROM
            t_enterprise_base_info u
            JOIN t_enterprise_extra_info c ON c.ENTERPRISE_ID = u.ENTERPRISE_ID
            AND u.status=101001
            <if test="extraSql != null and extraSql !=''">
                AND ${extraSql}
            </if>
        </select>
    
        <!--获取企业全景信息接口,根据enterpriseId查询详情。静态字段+22个动态字段-->
        <select id="detail" parameterType="java.lang.String" resultType="java.util.LinkedHashMap">
            SELECT u.*,c.*
            FROM
            t_enterprise_base_info u
            LEFT JOIN t_enterprise_extra_info c ON c.ENTERPRISE_ID = u.ENTERPRISE_ID
            WHERE u.ENTERPRISE_ID = #{enterpriseId,jdbcType=VARCHAR} AND u.status=101001
        </select>
    
    
        <!--获取动态指标明细数据接口-->
        <select id="tableName" parameterType="String" resultMap="DynaResultMap">
            SELECT
            *
            FROM
            t_dynatable_fields
            WHERE
            DYNA_KEY = #{dynaKey,jdbcType=VARCHAR}
        </select>
    
        <select id="overViewDetail" parameterType="String" resultType="java.util.LinkedHashMap">
            SELECT
            YEARMONTH,${dynaKey}
            FROM
            ${tableName}
            <where>
                status=101001
                <if test="startTime !=null and startTime !=''">
                    AND <![CDATA[ YEARMONTH >= #{startTime} ]]>
                </if>
                <if test="endTime !=null and endTime !=''">
                    AND <![CDATA[ YEARMONTH <= #{endTime}]]>
                </if>
            </where>
            ORDER BY YEARMONTH DESC
        </select>
    
    </mapper>
    

    相关文章

      网友评论

          本文标题:后台→xxMapper.xml中传参

          本文链接:https://www.haomeiwen.com/subject/xuwywxtx.html