Dto
@Getter
@Setter
public class OrderDto implements Serializable{
private static final long serialVersionUID = 1L;
private Long orderId;
private Integer productId; //商品ID
private BigDecimal unitPrice, //单价
private Integer quantity; //数量
}
Mapper
<insert id="insert" parameterType="com.OrderDto" useGeneratedKeys="true" keyProperty="order.orderId">
INSERT INTO order (
productId,
unitPrice,
quantity
)VALUES
(
#{order.productId,jdbcType=INTEGER},
#{order.unitPrice,jdbcType=DECIMAL},
#{order.quantity,jdbcType=INTEGER}
)
</insert>
Dao
Long insert(@Param(value = "order") OrderDto order);