dynamodb 데이터 초기화 처리
This commit is contained in:
@@ -0,0 +1,71 @@
|
||||
package com.caliverse.admin.dynamodb.domain.atrrib;
|
||||
|
||||
import com.fasterxml.jackson.annotation.JsonProperty;
|
||||
import com.fasterxml.jackson.databind.PropertyNamingStrategies;
|
||||
import com.fasterxml.jackson.databind.annotation.JsonNaming;
|
||||
import lombok.NoArgsConstructor;
|
||||
import lombok.Setter;
|
||||
import lombok.ToString;
|
||||
import software.amazon.awssdk.enhanced.dynamodb.mapper.annotations.DynamoDbAttribute;
|
||||
import software.amazon.awssdk.enhanced.dynamodb.mapper.annotations.DynamoDbBean;
|
||||
|
||||
@Setter
|
||||
@ToString(callSuper = true)
|
||||
@NoArgsConstructor
|
||||
@DynamoDbBean
|
||||
@JsonNaming(PropertyNamingStrategies.SnakeCaseStrategy.class)
|
||||
public class LandAuctionRefundBidPriceAttrib {
|
||||
@JsonProperty("land_meta_id")
|
||||
private Integer landMetaId;
|
||||
@JsonProperty("auction_number")
|
||||
private Integer auctionNumber;
|
||||
@JsonProperty("bid_user_guid")
|
||||
private String bidUserGuid;
|
||||
@JsonProperty("last_bid_type")
|
||||
private String lastBidType;
|
||||
@JsonProperty("bid_currency_type")
|
||||
private String bidCurrencyType;
|
||||
@JsonProperty("bid_price")
|
||||
private Double bidPrice;
|
||||
@JsonProperty("refundable_normal_bid_price")
|
||||
private Double refundableNormalBidPrice;
|
||||
@JsonProperty("refundable_blind_bid_price")
|
||||
private Double refundableBlindBidPrice;
|
||||
|
||||
@DynamoDbAttribute("land_meta_id")
|
||||
public Integer getLandMetaId() {
|
||||
return landMetaId;
|
||||
}
|
||||
|
||||
@DynamoDbAttribute("auction_number")
|
||||
public Integer getAuctionNumber() {
|
||||
return auctionNumber;
|
||||
}
|
||||
|
||||
@DynamoDbAttribute("bid_user_guid")
|
||||
public String getBidUserGuid() {
|
||||
return bidUserGuid;
|
||||
}
|
||||
|
||||
@DynamoDbAttribute("last_bid_type")
|
||||
public String getLastBidType() { return lastBidType; }
|
||||
|
||||
@DynamoDbAttribute("bid_currency_type")
|
||||
public String getBidCurrencyType() { return bidCurrencyType; }
|
||||
|
||||
@DynamoDbAttribute("bid_price")
|
||||
public Double getBidPrice() {
|
||||
return bidPrice;
|
||||
}
|
||||
|
||||
@DynamoDbAttribute("refundable_normal_bid_price")
|
||||
public Double getRefundableNormalBidPrice() {
|
||||
return refundableNormalBidPrice;
|
||||
}
|
||||
|
||||
@DynamoDbAttribute("refundable_blind_bid_price")
|
||||
public Double getRefundableBlindBidPrice() {
|
||||
return refundableBlindBidPrice;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,30 @@
|
||||
package com.caliverse.admin.dynamodb.domain.doc;
|
||||
|
||||
import com.caliverse.admin.dynamodb.domain.atrrib.LandAuctionRefundBidPriceAttrib;
|
||||
import com.fasterxml.jackson.annotation.JsonProperty;
|
||||
import lombok.EqualsAndHashCode;
|
||||
import lombok.NoArgsConstructor;
|
||||
import software.amazon.awssdk.enhanced.dynamodb.mapper.annotations.DynamoDbAttribute;
|
||||
import software.amazon.awssdk.enhanced.dynamodb.mapper.annotations.DynamoDbBean;
|
||||
|
||||
@EqualsAndHashCode(callSuper = true)
|
||||
@NoArgsConstructor
|
||||
@DynamoDbBean
|
||||
public class LandAuctionRefundBidPriceDoc extends DynamoDBDocBase {
|
||||
private LandAuctionRefundBidPriceAttrib landAuctionRefundBidPriceAttrib;
|
||||
|
||||
public String getAttribFieldName() {
|
||||
return "LandAuctionRefundBidPriceAttrib";
|
||||
}
|
||||
|
||||
@DynamoDbAttribute("LandAuctionRefundBidPriceAttrib")
|
||||
@JsonProperty("LandAuctionRefundBidPriceAttrib")
|
||||
public LandAuctionRefundBidPriceAttrib getAttribValue() {
|
||||
return landAuctionRefundBidPriceAttrib;
|
||||
}
|
||||
|
||||
public void setAttribValue(LandAuctionRefundBidPriceAttrib value) {
|
||||
this.landAuctionRefundBidPriceAttrib = value;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,13 @@
|
||||
package com.caliverse.admin.dynamodb.entity;
|
||||
|
||||
import com.caliverse.admin.dynamodb.domain.doc.DynamoDBDocBase;
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Data;
|
||||
|
||||
@Data
|
||||
@AllArgsConstructor
|
||||
public class DynamodbOperationResult {
|
||||
private boolean success;
|
||||
private String message;
|
||||
private DynamoDBDocBase data;
|
||||
}
|
||||
@@ -3,9 +3,12 @@ package com.caliverse.admin.dynamodb.repository;
|
||||
import com.caliverse.admin.domain.request.LandRequest;
|
||||
import com.caliverse.admin.dynamodb.domain.atrrib.BuildingAttrib;
|
||||
import com.caliverse.admin.dynamodb.domain.doc.BuildingDoc;
|
||||
import com.caliverse.admin.dynamodb.entity.DynamodbOperationResult;
|
||||
|
||||
public interface BuildingRepository extends DynamoDBRepository<BuildingDoc> {
|
||||
BuildingAttrib findBuildingAttrib(Integer buildingId);
|
||||
void insertBuilding(LandRequest landRequest);
|
||||
void updateBuilding(LandRequest landRequest);
|
||||
DynamodbOperationResult initBuildingOwner(int buildingId);
|
||||
DynamodbOperationResult initBuildingDesc(int buildingId);
|
||||
}
|
||||
|
||||
@@ -14,5 +14,7 @@ public interface DynamoDBRepository<T> {
|
||||
void deleteWithCondition(Key key, Expression condition);
|
||||
T findById(Key key);
|
||||
List<T> findAll(Key key);
|
||||
List<T> findAllScan(String prefix);
|
||||
List<T> findAllScan(String prefix, String sortKey);
|
||||
List<T> findByPrefix(String partitionKey, String sortKeyPrefix);
|
||||
}
|
||||
|
||||
@@ -92,9 +92,7 @@ public class AccountBaseRepositoryImpl extends BaseDynamoDBRepository<AccountBas
|
||||
HISTORYTYPE.BLACKLIST_UPDATE,
|
||||
HISTORYTYPE.BLACKLIST_UPDATE.name(),
|
||||
beforeDoc,
|
||||
afterDoc,
|
||||
CommonConstants.SCHEDULE,
|
||||
""
|
||||
afterDoc
|
||||
);
|
||||
}
|
||||
}catch (Exception e){
|
||||
@@ -134,9 +132,7 @@ public class AccountBaseRepositoryImpl extends BaseDynamoDBRepository<AccountBas
|
||||
HISTORYTYPE.BLACKLIST_UPDATE,
|
||||
HISTORYTYPE.BLACKLIST_UPDATE.name(),
|
||||
beforeDoc,
|
||||
afterDoc,
|
||||
CommonConstants.SCHEDULE,
|
||||
""
|
||||
afterDoc
|
||||
);
|
||||
}
|
||||
}catch (Exception e){
|
||||
|
||||
@@ -119,9 +119,7 @@ public class BattleEventRepositoryImpl extends BaseDynamoDBRepository<BattleEven
|
||||
dynamodbHistoryLogService.insertHistoryLog(
|
||||
HISTORYTYPE.BATTLE_EVENT_ADD,
|
||||
HISTORYTYPE.BATTLE_EVENT_ADD.name(),
|
||||
doc,
|
||||
CommonUtils.getAdmin().getEmail(),
|
||||
CommonUtils.getClientIp()
|
||||
doc
|
||||
);
|
||||
}catch (Exception e){
|
||||
log.error("insert Error: {}", e.getMessage());
|
||||
@@ -167,9 +165,7 @@ public class BattleEventRepositoryImpl extends BaseDynamoDBRepository<BattleEven
|
||||
HISTORYTYPE.BATTLE_EVENT_UPDATE,
|
||||
HISTORYTYPE.BATTLE_EVENT_UPDATE.name(),
|
||||
beforeDoc,
|
||||
afterDoc,
|
||||
CommonUtils.getAdmin().getEmail(),
|
||||
CommonUtils.getClientIp()
|
||||
afterDoc
|
||||
);
|
||||
}
|
||||
}catch (Exception e){
|
||||
@@ -209,9 +205,7 @@ public class BattleEventRepositoryImpl extends BaseDynamoDBRepository<BattleEven
|
||||
HISTORYTYPE.BATTLE_EVENT_UPDATE,
|
||||
HISTORYTYPE.BATTLE_EVENT_UPDATE.name(),
|
||||
beforeDoc,
|
||||
afterDoc,
|
||||
CommonUtils.getAdmin().getEmail(),
|
||||
CommonUtils.getClientIp()
|
||||
afterDoc
|
||||
);
|
||||
}
|
||||
}catch (Exception e){
|
||||
|
||||
@@ -3,9 +3,9 @@ package com.caliverse.admin.dynamodb.repository.Impl;
|
||||
import com.caliverse.admin.domain.entity.HISTORYTYPE;
|
||||
import com.caliverse.admin.domain.request.LandRequest;
|
||||
import com.caliverse.admin.dynamodb.domain.atrrib.BuildingAttrib;
|
||||
import com.caliverse.admin.dynamodb.domain.atrrib.LandAttrib;
|
||||
import com.caliverse.admin.dynamodb.domain.doc.BuildingDoc;
|
||||
import com.caliverse.admin.dynamodb.entity.ECurrencyType;
|
||||
import com.caliverse.admin.dynamodb.entity.DynamodbOperationResult;
|
||||
import com.caliverse.admin.dynamodb.repository.BaseDynamoDBRepository;
|
||||
import com.caliverse.admin.dynamodb.repository.BuildingRepository;
|
||||
import com.caliverse.admin.dynamodb.service.DynamoDBOperations;
|
||||
@@ -68,7 +68,7 @@ public class BuildingRepositoryImpl extends BaseDynamoDBRepository<BuildingDoc>
|
||||
attrib.setOwnerUserGuid(guid);
|
||||
attrib.setRentalCurrencyAmount(0.0);
|
||||
attrib.setRentalCurrencyType(ECurrencyType.Calium.getValue());
|
||||
attrib.setRentalOpen(true);
|
||||
attrib.setRentalOpen(false);
|
||||
attrib.setBuildingGuid("");
|
||||
|
||||
BuildingDoc doc = new BuildingDoc();
|
||||
@@ -88,9 +88,7 @@ public class BuildingRepositoryImpl extends BaseDynamoDBRepository<BuildingDoc>
|
||||
dynamodbHistoryLogService.insertHistoryLog(
|
||||
HISTORYTYPE.LAND_OWNER_CHANGE_ADD,
|
||||
HISTORYTYPE.LAND_OWNER_CHANGE_ADD.name(),
|
||||
doc,
|
||||
CommonUtils.getAdmin() == null ? "" : CommonUtils.getAdmin().getEmail(),
|
||||
CommonUtils.getClientIp() == null ? "" : CommonUtils.getClientIp()
|
||||
doc
|
||||
);
|
||||
|
||||
}catch (Exception e){
|
||||
@@ -132,13 +130,93 @@ public class BuildingRepositoryImpl extends BaseDynamoDBRepository<BuildingDoc>
|
||||
HISTORYTYPE.LAND_OWNER_CHANGE_UPDATE,
|
||||
HISTORYTYPE.LAND_OWNER_CHANGE_UPDATE.name(),
|
||||
beforeDoc,
|
||||
afterDoc,
|
||||
CommonUtils.getAdmin() == null ? "" : CommonUtils.getAdmin().getEmail(),
|
||||
CommonUtils.getClientIp() == null ? "" : CommonUtils.getClientIp()
|
||||
afterDoc
|
||||
);
|
||||
}
|
||||
}catch (Exception e){
|
||||
throw new RestApiException(CommonCode.ERROR.getHttpStatus(), ErrorCode.DYNAMODB_CONNECTION_ERROR.getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public DynamodbOperationResult initBuildingOwner(int buildingId) {
|
||||
|
||||
try {
|
||||
Key key = Key.builder()
|
||||
.partitionValue(DynamoDBConstants.PK_KEY_BUILDING + buildingId)
|
||||
.sortValue(DynamoDBConstants.EMPTY)
|
||||
.build();
|
||||
|
||||
BuildingDoc beforeDoc = findById(key);
|
||||
|
||||
if (beforeDoc != null) {
|
||||
BuildingDoc afterDoc = deepCopy(beforeDoc, BuildingDoc.class);
|
||||
|
||||
BuildingAttrib attrib = objectMapper.readValue(afterDoc.getAttribValue(), BuildingAttrib.class);
|
||||
attrib.setOwnerUserGuid("");
|
||||
|
||||
afterDoc.setAttribValue(objectMapper.writeValueAsString(attrib));
|
||||
afterDoc.setUpdatedDateTime(CommonUtils.convertUTCDate(LocalDateTime.now()));
|
||||
|
||||
update(afterDoc);
|
||||
|
||||
log.info("BuildingDoc Owned Init Update Success: {}", objectMapper.writeValueAsString(afterDoc));
|
||||
|
||||
dynamodbHistoryLogService.updateHistoryLog(
|
||||
HISTORYTYPE.LAND_OWNED_INITIALIZE,
|
||||
HISTORYTYPE.LAND_OWNED_INITIALIZE.name(),
|
||||
beforeDoc,
|
||||
afterDoc
|
||||
);
|
||||
return new DynamodbOperationResult(true, "", afterDoc);
|
||||
}
|
||||
return new DynamodbOperationResult(false, "null", null);
|
||||
}catch (Exception e){
|
||||
log.error("Init Building Owner Error: {}", e.getMessage());
|
||||
return new DynamodbOperationResult(false, e.getMessage(), null);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public DynamodbOperationResult initBuildingDesc(int buildingId) {
|
||||
|
||||
try {
|
||||
Key key = Key.builder()
|
||||
.partitionValue(DynamoDBConstants.PK_KEY_BUILDING + buildingId)
|
||||
.sortValue(DynamoDBConstants.EMPTY)
|
||||
.build();
|
||||
|
||||
BuildingDoc beforeDoc = findById(key);
|
||||
|
||||
if (beforeDoc != null) {
|
||||
BuildingDoc afterDoc = deepCopy(beforeDoc, BuildingDoc.class);
|
||||
|
||||
BuildingAttrib attrib = objectMapper.readValue(afterDoc.getAttribValue(), BuildingAttrib.class);
|
||||
attrib.setDescription("");
|
||||
attrib.setBuildingName("");
|
||||
attrib.setRentalCurrencyAmount(0.0);
|
||||
attrib.setRentalOpen(false);
|
||||
attrib.setRentalCurrencyType(ECurrencyType.Calium.getValue());
|
||||
|
||||
afterDoc.setAttribValue(objectMapper.writeValueAsString(attrib));
|
||||
afterDoc.setUpdatedDateTime(CommonUtils.convertUTCDate(LocalDateTime.now()));
|
||||
|
||||
update(afterDoc);
|
||||
|
||||
log.info("BuildingDoc Desc Init Update Success: {}", objectMapper.writeValueAsString(afterDoc));
|
||||
|
||||
dynamodbHistoryLogService.updateHistoryLog(
|
||||
HISTORYTYPE.LAND_DESC_INITIALIZE,
|
||||
HISTORYTYPE.LAND_DESC_INITIALIZE.name(),
|
||||
beforeDoc,
|
||||
afterDoc
|
||||
);
|
||||
return new DynamodbOperationResult(true, "Success", afterDoc);
|
||||
}
|
||||
return new DynamodbOperationResult(true, "null", beforeDoc);
|
||||
}catch (Exception e){
|
||||
log.error("Init Building Desc Error: {}", e.getMessage());
|
||||
return new DynamodbOperationResult(false, e.getMessage(), null);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -86,9 +86,7 @@ public class CaliumStorageRepositoryImpl extends BaseDynamoDBRepository<CaliumSt
|
||||
HISTORYTYPE.CALIUM_TOTAL_UPDATE,
|
||||
HISTORYTYPE.CALIUM_TOTAL_UPDATE.name(),
|
||||
beforeDoc,
|
||||
afterDoc,
|
||||
CommonUtils.getAdmin().getEmail(),
|
||||
CommonUtils.getClientIp()
|
||||
afterDoc
|
||||
);
|
||||
}
|
||||
}catch (Exception e){
|
||||
@@ -136,9 +134,7 @@ public class CaliumStorageRepositoryImpl extends BaseDynamoDBRepository<CaliumSt
|
||||
HISTORYTYPE.CALIUM_TOTAL_UPDATE,
|
||||
HISTORYTYPE.CALIUM_TOTAL_UPDATE.name(),
|
||||
beforeDoc,
|
||||
afterDoc,
|
||||
CommonUtils.getAdmin().getEmail(),
|
||||
CommonUtils.getClientIp()
|
||||
afterDoc
|
||||
);
|
||||
}
|
||||
}catch (Exception e){
|
||||
|
||||
@@ -4,6 +4,8 @@ import com.caliverse.admin.domain.entity.HISTORYTYPE;
|
||||
import com.caliverse.admin.domain.request.LandRequest;
|
||||
import com.caliverse.admin.dynamodb.domain.atrrib.LandAuctionActivityAttrib;
|
||||
import com.caliverse.admin.dynamodb.domain.doc.LandAuctionActivityDoc;
|
||||
import com.caliverse.admin.dynamodb.domain.doc.LandAuctionRegistryDoc;
|
||||
import com.caliverse.admin.dynamodb.entity.DynamodbOperationResult;
|
||||
import com.caliverse.admin.dynamodb.repository.BaseDynamoDBRepository;
|
||||
import com.caliverse.admin.dynamodb.repository.LandAuctionActivityRepository;
|
||||
import com.caliverse.admin.dynamodb.service.DynamoDBOperations;
|
||||
@@ -19,6 +21,7 @@ import org.springframework.stereotype.Component;
|
||||
import software.amazon.awssdk.enhanced.dynamodb.Key;
|
||||
|
||||
import java.time.LocalDateTime;
|
||||
import java.util.List;
|
||||
|
||||
@Component
|
||||
@Slf4j
|
||||
@@ -57,6 +60,35 @@ public class LandAuctionActivityRepositoryImpl extends BaseDynamoDBRepository<La
|
||||
return attrib.getAuctionNumber();
|
||||
}
|
||||
|
||||
@Override
|
||||
public DynamodbOperationResult initLandAuctionActivity(Integer landId, Integer auctionSeq) {
|
||||
try{
|
||||
Key key = Key.builder()
|
||||
.partitionValue(DynamoDBConstants.PK_KEY_LAND_AUCTION_ACTIVE)
|
||||
.sortValue(landId.toString())
|
||||
.build();
|
||||
LandAuctionActivityDoc doc = findById(key);
|
||||
|
||||
if(doc != null && doc.getAttribValue().getAuctionNumber().equals(auctionSeq)) {
|
||||
delete(key);
|
||||
|
||||
log.info("LandAuctionActivityDoc Delete Success: {}", objectMapper.writeValueAsString(doc));
|
||||
|
||||
dynamodbHistoryLogService.deleteHistoryLog(
|
||||
HISTORYTYPE.LAND_AUCTION_INITIALIZE,
|
||||
HISTORYTYPE.LAND_AUCTION_INITIALIZE.name(),
|
||||
doc
|
||||
);
|
||||
|
||||
return new DynamodbOperationResult(true, "delete success", doc);
|
||||
}
|
||||
return new DynamodbOperationResult(true, "null", doc);
|
||||
}catch (Exception e){
|
||||
log.error("Init LandAuctionActivity Error: {}", e.getMessage());
|
||||
return new DynamodbOperationResult(false, e.getMessage(), null);
|
||||
}
|
||||
}
|
||||
|
||||
private void insertLandAuctionActive(LandRequest landRequest){
|
||||
try {
|
||||
LocalDateTime nowDate = LocalDateTime.now();
|
||||
@@ -80,9 +112,7 @@ public class LandAuctionActivityRepositoryImpl extends BaseDynamoDBRepository<La
|
||||
dynamodbHistoryLogService.insertHistoryLog(
|
||||
HISTORYTYPE.LAND_AUCTION_ADD,
|
||||
HISTORYTYPE.LAND_AUCTION_ADD.name(),
|
||||
activityDoc,
|
||||
CommonUtils.getAdmin().getEmail(),
|
||||
CommonUtils.getClientIp()
|
||||
activityDoc
|
||||
);
|
||||
}catch (Exception e){
|
||||
throw new RestApiException(CommonCode.ERROR.getHttpStatus(), ErrorCode.DYNAMODB_CONNECTION_ERROR.getMessage());
|
||||
@@ -107,9 +137,7 @@ public class LandAuctionActivityRepositoryImpl extends BaseDynamoDBRepository<La
|
||||
HISTORYTYPE.LAND_AUCTION_ADD,
|
||||
HISTORYTYPE.LAND_AUCTION_ADD.name(),
|
||||
existingDoc,
|
||||
afterDoc,
|
||||
CommonUtils.getAdmin().getEmail(),
|
||||
CommonUtils.getClientIp()
|
||||
afterDoc
|
||||
);
|
||||
}catch (Exception e){
|
||||
throw new RestApiException(CommonCode.ERROR.getHttpStatus(), ErrorCode.DYNAMODB_CONNECTION_ERROR.getMessage());
|
||||
|
||||
@@ -4,8 +4,10 @@ import com.caliverse.admin.domain.entity.HISTORYTYPE;
|
||||
import com.caliverse.admin.domain.request.LandRequest;
|
||||
import com.caliverse.admin.dynamodb.domain.atrrib.LandAuctionHighestBidUserAttrib;
|
||||
import com.caliverse.admin.dynamodb.domain.atrrib.LandAuctionRegistryAttrib;
|
||||
import com.caliverse.admin.dynamodb.domain.doc.LandAuctionActivityDoc;
|
||||
import com.caliverse.admin.dynamodb.domain.doc.LandAuctionHighestBidUserDoc;
|
||||
import com.caliverse.admin.dynamodb.domain.doc.LandAuctionRegistryDoc;
|
||||
import com.caliverse.admin.dynamodb.entity.DynamodbOperationResult;
|
||||
import com.caliverse.admin.dynamodb.repository.BaseDynamoDBRepository;
|
||||
import com.caliverse.admin.dynamodb.repository.LandAuctionHighestBidUserRepository;
|
||||
import com.caliverse.admin.dynamodb.service.DynamoDBOperations;
|
||||
@@ -22,6 +24,7 @@ import org.springframework.stereotype.Component;
|
||||
import software.amazon.awssdk.enhanced.dynamodb.Key;
|
||||
|
||||
import java.time.LocalDateTime;
|
||||
import java.util.List;
|
||||
|
||||
@Component
|
||||
@Slf4j
|
||||
@@ -75,9 +78,7 @@ public class LandAuctionHighestBidUserRepositoryImpl extends BaseDynamoDBReposit
|
||||
dynamodbHistoryLogService.insertHistoryLog(
|
||||
HISTORYTYPE.LAND_AUCTION_ADD,
|
||||
HISTORYTYPE.LAND_AUCTION_ADD.name(),
|
||||
registry,
|
||||
CommonUtils.getAdmin().getEmail(),
|
||||
CommonUtils.getClientIp()
|
||||
registry
|
||||
);
|
||||
|
||||
save(registry);
|
||||
@@ -86,4 +87,34 @@ public class LandAuctionHighestBidUserRepositoryImpl extends BaseDynamoDBReposit
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public DynamodbOperationResult initLandAuctionHighestBidUser(Integer landId, Integer auctionSeq) {
|
||||
|
||||
try{
|
||||
Key key = Key.builder()
|
||||
.partitionValue(DynamoDBConstants.PK_KEY_LAND_AUCTION_HIGHEST_USER)
|
||||
.sortValue(String.format("%s#%s", landId, auctionSeq))
|
||||
.build();
|
||||
|
||||
LandAuctionHighestBidUserDoc doc = findById(key);
|
||||
|
||||
if(doc != null) {
|
||||
delete(key);
|
||||
|
||||
log.info("LandAuctionHighestBidUserDoc Delete Success: {}", objectMapper.writeValueAsString(doc));
|
||||
|
||||
dynamodbHistoryLogService.deleteHistoryLog(
|
||||
HISTORYTYPE.LAND_AUCTION_INITIALIZE,
|
||||
HISTORYTYPE.LAND_AUCTION_INITIALIZE.name(),
|
||||
doc
|
||||
);
|
||||
return new DynamodbOperationResult(true, "delete success", doc);
|
||||
}
|
||||
return new DynamodbOperationResult(true, "null", doc);
|
||||
}catch (Exception e){
|
||||
log.error("Init LandAuctionHighestBidUser Error: {}", e.getMessage());
|
||||
return new DynamodbOperationResult(false, e.getMessage(), null);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -1,13 +1,25 @@
|
||||
package com.caliverse.admin.dynamodb.repository.Impl;
|
||||
|
||||
import com.caliverse.admin.domain.entity.HISTORYTYPE;
|
||||
import com.caliverse.admin.dynamodb.domain.doc.LandAuctionActivityDoc;
|
||||
import com.caliverse.admin.dynamodb.domain.doc.LandAuctionRecordDoc;
|
||||
import com.caliverse.admin.dynamodb.domain.doc.LandAuctionRegistryDoc;
|
||||
import com.caliverse.admin.dynamodb.entity.DynamodbOperationResult;
|
||||
import com.caliverse.admin.dynamodb.repository.BaseDynamoDBRepository;
|
||||
import com.caliverse.admin.dynamodb.repository.LandAuctionRecordRepository;
|
||||
import com.caliverse.admin.dynamodb.service.DynamoDBOperations;
|
||||
import com.caliverse.admin.global.common.code.CommonCode;
|
||||
import com.caliverse.admin.global.common.code.ErrorCode;
|
||||
import com.caliverse.admin.global.common.constants.DynamoDBConstants;
|
||||
import com.caliverse.admin.global.common.exception.RestApiException;
|
||||
import com.caliverse.admin.global.common.utils.CommonUtils;
|
||||
import com.caliverse.admin.history.service.DynamodbHistoryLogService;
|
||||
import com.fasterxml.jackson.databind.ObjectMapper;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.stereotype.Component;
|
||||
import software.amazon.awssdk.enhanced.dynamodb.Key;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
@Component
|
||||
@Slf4j
|
||||
@@ -15,4 +27,34 @@ public class LandAuctionRecordRepositoryImpl extends BaseDynamoDBRepository<Land
|
||||
public LandAuctionRecordRepositoryImpl(DynamoDBOperations operations, DynamodbHistoryLogService dynamodbHistoryLogService, ObjectMapper objectMapper) {
|
||||
super(operations, LandAuctionRecordDoc.class, dynamodbHistoryLogService, objectMapper);
|
||||
}
|
||||
|
||||
@Override
|
||||
public DynamodbOperationResult initLandAuctionRecord(Integer landId) {
|
||||
|
||||
try{
|
||||
Key key = Key.builder()
|
||||
.partitionValue(DynamoDBConstants.PK_KEY_LAND_AUCTION_RECORD)
|
||||
.sortValue(String.valueOf(landId))
|
||||
.build();
|
||||
LandAuctionRecordDoc doc = findById(key);
|
||||
|
||||
if(doc != null) {
|
||||
|
||||
delete(key);
|
||||
|
||||
log.info("LandAuctionRecordDoc Delete Success: {}", objectMapper.writeValueAsString(doc));
|
||||
|
||||
dynamodbHistoryLogService.deleteHistoryLog(
|
||||
HISTORYTYPE.LAND_AUCTION_INITIALIZE,
|
||||
HISTORYTYPE.LAND_AUCTION_INITIALIZE.name(),
|
||||
doc
|
||||
);
|
||||
return new DynamodbOperationResult(true, "delete success", doc);
|
||||
}
|
||||
return new DynamodbOperationResult(true, "null", doc);
|
||||
}catch (Exception e){
|
||||
log.error("Init LandAuctionRecord Error: {}", e.getMessage());
|
||||
return new DynamodbOperationResult(false, e.getMessage(), null);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,60 @@
|
||||
package com.caliverse.admin.dynamodb.repository.Impl;
|
||||
|
||||
import com.caliverse.admin.domain.entity.HISTORYTYPE;
|
||||
import com.caliverse.admin.dynamodb.domain.doc.LandAuctionRefundBidPriceDoc;
|
||||
import com.caliverse.admin.dynamodb.entity.DynamodbOperationResult;
|
||||
import com.caliverse.admin.dynamodb.repository.BaseDynamoDBRepository;
|
||||
import com.caliverse.admin.dynamodb.repository.LandAuctionRefundBidPriceRepository;
|
||||
import com.caliverse.admin.dynamodb.service.DynamoDBOperations;
|
||||
import com.caliverse.admin.global.common.code.CommonCode;
|
||||
import com.caliverse.admin.global.common.code.ErrorCode;
|
||||
import com.caliverse.admin.global.common.constants.DynamoDBConstants;
|
||||
import com.caliverse.admin.global.common.exception.RestApiException;
|
||||
import com.caliverse.admin.global.common.utils.CommonUtils;
|
||||
import com.caliverse.admin.history.service.DynamodbHistoryLogService;
|
||||
import com.fasterxml.jackson.databind.ObjectMapper;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.stereotype.Component;
|
||||
import software.amazon.awssdk.enhanced.dynamodb.Key;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
@Component
|
||||
@Slf4j
|
||||
public class LandAuctionRefundBidPriceRepositoryImpl extends BaseDynamoDBRepository<LandAuctionRefundBidPriceDoc> implements LandAuctionRefundBidPriceRepository {
|
||||
|
||||
public LandAuctionRefundBidPriceRepositoryImpl(DynamoDBOperations operations, DynamodbHistoryLogService historyLogService, ObjectMapper objectMapper) {
|
||||
super(operations, LandAuctionRefundBidPriceDoc.class, historyLogService, objectMapper);
|
||||
}
|
||||
|
||||
@Override
|
||||
public DynamodbOperationResult initLandAuctionRefundBidPrice(String guid, Integer landId, Integer auctionSeq) {
|
||||
|
||||
try{
|
||||
Key key = Key.builder()
|
||||
.partitionValue(DynamoDBConstants.PK_KEY_LAND_AUCTION_REFUND_BID_PRICE + guid)
|
||||
.sortValue(String.format("%s#%s", landId, auctionSeq))
|
||||
.build();
|
||||
|
||||
LandAuctionRefundBidPriceDoc doc = findById(key);
|
||||
|
||||
if(doc != null) {
|
||||
|
||||
delete(key);
|
||||
|
||||
log.info("LandAuctionRefundBidPriceDoc Delete Success: {}", objectMapper.writeValueAsString(doc));
|
||||
|
||||
dynamodbHistoryLogService.deleteHistoryLog(
|
||||
HISTORYTYPE.LAND_AUCTION_INITIALIZE,
|
||||
HISTORYTYPE.LAND_AUCTION_INITIALIZE.name(),
|
||||
doc
|
||||
);
|
||||
return new DynamodbOperationResult(true, "delete success", doc);
|
||||
}
|
||||
return new DynamodbOperationResult(true, "null", doc);
|
||||
}catch (Exception e){
|
||||
log.error("Init LandAuctionRefundBidPrice Error: {}", e.getMessage());
|
||||
return new DynamodbOperationResult(false, e.getMessage(), null);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -2,8 +2,13 @@ package com.caliverse.admin.dynamodb.repository.Impl;
|
||||
|
||||
import com.caliverse.admin.domain.entity.HISTORYTYPE;
|
||||
import com.caliverse.admin.domain.request.LandRequest;
|
||||
import com.caliverse.admin.dynamodb.domain.atrrib.BuildingAttrib;
|
||||
import com.caliverse.admin.dynamodb.domain.atrrib.LandAuctionRegistryAttrib;
|
||||
import com.caliverse.admin.dynamodb.domain.doc.BuildingDoc;
|
||||
import com.caliverse.admin.dynamodb.domain.doc.LandAuctionRegistryDoc;
|
||||
import com.caliverse.admin.dynamodb.domain.doc.OwnedBuildingDoc;
|
||||
import com.caliverse.admin.dynamodb.entity.DynamodbOperationResult;
|
||||
import com.caliverse.admin.dynamodb.entity.ECurrencyType;
|
||||
import com.caliverse.admin.dynamodb.entity.ELandAuctionResult;
|
||||
import com.caliverse.admin.dynamodb.repository.BaseDynamoDBRepository;
|
||||
import com.caliverse.admin.dynamodb.repository.LandAuctionRegistryRepository;
|
||||
@@ -34,7 +39,7 @@ public class LandAuctionRegistryRepositoryImpl extends BaseDynamoDBRepository<La
|
||||
@Override
|
||||
public int findAuctionNumber(Integer landId) {
|
||||
List<LandAuctionRegistryDoc> docs = findByPrefix(
|
||||
DynamoDBConstants.PK_KEY_LAND_AUCTION,
|
||||
DynamoDBConstants.PK_KEY_LAND_AUCTION_REGISTRY,
|
||||
landId.toString()
|
||||
);
|
||||
|
||||
@@ -53,7 +58,7 @@ public class LandAuctionRegistryRepositoryImpl extends BaseDynamoDBRepository<La
|
||||
@Override
|
||||
public LandAuctionRegistryAttrib findRegistryAttrib(Integer landId, Integer auctionSeq) {
|
||||
Key key = Key.builder()
|
||||
.partitionValue(DynamoDBConstants.PK_KEY_LAND_AUCTION)
|
||||
.partitionValue(DynamoDBConstants.PK_KEY_LAND_AUCTION_REGISTRY)
|
||||
.sortValue(String.format("%s#%s", landId, auctionSeq))
|
||||
.build();
|
||||
|
||||
@@ -83,7 +88,7 @@ public class LandAuctionRegistryRepositoryImpl extends BaseDynamoDBRepository<La
|
||||
String sk = String.format("%s#%s", landRequest.getLandId(), landRequest.getAuctionSeq());
|
||||
|
||||
LandAuctionRegistryDoc registry = new LandAuctionRegistryDoc();
|
||||
registry.setPK(DynamoDBConstants.PK_KEY_LAND_AUCTION);
|
||||
registry.setPK(DynamoDBConstants.PK_KEY_LAND_AUCTION_REGISTRY);
|
||||
registry.setSK(sk);
|
||||
registry.setDocType(DynamoDBConstants.DOC_LANDAUCTION);
|
||||
registry.setAttribValue(attrib);
|
||||
@@ -97,13 +102,12 @@ public class LandAuctionRegistryRepositoryImpl extends BaseDynamoDBRepository<La
|
||||
dynamodbHistoryLogService.insertHistoryLog(
|
||||
HISTORYTYPE.LAND_AUCTION_ADD,
|
||||
HISTORYTYPE.LAND_AUCTION_ADD.name(),
|
||||
registry,
|
||||
CommonUtils.getAdmin().getEmail(),
|
||||
CommonUtils.getClientIp()
|
||||
registry
|
||||
);
|
||||
|
||||
save(registry);
|
||||
}catch (Exception e){
|
||||
log.error("Insert LandAuctionRegistry Error: {}", e.getMessage());
|
||||
throw new RestApiException(CommonCode.ERROR.getHttpStatus(), ErrorCode.DYNAMODB_CONNECTION_ERROR.getMessage());
|
||||
}
|
||||
}
|
||||
@@ -112,7 +116,7 @@ public class LandAuctionRegistryRepositoryImpl extends BaseDynamoDBRepository<La
|
||||
public void updateAuction(LandRequest landRequest) {
|
||||
try {
|
||||
Key key = Key.builder()
|
||||
.partitionValue(DynamoDBConstants.PK_KEY_LAND_AUCTION)
|
||||
.partitionValue(DynamoDBConstants.PK_KEY_LAND_AUCTION_REGISTRY)
|
||||
.sortValue(String.format("%s#%s", landRequest.getLandId(), landRequest.getAuctionSeq()))
|
||||
.build();
|
||||
|
||||
@@ -139,12 +143,11 @@ public class LandAuctionRegistryRepositoryImpl extends BaseDynamoDBRepository<La
|
||||
HISTORYTYPE.LAND_AUCTION_UPDATE,
|
||||
HISTORYTYPE.LAND_AUCTION_UPDATE.name(),
|
||||
beforeDoc,
|
||||
afterDoc,
|
||||
CommonUtils.getAdmin().getEmail(),
|
||||
CommonUtils.getClientIp()
|
||||
afterDoc
|
||||
);
|
||||
}
|
||||
}catch (Exception e){
|
||||
log.error("Update LandAuctionRegistry Error: {}", e.getMessage());
|
||||
throw new RestApiException(CommonCode.ERROR.getHttpStatus(), ErrorCode.DYNAMODB_CONNECTION_ERROR.getMessage());
|
||||
}
|
||||
}
|
||||
@@ -153,7 +156,7 @@ public class LandAuctionRegistryRepositoryImpl extends BaseDynamoDBRepository<La
|
||||
public void cancelAuction(Integer landId, Integer auctionSeq) {
|
||||
try {
|
||||
Key key = Key.builder()
|
||||
.partitionValue(DynamoDBConstants.PK_KEY_LAND_AUCTION)
|
||||
.partitionValue(DynamoDBConstants.PK_KEY_LAND_AUCTION_REGISTRY)
|
||||
.sortValue(String.format("%s#%s", landId, auctionSeq))
|
||||
.build();
|
||||
|
||||
@@ -178,14 +181,46 @@ public class LandAuctionRegistryRepositoryImpl extends BaseDynamoDBRepository<La
|
||||
HISTORYTYPE.LAND_AUCTION_UPDATE,
|
||||
HISTORYTYPE.LAND_AUCTION_UPDATE.name(),
|
||||
beforeDoc,
|
||||
afterDoc,
|
||||
CommonUtils.getAdmin().getEmail(),
|
||||
CommonUtils.getClientIp()
|
||||
afterDoc
|
||||
);
|
||||
}
|
||||
}catch (Exception e){
|
||||
log.error("Cancel LandAuctionRegistry Error: {}", e.getMessage());
|
||||
throw new RestApiException(CommonCode.ERROR.getHttpStatus(), ErrorCode.DYNAMODB_CONNECTION_ERROR.getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public DynamodbOperationResult initLandAuctionRegistry(Integer landId, Integer auctionSeq) {
|
||||
try{
|
||||
Key key = Key.builder()
|
||||
.partitionValue(DynamoDBConstants.PK_KEY_LAND_AUCTION_REGISTRY)
|
||||
.sortValue(String.format("%s#%s", landId, auctionSeq))
|
||||
.build();
|
||||
LandAuctionRegistryDoc doc = findById(key);
|
||||
|
||||
if(doc != null) {
|
||||
Key detailKey = Key.builder()
|
||||
.partitionValue(doc.getPK())
|
||||
.sortValue(doc.getSK())
|
||||
.build();
|
||||
|
||||
delete(detailKey);
|
||||
|
||||
log.info("LandAuctionRegistryDoc Delete Success: {}", objectMapper.writeValueAsString(doc));
|
||||
|
||||
dynamodbHistoryLogService.deleteHistoryLog(
|
||||
HISTORYTYPE.LAND_AUCTION_INITIALIZE,
|
||||
HISTORYTYPE.LAND_AUCTION_INITIALIZE.name(),
|
||||
doc
|
||||
);
|
||||
|
||||
return new DynamodbOperationResult(true, "", doc);
|
||||
}
|
||||
return new DynamodbOperationResult(true, "null", doc);
|
||||
}catch (Exception e){
|
||||
log.error("Init LandAuctionRegistry Error: {}", e.getMessage());
|
||||
return new DynamodbOperationResult(false, e.getMessage(), null);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -4,6 +4,7 @@ import com.caliverse.admin.domain.entity.HISTORYTYPE;
|
||||
import com.caliverse.admin.domain.request.LandRequest;
|
||||
import com.caliverse.admin.dynamodb.domain.atrrib.LandAttrib;
|
||||
import com.caliverse.admin.dynamodb.domain.doc.LandDoc;
|
||||
import com.caliverse.admin.dynamodb.entity.DynamodbOperationResult;
|
||||
import com.caliverse.admin.dynamodb.repository.BaseDynamoDBRepository;
|
||||
import com.caliverse.admin.dynamodb.repository.LandRepository;
|
||||
import com.caliverse.admin.dynamodb.service.DynamoDBOperations;
|
||||
@@ -82,13 +83,11 @@ public class LandRepositoryImpl extends BaseDynamoDBRepository<LandDoc> implemen
|
||||
dynamodbHistoryLogService.insertHistoryLog(
|
||||
HISTORYTYPE.LAND_OWNER_CHANGE_ADD,
|
||||
HISTORYTYPE.LAND_OWNER_CHANGE_ADD.name(),
|
||||
doc,
|
||||
CommonUtils.getAdmin() == null ? "" : CommonUtils.getAdmin().getEmail(),
|
||||
CommonUtils.getClientIp() == null ? "" : CommonUtils.getClientIp()
|
||||
doc
|
||||
);
|
||||
|
||||
}catch (Exception e){
|
||||
log.error("insert Error: {}", e.getMessage());
|
||||
log.error("insertLand Error: {}", e.getMessage());
|
||||
throw new RestApiException(CommonCode.ERROR.getHttpStatus(), ErrorCode.DYNAMODB_CONNECTION_ERROR.getMessage());
|
||||
}
|
||||
}
|
||||
@@ -126,13 +125,93 @@ public class LandRepositoryImpl extends BaseDynamoDBRepository<LandDoc> implemen
|
||||
HISTORYTYPE.LAND_OWNER_CHANGE_UPDATE,
|
||||
HISTORYTYPE.LAND_OWNER_CHANGE_UPDATE.name(),
|
||||
beforeDoc,
|
||||
afterDoc,
|
||||
CommonUtils.getAdmin() == null ? "" : CommonUtils.getAdmin().getEmail(),
|
||||
CommonUtils.getClientIp() == null ? "" : CommonUtils.getClientIp()
|
||||
afterDoc
|
||||
);
|
||||
}
|
||||
}catch (Exception e){
|
||||
log.error("updateLand Error: {}", e.getMessage());
|
||||
throw new RestApiException(CommonCode.ERROR.getHttpStatus(), ErrorCode.DYNAMODB_CONNECTION_ERROR.getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public DynamodbOperationResult initLandOwner(int landId) {
|
||||
LocalDateTime nowDate = LocalDateTime.now();
|
||||
|
||||
try {
|
||||
Key key = Key.builder()
|
||||
.partitionValue(DynamoDBConstants.PK_KEY_LAND + landId)
|
||||
.sortValue(DynamoDBConstants.EMPTY)
|
||||
.build();
|
||||
|
||||
LandDoc beforeDoc = findById(key);
|
||||
|
||||
if (beforeDoc != null) {
|
||||
LandDoc afterDoc = deepCopy(beforeDoc, LandDoc.class);
|
||||
|
||||
LandAttrib attrib = objectMapper.readValue(afterDoc.getAttribValue(), LandAttrib.class);
|
||||
attrib.setOwnerUserGuid("");
|
||||
|
||||
afterDoc.setAttribValue(objectMapper.writeValueAsString(attrib));
|
||||
afterDoc.setUpdatedDateTime(CommonUtils.convertUTCDate(nowDate));
|
||||
|
||||
update(afterDoc);
|
||||
|
||||
log.info("LandDoc Owned Init Update Success: {}", objectMapper.writeValueAsString(afterDoc));
|
||||
|
||||
dynamodbHistoryLogService.updateHistoryLog(
|
||||
HISTORYTYPE.LAND_OWNED_INITIALIZE,
|
||||
HISTORYTYPE.LAND_OWNED_INITIALIZE.name(),
|
||||
beforeDoc,
|
||||
afterDoc
|
||||
);
|
||||
|
||||
return new DynamodbOperationResult(true, "",afterDoc);
|
||||
}
|
||||
return new DynamodbOperationResult(false, "null",null);
|
||||
}catch (Exception e){
|
||||
log.error("Init Land Owner Error: {}", e.getMessage());
|
||||
return new DynamodbOperationResult(false, e.getMessage(),null);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public DynamodbOperationResult initLandDesc(int landId) {
|
||||
LocalDateTime nowDate = LocalDateTime.now();
|
||||
try {
|
||||
Key key = Key.builder()
|
||||
.partitionValue(DynamoDBConstants.PK_KEY_LAND + landId)
|
||||
.sortValue(DynamoDBConstants.EMPTY)
|
||||
.build();
|
||||
|
||||
LandDoc beforeDoc = findById(key);
|
||||
|
||||
if (beforeDoc != null) {
|
||||
LandDoc afterDoc = deepCopy(beforeDoc, LandDoc.class);
|
||||
|
||||
LandAttrib attrib = objectMapper.readValue(afterDoc.getAttribValue(), LandAttrib.class);
|
||||
attrib.setDescription("");
|
||||
attrib.setLandName("");
|
||||
|
||||
afterDoc.setAttribValue(objectMapper.writeValueAsString(attrib));
|
||||
afterDoc.setUpdatedDateTime(CommonUtils.convertUTCDate(nowDate));
|
||||
|
||||
update(afterDoc);
|
||||
|
||||
log.info("LandDoc Desc Init Update Success: {}", objectMapper.writeValueAsString(afterDoc));
|
||||
|
||||
dynamodbHistoryLogService.updateHistoryLog(
|
||||
HISTORYTYPE.LAND_DESC_INITIALIZE,
|
||||
HISTORYTYPE.LAND_DESC_INITIALIZE.name(),
|
||||
beforeDoc,
|
||||
afterDoc
|
||||
);
|
||||
return new DynamodbOperationResult(true, "Success",afterDoc);
|
||||
}
|
||||
return new DynamodbOperationResult(false, "null",beforeDoc);
|
||||
}catch (Exception e){
|
||||
log.error("Init Land Desc Error: {}", e.getMessage());
|
||||
return new DynamodbOperationResult(false, e.getMessage(),null);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -81,9 +81,7 @@ public class MailRepositoryImpl extends BaseDynamoDBRepository<MailDoc> implemen
|
||||
dynamodbHistoryLogService.insertHistoryLog(
|
||||
HISTORYTYPE.LAND_OWNER_CHANGE_MAIL,
|
||||
HISTORYTYPE.LAND_OWNER_CHANGE_MAIL.name(),
|
||||
doc,
|
||||
CommonUtils.getAdmin() == null ? "" : CommonUtils.getAdmin().getEmail(),
|
||||
CommonUtils.getClientIp() == null ? "" : CommonUtils.getClientIp()
|
||||
doc
|
||||
);
|
||||
|
||||
}catch (Exception e){
|
||||
|
||||
@@ -3,8 +3,8 @@ package com.caliverse.admin.dynamodb.repository.Impl;
|
||||
import com.caliverse.admin.domain.entity.HISTORYTYPE;
|
||||
import com.caliverse.admin.dynamodb.domain.atrrib.OwnedBuildingAttrib;
|
||||
import com.caliverse.admin.dynamodb.domain.doc.OwnedBuildingDoc;
|
||||
import com.caliverse.admin.dynamodb.domain.doc.OwnedLandDoc;
|
||||
import com.caliverse.admin.dynamodb.entity.EOwnedType;
|
||||
import com.caliverse.admin.dynamodb.entity.DynamodbOperationResult;
|
||||
import com.caliverse.admin.dynamodb.repository.BaseDynamoDBRepository;
|
||||
import com.caliverse.admin.dynamodb.repository.OwnedBuildingRepository;
|
||||
import com.caliverse.admin.dynamodb.service.DynamoDBOperations;
|
||||
@@ -75,9 +75,7 @@ public class OwnedBuildingRepositoryImpl extends BaseDynamoDBRepository<OwnedBui
|
||||
dynamodbHistoryLogService.insertHistoryLog(
|
||||
HISTORYTYPE.LAND_OWNER_CHANGE_ADD,
|
||||
HISTORYTYPE.LAND_OWNER_CHANGE_ADD.name(),
|
||||
doc,
|
||||
CommonUtils.getAdmin() == null ? "" : CommonUtils.getAdmin().getEmail(),
|
||||
CommonUtils.getClientIp() == null ? "" : CommonUtils.getClientIp()
|
||||
doc
|
||||
);
|
||||
|
||||
}catch (Exception e){
|
||||
@@ -103,9 +101,7 @@ public class OwnedBuildingRepositoryImpl extends BaseDynamoDBRepository<OwnedBui
|
||||
dynamodbHistoryLogService.deleteHistoryLog(
|
||||
HISTORYTYPE.LAND_OWNER_CHANGE_UPDATE,
|
||||
HISTORYTYPE.LAND_OWNER_CHANGE_UPDATE.name(),
|
||||
doc,
|
||||
CommonUtils.getAdmin() == null ? "" : CommonUtils.getAdmin().getEmail(),
|
||||
CommonUtils.getClientIp() == null ? "" : CommonUtils.getClientIp()
|
||||
doc
|
||||
);
|
||||
}catch (Exception e){
|
||||
log.error("delete Error: {}", e.getMessage());
|
||||
@@ -113,4 +109,31 @@ public class OwnedBuildingRepositoryImpl extends BaseDynamoDBRepository<OwnedBui
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public DynamodbOperationResult initOwnedBuilding(String guid, Integer buildingId) {
|
||||
try{
|
||||
Key key = Key.builder()
|
||||
.partitionValue(DynamoDBConstants.PK_KEY_OWNED_BUILDING + guid)
|
||||
.sortValue(String.valueOf(buildingId))
|
||||
.build();
|
||||
|
||||
OwnedBuildingDoc doc = findById(key);
|
||||
|
||||
delete(key);
|
||||
|
||||
log.info("OwnedBuildingDoc Delete Success: {}", objectMapper.writeValueAsString(doc));
|
||||
|
||||
dynamodbHistoryLogService.deleteHistoryLog(
|
||||
HISTORYTYPE.LAND_OWNED_INITIALIZE,
|
||||
HISTORYTYPE.LAND_OWNED_INITIALIZE.name(),
|
||||
doc
|
||||
);
|
||||
|
||||
return new DynamodbOperationResult(true, "", doc);
|
||||
}catch (Exception e){
|
||||
log.error("Init OwnedBuilding Error: {}", e.getMessage());
|
||||
return new DynamodbOperationResult(false, e.getMessage(), null);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -4,6 +4,7 @@ import com.caliverse.admin.domain.entity.HISTORYTYPE;
|
||||
import com.caliverse.admin.dynamodb.domain.atrrib.OwnedLandAttrib;
|
||||
import com.caliverse.admin.dynamodb.domain.doc.OwnedLandDoc;
|
||||
import com.caliverse.admin.dynamodb.entity.EOwnedType;
|
||||
import com.caliverse.admin.dynamodb.entity.DynamodbOperationResult;
|
||||
import com.caliverse.admin.dynamodb.repository.BaseDynamoDBRepository;
|
||||
import com.caliverse.admin.dynamodb.repository.OwnedLandRepository;
|
||||
import com.caliverse.admin.dynamodb.service.DynamoDBOperations;
|
||||
@@ -74,9 +75,7 @@ public class OwnedLandRepositoryImpl extends BaseDynamoDBRepository<OwnedLandDoc
|
||||
dynamodbHistoryLogService.insertHistoryLog(
|
||||
HISTORYTYPE.LAND_OWNER_CHANGE_ADD,
|
||||
HISTORYTYPE.LAND_OWNER_CHANGE_ADD.name(),
|
||||
doc,
|
||||
CommonUtils.getAdmin() == null ? "" : CommonUtils.getAdmin().getEmail(),
|
||||
CommonUtils.getClientIp() == null ? "" : CommonUtils.getClientIp()
|
||||
doc
|
||||
);
|
||||
|
||||
}catch (Exception e){
|
||||
@@ -102,13 +101,37 @@ public class OwnedLandRepositoryImpl extends BaseDynamoDBRepository<OwnedLandDoc
|
||||
dynamodbHistoryLogService.deleteHistoryLog(
|
||||
HISTORYTYPE.LAND_OWNER_CHANGE_UPDATE,
|
||||
HISTORYTYPE.LAND_OWNER_CHANGE_UPDATE.name(),
|
||||
doc,
|
||||
CommonUtils.getAdmin() == null ? "" : CommonUtils.getAdmin().getEmail(),
|
||||
CommonUtils.getClientIp() == null ? "" : CommonUtils.getClientIp()
|
||||
doc
|
||||
);
|
||||
}catch (Exception e){
|
||||
log.error("delete Error: {}", e.getMessage());
|
||||
throw new RestApiException(CommonCode.ERROR.getHttpStatus(), ErrorCode.DYNAMODB_CONNECTION_ERROR.getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public DynamodbOperationResult initOwnedLand(String guid, Integer landId) {
|
||||
try {
|
||||
Key key = Key.builder()
|
||||
.partitionValue(DynamoDBConstants.PK_KEY_OWNED_LAND + guid)
|
||||
.sortValue(String.valueOf(landId))
|
||||
.build();
|
||||
|
||||
OwnedLandDoc doc = findById(key);
|
||||
|
||||
delete(key);
|
||||
|
||||
log.info("OwnedLandDoc Delete Success: {}", objectMapper.writeValueAsString(doc));
|
||||
|
||||
dynamodbHistoryLogService.deleteHistoryLog(
|
||||
HISTORYTYPE.LAND_OWNER_CHANGE_UPDATE,
|
||||
HISTORYTYPE.LAND_OWNER_CHANGE_UPDATE.name(),
|
||||
doc
|
||||
);
|
||||
return new DynamodbOperationResult(true, "", doc);
|
||||
}catch (Exception e){
|
||||
log.error("Init OwnedLand Error: {}", e.getMessage());
|
||||
return new DynamodbOperationResult(false, e.getMessage(), null);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -63,9 +63,7 @@ public class SystemMetaMailRepositoryImpl extends BaseDynamoDBRepository<SystemM
|
||||
dynamodbHistoryLogService.insertHistoryLog(
|
||||
HISTORYTYPE.EVENT_ADD,
|
||||
HISTORYTYPE.EVENT_ADD.name(),
|
||||
doc,
|
||||
CommonConstants.SCHEDULE,
|
||||
""
|
||||
doc
|
||||
);
|
||||
|
||||
}catch (Exception e){
|
||||
|
||||
@@ -2,8 +2,10 @@ package com.caliverse.admin.dynamodb.repository;
|
||||
|
||||
import com.caliverse.admin.domain.request.LandRequest;
|
||||
import com.caliverse.admin.dynamodb.domain.doc.LandAuctionActivityDoc;
|
||||
import com.caliverse.admin.dynamodb.entity.DynamodbOperationResult;
|
||||
|
||||
public interface LandAuctionActivityRepository extends DynamoDBRepository<LandAuctionActivityDoc> {
|
||||
void upsertActivity(LandRequest landRequest);
|
||||
int findAuctionNumber(Integer landId);
|
||||
DynamodbOperationResult initLandAuctionActivity(Integer landId, Integer auctionSeq);
|
||||
}
|
||||
|
||||
@@ -3,8 +3,10 @@ package com.caliverse.admin.dynamodb.repository;
|
||||
import com.caliverse.admin.domain.request.LandRequest;
|
||||
import com.caliverse.admin.dynamodb.domain.atrrib.LandAuctionHighestBidUserAttrib;
|
||||
import com.caliverse.admin.dynamodb.domain.doc.LandAuctionHighestBidUserDoc;
|
||||
import com.caliverse.admin.dynamodb.entity.DynamodbOperationResult;
|
||||
|
||||
public interface LandAuctionHighestBidUserRepository extends DynamoDBRepository<LandAuctionHighestBidUserDoc> {
|
||||
LandAuctionHighestBidUserAttrib findHighestBidUserAttrib(Integer landId, Integer auctionSeq);
|
||||
void insertHighestBidUser(LandRequest landRequest);
|
||||
DynamodbOperationResult initLandAuctionHighestBidUser(Integer landId, Integer auctionSeq);
|
||||
}
|
||||
|
||||
@@ -1,6 +1,8 @@
|
||||
package com.caliverse.admin.dynamodb.repository;
|
||||
|
||||
import com.caliverse.admin.dynamodb.domain.doc.LandAuctionRecordDoc;
|
||||
import com.caliverse.admin.dynamodb.entity.DynamodbOperationResult;
|
||||
|
||||
public interface LandAuctionRecordRepository extends DynamoDBRepository<LandAuctionRecordDoc> {
|
||||
DynamodbOperationResult initLandAuctionRecord(Integer landId);
|
||||
}
|
||||
|
||||
@@ -0,0 +1,8 @@
|
||||
package com.caliverse.admin.dynamodb.repository;
|
||||
|
||||
import com.caliverse.admin.dynamodb.domain.doc.LandAuctionRefundBidPriceDoc;
|
||||
import com.caliverse.admin.dynamodb.entity.DynamodbOperationResult;
|
||||
|
||||
public interface LandAuctionRefundBidPriceRepository extends DynamoDBRepository<LandAuctionRefundBidPriceDoc> {
|
||||
DynamodbOperationResult initLandAuctionRefundBidPrice(String guid, Integer landId, Integer auctionSeq);
|
||||
}
|
||||
@@ -3,6 +3,7 @@ package com.caliverse.admin.dynamodb.repository;
|
||||
import com.caliverse.admin.domain.request.LandRequest;
|
||||
import com.caliverse.admin.dynamodb.domain.atrrib.LandAuctionRegistryAttrib;
|
||||
import com.caliverse.admin.dynamodb.domain.doc.LandAuctionRegistryDoc;
|
||||
import com.caliverse.admin.dynamodb.entity.DynamodbOperationResult;
|
||||
|
||||
public interface LandAuctionRegistryRepository extends DynamoDBRepository<LandAuctionRegistryDoc> {
|
||||
LandAuctionRegistryAttrib findRegistryAttrib(Integer landId, Integer auctionSeq);
|
||||
@@ -10,4 +11,5 @@ public interface LandAuctionRegistryRepository extends DynamoDBRepository<LandAu
|
||||
void insertAuction(LandRequest landRequest);
|
||||
void updateAuction(LandRequest landRequest);
|
||||
int findAuctionNumber(Integer landId);
|
||||
DynamodbOperationResult initLandAuctionRegistry(Integer landId, Integer auctionSeq);
|
||||
}
|
||||
|
||||
@@ -3,9 +3,12 @@ package com.caliverse.admin.dynamodb.repository;
|
||||
import com.caliverse.admin.domain.request.LandRequest;
|
||||
import com.caliverse.admin.dynamodb.domain.atrrib.LandAttrib;
|
||||
import com.caliverse.admin.dynamodb.domain.doc.LandDoc;
|
||||
import com.caliverse.admin.dynamodb.entity.DynamodbOperationResult;
|
||||
|
||||
public interface LandRepository extends DynamoDBRepository<LandDoc> {
|
||||
LandAttrib findLandAttrib(Integer landId);
|
||||
void insertLand(LandRequest landRequest);
|
||||
void updateLand(LandRequest landRequest);
|
||||
DynamodbOperationResult initLandOwner(int landId);
|
||||
DynamodbOperationResult initLandDesc(int landId);
|
||||
}
|
||||
|
||||
@@ -1,10 +1,11 @@
|
||||
package com.caliverse.admin.dynamodb.repository;
|
||||
|
||||
import com.caliverse.admin.domain.request.LandRequest;
|
||||
import com.caliverse.admin.dynamodb.domain.doc.OwnedBuildingDoc;
|
||||
import com.caliverse.admin.dynamodb.entity.DynamodbOperationResult;
|
||||
|
||||
public interface OwnedBuildingRepository extends DynamoDBRepository<OwnedBuildingDoc> {
|
||||
OwnedBuildingDoc findOwnedBuilding(String guid, Integer buildingId);
|
||||
void insert(String guid, Integer buildingId);
|
||||
void delete(String guid, Integer buildingId);
|
||||
DynamodbOperationResult initOwnedBuilding(String guid, Integer buildingId);
|
||||
}
|
||||
|
||||
@@ -1,9 +1,11 @@
|
||||
package com.caliverse.admin.dynamodb.repository;
|
||||
|
||||
import com.caliverse.admin.dynamodb.domain.doc.OwnedLandDoc;
|
||||
import com.caliverse.admin.dynamodb.entity.DynamodbOperationResult;
|
||||
|
||||
public interface OwnedLandRepository extends DynamoDBRepository<OwnedLandDoc> {
|
||||
OwnedLandDoc findOwnedLand(String guid, Integer landId);
|
||||
void insert(String guid, Integer landId);
|
||||
void delete(String guid, Integer landId);
|
||||
DynamodbOperationResult initOwnedLand(String guid, Integer landId);
|
||||
}
|
||||
|
||||
@@ -0,0 +1,76 @@
|
||||
package com.caliverse.admin.dynamodb.service;
|
||||
|
||||
import com.caliverse.admin.domain.datacomponent.MetaDataHandler;
|
||||
import com.caliverse.admin.domain.entity.metadata.MetaLandData;
|
||||
import com.caliverse.admin.domain.service.LandService;
|
||||
import com.caliverse.admin.dynamodb.domain.atrrib.LandAttrib;
|
||||
import com.caliverse.admin.dynamodb.domain.atrrib.LandAuctionRegistryAttrib;
|
||||
import com.caliverse.admin.dynamodb.domain.doc.LandAuctionRefundBidPriceDoc;
|
||||
import com.caliverse.admin.dynamodb.domain.doc.LandAuctionRegistryDoc;
|
||||
import com.caliverse.admin.dynamodb.repository.*;
|
||||
import com.caliverse.admin.global.common.constants.DynamoDBConstants;
|
||||
import com.caliverse.admin.global.component.transaction.TransactionIdManager;
|
||||
import com.caliverse.admin.history.service.DataInitializeHistoryService;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.stereotype.Service;
|
||||
import software.amazon.awssdk.enhanced.dynamodb.Key;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
@Slf4j
|
||||
@Service
|
||||
@RequiredArgsConstructor
|
||||
public class DynamodbDataService {
|
||||
private final LandAuctionRegistryRepository landAuctionRegistryRepository;
|
||||
private final LandAuctionActivityRepository landAuctionActivityRepository;
|
||||
private final LandAuctionRecordRepository landAuctionRecordRepository;
|
||||
private final LandAuctionHighestBidUserRepository landAuctionHighestBidUserRepository;
|
||||
private final LandAuctionRefundBidPriceRepository landAuctionRefundBidPriceRepository;
|
||||
private final LandRepository landRepository;
|
||||
private final BuildingRepository buildingRepository;
|
||||
private final OwnedBuildingRepository ownedBuildingRepository;
|
||||
private final OwnedLandRepository ownedLandRepository;
|
||||
private final MetaDataHandler metaDataHandler;
|
||||
private final TransactionIdManager transactionIdManager;
|
||||
private final DataInitializeHistoryService dataInitializeHistoryService;
|
||||
private final DynamodbLandService dynamodbLandService;
|
||||
private final LandService landService;
|
||||
private final DynamodbLandAuctionService dynamodbLandAuctionService;
|
||||
|
||||
public void InitDataLandAuction(){
|
||||
Key key = Key.builder()
|
||||
.partitionValue(DynamoDBConstants.PK_KEY_LAND_AUCTION_REGISTRY)
|
||||
.build();
|
||||
List<LandAuctionRegistryDoc> registryList = landAuctionRegistryRepository.findAll(key);
|
||||
registryList.forEach(data -> {
|
||||
LandAuctionRegistryAttrib attrib = data.getAttribValue();
|
||||
dynamodbLandAuctionService.initLandAuction(attrib.getLandMetaId(), attrib.getAuctionNumber(), "");
|
||||
});
|
||||
}
|
||||
|
||||
public void InitDataLandOwned(){
|
||||
List<MetaLandData> landData = metaDataHandler.getMetaLandListData();
|
||||
landData.forEach(land -> {
|
||||
LandAttrib landAttrib = landRepository.findLandAttrib(land.getLandId());
|
||||
if(landAttrib != null){
|
||||
String owner_guid = landAttrib.getOwnerUserGuid();
|
||||
if(!owner_guid.isEmpty()){
|
||||
dynamodbLandService.initLandOwner(land, owner_guid);
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
public void InitDataLandDesc(){
|
||||
List<MetaLandData> landData = metaDataHandler.getMetaLandListData();
|
||||
landData.forEach(land -> {
|
||||
LandAttrib landAttrib = landRepository.findLandAttrib(land.getLandId());
|
||||
if(landAttrib != null){
|
||||
dynamodbLandService.initLandDesc(land);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
@@ -1,21 +1,31 @@
|
||||
package com.caliverse.admin.dynamodb.service;
|
||||
|
||||
import com.caliverse.admin.domain.entity.EInitDataType;
|
||||
import com.caliverse.admin.domain.entity.LandAuction;
|
||||
import com.caliverse.admin.domain.entity.metadata.MetaLandData;
|
||||
import com.caliverse.admin.domain.request.LandRequest;
|
||||
import com.caliverse.admin.dynamodb.domain.atrrib.LandAuctionRefundBidPriceAttrib;
|
||||
import com.caliverse.admin.dynamodb.domain.doc.DynamoDBDocBase;
|
||||
import com.caliverse.admin.dynamodb.domain.doc.LandAuctionRecordDoc;
|
||||
import com.caliverse.admin.dynamodb.repository.LandAuctionRecordRepository;
|
||||
import com.caliverse.admin.dynamodb.domain.doc.LandAuctionRefundBidPriceDoc;
|
||||
import com.caliverse.admin.dynamodb.entity.DynamodbOperationResult;
|
||||
import com.caliverse.admin.dynamodb.repository.*;
|
||||
import com.caliverse.admin.global.common.annotation.DynamoDBTransaction;
|
||||
import com.caliverse.admin.dynamodb.domain.atrrib.LandAuctionHighestBidUserAttrib;
|
||||
import com.caliverse.admin.dynamodb.domain.atrrib.LandAuctionRegistryAttrib;
|
||||
import com.caliverse.admin.dynamodb.repository.LandAuctionActivityRepository;
|
||||
import com.caliverse.admin.dynamodb.repository.LandAuctionHighestBidUserRepository;
|
||||
import com.caliverse.admin.dynamodb.repository.LandAuctionRegistryRepository;
|
||||
import com.caliverse.admin.global.common.constants.DynamoDBConstants;
|
||||
import com.caliverse.admin.global.component.transaction.TransactionIdManager;
|
||||
import com.caliverse.admin.history.service.DataInitializeHistoryService;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.stereotype.Service;
|
||||
import software.amazon.awssdk.enhanced.dynamodb.Key;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
@Service
|
||||
@RequiredArgsConstructor
|
||||
@Slf4j
|
||||
@@ -24,6 +34,10 @@ public class DynamodbLandAuctionService {
|
||||
private final LandAuctionActivityRepository activityRepository;
|
||||
private final LandAuctionHighestBidUserRepository highestBidUserRepository;
|
||||
private final LandAuctionRecordRepository landAuctionRecordRepository;
|
||||
private final LandAuctionRefundBidPriceRepository refundBidPriceRepository;
|
||||
|
||||
private final DataInitializeHistoryService dataInitializeHistoryService;
|
||||
private final TransactionIdManager transactionIdManager;
|
||||
|
||||
@DynamoDBTransaction
|
||||
public void insertLandAuctionRegistryWithActivity(LandRequest landRequest) {
|
||||
@@ -66,4 +80,90 @@ public class DynamodbLandAuctionService {
|
||||
|
||||
return doc.getAttribValue().getAuctionNumber();
|
||||
}
|
||||
|
||||
@DynamoDBTransaction
|
||||
public void initLandAuction(Integer landId, Integer auctionSeq, String guid){
|
||||
String tranId = transactionIdManager.getCurrentTransactionId();
|
||||
|
||||
HashMap<String,String> map = new HashMap<>();
|
||||
map.put("landId", String.valueOf(landId));
|
||||
map.put("auctionSeq", String.valueOf(auctionSeq));
|
||||
|
||||
try{
|
||||
List<DynamoDBDocBase> dataList = new ArrayList<>();
|
||||
DynamodbOperationResult registryResult = registryRepository.initLandAuctionRegistry(landId, auctionSeq);
|
||||
if(registryResult.isSuccess()){
|
||||
if(registryResult.getData() != null) dataList.add(registryResult.getData());
|
||||
}else{
|
||||
historySave(EInitDataType.LandAuction, tranId, false, registryResult.getMessage(), dataList, map);
|
||||
throw new RuntimeException(registryResult.getMessage());
|
||||
}
|
||||
|
||||
DynamodbOperationResult activityResult = activityRepository.initLandAuctionActivity(landId, auctionSeq);
|
||||
if(activityResult.isSuccess()){
|
||||
if(activityResult.getData() != null) dataList.add(activityResult.getData());
|
||||
}else{
|
||||
historySave(EInitDataType.LandAuction, tranId, false, activityResult.getMessage(), dataList, map);
|
||||
throw new RuntimeException(activityResult.getMessage());
|
||||
}
|
||||
|
||||
DynamodbOperationResult highestBidUserResult = highestBidUserRepository.initLandAuctionHighestBidUser(landId, auctionSeq);
|
||||
if(highestBidUserResult.isSuccess()){
|
||||
if(highestBidUserResult.getData() != null) dataList.add(highestBidUserResult.getData());
|
||||
}else{
|
||||
historySave(EInitDataType.LandAuction, tranId, false, highestBidUserResult.getMessage(), dataList, map);
|
||||
throw new RuntimeException(highestBidUserResult.getMessage());
|
||||
}
|
||||
|
||||
DynamodbOperationResult recordResult = landAuctionRecordRepository.initLandAuctionRecord(landId);
|
||||
if(recordResult.isSuccess()){
|
||||
if(recordResult.getData() != null) dataList.add(recordResult.getData());
|
||||
}else{
|
||||
historySave(EInitDataType.LandAuction, tranId, false, recordResult.getMessage(), dataList, map);
|
||||
throw new RuntimeException(recordResult.getMessage());
|
||||
}
|
||||
if(guid != null && !guid.isEmpty()) {
|
||||
map.put("guid", guid);
|
||||
DynamodbOperationResult refundBidPriceResult = refundBidPriceRepository.initLandAuctionRefundBidPrice(guid, landId, auctionSeq);
|
||||
if (refundBidPriceResult.isSuccess()) {
|
||||
if (refundBidPriceResult.getData() != null) dataList.add(refundBidPriceResult.getData());
|
||||
} else {
|
||||
historySave(EInitDataType.LandAuction, tranId, false, refundBidPriceResult.getMessage(), dataList, map);
|
||||
throw new RuntimeException(refundBidPriceResult.getMessage());
|
||||
}
|
||||
}else{
|
||||
List<LandAuctionRefundBidPriceDoc> refundList = refundBidPriceRepository.findAllScan(
|
||||
DynamoDBConstants.PK_KEY_LAND_AUCTION_REFUND_BID_PRICE,
|
||||
String.format("%s#%s", landId, auctionSeq)
|
||||
);
|
||||
refundList.forEach(refund -> {
|
||||
LandAuctionRefundBidPriceAttrib attrib = refund.getAttribValue();
|
||||
DynamodbOperationResult refundBidPriceResult = refundBidPriceRepository.initLandAuctionRefundBidPrice(attrib.getBidUserGuid(), attrib.getLandMetaId(), attrib.getAuctionNumber());
|
||||
if (refundBidPriceResult.isSuccess()) {
|
||||
if (refundBidPriceResult.getData() != null) dataList.add(refundBidPriceResult.getData());
|
||||
} else {
|
||||
historySave(EInitDataType.LandAuction, tranId, false, refundBidPriceResult.getMessage(), dataList, map);
|
||||
throw new RuntimeException(refundBidPriceResult.getMessage());
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
historySave(EInitDataType.LandAuction, tranId, true, "", dataList, map);
|
||||
|
||||
}catch (Exception e){
|
||||
historySave(EInitDataType.LandAuction, tranId, false, e.getMessage(), null, map);
|
||||
throw new RuntimeException(e.getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
private void historySave(EInitDataType dataType, String tranId, boolean isSuccess, String msg, List<DynamoDBDocBase> dataList, Map map){
|
||||
if(dataList != null && !dataList.isEmpty()) {
|
||||
dataList.forEach(data -> {
|
||||
if(data != null)
|
||||
dataInitializeHistoryService.dynamodbDataInitHistory(dataType, tranId, isSuccess, msg, data, map);
|
||||
});
|
||||
}else{
|
||||
dataInitializeHistoryService.dynamodbDataInitHistory(dataType, tranId, isSuccess, msg, null, map);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,19 +1,30 @@
|
||||
package com.caliverse.admin.dynamodb.service;
|
||||
|
||||
import com.caliverse.admin.domain.entity.EInitDataType;
|
||||
import com.caliverse.admin.domain.entity.metadata.MetaLandData;
|
||||
import com.caliverse.admin.domain.request.LandRequest;
|
||||
import com.caliverse.admin.dynamodb.domain.atrrib.BuildingAttrib;
|
||||
import com.caliverse.admin.dynamodb.domain.atrrib.LandAttrib;
|
||||
import com.caliverse.admin.dynamodb.domain.doc.DynamoDBDocBase;
|
||||
import com.caliverse.admin.dynamodb.domain.doc.OwnedLandDoc;
|
||||
import com.caliverse.admin.dynamodb.entity.DynamodbOperationResult;
|
||||
import com.caliverse.admin.dynamodb.repository.BuildingRepository;
|
||||
import com.caliverse.admin.dynamodb.repository.LandRepository;
|
||||
import com.caliverse.admin.dynamodb.repository.OwnedBuildingRepository;
|
||||
import com.caliverse.admin.dynamodb.repository.OwnedLandRepository;
|
||||
import com.caliverse.admin.global.common.annotation.DynamoDBTransaction;
|
||||
import com.caliverse.admin.global.common.constants.DynamoDBConstants;
|
||||
import com.caliverse.admin.global.component.transaction.TransactionIdManager;
|
||||
import com.caliverse.admin.history.service.DataInitializeHistoryService;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
@Service
|
||||
@RequiredArgsConstructor
|
||||
@Slf4j
|
||||
@@ -23,6 +34,9 @@ public class DynamodbLandService {
|
||||
private final OwnedBuildingRepository ownedBuildingRepository;
|
||||
private final BuildingRepository buildingRepository;
|
||||
|
||||
private final DataInitializeHistoryService dataInitializeHistoryService;
|
||||
private final TransactionIdManager transactionIdManager;
|
||||
|
||||
public boolean isLandOwner(Integer landId){
|
||||
LandAttrib attrib = landRepository.findLandAttrib(landId);
|
||||
if(attrib == null) return false;
|
||||
@@ -67,4 +81,99 @@ public class DynamodbLandService {
|
||||
ownedBuildingRepository.insert(guid, buildingId);
|
||||
}
|
||||
}
|
||||
|
||||
@DynamoDBTransaction
|
||||
public void initLandOwner(MetaLandData land, String guid){
|
||||
String tranId = transactionIdManager.getCurrentTransactionId();
|
||||
int landId = land.getLandId();
|
||||
int buildingId = land.getBuildingId();
|
||||
|
||||
HashMap<String,String> map = new HashMap<>();
|
||||
map.put("landId", String.valueOf(landId));
|
||||
map.put("buildingId", String.valueOf(buildingId));
|
||||
|
||||
try{
|
||||
List<DynamoDBDocBase> dataList = new ArrayList<>();
|
||||
DynamodbOperationResult landResult = landRepository.initLandOwner(landId);
|
||||
if(landResult.isSuccess()){
|
||||
if(landResult.getData() != null) dataList.add(landResult.getData());
|
||||
}else{
|
||||
historySave(EInitDataType.LandOwned, tranId, false, landResult.getMessage(), dataList, map);
|
||||
throw new RuntimeException(landResult.getMessage());
|
||||
}
|
||||
DynamodbOperationResult buildingResult = buildingRepository.initBuildingOwner(buildingId);
|
||||
if(buildingResult.isSuccess()){
|
||||
if(landResult.getData() != null) dataList.add(buildingResult.getData());
|
||||
}else{
|
||||
historySave(EInitDataType.LandOwned, tranId, false, buildingResult.getMessage(), dataList, map);
|
||||
throw new RuntimeException(buildingResult.getMessage());
|
||||
}
|
||||
DynamodbOperationResult ownedLandResult = ownedLandRepository.initOwnedLand(guid, landId);
|
||||
if(ownedLandResult.isSuccess()){
|
||||
if(landResult.getData() != null) dataList.add(ownedLandResult.getData());
|
||||
}else{
|
||||
historySave(EInitDataType.LandOwned, tranId, false, ownedLandResult.getMessage(), dataList, map);
|
||||
throw new RuntimeException(ownedLandResult.getMessage());
|
||||
}
|
||||
DynamodbOperationResult ownedBuildingResult = ownedBuildingRepository.initOwnedBuilding(guid, buildingId);
|
||||
if(ownedBuildingResult.isSuccess()){
|
||||
if(landResult.getData() != null) dataList.add(ownedBuildingResult.getData());
|
||||
}else{
|
||||
historySave(EInitDataType.LandOwned, tranId, false, ownedBuildingResult.getMessage(), dataList, map);
|
||||
throw new RuntimeException(ownedBuildingResult.getMessage());
|
||||
}
|
||||
|
||||
historySave(EInitDataType.LandOwned, tranId, true, "", dataList, map);
|
||||
|
||||
}catch (Exception e){
|
||||
historySave(EInitDataType.LandOwned, tranId, false, e.getMessage(), null, map);
|
||||
throw new RuntimeException(e.getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
@DynamoDBTransaction
|
||||
public void initLandDesc(MetaLandData land){
|
||||
String tranId = transactionIdManager.getCurrentTransactionId();
|
||||
int landId = land.getLandId();
|
||||
int buildingId = land.getBuildingId();
|
||||
|
||||
HashMap<String,String> map = new HashMap<>();
|
||||
map.put("landId", String.valueOf(landId));
|
||||
map.put("buildingId", String.valueOf(buildingId));
|
||||
|
||||
try{
|
||||
List<DynamoDBDocBase> dataList = new ArrayList<>();
|
||||
DynamodbOperationResult landResult = landRepository.initLandDesc(landId);
|
||||
if(landResult.isSuccess()){
|
||||
if(landResult.getData() != null) dataList.add(landResult.getData());
|
||||
}else{
|
||||
historySave(EInitDataType.LandDesc, tranId, false, landResult.getMessage(), dataList, map);
|
||||
throw new RuntimeException(landResult.getMessage());
|
||||
}
|
||||
DynamodbOperationResult buildingResult = buildingRepository.initBuildingDesc(buildingId);
|
||||
if(buildingResult.isSuccess()){
|
||||
if(landResult.getData() != null) dataList.add(buildingResult.getData());
|
||||
}else{
|
||||
historySave(EInitDataType.LandDesc, tranId, false, buildingResult.getMessage(), dataList, map);
|
||||
throw new RuntimeException(buildingResult.getMessage());
|
||||
}
|
||||
|
||||
historySave(EInitDataType.LandDesc, tranId, true, "", dataList, map);
|
||||
|
||||
}catch (Exception e){
|
||||
historySave(EInitDataType.LandDesc, tranId, false, e.getMessage(), null, map);
|
||||
throw new RuntimeException(e.getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
private void historySave(EInitDataType dataType, String tranId, boolean isSuccess, String msg, List<DynamoDBDocBase> dataList, Map map){
|
||||
if(!dataList.isEmpty()) {
|
||||
dataList.forEach(data -> {
|
||||
if (data != null)
|
||||
dataInitializeHistoryService.dynamodbDataInitHistory(dataType, tranId, isSuccess, msg, data, map);
|
||||
});
|
||||
}else{
|
||||
dataInitializeHistoryService.dynamodbDataInitHistory(dataType, tranId, isSuccess, msg, null, map);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user