랜드 소유권 변경 처리

This commit is contained in:
2025-03-07 18:31:50 +09:00
parent c5292fa20f
commit 3acb92a579
31 changed files with 981 additions and 144 deletions

View File

@@ -55,12 +55,24 @@ public class LandController {
return ResponseEntity.ok().body(landService.postLandAuction(landRequest));
}
@PostMapping("/change")
public ResponseEntity<LandResponse> postLandOwnerChanges(
@RequestBody LandRequest landRequest){
return ResponseEntity.ok().body(landService.postLandOwnerChanges(landRequest));
}
@PutMapping("/auction/{id}")
public ResponseEntity<LandResponse> updateLandAuction(
@PathVariable("id")Long id, @RequestBody LandRequest landRequest){
return ResponseEntity.ok().body(landService.updateLandAuction(id, landRequest));
}
@PutMapping("/change/{id}")
public ResponseEntity<LandResponse> updateLandOwnerChanges(
@PathVariable("id")Long id, @RequestBody LandRequest landRequest){
return ResponseEntity.ok().body(landService.updateLandOwnerChanges(id, landRequest));
}
@DeleteMapping("/auction/delete")
public ResponseEntity<LandResponse> deleteLandAuction(
@RequestBody LandRequest landRequest){

View File

@@ -2,6 +2,7 @@ package com.caliverse.admin.domain.dao.admin;
import com.caliverse.admin.domain.entity.Event;
import com.caliverse.admin.domain.entity.LandAuction;
import com.caliverse.admin.domain.entity.LandOwnerChange;
import com.caliverse.admin.domain.entity.Message;
import com.caliverse.admin.domain.request.LandRequest;
@@ -15,6 +16,7 @@ public interface LandMapper {
int getAllCnt(Map map);
int getTotal();
LandAuction getLandAuctionDetail(Long id);
LandOwnerChange getLandOwnerChangeDetail(Long id);
List<Message> getMessage(Long id);
@@ -22,9 +24,11 @@ public interface LandMapper {
int getPossibleLand(Integer landId);
int postLandAuction(LandRequest landRequest);
int postLandOwnerChange(LandRequest landRequest);
void insertMessage(Map map);
int updateLandAuction(LandRequest landRequest);
int updateLandOwnerChange(LandRequest landRequest);
int deleteMessage(Map map);

View File

@@ -1,37 +0,0 @@
package com.caliverse.admin.domain.entity;
import java.util.Arrays;
public enum ECurrencyType {
NONE(0, "None"),
GOLD(1, "Gold"),
SAPPHIRE(2, "Sapphire"),
CALIUM(3, "Calium"),
BEAM(4, "Beam"),
RUBY(5, "Ruby");
private final int value;
private final String name;
ECurrencyType(int value, String name) {
this.value = value;
this.name = name;
}
public int getValue() {
return value;
}
public String getName() {
return name;
}
public static int getValueByName(String name) {
return Arrays.stream(values())
.filter(type -> type.name.equalsIgnoreCase(name))
.findFirst()
.map(ECurrencyType::getValue)
.orElse(NONE.value);
}
}

View File

@@ -44,7 +44,9 @@ public enum HISTORYTYPE {
LAND_AUCTION_DELETE("랜드경매 삭제"),
BATTLE_EVENT_ADD("전투시스템 이벤트 등록"),
BATTLE_EVENT_UPDATE("전투시스템 이벤트 수정"),
BATTLE_EVENT_DELETE("전투시스템 이벤트 삭제")
BATTLE_EVENT_DELETE("전투시스템 이벤트 삭제"),
LAND_OWNER_CHANGE_ADD("랜드 소유권 변경 등록"),
LAND_OWNER_CHANGE_UPDATE("랜드 소유권 변경 수정")
;
private String historyType;
HISTORYTYPE(String type) {

View File

@@ -29,6 +29,10 @@ public class LandInfo {
@JsonProperty("land_type")
private String landType;
private String category;
@JsonProperty("building_id")
private Integer buildingId;
@JsonProperty("building_name")
private String buildingName;
@JsonProperty("owner_user_guid")
private String ownerUserGuid;
@JsonProperty("owner_user_nickname")
@@ -36,12 +40,22 @@ public class LandInfo {
@JsonProperty("owner_user_create_date")
// private LocalDateTime ownerUserCreateDate;
private String ownerUserCreateDate;
@JsonProperty("owner_user_price")
private String ownerUserPrice;
@JsonProperty("owner_price")
private String ownerPrice;
@JsonProperty("non_auction")
private boolean nonAuction;
private Integer socket;
private Integer editor;
private String editor;
private String status;
private String isUpdate;
private boolean isOwned;
public enum LAND_STATUS {
NONE,
AUCTION_RUNNING,
AUCTION_WAIT,
AUCTION_END,
OWNED,
;
}
}

View File

@@ -0,0 +1,51 @@
package com.caliverse.admin.domain.entity;
import com.fasterxml.jackson.annotation.JsonInclude;
import com.fasterxml.jackson.annotation.JsonProperty;
import lombok.AllArgsConstructor;
import lombok.Builder;
import lombok.Data;
import lombok.NoArgsConstructor;
import java.time.LocalDateTime;
@AllArgsConstructor
@NoArgsConstructor
@Data
@Builder
@JsonInclude(JsonInclude.Include.NON_NULL)
public class LandOwnerChange {
private Long id;
@JsonProperty("row_num")
private Integer rowNum;
@JsonProperty("land_id")
private Integer landId;
@JsonProperty("land_name")
private String landName;
@JsonProperty("user_guid")
private String userGuid;
@JsonProperty("reservation_dt")
private LocalDateTime reservationDt;
@JsonProperty("is_reserve")
private LocalDateTime isReserve;
private CHANGE_STATUS status;
private boolean deleted;
@JsonProperty("create_by")
private String createBy;
@JsonProperty("create_dt")
private LocalDateTime createDt;
@JsonProperty("update_by")
private String updateBy;
@JsonProperty("update_dt")
private LocalDateTime updateDt;
public enum CHANGE_STATUS {
WAIT,
FINISH,
RUNNING,
FAIL
;
}
}

View File

@@ -50,6 +50,21 @@ public class LandRequest {
@JsonProperty("message_list")
private List<Message> massageList;
//소유권 변경
@JsonProperty("user_guid")
private String userGuid;
@JsonProperty("user_name")
private String userName;
@JsonProperty("is_reserve")
private boolean isReserve;
@JsonProperty("reservation_dt")
private LocalDateTime reservationDt;
@JsonProperty("building_id")
private Integer buildingId;
@JsonProperty("building_name")
private String buildingName;
@JsonProperty("create_by")
private Long createBy;
@JsonProperty("create_dt")

View File

@@ -12,6 +12,7 @@ import com.caliverse.admin.domain.request.LandRequest;
import com.caliverse.admin.domain.response.LandResponse;
import com.caliverse.admin.dynamodb.service.DynamodbLandAuctionService;
import com.caliverse.admin.dynamodb.service.DynamodbLandService;
import com.caliverse.admin.dynamodb.service.DynamodbService;
import com.caliverse.admin.dynamodb.service.DynamodbUserService;
import com.caliverse.admin.global.common.code.CommonCode;
import com.caliverse.admin.global.common.code.ErrorCode;
@@ -19,7 +20,9 @@ import com.caliverse.admin.global.common.code.SuccessCode;
import com.caliverse.admin.global.common.constants.CommonConstants;
import com.caliverse.admin.global.common.constants.MysqlConstants;
import com.caliverse.admin.global.common.utils.CommonUtils;
import com.caliverse.admin.global.common.utils.DateUtils;
import com.caliverse.admin.history.service.MysqlHistoryLogService;
import com.fasterxml.jackson.core.JsonProcessingException;
import com.fasterxml.jackson.databind.ObjectMapper;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
@@ -34,6 +37,7 @@ import java.util.*;
import java.util.concurrent.atomic.AtomicBoolean;
import static com.caliverse.admin.global.common.utils.CommonUtils.convertIsoByDatetime;
import static com.caliverse.admin.global.common.utils.DateUtils.stringToDateTime;
@Service
@RequiredArgsConstructor
@@ -50,6 +54,7 @@ public class LandService {
private final HistoryService historyService;
private final ObjectMapper objectMapper;
private final MysqlHistoryLogService mysqlHistoryLogService;
private final DynamodbService dynamodbService;
public LandResponse getLandInfo(@RequestParam Map<String, String> requestParam){
String searchType = requestParam.getOrDefault("land_type", "ID");
@@ -65,6 +70,7 @@ public class LandService {
List<MetaLandData> landData = metaDataHandler.getMetaLandListData();
List<MetaBuildingData> buildingData = metaDataHandler.getMetaBuildingListData();
List<LandAuction> auctions = landMapper.getLandAuctionList(new HashMap());
List<LandInfo> list = landData.stream()
//필터 전처리(map 처리속도를 최대한 빠르게하기 위해서 먼저 필터 처리할수 있는건 한다)
@@ -87,7 +93,7 @@ public class LandService {
return result;
})
.map(data -> buildLandInfo(data, buildingData))
.map(data -> buildLandInfo(data, buildingData, auctions))
.filter(info -> {
boolean result = true;
@@ -121,40 +127,92 @@ public class LandService {
.build();
}
private LandInfo buildLandInfo(MetaLandData data, List<MetaBuildingData> buildingData){
int landId = data.getLandId();
LandAttrib land = dynamodbLandService.getLandInfo(landId);
String ownerGuid = land == null ? "" : land.getOwnerUserGuid();
String ownerName = data.getEditor().equals(CommonConstants.CALIVERSE_CODE) ? CommonConstants.CALIVERSE_NAME :
ownerGuid.isEmpty() ? "" : dynamodbUserService.getGuidByName(ownerGuid);
String ownerDate = ownerGuid.isEmpty() ? null : dynamodbLandService.getLandOwnerCreateDate(ownerGuid, landId); //랜드 소유 일자
int buildingSocket = buildingData.stream()
.filter(building -> building.getBuildingId().equals(data.getBuildingId()))
.findFirst().get()
.getInstanceSocket();
String parsedDate = null;
if (ownerDate != null && !ownerDate.isEmpty()) {
private LandInfo buildLandInfo(MetaLandData data, List<MetaBuildingData> buildingData, List<LandAuction> auctions){
try {
parsedDate = convertIsoByDatetime(ownerDate);
} catch (DateTimeParseException e) {
log.warn("owner_date parsing fail: " + ownerDate, e);
int landId = data.getLandId();
String editor = data.getEditor();
boolean nonAction = data.isNonAuction();
String ownerGuid = "";
String ownerName = "";
String ownerDate = "";
double ownerPrice = 0;
String category = "";
String status = "";
if(editor.equals(CommonConstants.USER)){
LandAttrib land = dynamodbLandService.getLandInfo(landId);
//랜드 존재
if(land != null){
ownerGuid = land.getOwnerUserGuid();
ownerName = dynamodbUserService.getGuidByName(ownerGuid);
int auctionNumber = dynamodbLandAuctionService.getLandAuctionNumber(landId);
// 경매
if(auctionNumber > 0){
LandAuction auction = auctions.stream()
.filter(row -> row.getLandId().equals(landId) && row.getAuctionSeq().equals(auctionNumber))
.findFirst().orElse(null);
if(auction == null){
log.error("getLandInfo.buildLandInfo auction info error landId: {}, auctionNumber: {}", landId, auctionNumber);
}
LandAuction.AUCTION_STATUS auctionStatus = auction.getStatus();
if(auctionStatus.equals(LandAuction.AUCTION_STATUS.FAIL) || auctionStatus.equals(LandAuction.AUCTION_STATUS.CANCEL)){
status = "";
}else{
status = auctionStatus.toString();
}
ownerPrice = auction.getClosePrice();
ownerDate = stringToDateTime(auction.getCloseEndDt());
}else{
String parsedDate = dynamodbLandService.getLandOwnerCreateDate(ownerGuid, landId);
ownerDate = convertIsoByDatetime(parsedDate);
}
}
}else{
ownerName = CommonConstants.CALIVERSE_NAME;
}
if(editor.equals(CommonConstants.CALIVERSE_CODE)){
category = CommonConstants.LAND_PUBLIC;
}else{
if(nonAction){
category = CommonConstants.LAND_EVENT;
}else{
category = CommonConstants.LAND_AUCTION;
}
}
boolean isOwned = editor.equals(CommonConstants.USER) && nonAction && ownerGuid.isEmpty();
MetaBuildingData buildingInfo = buildingData.stream()
.filter(building -> building.getBuildingId().equals(data.getBuildingId()))
.findFirst().get();
return LandInfo.builder()
.id((long)landId)
.id((long) landId)
.landId(landId)
.landName(metaDataHandler.getTextStringData(data.getLandName()))
.landDesc(metaDataHandler.getTextStringData(data.getLandDesc()))
.nonAuction(data.isNonAuction())
.buildingId(data.getBuildingId())
.buildingName(metaDataHandler.getTextStringData(buildingInfo.getBuildingName()))
.nonAuction(nonAction)
.editor(editor)
.status(status)
.isOwned(isOwned)
.category(category)
.landSize(data.getLandSize())
.landType(data.getLandType())
.socket(buildingSocket)
.socket(buildingInfo.getInstanceSocket())
.ownerUserGuid(ownerGuid)
.ownerUserNickname(ownerName)
.ownerUserCreateDate(parsedDate)
.ownerUserCreateDate(ownerDate)
.ownerPrice(String.valueOf(ownerPrice))
.build();
}catch(Exception e){
log.error("buildLandInfo", e);
}
return null;
}
// 랜드 메타데이터 정보 조회
@@ -301,17 +359,17 @@ public class LandService {
map.put("id",String.valueOf(auction_id));
//메시지 저장
if(landRequest.getMassageList()!= null && !landRequest.getMassageList().isEmpty()){
landRequest.getMassageList().forEach(
item -> {
map.put("title",item.getTitle());
map.put("content",item.getContent());
map.put("language",item.getLanguage());
landMapper.insertMessage(map);
}
);
}
log.info("AdminToolDB Message Save Complete");
// if(landRequest.getMassageList()!= null && !landRequest.getMassageList().isEmpty()){
// landRequest.getMassageList().forEach(
// item -> {
// map.put("title",item.getTitle());
// map.put("content",item.getContent());
// map.put("language",item.getLanguage());
// landMapper.insertMessage(map);
// }
// );
// }
// log.info("AdminToolDB Message Save Complete");
LandAuction auction_info = landMapper.getLandAuctionDetail(auction_id);
auction_info.setMessageList(landMapper.getMessage(auction_id));
@@ -336,6 +394,61 @@ public class LandService {
.build();
}
@Transactional(transactionManager = "transactionManager")
public LandResponse postLandOwnerChanges(LandRequest landRequest){
String guid = landRequest.getUserGuid();
String nickname = dynamodbUserService.getGuidByName(guid);
if(nickname.isEmpty() || !nickname.equals(landRequest.getUserName())){
return LandResponse.builder()
.status(CommonCode.ERROR.getHttpStatus())
.result(ErrorCode.GUID_CHECK.toString())
.build();
}
landRequest.setCreateBy(CommonUtils.getAdmin().getId());
boolean is_reserve = landRequest.isReserve();
if(!is_reserve){
landRequest.setReservationDt(LocalDateTime.now());
}
int result = landMapper.postLandOwnerChange(landRequest);
try {
log.info("AdminToolDB LandOwnerChanges Save: {}", objectMapper.writeValueAsString(landRequest));
} catch (JsonProcessingException e) {
throw new RuntimeException(e);
}
long id = landRequest.getId();
HashMap<String,Object> map = new HashMap<>();
map.put("id",String.valueOf(id));
LandOwnerChange info = landMapper.getLandOwnerChangeDetail(id);
mysqlHistoryLogService.insertHistoryLog(
HISTORYTYPE.LAND_OWNER_CHANGE_ADD,
MysqlConstants.TABLE_NAME_LAND_OWNER_CHANGE,
HISTORYTYPE.LAND_OWNER_CHANGE_ADD.name(),
info,
CommonUtils.getAdmin().getEmail(),
CommonUtils.getClientIp()
);
if(!is_reserve){
dynamodbLandService.ChangesLandOwner(landRequest);
map.put("status", LandOwnerChange.CHANGE_STATUS.FINISH);
updateLandOwnedChangeStatus(map);
}
return LandResponse.builder()
.status(CommonCode.SUCCESS.getHttpStatus())
.result(CommonCode.SUCCESS.getResult())
.resultData(LandResponse.ResultData.builder()
.message(SuccessCode.SAVE.getMessage())
.build())
.build();
}
@Transactional(transactionManager = "transactionManager")
public LandResponse updateLandAuction(Long id, LandRequest landRequest) {
landRequest.setId(id);
@@ -343,7 +456,7 @@ public class LandService {
landRequest.setUpdateDt(LocalDateTime.now());
LandAuction before_info = landMapper.getLandAuctionDetail(id);
before_info.setMessageList(landMapper.getMessage(id));
// before_info.setMessageList(landMapper.getMessage(id));
if(!before_info.getStatus().equals(LandAuction.AUCTION_STATUS.WAIT) && !before_info.getStatus().equals(LandAuction.AUCTION_STATUS.RESV_START)){
return LandResponse.builder()
@@ -359,19 +472,19 @@ public class LandService {
map.put("id", String.valueOf(id));
// message 테이블 데이터 삭제 처리 by mail_id
landMapper.deleteMessage(map);
// 메시지 업데이트
if (landRequest.getMassageList() != null && !landRequest.getMassageList().isEmpty()) {
landRequest.getMassageList().forEach(item -> {
map.put("title", item.getTitle());
map.put("content", item.getContent());
map.put("language", item.getLanguage());
landMapper.insertMessage(map);
});
}
log.info("AdminToolDB Message Update Complete");
// landMapper.deleteMessage(map);
//
// // 메시지 업데이트
// if (landRequest.getMassageList() != null && !landRequest.getMassageList().isEmpty()) {
// landRequest.getMassageList().forEach(item -> {
// map.put("title", item.getTitle());
// map.put("content", item.getContent());
// map.put("language", item.getLanguage());
//
// landMapper.insertMessage(map);
// });
// }
// log.info("AdminToolDB Message Update Complete");
LandAuction after_info = landMapper.getLandAuctionDetail(id);
after_info.setMessageList(landMapper.getMessage(id));
@@ -388,17 +501,40 @@ public class LandService {
dynamodbLandAuctionService.updateLandAuction(landRequest);
//로그 기록
try{
JSONObject jsonObject = new JSONObject();
jsonObject.put("before_info",before_info.toString());
jsonObject.put("after_info",after_info.toString());
// jsonObject.put("dynamoDB_result",land_auction_registry_result);
historyService.setLog(HISTORYTYPE.LAND_AUCTION_UPDATE, jsonObject);
}catch(Exception e){
log.error("history log Save Fail: {}", e.getMessage());
return LandResponse.builder()
.resultData(LandResponse.ResultData.builder()
.build())
.status(CommonCode.SUCCESS.getHttpStatus())
.result(CommonCode.SUCCESS.getResult())
.build();
}
@Transactional(transactionManager = "transactionManager")
public LandResponse updateLandOwnerChanges(Long id, LandRequest landRequest) {
landRequest.setId(id);
landRequest.setUpdateBy(CommonUtils.getAdmin().getId());
landRequest.setUpdateDt(LocalDateTime.now());
LandOwnerChange before_info = landMapper.getLandOwnerChangeDetail(id);
int result = landMapper.updateLandOwnerChange(landRequest);
log.info("AdminToolDB LandOwnerChanges Update Complete: {}", landRequest);
LandOwnerChange after_info = landMapper.getLandOwnerChangeDetail(id);
mysqlHistoryLogService.updateHistoryLog(
HISTORYTYPE.LAND_OWNER_CHANGE_UPDATE,
MysqlConstants.TABLE_NAME_LAND_OWNER_CHANGE,
HISTORYTYPE.LAND_OWNER_CHANGE_UPDATE.name(),
before_info,
after_info,
CommonUtils.getAdmin().getEmail(),
CommonUtils.getClientIp()
);
dynamodbLandService.ChangesLandOwner(landRequest);
return LandResponse.builder()
.resultData(LandResponse.ResultData.builder()
.build())
@@ -488,4 +624,14 @@ public class LandService {
log.error("updateLandAuction LandAuction Update Fail map: {}", map);
}
}
@Transactional(transactionManager = "transactionManager")
public void updateLandOwnedChangeStatus(Map<String,Object> map){
try{
landMapper.updateStatusLandAuction(map);
log.info("updateLandOwnedChangeStatus LandOwned status changed: {}", map.get("status"));
}catch(Exception e){
log.error("updateLandOwnedChangeStatus LandOwned Update Fail map: {}", map);
}
}
}

View File

@@ -28,9 +28,9 @@ public class BuildingAttrib extends DynamoDBAttribBase{
@JsonProperty("owner_user_guid")
private String ownerUserGuid;
@JsonProperty("RentalCurrencyType")
private String rentalCurrencyType;
private Integer rentalCurrencyType;
@JsonProperty("RentalCurrencyAmount")
private Double rentalCurrencyAmount;
@JsonProperty("IsRentalOpen")
private String isRentalOpen;
private boolean isRentalOpen;
}

View File

@@ -0,0 +1,33 @@
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 LandAuctionRecordAttrib {
@JsonProperty("land_meta_id")
private Integer landMetaId;
@JsonProperty("auction_number")
private Integer auctionNumber;
@DynamoDbAttribute("land_meta_id")
public Integer getLandMetaId() {
return landMetaId;
}
@DynamoDbAttribute("auction_number")
public Integer getAuctionNumber() {
return auctionNumber;
}
}

View File

@@ -0,0 +1,28 @@
package com.caliverse.admin.dynamodb.domain.doc;
import com.caliverse.admin.dynamodb.domain.atrrib.LandAuctionRecordAttrib;
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 LandAuctionRecordDoc extends DynamoDBDocBase {
private LandAuctionRecordAttrib landAuctionRecordAttrib;
public String getAttribFieldName() {
return "LandAuctionActivityAttrib";
}
@DynamoDbAttribute("LandAuctionRecordAttrib")
public LandAuctionRecordAttrib getAttribValue() {
return landAuctionRecordAttrib;
}
public void setAttribValue(LandAuctionRecordAttrib value) {
this.landAuctionRecordAttrib = value;
}
}

View File

@@ -0,0 +1,25 @@
package com.caliverse.admin.dynamodb.entity;
import com.caliverse.admin.domain.entity.common.ValueEnum;
public enum ECurrencyType implements ValueEnum {
None(0),
Gold(1),
Sapphire(2),
Calium(4),
Beam(5),
Ruby(6),
;
private final int value;
ECurrencyType(int value) {
this.value = value;
}
@Override
public int getValue() {
return value;
}
}

View File

@@ -0,0 +1,22 @@
package com.caliverse.admin.dynamodb.entity;
import com.caliverse.admin.domain.entity.common.ValueEnum;
public enum EOwnedType implements ValueEnum {
None(0),
Own(1),
Rent(2),
;
private final int value;
EOwnedType(int value) {
this.value = value;
}
@Override
public int getValue() {
return value;
}
}

View File

@@ -0,0 +1,141 @@
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.doc.BuildingDoc;
import com.caliverse.admin.dynamodb.entity.ECurrencyType;
import com.caliverse.admin.dynamodb.repository.BaseDynamoDBRepository;
import com.caliverse.admin.dynamodb.repository.BuildingRepository;
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.core.JsonProcessingException;
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.time.LocalDateTime;
import static com.caliverse.admin.global.common.utils.CommonUtils.convertUTCDate;
@Component
@Slf4j
public class BuildingRepositoryImpl extends BaseDynamoDBRepository<BuildingDoc> implements BuildingRepository {
public BuildingRepositoryImpl(DynamoDBOperations operations, DynamodbHistoryLogService dynamodbHistoryLogService, ObjectMapper objectMapper) {
super(operations, BuildingDoc.class, dynamodbHistoryLogService, objectMapper);
}
@Override
public BuildingAttrib findBuildingAttrib(Integer buildingId) {
Key key = Key.builder()
.partitionValue(DynamoDBConstants.PK_KEY_BUILDING + buildingId)
.sortValue(DynamoDBConstants.EMPTY)
.build();
BuildingDoc doc = findById(key);
if (doc == null) return null;
String attribJson = doc.getAttribValue();
try {
return objectMapper.readValue(attribJson, BuildingAttrib.class);
} catch (JsonProcessingException e) {
throw new RestApiException(CommonCode.ERROR.getHttpStatus(),
ErrorCode.DYNAMODB_JSON_PARSE_ERROR.getMessage());
}
}
@Override
public void insertBuilding(LandRequest landRequest) {
try {
LocalDateTime nowDate = LocalDateTime.now();
int building_id = landRequest.getBuildingId();
String guid = landRequest.getUserGuid();
String pk = DynamoDBConstants.PK_KEY_BUILDING + building_id;
BuildingAttrib attrib = new BuildingAttrib();
attrib.setAttribType(DynamoDBConstants.ATTRIB_BUILDING);
attrib.setBuildingName(landRequest.getBuildingName());
attrib.setBuildingMetaId(building_id);
attrib.setDescription("");
attrib.setOwnerUserGuid(guid);
attrib.setRentalCurrencyAmount(0.0);
attrib.setRentalCurrencyType(ECurrencyType.Calium.getValue());
attrib.setRentalOpen(true);
attrib.setBuildingGuid("");
BuildingDoc doc = new BuildingDoc();
doc.setPK(pk);
doc.setSK(DynamoDBConstants.EMPTY);
doc.setDocType(DynamoDBConstants.DOC_BUILDING);
doc.setAttribValue(objectMapper.writeValueAsString(attrib));
doc.setCreatedDateTime(convertUTCDate(nowDate));
doc.setUpdatedDateTime(convertUTCDate(nowDate));
doc.setDeletedDateTime(DynamoDBConstants.MIN_DATE);
doc.setRestoredDateTime(DynamoDBConstants.MIN_DATE);
save(doc);
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()
);
}catch (Exception e){
log.error("insert Error: {}", e.getMessage());
throw new RestApiException(CommonCode.ERROR.getHttpStatus(), ErrorCode.DYNAMODB_CONNECTION_ERROR.getMessage());
}
}
@Override
public void updateBuilding(LandRequest landRequest) {
LocalDateTime nowDate = LocalDateTime.now();
int land_id = landRequest.getLandId();
String guid = landRequest.getUserGuid();
try {
Key key = Key.builder()
.partitionValue(DynamoDBConstants.PK_KEY_LAND + land_id)
.sortValue(DynamoDBConstants.EMPTY)
.build();
BuildingDoc beforeDoc = findById(key);
if (beforeDoc != null) {
BuildingDoc afterDoc = deepCopy(beforeDoc, BuildingDoc.class);
BuildingAttrib attrib = new BuildingAttrib();
attrib.setDescription("");
attrib.setOwnerUserGuid(guid);
afterDoc.setAttribValue(objectMapper.writeValueAsString(attrib));
afterDoc.setUpdatedDateTime(CommonUtils.convertUTCDate(nowDate));
update(afterDoc);
log.info("BuildingDoc Update Success: {}", objectMapper.writeValueAsString(afterDoc));
dynamodbHistoryLogService.updateHistoryLog(
HISTORYTYPE.LAND_OWNER_CHANGE_UPDATE,
HISTORYTYPE.LAND_OWNER_CHANGE_UPDATE.name(),
beforeDoc,
afterDoc,
CommonUtils.getAdmin() == null ? "" : CommonUtils.getAdmin().getEmail(),
CommonUtils.getClientIp() == null ? "" : CommonUtils.getClientIp()
);
}
}catch (Exception e){
throw new RestApiException(CommonCode.ERROR.getHttpStatus(), ErrorCode.DYNAMODB_CONNECTION_ERROR.getMessage());
}
}
}

View File

@@ -0,0 +1,18 @@
package com.caliverse.admin.dynamodb.repository.Impl;
import com.caliverse.admin.dynamodb.domain.doc.LandAuctionRecordDoc;
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.history.service.DynamodbHistoryLogService;
import com.fasterxml.jackson.databind.ObjectMapper;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Component;
@Component
@Slf4j
public class LandAuctionRecordRepositoryImpl extends BaseDynamoDBRepository<LandAuctionRecordDoc> implements LandAuctionRecordRepository {
public LandAuctionRecordRepositoryImpl(DynamoDBOperations operations, DynamodbHistoryLogService dynamodbHistoryLogService, ObjectMapper objectMapper) {
super(operations, LandAuctionRecordDoc.class, dynamodbHistoryLogService, objectMapper);
}
}

View File

@@ -1,5 +1,6 @@
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.LandAttrib;
import com.caliverse.admin.dynamodb.domain.doc.LandDoc;
@@ -10,6 +11,7 @@ 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.core.JsonProcessingException;
import com.fasterxml.jackson.databind.ObjectMapper;
@@ -19,6 +21,8 @@ import software.amazon.awssdk.enhanced.dynamodb.Key;
import java.time.LocalDateTime;
import static com.caliverse.admin.global.common.utils.CommonUtils.convertUTCDate;
@Component
@Slf4j
public class LandRepositoryImpl extends BaseDynamoDBRepository<LandDoc> implements LandRepository {
@@ -49,37 +53,38 @@ public class LandRepositoryImpl extends BaseDynamoDBRepository<LandDoc> implemen
try {
LocalDateTime nowDate = LocalDateTime.now();
// String pk =
//
// LandAttrib attrib = new LandAttrib();
// attrib.setLandName();
// attrib.setMailId(event.getId().intValue());
// attrib.setStartTime(convertUTCDate(event.getStartDt()));
// attrib.setEndTime(convertUTCDate(event.getEndDt()));
// attrib.setSenderNickName(createSystemMessages(event.getMailList(), DynamodbUtil::getSenderByLanguage));
// attrib.setTitle(createSystemMessages(event.getMailList(), Message::getTitle));
// attrib.setText(createSystemMessages(event.getMailList(), Message::getContent));
// attrib.setItemList(createMailItems(event.getItemList()));
//
// LandDoc doc = new LandDoc();
// doc.setPK(DynamoDBConstants.PK_KEY_LAND + landRequest.getLandId());
// doc.setSK(String.valueOf(event.getId()));
// doc.setDocType(DynamoDBConstants.DOC_SYSTEMMAIL);
// doc.setAttribValue(objectMapper.writeValueAsString(attrib));
// doc.setCreatedDateTime(convertUTCDate(nowDate));
// doc.setUpdatedDateTime(convertUTCDate(nowDate));
// doc.setDeletedDateTime(DynamoDBConstants.MIN_DATE);
// doc.setRestoredDateTime(DynamoDBConstants.MIN_DATE);
//
// save(doc);
//
// dynamodbHistoryLogService.insertHistoryLog(
// HISTORYTYPE.EVENT_ADD,
// HISTORYTYPE.EVENT_ADD.name(),
// doc,
// CommonUtils.getAdmin().getEmail(),
// CommonUtils.getClientIp()
// );
int land_id = landRequest.getLandId();
String guid = landRequest.getUserGuid();
String pk = DynamoDBConstants.PK_KEY_LAND + land_id;
LandAttrib attrib = new LandAttrib();
attrib.setAttribType(DynamoDBConstants.ATTRIB_LAND);
attrib.setLandName(landRequest.getLandName());
attrib.setLandMetaId(land_id);
attrib.setDescription("");
attrib.setOwnerUserGuid(guid);
LandDoc doc = new LandDoc();
doc.setPK(pk);
doc.setSK(DynamoDBConstants.EMPTY);
doc.setDocType(DynamoDBConstants.DOC_LAND);
doc.setAttribValue(objectMapper.writeValueAsString(attrib));
doc.setCreatedDateTime(convertUTCDate(nowDate));
doc.setUpdatedDateTime(convertUTCDate(nowDate));
doc.setDeletedDateTime(DynamoDBConstants.MIN_DATE);
doc.setRestoredDateTime(DynamoDBConstants.MIN_DATE);
save(doc);
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()
);
}catch (Exception e){
log.error("insert Error: {}", e.getMessage());
@@ -89,6 +94,44 @@ public class LandRepositoryImpl extends BaseDynamoDBRepository<LandDoc> implemen
@Override
public void updateLand(LandRequest landRequest) {
LocalDateTime nowDate = LocalDateTime.now();
int land_id = landRequest.getLandId();
String guid = landRequest.getUserGuid();
try {
Key key = Key.builder()
.partitionValue(DynamoDBConstants.PK_KEY_LAND + land_id)
.sortValue(DynamoDBConstants.EMPTY)
.build();
LandDoc beforeDoc = findById(key);
if (beforeDoc != null) {
LandDoc afterDoc = deepCopy(beforeDoc, LandDoc.class);
LandAttrib attrib = new LandAttrib();
attrib.setDescription("");
attrib.setOwnerUserGuid(guid);
afterDoc.setAttribValue(objectMapper.writeValueAsString(attrib));
afterDoc.setUpdatedDateTime(CommonUtils.convertUTCDate(nowDate));
update(afterDoc);
log.info("LandDoc Update Success: {}", objectMapper.writeValueAsString(afterDoc));
dynamodbHistoryLogService.updateHistoryLog(
HISTORYTYPE.LAND_OWNER_CHANGE_UPDATE,
HISTORYTYPE.LAND_OWNER_CHANGE_UPDATE.name(),
beforeDoc,
afterDoc,
CommonUtils.getAdmin() == null ? "" : CommonUtils.getAdmin().getEmail(),
CommonUtils.getClientIp() == null ? "" : CommonUtils.getClientIp()
);
}
}catch (Exception e){
throw new RestApiException(CommonCode.ERROR.getHttpStatus(), ErrorCode.DYNAMODB_CONNECTION_ERROR.getMessage());
}
}
}

View File

@@ -32,6 +32,8 @@ public class NicknameRepositoryImpl extends BaseDynamoDBRepository<NicknameDoc>
NicknameDoc doc = findById(key);
if (doc == null) return null;
try {
return objectMapper.readValue(doc.getAttribValue(), NicknameAttrib.class);
} catch (JsonProcessingException e) {

View File

@@ -0,0 +1,100 @@
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.entity.EOwnedType;
import com.caliverse.admin.dynamodb.repository.BaseDynamoDBRepository;
import com.caliverse.admin.dynamodb.repository.OwnedBuildingRepository;
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.time.LocalDateTime;
import static com.caliverse.admin.global.common.utils.CommonUtils.convertUTCDate;
@Component
@Slf4j
public class OwnedBuildingRepositoryImpl extends BaseDynamoDBRepository<OwnedBuildingDoc> implements OwnedBuildingRepository {
public OwnedBuildingRepositoryImpl(DynamoDBOperations operations, DynamodbHistoryLogService dynamodbHistoryLogService, ObjectMapper objectMapper) {
super(operations, OwnedBuildingDoc.class, dynamodbHistoryLogService, objectMapper);
}
@Override
public OwnedBuildingDoc findOwnedBuilding(String guid, Integer buildingId) {
Key key = Key.builder()
.partitionValue(DynamoDBConstants.PK_KEY_OWNED_BUILDING + guid)
.sortValue(String.valueOf(buildingId))
.build();
return findById(key);
}
@Override
public void insert(String guid, Integer buildingId) {
try {
LocalDateTime nowDate = LocalDateTime.now();
String pk = DynamoDBConstants.PK_KEY_OWNED_BUILDING + guid;
OwnedBuildingAttrib attrib = new OwnedBuildingAttrib();
attrib.setAttribType(DynamoDBConstants.ATTRIB_OWNED_BUILDING);
attrib.setBuildingMetaId(buildingId);
attrib.setOwnedType(EOwnedType.Own.getValue());
OwnedBuildingDoc doc = new OwnedBuildingDoc();
doc.setPK(pk);
doc.setSK(String.valueOf(buildingId));
doc.setDocType(DynamoDBConstants.DOC_OWNED_BUILDING);
doc.setAttribValue(objectMapper.writeValueAsString(attrib));
doc.setCreatedDateTime(convertUTCDate(nowDate));
doc.setUpdatedDateTime(convertUTCDate(nowDate));
doc.setDeletedDateTime(DynamoDBConstants.MIN_DATE);
doc.setRestoredDateTime(DynamoDBConstants.MIN_DATE);
save(doc);
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()
);
}catch (Exception e){
log.error("insert Error: {}", e.getMessage());
throw new RestApiException(CommonCode.ERROR.getHttpStatus(), ErrorCode.DYNAMODB_CONNECTION_ERROR.getMessage());
}
}
@Override
public void delete(String guid, Integer buildingId) {
Key key = Key.builder()
.partitionValue(DynamoDBConstants.PK_KEY_OWNED_BUILDING + guid)
.sortValue(String.valueOf(buildingId))
.build();
OwnedBuildingDoc doc = findById(key);
delete(key);
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()
);
}
}

View File

@@ -1,10 +1,17 @@
package com.caliverse.admin.dynamodb.repository.Impl;
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.repository.BaseDynamoDBRepository;
import com.caliverse.admin.dynamodb.repository.OwnedLandRepository;
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;
@@ -13,6 +20,8 @@ import software.amazon.awssdk.enhanced.dynamodb.Key;
import java.time.LocalDateTime;
import static com.caliverse.admin.global.common.utils.CommonUtils.convertUTCDate;
@Component
@Slf4j
public class OwnedLandRepositoryImpl extends BaseDynamoDBRepository<OwnedLandDoc> implements OwnedLandRepository {
@@ -29,4 +38,62 @@ public class OwnedLandRepositoryImpl extends BaseDynamoDBRepository<OwnedLandDoc
return findById(key);
}
@Override
public void insert(String guid, Integer landId) {
try {
LocalDateTime nowDate = LocalDateTime.now();
String pk = DynamoDBConstants.PK_KEY_OWNED_LAND + guid;
OwnedLandAttrib attrib = new OwnedLandAttrib();
attrib.setAttribType(DynamoDBConstants.ATTRIB_OWNED_LAND);
attrib.setLandMetaId(landId);
attrib.setOwnedType(EOwnedType.Own.getValue());
OwnedLandDoc doc = new OwnedLandDoc();
doc.setPK(pk);
doc.setSK(String.valueOf(landId));
doc.setDocType(DynamoDBConstants.DOC_OWNED_LAND);
doc.setAttribValue(objectMapper.writeValueAsString(attrib));
doc.setCreatedDateTime(convertUTCDate(nowDate));
doc.setUpdatedDateTime(convertUTCDate(nowDate));
doc.setDeletedDateTime(DynamoDBConstants.MIN_DATE);
doc.setRestoredDateTime(DynamoDBConstants.MIN_DATE);
save(doc);
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()
);
}catch (Exception e){
log.error("insert Error: {}", e.getMessage());
throw new RestApiException(CommonCode.ERROR.getHttpStatus(), ErrorCode.DYNAMODB_CONNECTION_ERROR.getMessage());
}
}
@Override
public void delete(String guid, Integer landId) {
Key key = Key.builder()
.partitionValue(DynamoDBConstants.PK_KEY_OWNED_LAND + guid)
.sortValue(String.valueOf(landId))
.build();
OwnedLandDoc doc = findById(key);
delete(key);
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()
);
}
}

View File

@@ -31,6 +31,7 @@ public class UserBaseRepositoryImpl extends BaseDynamoDBRepository<UserBaseDoc>
.build();
UserBaseDoc doc = findById(key);
if(doc == null) return null;
try {
return objectMapper.readValue(doc.getAttribValue(), UserBaseAttrib.class);

View File

@@ -0,0 +1,6 @@
package com.caliverse.admin.dynamodb.repository;
import com.caliverse.admin.dynamodb.domain.doc.LandAuctionRecordDoc;
public interface LandAuctionRecordRepository extends DynamoDBRepository<LandAuctionRecordDoc> {
}

View File

@@ -0,0 +1,10 @@
package com.caliverse.admin.dynamodb.repository;
import com.caliverse.admin.domain.request.LandRequest;
import com.caliverse.admin.dynamodb.domain.doc.OwnedBuildingDoc;
public interface OwnedBuildingRepository extends DynamoDBRepository<OwnedBuildingDoc> {
OwnedBuildingDoc findOwnedBuilding(String guid, Integer buildingId);
void insert(String guid, Integer buildingId);
void delete(String guid, Integer buildingId);
}

View File

@@ -4,4 +4,6 @@ import com.caliverse.admin.dynamodb.domain.doc.OwnedLandDoc;
public interface OwnedLandRepository extends DynamoDBRepository<OwnedLandDoc> {
OwnedLandDoc findOwnedLand(String guid, Integer landId);
void insert(String guid, Integer landId);
void delete(String guid, Integer landId);
}

View File

@@ -2,15 +2,19 @@ package com.caliverse.admin.dynamodb.service;
import com.caliverse.admin.domain.entity.LandAuction;
import com.caliverse.admin.domain.request.LandRequest;
import com.caliverse.admin.dynamodb.domain.doc.LandAuctionRecordDoc;
import com.caliverse.admin.dynamodb.repository.LandAuctionRecordRepository;
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 lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Service;
import software.amazon.awssdk.enhanced.dynamodb.Key;
@Service
@RequiredArgsConstructor
@@ -19,6 +23,7 @@ public class DynamodbLandAuctionService {
private final LandAuctionRegistryRepository registryRepository;
private final LandAuctionActivityRepository activityRepository;
private final LandAuctionHighestBidUserRepository highestBidUserRepository;
private final LandAuctionRecordRepository landAuctionRecordRepository;
@DynamoDBTransaction
public void insertLandAuctionRegistryWithActivity(LandRequest landRequest) {
@@ -49,4 +54,16 @@ public class DynamodbLandAuctionService {
// return activityRepository.findAuctionNumber(landId);
return registryRepository.findAuctionNumber(landId);
}
public int getLandAuctionRecordNumber(Integer landId){
Key key = Key.builder()
.partitionValue(DynamoDBConstants.PK_KEY_LAND_AUCTION_RECORD)
.sortValue(String.valueOf(landId))
.build();
LandAuctionRecordDoc doc = landAuctionRecordRepository.findById(key);
if(doc == null) return 0;
return doc.getAttribValue().getAuctionNumber();
}
}

View File

@@ -1,9 +1,14 @@
package com.caliverse.admin.dynamodb.service;
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.OwnedLandDoc;
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 lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
@@ -15,6 +20,8 @@ import org.springframework.stereotype.Service;
public class DynamodbLandService {
private final LandRepository landRepository;
private final OwnedLandRepository ownedLandRepository;
private final OwnedBuildingRepository ownedBuildingRepository;
private final BuildingRepository buildingRepository;
public boolean isLandOwner(Integer landId){
LandAttrib attrib = landRepository.findLandAttrib(landId);
@@ -31,4 +38,31 @@ public class DynamodbLandService {
OwnedLandDoc ownedLand = ownedLandRepository.findOwnedLand(guid, landId);
return ownedLand == null ? "" : ownedLand.getCreatedDateTime();
}
@DynamoDBTransaction
public void ChangesLandOwner(LandRequest landRequest){
int landId = landRequest.getLandId();
int buildingId = landRequest.getBuildingId();
String guid = landRequest.getUserGuid();
LandAttrib landAttrib = landRepository.findLandAttrib(landId);
if(landAttrib == null){
landRepository.insertLand(landRequest);
ownedLandRepository.insert(guid, landId);
}else{
ownedLandRepository.delete(landAttrib.getOwnerUserGuid(), landId);
landRepository.updateLand(landRequest);
ownedLandRepository.insert(guid, landId);
}
BuildingAttrib buildingAttrib = buildingRepository.findBuildingAttrib(buildingId);
if(buildingAttrib == null){
buildingRepository.insertBuilding(landRequest);
ownedBuildingRepository.insert(guid, landId);
}else{
ownedBuildingRepository.delete(buildingAttrib.getOwnerUserGuid(), landId);
buildingRepository.updateBuilding(landRequest);
ownedBuildingRepository.insert(guid, landId);
}
}
}

View File

@@ -10,6 +10,10 @@ public class CommonConstants {
public static final String CALIUM_ITEM_CODE = "19010003";
public static final String CALIVERSE_CODE = "CALIVERSE";
public static final String CALIVERSE_NAME = "칼리버스";
public static final String USER = "USER";
public static final String LAND_PUBLIC = "public";
public static final String LAND_AUCTION = "auction";
public static final String LAND_EVENT = "event";
public static final String FORMAT_DATE_ISO_DATETIME_MILLIS = "yyyy-MM-dd'T'HH:mm:ss.SSS'Z'";
public static final String FORMAT_DATE_DATETIME = "yyyy-MM-dd HH:mm:ss";

View File

@@ -11,6 +11,7 @@ public class DynamoDBConstants {
public static final String PK_KEY_LAND_AUCTION = "land_auction_registry#global";
public static final String PK_KEY_LAND_AUCTION_ACTIVE = "land_auction_activity#global";
public static final String PK_KEY_LAND_AUCTION_HIGHEST_USER = "land_auction_highest_bid_user#global";
public static final String PK_KEY_LAND_AUCTION_RECORD = "land_auction_record#global";
public static final String PK_KEY_USER_NICKNAME_REGISTRY = "user_nickname_registry#global";
public static final String PK_KEY_MONEY = "money#";
public static final String PK_KEY_LAND = "land#";
@@ -32,6 +33,10 @@ public class DynamoDBConstants {
public static final String ATTRIB_LANDAUCTION_HIGHEST_USER = "LandAuctionHighestBidUserAttrib";
public static final String ATTRIB_USER_NICKNAME_REGISTRY = "UserNicknameRegistryAttrib";
public static final String ATTRIB_BATTLE_EVENT = "BattleEventAttrib";
public static final String ATTRIB_LAND = "LandAttrib";
public static final String ATTRIB_BUILDING = "BuildingAttrib";
public static final String ATTRIB_OWNED_LAND = "OwnedLandAttrib";
public static final String ATTRIB_OWNED_BUILDING = "OwnedBuildingAttrib";
//DOC
public static final String DOC_SYSTEMMAIL = "SystemMetaMailDoc";
@@ -40,6 +45,10 @@ public class DynamoDBConstants {
public static final String DOC_LANDAUCTION_HIGHEST_USER = "LandAuctionHighestBidUserDoc";
public static final String DOC_USER_NICKNAME_REGISTRY = "UserNicknameRegistryDoc";
public static final String DOC_BATTLE_EVENT = "BattleEventDoc";
public static final String DOC_LAND = "LandDoc";
public static final String DOC_BUILDING = "BuildingDoc";
public static final String DOC_OWNED_LAND = "OwnedLandDoc";
public static final String DOC_OWNED_BUILDING = "OwnedBuildingDoc";
//SCHEMA
public static final String SCHEMA_UPDATE_TIME = "UpdatedDateTime";

View File

@@ -2,6 +2,7 @@ package com.caliverse.admin.global.common.constants;
public class MysqlConstants {
public static String TABLE_NAME_LAND_AUCTION = "land_auction";
public static String TABLE_NAME_LAND_OWNER_CHANGE = "land_ownership_changes";
public static String TABLE_NAME_CALIUM_REQUEST = "calium_request";
public static String TABLE_NAME_EVENT = "event";
public static String TABLE_NAME_MAIL = "mail";

View File

@@ -8,6 +8,7 @@ import java.time.format.DateTimeFormatter;
public class DateUtils {
public static String stringToDateTime(LocalDateTime date) {
if(date == null) return null;
DateTimeFormatter formatter = DateTimeFormatter.ofPattern(CommonConstants.FORMAT_DATE_DATETIME);
return date.format(formatter);
}

View File

@@ -77,7 +77,6 @@ public class DynamicScheduler {
LocalDateTime end_dt = event.getEventEndDt();
int operation_time = event.getEventOperationTime();
//자정 체크
LocalTime endTime = startTime.plusSeconds(operation_time);
// 현재시간이 자정을 넘어간 경우(00:00 ~ endTime)라면 전날을 기준으로

View File

@@ -25,6 +25,21 @@
<result property="updateBy" column="update_by"/>
<result property="updateDt" column="update_dt"/>
</resultMap>
<resultMap id="LandOwnerChangeResultMap" type="com.caliverse.admin.domain.entity.LandOwnerChange">
<id property="id" column="id"/>
<result property="landId" column="land_id"/>
<result property="landName" column="land_name"/>
<result property="buildingId" column="building_id"/>
<result property="buildingName" column="building_name"/>
<result property="userGuid" column="user_guid"/>
<result property="isReserve" column="is_reserve"/>
<result property="reservationDt" column="reservation_dt"/>
<result property="status" column="status"/>
<result property="createBy" column="create_by"/>
<result property="createDt" column="create_dt"/>
<result property="updateBy" column="update_by"/>
<result property="updateDt" column="update_dt"/>
</resultMap>
<resultMap id="MessageResultMap" type="com.caliverse.admin.domain.entity.Message">
<result property="title" column="title"/>
<result property="language" column="language"/>
@@ -123,9 +138,9 @@
, (SELECT @row_number:=0) AS t
) Z
ORDER BY
CASE WHEN Z.status = 'FAIL' OR Z.status = 'CANCEL' THEN 1 ELSE 0 END,
CASE WHEN Z.status = 'FAIL' OR Z.status = 'CANCEL' THEN 1 ELSE 0 END
<if test="orderby != null and orderby != ''">
row_num ${orderby}
,row_num ${orderby}
</if>
<if test="pageSize != null and pageSize != ''">
LIMIT ${pageSize} OFFSET ${offset}
@@ -219,6 +234,22 @@
WHERE a.id = #{id}
</select>
<select id="getLandOwnerChangeDetail" parameterType="java.lang.Long" resultMap="LandOwnerChangeResultMap" >
SELECT
a.id
, a.land_id
, a.land_name
, a.user_guid
, a.reservation_dt
, a.status
, (SELECT email FROM admin WHERE id = a.create_by ) AS create_by
, a.create_dt
, (SELECT email FROM admin WHERE id = a.update_by ) AS update_by
, a.update_dt
FROM land_ownership_changes a
WHERE a.id = #{id}
</select>
<select id="getMessage" parameterType="java.lang.Long" resultMap="MessageResultMap" >
SELECT
*
@@ -233,6 +264,11 @@
VALUES (#{landId}, #{landName}, #{landSize}, #{landSocket}, #{auctionSeq}, #{resvStartDt}, #{resvEndDt}, #{auctionStartDt}, #{auctionEndDt}, #{currencyType}, #{startPrice}, #{createBy}, #{updateBy})
</insert>
<insert id="postLandOwnerChange" parameterType="com.caliverse.admin.domain.request.LandRequest" useGeneratedKeys="true" keyProperty="id">
INSERT INTO land_ownership_changes (land_id, land_name, building_id, building_name, user_guid, is_reserve, reservation_dt, create_by, update_by)
VALUES (#{landId}, #{landName}, #{buildingId}, #{buildingName}, #{userGuid}, #{isReserve}, #{reservationDt}, #{createBy}, #{updateBy})
</insert>
<insert id="insertMessage" parameterType="map">
INSERT INTO message (target_id, type, content, language)
VALUES (#{id}, 'LANDAUCTION', #{content}, #{language})
@@ -251,6 +287,15 @@
WHERE id = #{id}
</update>
<update id="updateLandOwnerChange" parameterType="com.caliverse.admin.domain.request.LandRequest">
UPDATE land_ownership_changes
SET user_guid = #{userGuid}
, reservation_dt = #{reservationDt}
, update_by = #{updateBy}
, update_dt = NOW()
WHERE id = #{id}
</update>
<update id="deleteMessage" parameterType="map">
DELETE FROM message
WHERE target_id = #{id}
@@ -282,6 +327,12 @@
where id = #{id}
</update>
<update id="updateStatusLandOwnedChange" parameterType="map">
UPDATE land_ownership_changes
SET status = #{status}
where id = #{id}
</update>
<select id="getScheduleLandAuctionList" resultMap="LandAuctionResultMap">
SELECT id
, land_id
@@ -298,4 +349,20 @@
AND deleted = 0
</select>
<select id="getScheduleLandOwnedChangeList" resultMap="LandOwnerChangeResultMap">
SELECT id
, land_id
, land_name
, building_id
, building_name
, status
, user_guid
, is_reserve
, reservation_dt
FROM land_ownership_changes
WHERE (status = 'WAIT')
AND deleted = 0
AND is_reserve = 1
</select>
</mapper>