update
This commit is contained in:
@@ -8,10 +8,11 @@ from layercake.dateutils import now
|
||||
from layercake.dynamodb import (
|
||||
DynamoDBPersistenceLayer,
|
||||
KeyPair,
|
||||
TransactItems,
|
||||
)
|
||||
|
||||
from boto3clients import dynamodb_client
|
||||
from conf import ORDER_TABLE
|
||||
from config import ORDER_TABLE
|
||||
|
||||
logger = Logger(__name__)
|
||||
order_layer = DynamoDBPersistenceLayer(ORDER_TABLE, dynamodb_client)
|
||||
@@ -21,7 +22,9 @@ order_layer = DynamoDBPersistenceLayer(ORDER_TABLE, dynamodb_client)
|
||||
@logger.inject_lambda_context
|
||||
def lambda_handler(event: EventBridgeEvent, context: LambdaContext) -> bool:
|
||||
new_image = event.detail['new_image']
|
||||
order_layer.update_item(
|
||||
now_ = now()
|
||||
transact = TransactItems(order_layer.table_name)
|
||||
transact.update(
|
||||
key=KeyPair(new_image['id'], '0'),
|
||||
update_expr='SET #status = :status, update_date = :update_date',
|
||||
expr_attr_names={
|
||||
@@ -29,8 +32,15 @@ def lambda_handler(event: EventBridgeEvent, context: LambdaContext) -> bool:
|
||||
},
|
||||
expr_attr_values={
|
||||
':status': 'PAID',
|
||||
':update_date': now(),
|
||||
':update_date': now_,
|
||||
},
|
||||
)
|
||||
|
||||
transact.put(
|
||||
item={
|
||||
'id': new_image['id'],
|
||||
'sk': 'paid_date',
|
||||
'create_date': now_,
|
||||
}
|
||||
)
|
||||
order_layer.transact_write_items(transact)
|
||||
return True
|
||||
|
||||
Reference in New Issue
Block a user