mybatis框架,执行插入语句的时候,如果没有字段传过来就赋值为空 进行判断

<insert id="insert" parameterType="com.picc.hmbms.outinterface.scoreDetail.po.ScoreSettlePo">
        insert into t_score_settel
        (score_settel_id,
        member_code,
        order_no,
        product_code,
        product_name,
        pay_way,
        payable_amount,
        payable_score,
        consumer_date,
        consumer_org,
        sys_no,
        settel_type,
        remark,
        insert_time,
        insert_oper,
        update_time,
        update_oper)
        values
        (
        cast(#{scoreSettelId} as NUMERIC),
        #{memberCode},
        #{orderNo},
        #{productCode},
        #{productName},
        #{payWay},
        <choose>
            <when test="payableAmount != null and payableAmount != ‘‘">
                cast(#{payableAmount} as NUMERIC),
            </when>
            <otherwise>
                null,
            </otherwise>
        </choose>

        <choose>
            <when test="payableScore != null and payableScore != ‘‘">
                cast(#{payableScore} as NUMERIC),
            </when>
            <otherwise>
                null,
            </otherwise>
        </choose>
        #{consumerDate},
        #{consumerOrg},
        #{sysNo},
        #{settelType},
        #{remark},
        #{insertTime},
        #{insertOper},
        #{updateTime},
        #{updateOper})
    </insert>

相关推荐