mybatis动态数据更新 + 批量动态数据插入




  动态更新


update dc_elevator

inspection_code = #{inspectionCode,jdbcType=VARCHAR},
brand_code = #{brandCode},
model_specs = #{modelSpecs},
elevator_type=#{elevatorType},
id_district=#{idDistrict},
id_property_company=#{idPropertyCompany},
id_service_company=#{idServiceCompany},
id_service_manager=#{idServiceManager},
contract_code=#{contractCode},
run_status=#{runStatus},
qr_code_check=#{qrCodeCheck},
qr_code_product=#{qrCodeProduct},
last_annual_date=#{lastAnnualDate},
next_annual_date=#{nextAnnualDate},
last_maintain_date=#{lastMaintainDate},
next_maintain_date=#{nextMaintainDate},
repair_times=#{repairTimes},
maintain_times=#{maintainTimes},
accessories_exchanges=#{accessoriesExchanges},
Install_date=#{installDate},
status=#{status},
created_by=#{createdBy},
created_date=#{createdDate},
updated_by=#{updatedBy},
updated_date=#{updatedDate}

where
id_elevator = #{idElevator}



批量动态插入

insert into dc_elevator
(

inspection_code,
brand_code,
model_specs,
elevator_type,
id_district,
id_property_company,
id_service_company,
id_service_manager,
contract_code,
run_status,
qr_code_check,
qr_code_product,
last_annual_date,
next_annual_date,
last_maintain_date,
next_maintain_date,
repair_times,
maintain_times,
accessories_exchanges,
Install_date,
status,
created_by,
created_date,
updated_by,
updated_date,
id_elevator

)
values

(
#{item.inspectionCode},
#{item.brandCode},
#{item.modelSpecs},
#{item.elevatorType},
#{item.idDistrict},
#{item.idPropertyCompany},
#{item.idServiceCompany},
#{item.idServiceManager},
#{item.contractCode},
#{item.runStatus},
#{item.qrCodeCheck},
#{item.qrCodeProduct},
#{item.lastAnnualDate},
#{item.nextAnnualDate},
#{item.lastMaintainDate},
#{item.nextMaintainDate},
#{item.repairTimes},
#{item.maintainTimes},
#{item.accessoriesExchanges},
#{item.installDate},
#{item.status},
#{item.createdBy},
#{item.createdDate},
#{item.updatedBy},
#{item.updatedDate},
#{item.idElevator}
)



  

  动态插入,返回主键

/*先插入,再将主键返回实体*/

SELECT LAST_INSERT_ID()

/*插入*/
INSERT INTO ac_bank_card

bank_name,
card_number,
expiry_date,
ower,
account_id

VALUES

#{bankName},
#{cardNumber},

#{expiryDate},

#{ower},
#{accountId}

转载于:https://www.cnblogs.com/Soy-technology/p/10785084.html

你可能感兴趣的:(mybatis动态数据更新 + 批量动态数据插入)