Compare commits
2 Commits
45e6b05cab
...
0cd0853a63
| Author | SHA1 | Date | |
|---|---|---|---|
| 0cd0853a63 | |||
| c8f76004ed |
@@ -20,13 +20,13 @@ import java.util.Map;
|
||||
public class ItemsController {
|
||||
private final ItemsService itemsService;
|
||||
|
||||
@GetMapping("/list")
|
||||
@PostMapping("/list")
|
||||
public ResponseEntity<ItemsResponse> findItems(
|
||||
@RequestParam Map<String, String> requestParams){
|
||||
return ResponseEntity.ok().body( itemsService.findItems(requestParams));
|
||||
@RequestBody ItemsRequest itemRequest){
|
||||
return ResponseEntity.ok().body( itemsService.findItems(itemRequest));
|
||||
}
|
||||
|
||||
@PostMapping("/delete")
|
||||
@DeleteMapping("/delete")
|
||||
public ResponseEntity<ItemDeleteResponse> postItemDelete(
|
||||
@RequestBody ItemsRequest ItemDeleteRequest){
|
||||
return ResponseEntity.ok().body( itemsService.postItemDelete(ItemDeleteRequest));
|
||||
|
||||
@@ -1,73 +0,0 @@
|
||||
package com.caliverse.admin.domain.api;
|
||||
|
||||
import java.util.Map;
|
||||
|
||||
import org.springframework.http.ResponseEntity;
|
||||
import org.springframework.web.bind.annotation.DeleteMapping;
|
||||
import org.springframework.web.bind.annotation.GetMapping;
|
||||
import org.springframework.web.bind.annotation.PatchMapping;
|
||||
import org.springframework.web.bind.annotation.PostMapping;
|
||||
import org.springframework.web.bind.annotation.RequestBody;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.bind.annotation.RequestParam;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
import org.springframework.web.multipart.MultipartFile;
|
||||
|
||||
import com.caliverse.admin.domain.request.WhiteListRequest;
|
||||
import com.caliverse.admin.domain.response.WhiteListResponse;
|
||||
import com.caliverse.admin.domain.service.WhiteListService;
|
||||
|
||||
import io.swagger.v3.oas.annotations.tags.Tag;
|
||||
import jakarta.servlet.http.HttpServletResponse;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
|
||||
@Tag(name = "화이트리스트", description = "화이트리스트 메뉴 api 입니다.")
|
||||
@RestController
|
||||
@RequiredArgsConstructor
|
||||
@RequestMapping("/api/v1/white-list")
|
||||
public class WhiteListController {
|
||||
private final WhiteListService whiteListService;
|
||||
//화이트 리스트 명단 조회
|
||||
@GetMapping("/list")
|
||||
public ResponseEntity<WhiteListResponse> getWhiteList(
|
||||
@RequestParam Map<String, String> requestParams){
|
||||
return ResponseEntity.ok().body( whiteListService.getWhiteList(requestParams));
|
||||
}
|
||||
|
||||
|
||||
// 화이트리스트 일광 등록 (엑셀 업로드)
|
||||
@PostMapping("/excel-upload")
|
||||
public ResponseEntity<WhiteListResponse> excelUpload(
|
||||
@RequestParam("file") MultipartFile file){
|
||||
return ResponseEntity.ok().body( whiteListService.excelUpload(file));
|
||||
}
|
||||
|
||||
// 화이트리스트 단일 등록
|
||||
@PostMapping
|
||||
public ResponseEntity<WhiteListResponse> postWhiteList(
|
||||
@RequestBody WhiteListRequest whiteListRequest){
|
||||
return ResponseEntity.ok().body( whiteListService.postWhiteList(whiteListRequest));
|
||||
}
|
||||
// 화이트리스트 복수 등록
|
||||
@PostMapping("/multiPost")
|
||||
public ResponseEntity<WhiteListResponse> multiPost(
|
||||
@RequestParam("file") MultipartFile file){
|
||||
return ResponseEntity.ok().body( whiteListService.multiPost(file));
|
||||
}
|
||||
@GetMapping("/excelDownLoad")
|
||||
public void excelDownLoad(HttpServletResponse res){
|
||||
whiteListService.excelDownLoad(res);
|
||||
}
|
||||
// 화이트리스트 승인
|
||||
@PatchMapping
|
||||
public ResponseEntity<WhiteListResponse> updateWhiteList(
|
||||
@RequestBody WhiteListRequest whiteListRequest){
|
||||
return ResponseEntity.ok().body(whiteListService.updateWhiteList(whiteListRequest));
|
||||
}
|
||||
|
||||
@DeleteMapping
|
||||
public ResponseEntity<WhiteListResponse> deleteWhiteList(
|
||||
@RequestBody WhiteListRequest whiteListRequest){
|
||||
return ResponseEntity.ok().body(whiteListService.deleteWhiteList(whiteListRequest));
|
||||
}
|
||||
}
|
||||
@@ -1,23 +0,0 @@
|
||||
package com.caliverse.admin.domain.dao.admin;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
import com.caliverse.admin.domain.entity.WhiteList;
|
||||
|
||||
public interface WhiteListMapper {
|
||||
|
||||
// 화이트 리스트 조회
|
||||
List<WhiteList> getWhiteList();
|
||||
|
||||
Map<String,String> getGuidById(Long id);
|
||||
|
||||
int getCountByGuid(String guid);
|
||||
//화이트리스트 등록
|
||||
int postWhiteList(Map<String, Object> map);
|
||||
|
||||
//선택 승인
|
||||
int updateStatus(Long id);
|
||||
//선택 삭제
|
||||
void deleteWhiteList(Long id);
|
||||
}
|
||||
@@ -39,7 +39,7 @@ public class Admin implements UserDetails{
|
||||
private LocalDateTime expiredDt;
|
||||
|
||||
@JsonProperty("auth_level_type")
|
||||
private EAuthAdminLevelType authLevelType;
|
||||
private AuthAdminLevelType authLevelType;
|
||||
|
||||
/* 만료일 만 가져올려면 */
|
||||
/*@Column(name = "expired_dt")
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
package com.caliverse.admin.domain.entity;
|
||||
|
||||
public enum EAuthAdminLevelType {
|
||||
public enum AuthAdminLevelType {
|
||||
None,
|
||||
Reader,
|
||||
Master,
|
||||
@@ -0,0 +1,9 @@
|
||||
package com.caliverse.admin.domain.entity;
|
||||
|
||||
public enum EFilterOperator {
|
||||
NONE,
|
||||
EQUALS, // 같음
|
||||
CONTAINS, // 포함
|
||||
BEGINS_WITH, // 시작 문자
|
||||
NOT_EQUALS // 같지 않음
|
||||
}
|
||||
@@ -55,6 +55,9 @@ public enum HISTORYTYPE {
|
||||
MENU_BANNER_ADD("메뉴 배너 등록"),
|
||||
MENU_BANNER_UPDATE("메뉴 배너 수정"),
|
||||
MENU_BANNER_DELETE("메뉴 배너 삭제"),
|
||||
ITEM_UPDATE("아이템 수정"),
|
||||
ITEM_DELETE("아이템 삭제"),
|
||||
USER_ADMIN_AUTH_UPDATE("유저 관리자 권한 수정")
|
||||
;
|
||||
private String historyType;
|
||||
HISTORYTYPE(String type) {
|
||||
|
||||
@@ -1,32 +0,0 @@
|
||||
package com.caliverse.admin.domain.entity;
|
||||
|
||||
import com.caliverse.admin.domain.response.ItemsResponse;
|
||||
import com.fasterxml.jackson.annotation.JsonProperty;
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Builder;
|
||||
import lombok.Data;
|
||||
import lombok.NoArgsConstructor;
|
||||
|
||||
@AllArgsConstructor
|
||||
@NoArgsConstructor
|
||||
@Data
|
||||
@Builder
|
||||
public class ItemList {
|
||||
@JsonProperty("row_num")
|
||||
private Long rowNum;
|
||||
private String guid;
|
||||
@JsonProperty("item_id")
|
||||
private String itemId; //아이템 id
|
||||
@JsonProperty("item_nm")
|
||||
private String itemName; //아이템명
|
||||
@JsonProperty("restore_type")
|
||||
private String restoreType; //복구가능여부
|
||||
private STATUS status;
|
||||
@JsonProperty("create_by")
|
||||
private String createBy; //생성날짜
|
||||
public enum STATUS{
|
||||
PERMITTED,
|
||||
REJECT
|
||||
;
|
||||
}
|
||||
}
|
||||
@@ -1,10 +1,10 @@
|
||||
package com.caliverse.admin.domain.request;
|
||||
|
||||
import com.caliverse.admin.domain.entity.ItemList;
|
||||
import com.caliverse.admin.domain.entity.SEARCHTYPE;
|
||||
import com.caliverse.admin.dynamodb.entity.KeyParam;
|
||||
import com.fasterxml.jackson.annotation.JsonProperty;
|
||||
import lombok.*;
|
||||
|
||||
import java.util.List;
|
||||
import java.time.LocalDateTime;
|
||||
|
||||
@Data
|
||||
@@ -12,34 +12,34 @@ import java.time.LocalDateTime;
|
||||
@AllArgsConstructor
|
||||
@NoArgsConstructor
|
||||
public class ItemsRequest {
|
||||
private SEARCHTYPE searchType;
|
||||
private String searchData;
|
||||
private KeyParam pageKey;
|
||||
|
||||
@JsonProperty("user_guid")
|
||||
private String userGuid;
|
||||
|
||||
//guid
|
||||
@JsonProperty("item_guid")
|
||||
private String itemGuid;
|
||||
|
||||
//아이템id
|
||||
@JsonProperty("item_id")
|
||||
private String itemId;
|
||||
|
||||
//아이템 수
|
||||
@JsonProperty("item_count")
|
||||
private String itemCount;
|
||||
|
||||
private Integer itemCount;
|
||||
@JsonProperty("delete_count")
|
||||
private Integer deleteCount;
|
||||
//아이템명
|
||||
@JsonProperty("item_nm")
|
||||
private String itemName;
|
||||
//상태
|
||||
private String status;
|
||||
|
||||
//복구가능여부
|
||||
@JsonProperty("restore")
|
||||
private String restoreType;
|
||||
|
||||
//생성 날짜
|
||||
@JsonProperty("start_dt")
|
||||
private LocalDateTime startDt;
|
||||
|
||||
@JsonProperty("end_dt")
|
||||
private LocalDateTime endDt;
|
||||
|
||||
}
|
||||
|
||||
@@ -2,6 +2,7 @@ package com.caliverse.admin.domain.request;
|
||||
|
||||
import com.caliverse.admin.domain.entity.SEARCHTYPE;
|
||||
import com.caliverse.admin.domain.entity.WhiteList;
|
||||
import com.caliverse.admin.dynamodb.entity.EAuthAdminLevelType;
|
||||
import com.caliverse.admin.dynamodb.entity.KeyParam;
|
||||
import com.fasterxml.jackson.annotation.JsonProperty;
|
||||
import lombok.*;
|
||||
@@ -20,7 +21,7 @@ public class UsersRequest {
|
||||
@JsonProperty("new_nickname")
|
||||
private String newNickname;
|
||||
@JsonProperty("admin_level")
|
||||
private String adminLevel;
|
||||
private EAuthAdminLevelType adminLevel;
|
||||
|
||||
@JsonProperty("mail_type")
|
||||
private SEARCHTYPE mailType;
|
||||
|
||||
@@ -1,32 +0,0 @@
|
||||
package com.caliverse.admin.domain.request;
|
||||
|
||||
import com.caliverse.admin.domain.entity.WhiteList;
|
||||
import com.fasterxml.jackson.annotation.JsonProperty;
|
||||
import lombok.*;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
@Data
|
||||
@Builder
|
||||
@AllArgsConstructor
|
||||
@NoArgsConstructor
|
||||
public class WhiteListRequest {
|
||||
//guid
|
||||
private String guid;
|
||||
//닉네임
|
||||
private String name;
|
||||
//상태
|
||||
private WhiteList.STATUS status;
|
||||
//등록자
|
||||
private Long createBy;
|
||||
|
||||
private List<Guid> list;
|
||||
|
||||
@Getter
|
||||
public static class Guid{
|
||||
private Long id;
|
||||
private String guid;
|
||||
private String nickname;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -48,7 +48,7 @@ public class AdminResponse {
|
||||
private Long groupId;
|
||||
|
||||
@JsonProperty("auth_level_type")
|
||||
private EAuthAdminLevelType authLevelType;
|
||||
private AuthAdminLevelType authLevelType;
|
||||
|
||||
@JsonProperty("list")
|
||||
private List<Admin> adminList;
|
||||
|
||||
@@ -1,6 +1,5 @@
|
||||
package com.caliverse.admin.domain.response;
|
||||
|
||||
import com.caliverse.admin.domain.entity.ItemList;
|
||||
import com.fasterxml.jackson.annotation.JsonInclude;
|
||||
import com.fasterxml.jackson.annotation.JsonProperty;
|
||||
import lombok.AllArgsConstructor;
|
||||
@@ -8,8 +7,6 @@ import lombok.Builder;
|
||||
import lombok.Data;
|
||||
import lombok.NoArgsConstructor;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
|
||||
@Data
|
||||
@Builder
|
||||
|
||||
@@ -1,7 +1,8 @@
|
||||
package com.caliverse.admin.domain.response;
|
||||
|
||||
import com.caliverse.admin.domain.entity.Item;
|
||||
import com.caliverse.admin.domain.entity.ItemList;
|
||||
import com.caliverse.admin.domain.entity.ITEMLARGETYPE;
|
||||
import com.caliverse.admin.dynamodb.domain.doc.ItemDoc;
|
||||
import com.caliverse.admin.dynamodb.entity.EInvenEquipType;
|
||||
import com.fasterxml.jackson.annotation.JsonInclude;
|
||||
import com.fasterxml.jackson.annotation.JsonProperty;
|
||||
import lombok.AllArgsConstructor;
|
||||
@@ -9,7 +10,6 @@ import lombok.Builder;
|
||||
import lombok.Data;
|
||||
import lombok.NoArgsConstructor;
|
||||
|
||||
import java.time.LocalDateTime;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
@@ -36,13 +36,38 @@ public class ItemsResponse {
|
||||
@JsonProperty("page_no")
|
||||
private int pageNo;
|
||||
|
||||
private ItemList item;
|
||||
private List<ItemList> list;
|
||||
@JsonProperty("list")
|
||||
private List<Item> itemList;
|
||||
|
||||
private int totalCnt;
|
||||
private int resolve;
|
||||
private int unresolve;
|
||||
private String rate;
|
||||
private Map<String,String> pageKey;
|
||||
}
|
||||
|
||||
@Data
|
||||
@Builder
|
||||
public static class Item{
|
||||
private Integer id;
|
||||
@JsonProperty("user_guid")
|
||||
private String userGuid;
|
||||
@JsonProperty("item_guid")
|
||||
private String itemGuid;
|
||||
@JsonProperty("item_id")
|
||||
private Integer itemId;
|
||||
@JsonProperty("item_name")
|
||||
private String itemName;
|
||||
private Integer count;
|
||||
private Integer level;
|
||||
@JsonProperty("equip_type")
|
||||
private EInvenEquipType equipType;
|
||||
@JsonProperty("equiped_pos")
|
||||
private Integer equipedPos;
|
||||
@JsonProperty("item_type")
|
||||
private ITEMLARGETYPE itemType;
|
||||
@JsonProperty("create_dt")
|
||||
private String createDt;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -2,6 +2,7 @@ package com.caliverse.admin.domain.response;
|
||||
|
||||
import com.caliverse.admin.domain.entity.FriendRequest;
|
||||
import com.caliverse.admin.domain.entity.LANGUAGETYPE;
|
||||
import com.caliverse.admin.dynamodb.entity.EAuthAdminLevelType;
|
||||
import com.caliverse.admin.dynamodb.entity.ELanguageType;
|
||||
import com.fasterxml.jackson.annotation.JsonInclude;
|
||||
import com.fasterxml.jackson.annotation.JsonProperty;
|
||||
@@ -94,7 +95,7 @@ public class UsersResponse {
|
||||
private String walletUrl;
|
||||
// GM 타입
|
||||
@JsonProperty("admin_level")
|
||||
private String adminLevel;
|
||||
private EAuthAdminLevelType adminLevel;
|
||||
//예비 슬롯
|
||||
@JsonProperty("spare_slot")
|
||||
private String spareSlot;
|
||||
@@ -277,8 +278,8 @@ public class UsersResponse {
|
||||
@Builder
|
||||
public static class Item{
|
||||
@JsonProperty("item_id")
|
||||
private String itemId;
|
||||
private Double count;
|
||||
private Integer itemId;
|
||||
private Integer count;
|
||||
@JsonProperty("item_name")
|
||||
private String itemName;
|
||||
@JsonProperty("item_guid")
|
||||
|
||||
@@ -1,35 +0,0 @@
|
||||
package com.caliverse.admin.domain.response;
|
||||
|
||||
import com.caliverse.admin.domain.entity.WhiteList;
|
||||
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.util.List;
|
||||
|
||||
@Data
|
||||
@Builder
|
||||
@AllArgsConstructor
|
||||
@NoArgsConstructor
|
||||
public class WhiteListResponse {
|
||||
private int status;
|
||||
|
||||
private String result;
|
||||
@JsonProperty("data")
|
||||
private ResultData resultData;
|
||||
|
||||
@Data
|
||||
@Builder
|
||||
@JsonInclude(JsonInclude.Include.NON_NULL)
|
||||
public static class ResultData {
|
||||
|
||||
private String message;
|
||||
|
||||
@JsonProperty("list")
|
||||
private List<WhiteList> list ;
|
||||
|
||||
}
|
||||
}
|
||||
@@ -18,6 +18,7 @@ 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.ELandAuctionResult;
|
||||
import com.caliverse.admin.dynamodb.service.DynamodbUserService;
|
||||
import com.caliverse.admin.global.common.annotation.DynamoDBTransaction;
|
||||
import com.caliverse.admin.global.common.code.CommonCode;
|
||||
import com.caliverse.admin.global.common.code.ErrorCode;
|
||||
@@ -65,6 +66,8 @@ public class DynamoDBService {
|
||||
private final DynamoDbEnhancedClient enhancedClient;
|
||||
private final DynamoDBOperations DynamoDBOperations;
|
||||
|
||||
private final DynamodbUserService dynamodbUserService;
|
||||
|
||||
private final AdminMapper adminMapper;
|
||||
private final MetaDataHandler metaDataHandler;
|
||||
//private final HistoryService historyService;
|
||||
@@ -76,12 +79,14 @@ public class DynamoDBService {
|
||||
HistoryService historyService,
|
||||
MetaDataHandler metaDataHandler,
|
||||
DynamoDbEnhancedClient enhancedClient,
|
||||
DynamoDBOperations DynamoDBOperations) {
|
||||
DynamoDBOperations DynamoDBOperations,
|
||||
DynamodbUserService dynamodbUserService) {
|
||||
this.dynamoDbClient = dynamoDbClient;
|
||||
this.adminMapper = adminMapper;
|
||||
this.metaDataHandler = metaDataHandler;
|
||||
this.enhancedClient = enhancedClient;
|
||||
this.DynamoDBOperations = DynamoDBOperations;
|
||||
this.dynamodbUserService = dynamodbUserService;
|
||||
}
|
||||
|
||||
// guid check
|
||||
@@ -91,239 +96,6 @@ public class DynamoDBService {
|
||||
return item.isEmpty();
|
||||
}
|
||||
|
||||
// nickname > guid
|
||||
public String getNickNameByGuid(String primaryKey) {
|
||||
Map<String, Object> resMap = new HashMap<>();
|
||||
Map<String, AttributeValue> key = new HashMap<>();
|
||||
key.put("PK", AttributeValue.builder().s("user_nickname_registry#global").build());
|
||||
key.put("SK", AttributeValue.builder().s(primaryKey.toLowerCase(Locale.ENGLISH)).build());
|
||||
// GetItem 요청을 만듭니다.
|
||||
GetItemRequest getItemRequest = GetItemRequest.builder()
|
||||
.tableName(metaTable)
|
||||
.key(key)
|
||||
.build();
|
||||
|
||||
try {
|
||||
// GetItem 요청을 실행하고 응답을 받습니다.
|
||||
GetItemResponse response = dynamoDbClient.getItem(getItemRequest);
|
||||
|
||||
// 응답에서 원하는 속성을 가져옵니다.
|
||||
AttributeValue attributeValue = response.item().get("UserNicknameRegistryAttrib");
|
||||
|
||||
if (attributeValue != null) {
|
||||
String attrJsonString = attributeValue.s();
|
||||
// JSON 문자열을 파싱합니다.
|
||||
ObjectMapper objectMapper = new ObjectMapper();
|
||||
JsonNode attrJson = objectMapper.readTree(attrJsonString);
|
||||
|
||||
// 원하는 필드를 추출합니다.
|
||||
return attrJson.get("user_guid").asText();
|
||||
|
||||
}
|
||||
return primaryKey;
|
||||
} catch (Exception e) {
|
||||
log.error("getNickNameByGuid exception: {}", e.getMessage());
|
||||
throw new RestApiException(CommonCode.ERROR.getHttpStatus(), ErrorCode.DYNAMODB_CONNECTION_ERROR.getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
// guid > nickname
|
||||
public String getGuidByName(String guid){
|
||||
Map<String, AttributeValue> item = getItem("nickname#"+guid,"empty");
|
||||
|
||||
if(item.isEmpty()) return null;
|
||||
|
||||
Map<String, Object> attrMap = CommonUtils.stringByObject(item.get("NicknameAttrib").s());
|
||||
|
||||
return CommonUtils.objectToString(attrMap.get("nickname"));
|
||||
}
|
||||
|
||||
// guid > account_id
|
||||
public String getGuidByAccountId(String guid){
|
||||
Map<String, AttributeValue> item = getItem("user_base#"+guid,"empty");
|
||||
|
||||
if(item.isEmpty()) return null;
|
||||
|
||||
Map<String, Object> attrMap = CommonUtils.stringByObject(item.get("UserBaseAttrib").s());
|
||||
|
||||
return CommonUtils.objectToString(attrMap.get("account_id"));
|
||||
}
|
||||
|
||||
// account_id > guid
|
||||
public String getAccountIdByGuid(Long id){
|
||||
Map<String, AttributeValue> item = getItem("account_base#"+id,"empty");
|
||||
|
||||
if(item.isEmpty()) return null;
|
||||
|
||||
Map<String, Object> attrMap = CommonUtils.stringByObject(item.get("AccountBaseAttrib").s());
|
||||
|
||||
return CommonUtils.objectToString(attrMap.get("user_guid"));
|
||||
}
|
||||
|
||||
// 유저 언어타입
|
||||
public String getUserLanguage(String guid){
|
||||
String account_id = getGuidByAccountId(guid);
|
||||
Map<String, AttributeValue> item = getItem("account_base#" + account_id,"empty");
|
||||
|
||||
if(item.isEmpty()) return null;
|
||||
|
||||
Map<String, Object> attrMap = CommonUtils.stringByObject(item.get("AccountBaseAttrib").s());
|
||||
|
||||
return CommonUtils.objectToString(attrMap.get("language_type"));
|
||||
}
|
||||
|
||||
// 유저조회 타입별 분기
|
||||
public Map<String,String> findUsersBykey(String searchType, String searchKey){
|
||||
Map<String, String> resultMap = new HashMap<>();
|
||||
Map<String, AttributeValue> key = new HashMap<>();
|
||||
try {
|
||||
if(searchType.equals(SEARCHTYPE.NAME.name())){
|
||||
return getUsersByName(searchKey.toLowerCase()); //nickname은 무조건 소문자
|
||||
}else if(searchType.equals(SEARCHTYPE.GUID.name())){
|
||||
return getUsersByGuid(searchKey);
|
||||
}else if(searchType.equals(SEARCHTYPE.ACCOUNT.name())){
|
||||
return getUsersByAccountId(searchKey);
|
||||
}
|
||||
//else if(searchType.equals(SEARCHTYPE.TEMP_DATA.name())){
|
||||
// return historyService.insertTempMetaData();
|
||||
//}
|
||||
|
||||
|
||||
return resultMap;
|
||||
} catch (Exception e) {
|
||||
log.error("findUsersBykey exception: {}", e.getMessage());
|
||||
throw new RestApiException(CommonCode.ERROR.getHttpStatus(), ErrorCode.DYNAMODB_CONNECTION_ERROR.getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
// 유저조회 닉네임
|
||||
// return guid, 닉네임
|
||||
public Map<String, String> getUsersByName(String searchKey){
|
||||
Map<String,String> resultMap = null;
|
||||
|
||||
QueryRequest queryRequest = QueryRequest.builder()
|
||||
.tableName(metaTable)
|
||||
.keyConditionExpression("PK = :pkValue AND SK = :skValue") // 파티션 키와 조건식 설정
|
||||
// .expressionAttributeValues(Map.of(":pkValue", AttributeValue.builder().s("nickname#"+searchKey).build()
|
||||
// ,":skValue", AttributeValue.builder().s("nickname#").build()))
|
||||
.expressionAttributeValues(Map.of(":pkValue", AttributeValue.builder().s("user_nickname_registry#global").build()
|
||||
,":skValue", AttributeValue.builder().s(searchKey).build()))
|
||||
.build();
|
||||
|
||||
try{
|
||||
// 쿼리 실행
|
||||
QueryResponse response = dynamoDbClient.query(queryRequest);
|
||||
|
||||
// 응답에서 원하는 속성을 가져옵니다.
|
||||
for (Map<String, AttributeValue> item : response.items()) {
|
||||
// AttributeValue attrValue = item.get("Attr");
|
||||
AttributeValue attrValue = item.get("UserNicknameRegistryAttrib");
|
||||
if (attrValue != null) {
|
||||
resultMap = new HashMap<>();
|
||||
// "Attr" 속성의 값을 읽어옵니다.
|
||||
String attrJson = attrValue.s();
|
||||
|
||||
// JSON 문자열을 파싱하여 Map 또는 다른 객체로 변환합니다.
|
||||
ObjectMapper objectMapper = new ObjectMapper();
|
||||
Map<String, Object> attrMap = objectMapper.readValue(attrJson, new TypeReference<Map<String, Object>>() {
|
||||
});
|
||||
|
||||
// resultMap.put("guid", (String) attrMap.get("AccountGuid"));
|
||||
// resultMap.put("nickname", (String) attrMap.get("AccountId"));
|
||||
resultMap.put("guid", (String) attrMap.get("user_guid"));
|
||||
resultMap.put("nickname", searchKey);
|
||||
}
|
||||
}
|
||||
return resultMap;
|
||||
}catch (Exception e){
|
||||
log.error("getUsersByName exception: {}", e.getMessage());
|
||||
throw new RestApiException(CommonCode.ERROR.getHttpStatus(), ErrorCode.DYNAMODB_CONNECTION_ERROR.getMessage());
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
// 유저조회 guid
|
||||
// return guid, account_id
|
||||
public Map<String, String> getUsersByGuid(String searchKey){
|
||||
Map<String,String> resultMap = null;
|
||||
|
||||
QueryRequest queryRequest = QueryRequest.builder()
|
||||
.tableName(metaTable)
|
||||
.keyConditionExpression("PK = :pkValue AND SK = :skValue") // 파티션 키와 조건식 설정
|
||||
.expressionAttributeValues(Map.of(":pkValue", AttributeValue.builder().s("user_base#"+searchKey).build()
|
||||
,":skValue", AttributeValue.builder().s("empty").build()))
|
||||
.build();
|
||||
|
||||
try{
|
||||
// 쿼리 실행
|
||||
QueryResponse response = dynamoDbClient.query(queryRequest);
|
||||
|
||||
// 응답에서 원하는 속성을 가져옵니다.
|
||||
for (Map<String, AttributeValue> item : response.items()) {
|
||||
AttributeValue attrValue = item.get("UserBaseAttrib");
|
||||
if (attrValue != null) {
|
||||
resultMap = new HashMap<>();
|
||||
// "Attr" 속성의 값을 읽어옵니다.
|
||||
String attrJson = attrValue.s();
|
||||
|
||||
// JSON 문자열을 파싱하여 Map 또는 다른 객체로 변환합니다.
|
||||
ObjectMapper objectMapper = new ObjectMapper();
|
||||
Map<String, Object> attrMap = objectMapper.readValue(attrJson, new TypeReference<Map<String, Object>>() {
|
||||
});
|
||||
|
||||
resultMap.put("guid", searchKey);
|
||||
resultMap.put("nickname", (String) attrMap.get("account_id"));
|
||||
}
|
||||
}
|
||||
return resultMap;
|
||||
}catch (Exception e){
|
||||
log.error("getUsersByGuid exception: {}", e.getMessage());
|
||||
throw new RestApiException(CommonCode.ERROR.getHttpStatus(), ErrorCode.DYNAMODB_CONNECTION_ERROR.getMessage());
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
//유저조회 account_id
|
||||
//return guid, account_id
|
||||
public Map<String, String> getUsersByAccountId(String searchKey){
|
||||
Map<String,String> resultMap = null;
|
||||
|
||||
QueryRequest queryRequest = QueryRequest.builder()
|
||||
.tableName(metaTable)
|
||||
.keyConditionExpression("PK = :pkValue AND SK = :skValue") // 파티션 키와 조건식 설정
|
||||
.expressionAttributeValues(Map.of(":pkValue", AttributeValue.builder().s("account_base#"+searchKey).build()
|
||||
,":skValue", AttributeValue.builder().s("empty").build()))
|
||||
.build();
|
||||
|
||||
try{
|
||||
// 쿼리 실행
|
||||
QueryResponse response = dynamoDbClient.query(queryRequest);
|
||||
|
||||
// 응답에서 원하는 속성을 가져옵니다.
|
||||
for (Map<String, AttributeValue> item : response.items()) {
|
||||
AttributeValue attrValue = item.get("AccountBaseAttrib");
|
||||
if (attrValue != null) {
|
||||
resultMap = new HashMap<>();
|
||||
// "Attr" 속성의 값을 읽어옵니다.
|
||||
String attrJson = attrValue.s();
|
||||
|
||||
// JSON 문자열을 파싱하여 Map 또는 다른 객체로 변환합니다.
|
||||
ObjectMapper objectMapper = new ObjectMapper();
|
||||
Map<String, Object> attrMap = objectMapper.readValue(attrJson, new TypeReference<Map<String, Object>>() {
|
||||
});
|
||||
|
||||
resultMap.put("guid", (String) attrMap.get("user_guid"));
|
||||
resultMap.put("nickname", (String) attrMap.get("account_id"));
|
||||
}
|
||||
}
|
||||
return resultMap;
|
||||
}catch (Exception e){
|
||||
log.error("getUsersByAccountId exception: {}", e.getMessage());
|
||||
throw new RestApiException(CommonCode.ERROR.getHttpStatus(), ErrorCode.DYNAMODB_CONNECTION_ERROR.getMessage());
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
// public Map<String, Object> getAccountInfo(String guid){
|
||||
// Map<String, Object> resMap = new HashMap<>();
|
||||
@@ -371,45 +143,6 @@ public class DynamoDBService {
|
||||
// } catch (Exception e) {
|
||||
// throw new RestApiException(CommonCode.ERROR.getHttpStatus(), ErrorCode.DYNAMODB_CONNECTION_ERROR.getMessage());
|
||||
// }
|
||||
// }
|
||||
//
|
||||
// // 유저조회 - 기본정보
|
||||
// public Map<String, Object> getCharInfo(String guid){
|
||||
// Map<String, Object> resMap = new HashMap<>();
|
||||
//
|
||||
// String key = "PK = :pkValue AND SK = :skValue";
|
||||
// Map<String, AttributeValue> values = Map.of(":pkValue", AttributeValue.builder().s("money#"+guid).build()
|
||||
// ,":skValue", AttributeValue.builder().s("empty").build());
|
||||
//
|
||||
// try {
|
||||
// // 쿼리 실행
|
||||
// QueryResponse response = executeQuery(key, values);
|
||||
//
|
||||
// // 응답에서 원하는 속성을 가져옵니다.
|
||||
// for (Map<String, AttributeValue> item : response.items()) {
|
||||
//
|
||||
// //캐릭터 CharInfo 조회
|
||||
// AttributeValue charValue = item.get("MoneyAttrib");
|
||||
// if (charValue != null) {
|
||||
// // "Attr" 속성의 값을 읽어옵니다.
|
||||
// Map<String, AttributeValue> attrMap = charValue.m();
|
||||
//
|
||||
// resMap.put("charInfo", UsersResponse.CharInfo.builder()
|
||||
// .characterName(getGuidByName(guid))
|
||||
// .level(CommonUtils.objectToString(null))
|
||||
// .goldCali(CommonUtils.objectToString(attrMap.get("gold").n()))
|
||||
// .redCali(CommonUtils.objectToString(attrMap.get("calium").n()))
|
||||
// .blackCali(CommonUtils.objectToString(attrMap.get("ruby").n()))
|
||||
// .blueCali(CommonUtils.objectToString(attrMap.get("sapphire").n()))
|
||||
// .build());
|
||||
// }
|
||||
// }
|
||||
// log.info("getCharInfo CharInfo: {}", resMap);
|
||||
//
|
||||
// return resMap;
|
||||
// } catch (Exception e) {
|
||||
// throw new RestApiException(CommonCode.ERROR.getHttpStatus(), ErrorCode.DYNAMODB_CONNECTION_ERROR.getMessage());
|
||||
// }
|
||||
// }
|
||||
|
||||
// 유저조회 - 아바타
|
||||
@@ -494,67 +227,6 @@ public class DynamoDBService {
|
||||
}
|
||||
}
|
||||
|
||||
//guid 로 item 테이블 조회
|
||||
public Map<String, Object> getItemTable(String guid){
|
||||
QueryRequest queryRequest = QueryRequest.builder()
|
||||
.tableName(metaTable)
|
||||
.keyConditionExpression("PK = :pkValue AND SK = :skValue") // 파티션 키와 조건식 설정
|
||||
.expressionAttributeValues(
|
||||
Map.of(":pkValue", AttributeValue.builder().s("item#"+guid).build()
|
||||
,":skValue", AttributeValue.builder().s("item#"+guid).build()))
|
||||
.build();
|
||||
|
||||
try {
|
||||
// 쿼리 실행
|
||||
QueryResponse response = dynamoDbClient.query(queryRequest);
|
||||
|
||||
// 응답에서 원하는 속성을 가져옵니다.
|
||||
for (Map<String, AttributeValue> item : response.items()) {
|
||||
AttributeValue attrValue = item.get("Attr");
|
||||
if (attrValue != null) {
|
||||
// "Attr" 속성의 값을 읽어옵니다.
|
||||
String attrJson = attrValue.s();
|
||||
|
||||
// JSON 문자열을 파싱하여 Map 또는 다른 객체로 변환합니다.
|
||||
ObjectMapper objectMapper = new ObjectMapper();
|
||||
// JSON 문자열을 Map으로 파싱
|
||||
Map<String, Object> attrMap = objectMapper.readValue(attrJson, new TypeReference<Map<String, Object>>() {});
|
||||
|
||||
return attrMap;
|
||||
}
|
||||
}
|
||||
|
||||
return null;
|
||||
} catch (Exception e) {
|
||||
throw new RestApiException(CommonCode.ERROR.getHttpStatus(), ErrorCode.DYNAMODB_CONNECTION_ERROR.getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
public void insertUpdateData(String guid, String type, boolean flag) {
|
||||
|
||||
// 업데이트할 데이터 맵 생성
|
||||
Map<String, AttributeValue> key = new HashMap<>();
|
||||
key.put("PK", AttributeValue.builder().s("char#"+guid).build());
|
||||
key.put("SK", AttributeValue.builder().s("char#"+guid).build());
|
||||
|
||||
Map<String, AttributeValueUpdate> attributeUpdates = new HashMap<>();
|
||||
|
||||
attributeUpdates.put(type, AttributeValueUpdate.builder()
|
||||
.action(AttributeAction.PUT)
|
||||
.value(AttributeValue.builder().bool(flag).build())
|
||||
.build());
|
||||
|
||||
// UpdateItem 요청 작성
|
||||
UpdateItemRequest updateItemRequest = UpdateItemRequest.builder()
|
||||
.tableName(metaTable)
|
||||
.key(key)
|
||||
.attributeUpdates(attributeUpdates)
|
||||
.build();
|
||||
|
||||
// 데이터 업데이트 또는 인서트 요청
|
||||
dynamoDbClient.updateItem(updateItemRequest);
|
||||
}
|
||||
|
||||
// dynamoDB 쿼리 리턴
|
||||
public QueryResponse executeQuery(String key, Map<String, AttributeValue> values) {
|
||||
QueryRequest getItemRequest = QueryRequest.builder()
|
||||
@@ -634,107 +306,6 @@ public class DynamoDBService {
|
||||
|
||||
}
|
||||
|
||||
public void updateBlockUserStart(BlackList blockUser){
|
||||
try{
|
||||
String accountId = getGuidByAccountId(blockUser.getGuid());
|
||||
SANCTIONS reasonType = blockUser.getSanctions();
|
||||
// SANCTIONSTYPE policyType = blockUser.getType();
|
||||
// List<SANCTIONSTYPE> listPolicyType = new ArrayList<>();
|
||||
// listPolicyType.add(policyType);
|
||||
DateTimeFormatter formatter = DateTimeFormatter.ofPattern("yyyy-MM-dd'T'HH:mm:ss.SSSSSSS");
|
||||
String startTime = blockUser.getStartDt().format(formatter);
|
||||
String endTime = blockUser.getEndDt().format(formatter);
|
||||
|
||||
Map<String, AttributeValue> item = getItem("account_base#" + accountId,"empty");
|
||||
|
||||
String InfoJson = item.get("AccountBaseAttrib").s();
|
||||
log.info("updateBlockUserStart Before AccountBaseAttrib: {}", InfoJson);
|
||||
|
||||
ObjectMapper objectMapper = new ObjectMapper();
|
||||
JsonNode infoNode = objectMapper.readTree(InfoJson);
|
||||
|
||||
((ObjectNode) infoNode).put("block_start_datetime", startTime);
|
||||
((ObjectNode) infoNode).put("block_end_datetime", endTime);
|
||||
ArrayNode policyArray = objectMapper.createArrayNode();
|
||||
policyArray.add(blockUser.getType().toString());
|
||||
((ObjectNode) infoNode).set("block_policy", policyArray);
|
||||
// ((ObjectNode) infoNode).put("block_policy", listPolicyType.toString());
|
||||
((ObjectNode) infoNode).put("block_reason", reasonType.toString());
|
||||
|
||||
String updatedInfoJson = infoNode.toString();
|
||||
String nowDateTime = LocalDateTime.now().format(formatter);
|
||||
log.info("updateBlockUserStart Tobe AccountBaseAttrib: {}", updatedInfoJson);
|
||||
|
||||
Map<String, AttributeValue> expressionAttributeValues = new HashMap<>();
|
||||
expressionAttributeValues.put(":newAttrib", AttributeValue.builder().s(updatedInfoJson).build());
|
||||
expressionAttributeValues.put(":nowDate", AttributeValue.builder().s(nowDateTime).build());
|
||||
|
||||
String updateExpression = "SET AccountBaseAttrib = :newAttrib, UpdatedDateTime = :nowDate";
|
||||
|
||||
UpdateItemRequest updateRequest = UpdateItemRequest.builder()
|
||||
.tableName(metaTable)
|
||||
.key(Map.of(
|
||||
"PK", AttributeValue.builder().s("account_base#" + accountId).build(),
|
||||
"SK", AttributeValue.builder().s("empty").build()))
|
||||
.updateExpression(updateExpression)
|
||||
.expressionAttributeValues(expressionAttributeValues)
|
||||
.returnValues(ReturnValue.ALL_NEW) // 업데이트 후의 값을 반환하려면 지정
|
||||
.build();
|
||||
|
||||
|
||||
dynamoDbClient.updateItem(updateRequest);
|
||||
}catch(Exception e){
|
||||
log.error("updateBlockUserStart: " + e.getMessage());
|
||||
throw new RestApiException(CommonCode.ERROR.getHttpStatus(), ErrorCode.DYNAMODB_CONNECTION_ERROR.getMessage() );
|
||||
}
|
||||
}
|
||||
|
||||
public void updateBlockUserEnd(String guid){
|
||||
try{
|
||||
String accountId = getGuidByAccountId(guid);
|
||||
DateTimeFormatter formatter = DateTimeFormatter.ofPattern("yyyy-MM-dd'T'HH:mm:ss.SSSSSSS");
|
||||
String endTime = LocalDateTime.of(9999, 12, 31, 23, 59, 59, 999999900).format(formatter);
|
||||
|
||||
Map<String, AttributeValue> item = getItem("account_base#" + accountId,"empty");
|
||||
|
||||
String InfoJson = item.get("AccountBaseAttrib").s();
|
||||
log.info("updateBlockUserEnd Before AccountBaseAttrib: {}", InfoJson);
|
||||
|
||||
ObjectMapper objectMapper = new ObjectMapper();
|
||||
JsonNode infoNode = objectMapper.readTree(InfoJson);
|
||||
|
||||
((ObjectNode) infoNode).put("block_start_datetime", endTime);
|
||||
((ObjectNode) infoNode).put("block_end_datetime", endTime);
|
||||
((ObjectNode) infoNode).put("block_policy", new ArrayList<>().toString());
|
||||
((ObjectNode) infoNode).put("block_reason", "");
|
||||
|
||||
String updatedInfoJson = infoNode.toString();
|
||||
String nowDateTime = LocalDateTime.now().format(formatter);
|
||||
log.info("updateBlockUserEnd Tobe AccountBaseAttrib: {}", updatedInfoJson);
|
||||
|
||||
Map<String, AttributeValue> expressionAttributeValues = new HashMap<>();
|
||||
expressionAttributeValues.put(":newAttrib", AttributeValue.builder().s(updatedInfoJson).build());
|
||||
expressionAttributeValues.put(":nowDate", AttributeValue.builder().s(nowDateTime).build());
|
||||
|
||||
String updateExpression = "SET AccountBaseAttrib = :newAttrib, UpdatedDateTime = :nowDate";
|
||||
|
||||
UpdateItemRequest updateRequest = UpdateItemRequest.builder()
|
||||
.tableName(metaTable)
|
||||
.key(Map.of(
|
||||
"PK", AttributeValue.builder().s("account_base#" + accountId).build(),
|
||||
"SK", AttributeValue.builder().s("empty").build()))
|
||||
.updateExpression(updateExpression)
|
||||
.expressionAttributeValues(expressionAttributeValues)
|
||||
.returnValues(ReturnValue.ALL_NEW) // 업데이트 후의 값을 반환하려면 지정
|
||||
.build();
|
||||
|
||||
dynamoDbClient.updateItem(updateRequest);
|
||||
}catch(Exception e){
|
||||
log.error("updateBlockUserEnd: {}", e.getMessage());
|
||||
throw new RestApiException(CommonCode.ERROR.getHttpStatus(), ErrorCode.DYNAMODB_CONNECTION_ERROR.getMessage() );
|
||||
}
|
||||
}
|
||||
|
||||
// 닉네임 변경
|
||||
public void updateNickname(String guid,String nickname,String newNickname){
|
||||
try{
|
||||
@@ -753,49 +324,6 @@ public class DynamoDBService {
|
||||
|
||||
}
|
||||
|
||||
// GM 권한 변경
|
||||
public void updateAdminLevel(String guid, String type){
|
||||
AuthAdminLevelType adminLevel = RabbitMqUtils.getUserAdminLevelType(type);
|
||||
|
||||
try{
|
||||
String accountId = getGuidByAccountId(guid);
|
||||
Map<String, AttributeValue> item = getItem("account_base#" + accountId, "empty");
|
||||
|
||||
String InfoJson = item.get("AccountBaseAttrib").s();
|
||||
log.info("updateAdminLevel Before AccountBaseAttrib: {}", InfoJson);
|
||||
|
||||
ObjectMapper objectMapper = new ObjectMapper();
|
||||
JsonNode infoNode = objectMapper.readTree(InfoJson);
|
||||
|
||||
((ObjectNode) infoNode).put("auth_amdin_level_type", adminLevel.getNumber());
|
||||
|
||||
String updatedInfoJson = infoNode.toString();
|
||||
log.info("updateAdminLevel Tobe AccountBaseAttrib: {}", updatedInfoJson);
|
||||
|
||||
Map<String, AttributeValue> expressionAttributeValues = new HashMap<>();
|
||||
expressionAttributeValues.put(":newAttrib", AttributeValue.builder().s(updatedInfoJson).build());
|
||||
|
||||
String updateExpression = "SET AccountBaseAttrib = :newAttrib";
|
||||
|
||||
UpdateItemRequest updateRequest = UpdateItemRequest.builder()
|
||||
.tableName(metaTable)
|
||||
.key(Map.of(
|
||||
"PK", AttributeValue.builder().s("account_base#" + accountId).build(),
|
||||
"SK", AttributeValue.builder().s("empty").build()))
|
||||
.updateExpression(updateExpression)
|
||||
.expressionAttributeValues(expressionAttributeValues)
|
||||
.returnValues(ReturnValue.ALL_NEW) // 업데이트 후의 값을 반환하려면 지정
|
||||
.build();
|
||||
|
||||
|
||||
dynamoDbClient.updateItem(updateRequest);
|
||||
}catch (Exception e){
|
||||
log.error("updateAdminLevel: {}", e.getMessage());
|
||||
throw new RestApiException(CommonCode.ERROR.getHttpStatus(), ErrorCode.DYNAMODB_CONNECTION_ERROR.getMessage() );
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
public void updateCharInfo(String guid, String newNickname) throws JsonProcessingException {
|
||||
|
||||
// 기존 CharInfo 값 가져오기
|
||||
@@ -832,6 +360,7 @@ public class DynamoDBService {
|
||||
|
||||
dynamoDbClient.updateItem(updateRequest);
|
||||
}
|
||||
|
||||
public void createNewNickName(String guid, String newNickname) {
|
||||
String attrJson = String.format("{\"AccountGuid\":\"%s\",\"AccountId\":\"%s\"}", guid, newNickname);
|
||||
|
||||
@@ -1180,61 +709,61 @@ public class DynamoDBService {
|
||||
}
|
||||
|
||||
//아이템 내역 조회
|
||||
public List<ItemList> getItems(String guid){
|
||||
List<ItemList> list = new ArrayList<>();
|
||||
|
||||
String key = "PK = :pkValue";
|
||||
Map<String, AttributeValue> values = Map.of(":pkValue", AttributeValue.builder().s("item#"+guid).build());
|
||||
|
||||
// QueryRequest queryRequest = QueryRequest.builder()
|
||||
// .tableName(metaTable)
|
||||
// .keyConditionExpression("PK = :pkValue") // 파티션 키와 조건식 설정
|
||||
// .expressionAttributeValues(Map.of(":pkValue", AttributeValue.builder().s("item#"+guid).build()))
|
||||
// .build();
|
||||
|
||||
try {
|
||||
// 쿼리 실행
|
||||
QueryResponse response = executeQuery(key, values);
|
||||
|
||||
int row = 1;
|
||||
// 응답에서 원하는 속성을 가져옵니다.
|
||||
for (Map<String, AttributeValue> item : response.items()) {
|
||||
AttributeValue attrValue = item.get("ItemAttrib");
|
||||
if (attrValue != null) {
|
||||
// "Attr" 속성의 값을 읽어옵니다.
|
||||
String attrJson = attrValue.s();
|
||||
|
||||
// JSON 문자열을 파싱하여 Map 또는 다른 객체로 변환합니다.
|
||||
ObjectMapper objectMapper = new ObjectMapper();
|
||||
Map<String, Object> attrMap = objectMapper.readValue(attrJson, new TypeReference<Map<String, Object>>() {
|
||||
});
|
||||
|
||||
String item_nm = metaDataHandler.getMetaItemNameData(CommonUtils.objectToInteger(attrMap.get("item_meta_id")));
|
||||
ItemList itemInfo = ItemList.builder()
|
||||
.rowNum((long) row)
|
||||
.guid(guid)
|
||||
.itemId(attrMap.get("item_meta_id").toString())
|
||||
.itemName(metaDataHandler.getTextStringData(item_nm))
|
||||
.status(ItemList.STATUS.PERMITTED)
|
||||
.restoreType("")
|
||||
.createBy(item.get("CreatedDateTime").s()).build();
|
||||
|
||||
list.add(itemInfo);
|
||||
|
||||
row++;
|
||||
}
|
||||
}
|
||||
log.info("getItems Response ItemInfo: {}", list);
|
||||
}
|
||||
catch (JsonProcessingException jpe){
|
||||
log.error("getItems JsonProcessingException: {}", jpe.getMessage());
|
||||
throw new RestApiException(CommonCode.ERROR.getHttpStatus(), ErrorCode.DYNAMODB_CONNECTION_ERROR.getMessage());
|
||||
}catch (Exception e){
|
||||
log.error("getItems: {}", e.getMessage());
|
||||
throw new RestApiException(CommonCode.ERROR.getHttpStatus(), ErrorCode.DYNAMODB_CONNECTION_ERROR.getMessage());
|
||||
}
|
||||
return list;
|
||||
}
|
||||
// public List<ItemList> getItems(String guid){
|
||||
// List<ItemList> list = new ArrayList<>();
|
||||
//
|
||||
// String key = "PK = :pkValue";
|
||||
// Map<String, AttributeValue> values = Map.of(":pkValue", AttributeValue.builder().s("item#"+guid).build());
|
||||
//
|
||||
//// QueryRequest queryRequest = QueryRequest.builder()
|
||||
//// .tableName(metaTable)
|
||||
//// .keyConditionExpression("PK = :pkValue") // 파티션 키와 조건식 설정
|
||||
//// .expressionAttributeValues(Map.of(":pkValue", AttributeValue.builder().s("item#"+guid).build()))
|
||||
//// .build();
|
||||
//
|
||||
// try {
|
||||
// // 쿼리 실행
|
||||
// QueryResponse response = executeQuery(key, values);
|
||||
//
|
||||
// int row = 1;
|
||||
// // 응답에서 원하는 속성을 가져옵니다.
|
||||
// for (Map<String, AttributeValue> item : response.items()) {
|
||||
// AttributeValue attrValue = item.get("ItemAttrib");
|
||||
// if (attrValue != null) {
|
||||
// // "Attr" 속성의 값을 읽어옵니다.
|
||||
// String attrJson = attrValue.s();
|
||||
//
|
||||
// // JSON 문자열을 파싱하여 Map 또는 다른 객체로 변환합니다.
|
||||
// ObjectMapper objectMapper = new ObjectMapper();
|
||||
// Map<String, Object> attrMap = objectMapper.readValue(attrJson, new TypeReference<Map<String, Object>>() {
|
||||
// });
|
||||
//
|
||||
// String item_nm = metaDataHandler.getMetaItemNameData(CommonUtils.objectToInteger(attrMap.get("item_meta_id")));
|
||||
// ItemList itemInfo = ItemList.builder()
|
||||
// .rowNum((long) row)
|
||||
// .guid(guid)
|
||||
// .itemId(attrMap.get("item_meta_id").toString())
|
||||
// .itemName(metaDataHandler.getTextStringData(item_nm))
|
||||
// .status(ItemList.STATUS.PERMITTED)
|
||||
// .restoreType("")
|
||||
// .createBy(item.get("CreatedDateTime").s()).build();
|
||||
//
|
||||
// list.add(itemInfo);
|
||||
//
|
||||
// row++;
|
||||
// }
|
||||
// }
|
||||
// log.info("getItems Response ItemInfo: {}", list);
|
||||
// }
|
||||
// catch (JsonProcessingException jpe){
|
||||
// log.error("getItems JsonProcessingException: {}", jpe.getMessage());
|
||||
// throw new RestApiException(CommonCode.ERROR.getHttpStatus(), ErrorCode.DYNAMODB_CONNECTION_ERROR.getMessage());
|
||||
// }catch (Exception e){
|
||||
// log.error("getItems: {}", e.getMessage());
|
||||
// throw new RestApiException(CommonCode.ERROR.getHttpStatus(), ErrorCode.DYNAMODB_CONNECTION_ERROR.getMessage());
|
||||
// }
|
||||
// return list;
|
||||
// }
|
||||
|
||||
//아이템 - 의상 조회
|
||||
public Map<String, Object> getCloth(String guid){
|
||||
@@ -1360,9 +889,9 @@ public class DynamoDBService {
|
||||
String item_type = metaDataHandler.getMetaItemLargeTypeData(item_id);
|
||||
|
||||
UsersResponse.Item inventory = UsersResponse.Item.builder()
|
||||
.itemId(CommonUtils.objectToString(item_id))
|
||||
.itemId(item_id)
|
||||
.itemName(item_nm)
|
||||
.count(CommonUtils.objectToDouble(attrMap.get("item_stack_count")))
|
||||
.count(CommonUtils.objectToInteger(attrMap.get("item_stack_count")))
|
||||
.itemGuid(CommonUtils.objectToString(attrMap.get("item_guid")))
|
||||
.build();
|
||||
|
||||
@@ -1396,55 +925,6 @@ public class DynamoDBService {
|
||||
}
|
||||
}
|
||||
|
||||
// 유저 조회 - 메일
|
||||
public List<UsersResponse.Mail> getMail(String guid, String type){
|
||||
List<UsersResponse.Mail> resList = new ArrayList<>();
|
||||
|
||||
String key = "PK = :pkValue";
|
||||
Map<String, AttributeValue> values = null;
|
||||
if(type.equals(SEARCHTYPE.SEND.name())){
|
||||
values = Map.of(":pkValue", AttributeValue.builder().s("sent_mail#"+guid).build());
|
||||
}else{
|
||||
values = Map.of(":pkValue", AttributeValue.builder().s("recv_mail#"+guid).build());
|
||||
}
|
||||
|
||||
try {
|
||||
excuteItems(executeQuery(key, values), "MailAttrib")
|
||||
.forEach(attrMap -> {
|
||||
List<UsersResponse.MailItem> itemList = new ArrayList<>();
|
||||
for (Map<String,Object> val : (List<Map<String,Object>>)attrMap.get("item_list")){
|
||||
UsersResponse.MailItem item = new UsersResponse.MailItem();
|
||||
item.setItemId(CommonUtils.objectToString(val.get("ItemId")));
|
||||
item.setCount(CommonUtils.objectToDouble(val.get("Count")));
|
||||
String item_nm = metaDataHandler.getMetaItemNameData(CommonUtils.objectToInteger(val.get("ItemId")));
|
||||
item.setItemName(metaDataHandler.getTextStringData(item_nm));
|
||||
itemList.add(item);
|
||||
}
|
||||
|
||||
UsersResponse.Mail mail = UsersResponse.Mail.builder()
|
||||
.mailGuid(CommonUtils.objectToString(attrMap.get("mail_guid")))
|
||||
.createDt(CommonUtils.objectToString(attrMap.get("create_time")))
|
||||
.title(CommonUtils.objectToString(attrMap.get("title")))
|
||||
.content(CommonUtils.objectToString(attrMap.get("text")))
|
||||
.receiveNickname(CommonUtils.objectToString(attrMap.get("receiver_nickname")))
|
||||
.senderNickname(CommonUtils.objectToString(attrMap.get("sender_nickname")))
|
||||
.isGetItem((boolean)attrMap.get("is_get_item"))
|
||||
.status((boolean) attrMap.get("is_read"))
|
||||
.isSystemMail((boolean) attrMap.get("is_system_mail"))
|
||||
.mailItemList(itemList)
|
||||
.build();
|
||||
|
||||
resList.add(mail);
|
||||
});
|
||||
log.info("getMail Response MailInfo: {}", resList);
|
||||
|
||||
return resList;
|
||||
} catch (Exception e) {
|
||||
log.error("getMail: {}", e.getMessage());
|
||||
throw new RestApiException(CommonCode.ERROR.getHttpStatus(), ErrorCode.DYNAMODB_CONNECTION_ERROR.getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
// 유저 조회 - 우편 삭제
|
||||
public String deleteMail(String type, String guid, String mail_guid) {
|
||||
Map<String, AttributeValue> itemAttributes = new HashMap<>();
|
||||
@@ -1559,78 +1039,78 @@ public class DynamoDBService {
|
||||
}
|
||||
|
||||
// 아이템 삭제
|
||||
public String deleteItem(String guid, String item_guid) {
|
||||
Map<String, AttributeValue> itemAttributes = new HashMap<>();
|
||||
itemAttributes.put("PK", AttributeValue.builder().s("item#" + guid).build());
|
||||
itemAttributes.put("SK", AttributeValue.builder().s(item_guid).build());
|
||||
try {
|
||||
Map<String, AttributeValue> item = getItem("item#" + guid, item_guid);
|
||||
log.info("deleteItem PK: {}, SK: {}", "item#" + guid, item_guid);
|
||||
|
||||
DeleteItemRequest request = DeleteItemRequest.builder()
|
||||
.tableName(metaTable)
|
||||
.key(itemAttributes)
|
||||
.build();
|
||||
|
||||
DeleteItemResponse response = dynamoDbClient.deleteItem(request);
|
||||
|
||||
if(response.sdkHttpResponse().isSuccessful())
|
||||
return item.toString();
|
||||
|
||||
return "";
|
||||
}catch (ConditionalCheckFailedException e) {
|
||||
log.error("deleteItem Conditional check failed: {}", e.getMessage());
|
||||
throw new RestApiException(CommonCode.ERROR.getHttpStatus(), ErrorCode.DYNAMODB_CONNECTION_ERROR.getMessage());
|
||||
}catch(Exception e){
|
||||
log.error("deleteItem: {}", e.getMessage());
|
||||
throw new RestApiException(CommonCode.ERROR.getHttpStatus(), ErrorCode.DYNAMODB_CONNECTION_ERROR.getMessage());
|
||||
}
|
||||
}
|
||||
// public String deleteItem(String guid, String item_guid) {
|
||||
// Map<String, AttributeValue> itemAttributes = new HashMap<>();
|
||||
// itemAttributes.put("PK", AttributeValue.builder().s("item#" + guid).build());
|
||||
// itemAttributes.put("SK", AttributeValue.builder().s(item_guid).build());
|
||||
// try {
|
||||
// Map<String, AttributeValue> item = getItem("item#" + guid, item_guid);
|
||||
// log.info("deleteItem PK: {}, SK: {}", "item#" + guid, item_guid);
|
||||
//
|
||||
// DeleteItemRequest request = DeleteItemRequest.builder()
|
||||
// .tableName(metaTable)
|
||||
// .key(itemAttributes)
|
||||
// .build();
|
||||
//
|
||||
// DeleteItemResponse response = dynamoDbClient.deleteItem(request);
|
||||
//
|
||||
// if(response.sdkHttpResponse().isSuccessful())
|
||||
// return item.toString();
|
||||
//
|
||||
// return "";
|
||||
// }catch (ConditionalCheckFailedException e) {
|
||||
// log.error("deleteItem Conditional check failed: {}", e.getMessage());
|
||||
// throw new RestApiException(CommonCode.ERROR.getHttpStatus(), ErrorCode.DYNAMODB_CONNECTION_ERROR.getMessage());
|
||||
// }catch(Exception e){
|
||||
// log.error("deleteItem: {}", e.getMessage());
|
||||
// throw new RestApiException(CommonCode.ERROR.getHttpStatus(), ErrorCode.DYNAMODB_CONNECTION_ERROR.getMessage());
|
||||
// }
|
||||
// }
|
||||
|
||||
// 아이템 정보 수정
|
||||
public JSONObject updateItem(String guid, String item_guid, int cnt) {
|
||||
try{
|
||||
|
||||
Map<String, AttributeValue> item = getItem("item#" + guid, item_guid);
|
||||
|
||||
String InfoJson = item.get("ItemAttrib").s();
|
||||
|
||||
ObjectMapper objectMapper = new ObjectMapper();
|
||||
JsonNode infoNode = objectMapper.readTree(InfoJson);
|
||||
log.info("updateItem Before UpdateInfo : {}", infoNode.toString());
|
||||
|
||||
((ObjectNode) infoNode).put("item_stack_count", cnt);
|
||||
|
||||
String updatedInfoJson = infoNode.toString();
|
||||
log.info("updateItem Tobe UpdateInfo : {}", updatedInfoJson);
|
||||
|
||||
Map<String, AttributeValue> expressionAttributeValues = new HashMap<>();
|
||||
expressionAttributeValues.put(":newAttrib", AttributeValue.builder().s(updatedInfoJson).build());
|
||||
|
||||
String updateExpression = "SET ItemAttrib = :newAttrib";
|
||||
|
||||
UpdateItemRequest updateRequest = UpdateItemRequest.builder()
|
||||
.tableName(metaTable)
|
||||
.key(Map.of(
|
||||
"PK", AttributeValue.builder().s("item#" + guid).build(),
|
||||
"SK", AttributeValue.builder().s(item_guid).build()))
|
||||
.updateExpression(updateExpression)
|
||||
.expressionAttributeValues(expressionAttributeValues)
|
||||
.returnValues(ReturnValue.ALL_NEW) // 업데이트 후의 값을 반환하려면 지정
|
||||
.build();
|
||||
|
||||
|
||||
dynamoDbClient.updateItem(updateRequest);
|
||||
|
||||
JSONObject jsonObject = new JSONObject();
|
||||
jsonObject.put("data(before)", InfoJson);
|
||||
jsonObject.put("data(after)", updatedInfoJson);
|
||||
return jsonObject;
|
||||
}catch(Exception e){
|
||||
log.error("updateItem: {}", e.getMessage());
|
||||
throw new RestApiException(CommonCode.ERROR.getHttpStatus(), ErrorCode.DYNAMODB_CONNECTION_ERROR.getMessage() );
|
||||
}
|
||||
}
|
||||
// public JSONObject updateItem(String guid, String item_guid, int cnt) {
|
||||
// try{
|
||||
//
|
||||
// Map<String, AttributeValue> item = getItem("item#" + guid, item_guid);
|
||||
//
|
||||
// String InfoJson = item.get("ItemAttrib").s();
|
||||
//
|
||||
// ObjectMapper objectMapper = new ObjectMapper();
|
||||
// JsonNode infoNode = objectMapper.readTree(InfoJson);
|
||||
// log.info("updateItem Before UpdateInfo : {}", infoNode.toString());
|
||||
//
|
||||
// ((ObjectNode) infoNode).put("item_stack_count", cnt);
|
||||
//
|
||||
// String updatedInfoJson = infoNode.toString();
|
||||
// log.info("updateItem Tobe UpdateInfo : {}", updatedInfoJson);
|
||||
//
|
||||
// Map<String, AttributeValue> expressionAttributeValues = new HashMap<>();
|
||||
// expressionAttributeValues.put(":newAttrib", AttributeValue.builder().s(updatedInfoJson).build());
|
||||
//
|
||||
// String updateExpression = "SET ItemAttrib = :newAttrib";
|
||||
//
|
||||
// UpdateItemRequest updateRequest = UpdateItemRequest.builder()
|
||||
// .tableName(metaTable)
|
||||
// .key(Map.of(
|
||||
// "PK", AttributeValue.builder().s("item#" + guid).build(),
|
||||
// "SK", AttributeValue.builder().s(item_guid).build()))
|
||||
// .updateExpression(updateExpression)
|
||||
// .expressionAttributeValues(expressionAttributeValues)
|
||||
// .returnValues(ReturnValue.ALL_NEW) // 업데이트 후의 값을 반환하려면 지정
|
||||
// .build();
|
||||
//
|
||||
//
|
||||
// dynamoDbClient.updateItem(updateRequest);
|
||||
//
|
||||
// JSONObject jsonObject = new JSONObject();
|
||||
// jsonObject.put("data(before)", InfoJson);
|
||||
// jsonObject.put("data(after)", updatedInfoJson);
|
||||
// return jsonObject;
|
||||
// }catch(Exception e){
|
||||
// log.error("updateItem: {}", e.getMessage());
|
||||
// throw new RestApiException(CommonCode.ERROR.getHttpStatus(), ErrorCode.DYNAMODB_CONNECTION_ERROR.getMessage() );
|
||||
// }
|
||||
// }
|
||||
|
||||
// 아이템 - 타투 죄회
|
||||
public List<UsersResponse.Tattoo> getTattoo(String guid){Map<String, Object> resultMap = new HashMap<>();
|
||||
@@ -1680,9 +1160,9 @@ public class DynamoDBService {
|
||||
friend.setRowNum(idx.getAndIncrement());
|
||||
String friend_guid = CommonUtils.objectToString(attrMap.get("friend_guid"));
|
||||
friend.setFriendGuid(friend_guid);
|
||||
friend.setFriendName(getGuidByName(friend_guid));
|
||||
friend.setFriendName(dynamodbUserService.getGuidByName(friend_guid));
|
||||
friend.setReceiveDt(CommonUtils.objectToString(attrMap.get("create_time")));
|
||||
friend.setLanguage(LANGUAGETYPE.values()[Integer.parseInt(getUserLanguage(friend_guid))].toString());
|
||||
friend.setLanguage(dynamodbUserService.getUserLanguage(guid));
|
||||
resList.add(friend);
|
||||
});
|
||||
log.info("getFriendList FriendInfo: {}", resList);
|
||||
@@ -1719,9 +1199,9 @@ public class DynamoDBService {
|
||||
friend.setRowNum(idx.getAndIncrement());
|
||||
String block_guid = CommonUtils.objectToString(attrMap.get("guid"));
|
||||
friend.setFriendGuid(block_guid);
|
||||
friend.setFriendName(getGuidByName(block_guid));
|
||||
friend.setFriendName(dynamodbUserService.getGuidByName(block_guid));
|
||||
friend.setReceiveDt(CommonUtils.objectToString(item.get("CreatedDateTime").s()));
|
||||
friend.setLanguage(LANGUAGETYPE.values()[Integer.parseInt(getUserLanguage(block_guid))].toString());
|
||||
friend.setLanguage(dynamodbUserService.getUserLanguage(guid));
|
||||
|
||||
resList.add(friend);
|
||||
}
|
||||
@@ -1750,12 +1230,12 @@ public class DynamoDBService {
|
||||
String second_key = "PK = :pkValue";
|
||||
Map<String, AttributeValue> second_values = Map.of(":pkValue", AttributeValue.builder().s("item#"+myhome_guid).build());
|
||||
excuteItems(executeQuery(second_key, second_values), "ItemAttrib").forEach(attrMap2 -> {
|
||||
String item_id = CommonUtils.objectToString(attrMap2.get("item_meta_id"));
|
||||
String item_name = metaDataHandler.getMetaItemNameData(Integer.parseInt(item_id));
|
||||
int item_id = CommonUtils.objectToInteger(attrMap2.get("item_meta_id"));
|
||||
String item_name = metaDataHandler.getMetaItemNameData(item_id);
|
||||
UsersResponse.Item item = UsersResponse.Item.builder()
|
||||
.itemId(item_id)
|
||||
.itemName(metaDataHandler.getTextStringData(item_name))
|
||||
.count(CommonUtils.objectToDouble(attrMap2.get("item_stack_count")))
|
||||
.count(CommonUtils.objectToInteger(attrMap2.get("item_stack_count")))
|
||||
.itemGuid(CommonUtils.objectToString(attrMap2.get("item_guid")))
|
||||
.build();
|
||||
itemList.add(item);
|
||||
|
||||
@@ -1,16 +1,18 @@
|
||||
package com.caliverse.admin.domain.service;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
import com.caliverse.admin.domain.adminlog.AdminItemDeleteLog;
|
||||
import com.caliverse.admin.domain.adminlog.IAdminLog;
|
||||
import com.caliverse.admin.domain.dao.admin.HistoryMapper;
|
||||
import com.caliverse.admin.domain.entity.ItemList;
|
||||
import com.caliverse.admin.domain.datacomponent.MetaDataHandler;
|
||||
import com.caliverse.admin.domain.entity.ITEMLARGETYPE;
|
||||
import com.caliverse.admin.domain.entity.SEARCHTYPE;
|
||||
import com.caliverse.admin.domain.response.ItemDeleteResponse;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
import com.caliverse.admin.domain.response.UsersResponse;
|
||||
import com.caliverse.admin.dynamodb.domain.atrrib.ItemAttrib;
|
||||
import com.caliverse.admin.dynamodb.domain.doc.ItemDoc;
|
||||
import com.caliverse.admin.dynamodb.dto.PageResult;
|
||||
import com.caliverse.admin.dynamodb.service.DynamodbItemService;
|
||||
import com.caliverse.admin.dynamodb.service.DynamodbUserService;
|
||||
import com.caliverse.admin.global.common.code.ErrorCode;
|
||||
import com.caliverse.admin.global.common.utils.CommonUtils;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import com.caliverse.admin.domain.request.ItemsRequest;
|
||||
@@ -21,33 +23,75 @@ import com.caliverse.admin.global.common.code.SuccessCode;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
@Service
|
||||
@RequiredArgsConstructor
|
||||
@Slf4j
|
||||
public class ItemsService {
|
||||
private static final Logger logger = LoggerFactory.getLogger(ItemsService.class);
|
||||
|
||||
private final DynamoDBService dynamoDBService;
|
||||
private final UserGameSessionService userGameSessionService;
|
||||
private final DynamoDBQueryServiceBase dynamoDBQueryServiceBase;
|
||||
private final HistoryMapper historyMapper;
|
||||
private final DynamodbUserService dynamodbUserService;
|
||||
private final DynamodbItemService dynamodbItemService;
|
||||
private final MetaDataHandler metaDataHandler;
|
||||
|
||||
public ItemsResponse findItems(ItemsRequest itemDeleteRequest){
|
||||
String guid = "";
|
||||
String searchData = itemDeleteRequest.getSearchData();
|
||||
|
||||
|
||||
// 아이템 정보 조회 GUID,item ID, item name
|
||||
public ItemsResponse findItems(Map<String,String> requestParam){
|
||||
String searchType = requestParam.get("search_type").toString();
|
||||
String search_key = requestParam.get("search_key").toString().trim();
|
||||
String guid = search_key;
|
||||
|
||||
if(searchType.equals(SEARCHTYPE.NAME.name())){
|
||||
guid = dynamoDBService.getNickNameByGuid(search_key);
|
||||
if(itemDeleteRequest.getSearchType().equals(SEARCHTYPE.NAME)){
|
||||
guid = dynamodbUserService.getNameByGuid(searchData);
|
||||
}else{
|
||||
guid = dynamodbUserService.isUser(searchData) ? searchData: "";
|
||||
}
|
||||
|
||||
List<ItemList> itemList = dynamoDBService.getItems(guid);
|
||||
if(guid.isEmpty()){
|
||||
return ItemsResponse.builder()
|
||||
.status(CommonCode.ERROR.getHttpStatus())
|
||||
.result(CommonCode.ERROR.getResult())
|
||||
.resultData(ItemsResponse.ResultData.builder()
|
||||
.message(ErrorCode.DYNAMODB_NOT_USER.name())
|
||||
.build())
|
||||
.build();
|
||||
}
|
||||
|
||||
PageResult<ItemDoc> itemPageResult = dynamodbItemService.getItems(guid, itemDeleteRequest.getPageKey());
|
||||
List<ItemsResponse.Item> items = new ArrayList<>();
|
||||
String finalGuid = guid;
|
||||
itemPageResult.getItems().forEach(itemDoc -> {
|
||||
ItemAttrib attrib = CommonUtils.stringByObject(itemDoc.getAttribValue(), ItemAttrib.class);
|
||||
int itemId = attrib.getItemMetaId();
|
||||
String itemType = metaDataHandler.getMetaItemLargeTypeData(itemId);
|
||||
ItemsResponse.Item item = ItemsResponse.Item.builder()
|
||||
.userGuid(finalGuid)
|
||||
.itemGuid(attrib.getItemGuid())
|
||||
.id(itemId)
|
||||
.itemId(itemId)
|
||||
.itemName(metaDataHandler.getTextStringData(metaDataHandler.getMetaItemNameData(itemId)))
|
||||
.count(attrib.getItemStackCount())
|
||||
.level(attrib.getLevel())
|
||||
.equipedPos(attrib.getEquipedPos())
|
||||
.equipType(attrib.getEquipedIvenType())
|
||||
.itemType(ITEMLARGETYPE.valueOf(itemType))
|
||||
.createDt(itemDoc.getCreatedDateTime())
|
||||
.build();
|
||||
items.add(item);
|
||||
});
|
||||
|
||||
return ItemsResponse.builder()
|
||||
.resultData(ItemsResponse.ResultData.builder()
|
||||
.list(itemList)
|
||||
.itemList(items)
|
||||
.pageKey(itemPageResult.getLastEvaluatedKey() == null ?
|
||||
null :
|
||||
itemPageResult.getLastEvaluatedKey().entrySet().stream()
|
||||
.collect(Collectors.toMap(
|
||||
Map.Entry::getKey,
|
||||
entry -> entry.getValue().s()
|
||||
))
|
||||
)
|
||||
.build())
|
||||
.status(CommonCode.SUCCESS.getHttpStatus())
|
||||
.result(CommonCode.SUCCESS.getResult())
|
||||
@@ -57,19 +101,20 @@ public class ItemsService {
|
||||
|
||||
@Transactional(transactionManager = "transactionManager")
|
||||
public ItemDeleteResponse postItemDelete(ItemsRequest itemDeleteRequest){
|
||||
var userGuid = itemDeleteRequest.getUserGuid();
|
||||
var itemGuid = itemDeleteRequest.getItemGuid();
|
||||
var itemCount = itemDeleteRequest.getItemCount();
|
||||
String userGuid = itemDeleteRequest.getUserGuid();
|
||||
String itemGuid = itemDeleteRequest.getItemGuid();
|
||||
int itemCount = itemDeleteRequest.getItemCount();
|
||||
int deleteCount = itemDeleteRequest.getDeleteCount();
|
||||
|
||||
//UserKick
|
||||
userGameSessionService.kickUserSession(userGuid, "item delete");
|
||||
//ItemDelete
|
||||
dynamoDBQueryServiceBase.deleteUserItem(userGuid, itemGuid);
|
||||
|
||||
//로그 기록
|
||||
IAdminLog adminLog = new AdminItemDeleteLog(userGuid, itemGuid, itemCount);
|
||||
adminLog.saveLogToDB();
|
||||
|
||||
if(deleteCount >= itemCount){
|
||||
dynamodbItemService.deleteItem(userGuid, itemGuid);
|
||||
}else{
|
||||
int cnt = itemCount - deleteCount;
|
||||
dynamodbItemService.updateItemStack(userGuid, itemGuid, cnt);
|
||||
}
|
||||
|
||||
return ItemDeleteResponse.builder()
|
||||
.status(CommonCode.SUCCESS.getHttpStatus())
|
||||
|
||||
@@ -8,6 +8,7 @@ import com.caliverse.admin.domain.entity.*;
|
||||
import com.caliverse.admin.domain.request.MailRequest;
|
||||
import com.caliverse.admin.domain.response.MailResponse;
|
||||
import com.caliverse.admin.dynamodb.service.DynamodbCaliumService;
|
||||
import com.caliverse.admin.dynamodb.service.DynamodbUserService;
|
||||
import com.caliverse.admin.global.common.code.CommonCode;
|
||||
import com.caliverse.admin.global.common.code.ErrorCode;
|
||||
import com.caliverse.admin.global.common.code.SuccessCode;
|
||||
@@ -38,6 +39,7 @@ import java.util.*;
|
||||
public class MailService {
|
||||
private final DynamoDBService dynamoDBService;
|
||||
private final WalletUserMapper walletUserMapper;
|
||||
private final DynamodbUserService dynamodbUserService;
|
||||
|
||||
@Value("${excel.file-path}")
|
||||
private String excelPath;
|
||||
@@ -323,7 +325,7 @@ public class MailService {
|
||||
if (mailRequest.getGuid() != null) {
|
||||
String guid = mailRequest.getGuid();
|
||||
// 닉네임이면 guid로 바꾼다
|
||||
if(mailRequest.getUserType().equals(Mail.USERTYPE.NICKNAME)) guid = dynamoDBService.getNickNameByGuid(guid);
|
||||
if(mailRequest.getUserType().equals(Mail.USERTYPE.NICKNAME)) guid = dynamodbUserService.getNameByGuid(guid);
|
||||
mailRequest.setReceiveType(Mail.RECEIVETYPE.SINGLE);
|
||||
mailRequest.setTarget(guid);
|
||||
} else {
|
||||
@@ -486,9 +488,9 @@ public class MailService {
|
||||
public String getGuid(String target, String type){
|
||||
if(Mail.USERTYPE.EMAIL.name().equals(type)){
|
||||
WalletUser user = walletUserMapper.getUser(target);
|
||||
return dynamoDBService.getAccountIdByGuid(user.getAccount_id());
|
||||
return dynamodbUserService.getAccountIdByGuid(String.valueOf(user.getAccount_id()));
|
||||
}else if(Mail.USERTYPE.NICKNAME.name().equals(type)){
|
||||
return dynamoDBService.getNickNameByGuid(target);
|
||||
return dynamodbUserService.getNameByGuid(target);
|
||||
}
|
||||
return target;
|
||||
}
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
package com.caliverse.admin.domain.service;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.concurrent.atomic.AtomicInteger;
|
||||
@@ -8,6 +9,7 @@ import java.util.stream.Collectors;
|
||||
|
||||
import com.caliverse.admin.domain.entity.FriendRequest;
|
||||
import com.caliverse.admin.domain.entity.HISTORYTYPE;
|
||||
import com.caliverse.admin.domain.entity.SEARCHTYPE;
|
||||
import com.caliverse.admin.domain.request.MailRequest;
|
||||
import com.caliverse.admin.dynamodb.domain.atrrib.AccountBaseAttrib;
|
||||
import com.caliverse.admin.dynamodb.domain.atrrib.MailAttrib;
|
||||
@@ -15,6 +17,7 @@ import com.caliverse.admin.dynamodb.domain.atrrib.MailJsonAttrib;
|
||||
import com.caliverse.admin.dynamodb.domain.atrrib.MoneyAttrib;
|
||||
import com.caliverse.admin.dynamodb.domain.doc.MailDoc;
|
||||
import com.caliverse.admin.dynamodb.dto.PageResult;
|
||||
import com.caliverse.admin.dynamodb.service.DynamodbItemService;
|
||||
import com.caliverse.admin.dynamodb.service.DynamodbService;
|
||||
import com.caliverse.admin.dynamodb.service.DynamodbUserService;
|
||||
import com.caliverse.admin.global.common.utils.DynamodbUtil;
|
||||
@@ -50,15 +53,12 @@ public class UsersService {
|
||||
private final HistoryService historyService;
|
||||
private final UserGameSessionService userGameSessionService;
|
||||
private final RedisUserInfoService redisUserInfoService;
|
||||
|
||||
private final DynamodbUserService dynamodbUserService;
|
||||
private final DynamodbItemService dynamodbItemService;
|
||||
|
||||
//metadataHandler 어떻게 가져와야 되는가
|
||||
@Autowired
|
||||
private MetaDataHandler metaDataHandler;
|
||||
@Qualifier("objectMapper")
|
||||
@Autowired
|
||||
private ObjectMapper objectMapper;
|
||||
@Autowired
|
||||
private DynamodbUserService dynamodbUserService;
|
||||
|
||||
// 닉네임 변경
|
||||
public UsersResponse changeNickname(UsersRequest usersRequest){
|
||||
@@ -72,8 +72,9 @@ public class UsersService {
|
||||
throw new RestApiException(CommonCode.ERROR.getHttpStatus(), check.getMessage() );
|
||||
}
|
||||
|
||||
Map<String, String> serachNickname = dynamoDBService.getUsersByName(newNickname);
|
||||
if(serachNickname != null){
|
||||
String isGuid = dynamodbUserService.getNameByGuid(newNickname);
|
||||
|
||||
if(!isGuid.isEmpty()){
|
||||
//변경 닉네임이 존재합니다. 다시 시도해주세요.
|
||||
throw new RestApiException(CommonCode.ERROR.getHttpStatus(), ErrorCode.NICKNAME_EXIT_ERROR.getMessage() );
|
||||
}else{
|
||||
@@ -93,9 +94,8 @@ public class UsersService {
|
||||
// GM 권한 변경
|
||||
public UsersResponse changeAdminLevel(UsersRequest usersRequest){
|
||||
String guid = usersRequest.getGuid();
|
||||
String type = usersRequest.getAdminLevel();
|
||||
|
||||
dynamoDBService.updateAdminLevel(guid, type);
|
||||
dynamodbUserService.updateAdminLevel(guid, usersRequest.getAdminLevel());
|
||||
|
||||
return UsersResponse.builder()
|
||||
.resultData(UsersResponse.ResultData.builder()
|
||||
@@ -130,11 +130,22 @@ public class UsersService {
|
||||
String searchType = requestParam.get("search_type").toString();
|
||||
String searchKey = requestParam.get("search_key").toString();
|
||||
|
||||
Map<String,String> res = dynamoDBService.findUsersBykey(searchType, searchKey);
|
||||
// Map<String,String> res = dynamoDBService.findUsersBykey(searchType, searchKey);
|
||||
Map<String,String> resultMap = new HashMap<>();
|
||||
if(searchType.equals(SEARCHTYPE.NAME.name())){
|
||||
resultMap.put("guid", dynamodbUserService.getNameByGuid(searchKey.toLowerCase())); //nickname은 무조건 소문자
|
||||
resultMap.put("nickname", searchKey);
|
||||
}else if(searchType.equals(SEARCHTYPE.GUID.name())){
|
||||
resultMap.put("guid", searchKey);
|
||||
resultMap.put("nickname", dynamodbUserService.getGuidByName(searchKey));
|
||||
}else if(searchType.equals(SEARCHTYPE.ACCOUNT.name())){
|
||||
resultMap.put("guid", dynamodbUserService.getAccountIdByGuid(searchKey));
|
||||
resultMap.put("nickname", dynamodbUserService.getAccountIdByName(searchKey));
|
||||
}
|
||||
|
||||
return UsersResponse.builder()
|
||||
.resultData(UsersResponse.ResultData.builder()
|
||||
.result(res)
|
||||
.result(resultMap)
|
||||
.build())
|
||||
.status(CommonCode.SUCCESS.getHttpStatus())
|
||||
.result(CommonCode.SUCCESS.getResult())
|
||||
@@ -156,7 +167,7 @@ public class UsersService {
|
||||
.accessDt(accountBaseAttrib.getLoginDateTime())
|
||||
.endDt(accountBaseAttrib.getLogoutDateTime())
|
||||
.walletUrl("")
|
||||
.adminLevel(accountBaseAttrib.getAuthAdminLevelType().name())
|
||||
.adminLevel(accountBaseAttrib.getAuthAdminLevelType())
|
||||
.spareSlot("")
|
||||
.build();
|
||||
|
||||
@@ -265,7 +276,8 @@ public class UsersService {
|
||||
// inventoryList.add(innerList);
|
||||
// }
|
||||
// }
|
||||
UsersResponse.InventoryInfo inventoryInfo = dynamoDBService.getInvenItems(guid);
|
||||
// UsersResponse.InventoryInfo inventoryInfo = dynamoDBService.getInvenItems(guid);
|
||||
UsersResponse.InventoryInfo inventoryInfo = dynamodbItemService.getInvenItems(guid);
|
||||
logger.info("getInventoryInfo Inventory Items: {}", inventoryInfo);
|
||||
|
||||
return UsersResponse.builder()
|
||||
@@ -288,12 +300,13 @@ public class UsersService {
|
||||
|
||||
userGameSessionService.kickUserSession(guid, "Item delete");
|
||||
if(update_cnt >= current_cnt){
|
||||
String attrib = dynamoDBService.deleteItem(guid, item_guid);
|
||||
if(!attrib.isEmpty()){
|
||||
JSONObject jsonObject = new JSONObject();
|
||||
jsonObject.put("data",attrib);
|
||||
historyService.setLog(HISTORYTYPE.INVENTORY_ITEM_DELETE, jsonObject);
|
||||
}
|
||||
// String attrib = dynamoDBService.deleteItem(guid, item_guid);
|
||||
// if(!attrib.isEmpty()){
|
||||
// JSONObject jsonObject = new JSONObject();
|
||||
// jsonObject.put("data",attrib);
|
||||
// historyService.setLog(HISTORYTYPE.INVENTORY_ITEM_DELETE, jsonObject);
|
||||
// }
|
||||
dynamodbItemService.deleteItem(guid, item_guid);
|
||||
return UsersResponse.builder()
|
||||
.status(CommonCode.SUCCESS.getHttpStatus())
|
||||
.result(CommonCode.SUCCESS.getResult())
|
||||
@@ -303,10 +316,11 @@ public class UsersService {
|
||||
.build();
|
||||
}else{
|
||||
int cnt = current_cnt - update_cnt;
|
||||
JSONObject json = dynamoDBService.updateItem(guid, item_guid, cnt);
|
||||
if(!json.isEmpty()){
|
||||
historyService.setLog(HISTORYTYPE.INVENTORY_ITEM_UPDATE, json);
|
||||
}
|
||||
dynamodbItemService.updateItemStack(guid, item_guid, cnt);
|
||||
// JSONObject json = dynamoDBService.updateItem(guid, item_guid, cnt);
|
||||
// if(!json.isEmpty()){
|
||||
// historyService.setLog(HISTORYTYPE.INVENTORY_ITEM_UPDATE, json);
|
||||
// }
|
||||
return UsersResponse.builder()
|
||||
.status(CommonCode.SUCCESS.getHttpStatus())
|
||||
.result(CommonCode.SUCCESS.getResult())
|
||||
@@ -319,7 +333,7 @@ public class UsersService {
|
||||
|
||||
public UsersResponse getMail(UsersRequest usersRequest){
|
||||
// List<UsersResponse.Mail> mailList = dynamoDBService.getMail(guid, type);
|
||||
PageResult<MailDoc> mailPageResult = dynamodbService.getMail(usersRequest.getMailType(), usersRequest.getGuid(), "", "", "", usersRequest.getPageKey(), false);
|
||||
PageResult<MailDoc> mailPageResult = dynamodbService.getMail(usersRequest.getMailType(), usersRequest.getGuid(), "", usersRequest.getPageKey());
|
||||
List<UsersResponse.Mail> mailList = new ArrayList<>();
|
||||
|
||||
mailPageResult.getItems().forEach(doc -> {
|
||||
@@ -377,7 +391,7 @@ public class UsersService {
|
||||
}
|
||||
} catch (Exception e) {
|
||||
log.error(e.getMessage());
|
||||
return;
|
||||
throw new RestApiException(CommonCode.ERROR.getHttpStatus(), e.getMessage());
|
||||
}
|
||||
});
|
||||
return UsersResponse.builder()
|
||||
@@ -469,9 +483,9 @@ public class UsersService {
|
||||
friend.setRowNum(idx.getAndIncrement());
|
||||
String receive_guid = friendReq.getReceiverGuid();
|
||||
friend.setFriendGuid(receive_guid);
|
||||
friend.setFriendName(dynamoDBService.getGuidByName(receive_guid));
|
||||
friend.setFriendName(dynamodbUserService.getGuidByName(receive_guid));
|
||||
friend.setReceiveDt(friendReq.getRequestTime());
|
||||
friend.setLanguage(dynamoDBService.getUserLanguage(receive_guid));
|
||||
friend.setLanguage(dynamodbUserService.getUserLanguage(receive_guid));
|
||||
|
||||
friendSendList.add(friend);
|
||||
}
|
||||
@@ -481,9 +495,9 @@ public class UsersService {
|
||||
friend.setRowNum(idx.getAndIncrement());
|
||||
String send_guid = friendReq.getSenderGuid();
|
||||
friend.setFriendGuid(send_guid);
|
||||
friend.setFriendName(dynamoDBService.getGuidByName(send_guid));
|
||||
friend.setFriendName(dynamodbUserService.getGuidByName(send_guid));
|
||||
friend.setReceiveDt(friendReq.getRequestTime());
|
||||
friend.setLanguage(dynamoDBService.getUserLanguage(send_guid));
|
||||
friend.setLanguage(dynamodbUserService.getUserLanguage(send_guid));
|
||||
|
||||
friendReceiveList.add(friend);
|
||||
}
|
||||
|
||||
@@ -1,251 +0,0 @@
|
||||
package com.caliverse.admin.domain.service;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
import org.json.JSONObject;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
import org.springframework.web.multipart.MultipartFile;
|
||||
|
||||
import com.caliverse.admin.domain.dao.admin.HistoryMapper;
|
||||
import com.caliverse.admin.domain.dao.admin.WhiteListMapper;
|
||||
import com.caliverse.admin.domain.entity.Admin;
|
||||
import com.caliverse.admin.domain.entity.HISTORYTYPE;
|
||||
import com.caliverse.admin.domain.entity.WhiteList;
|
||||
import com.caliverse.admin.domain.request.WhiteListRequest;
|
||||
import com.caliverse.admin.domain.response.WhiteListResponse;
|
||||
import com.caliverse.admin.global.common.code.CommonCode;
|
||||
import com.caliverse.admin.global.common.code.ErrorCode;
|
||||
import com.caliverse.admin.global.common.code.SuccessCode;
|
||||
import com.caliverse.admin.global.common.exception.RestApiException;
|
||||
import com.caliverse.admin.global.common.utils.CommonUtils;
|
||||
import com.caliverse.admin.global.common.utils.ExcelUtils;
|
||||
|
||||
import jakarta.servlet.http.HttpServletResponse;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import software.amazon.awssdk.services.dynamodb.model.AttributeValue;
|
||||
|
||||
@Service
|
||||
@RequiredArgsConstructor
|
||||
public class WhiteListService {
|
||||
private static final Logger logger = LoggerFactory.getLogger(WhiteListService.class);
|
||||
private final ExcelUtils excelUtils;
|
||||
private final WhiteListMapper whiteListMapper;
|
||||
private final HistoryMapper historyMapper;
|
||||
private final DynamoDBService dynamoDBService;
|
||||
public WhiteListResponse getWhiteList(Map<String, String> requestParams){
|
||||
|
||||
List<WhiteList> whiteList = whiteListMapper.getWhiteList();
|
||||
|
||||
return WhiteListResponse.builder()
|
||||
.resultData(WhiteListResponse.ResultData.builder()
|
||||
.list(whiteList).build())
|
||||
.status(CommonCode.SUCCESS.getHttpStatus())
|
||||
.result(CommonCode.SUCCESS.getResult())
|
||||
.build();
|
||||
}
|
||||
public WhiteListResponse excelUpload(MultipartFile file){
|
||||
|
||||
List<WhiteList> list = new ArrayList<>();
|
||||
// 파일 존재하지 않는 경우
|
||||
if (file.isEmpty()) {
|
||||
throw new RestApiException(CommonCode.ERROR.getHttpStatus(), ErrorCode.NOT_EXIT_EXCEL.getMessage() ); //Excel 파일을 선택해주세요.
|
||||
}
|
||||
|
||||
List<String> listData = excelUtils.getListData(file, 1, 0);
|
||||
|
||||
// 엑셀 파일내 중복된 데이터 있는지 체크
|
||||
if(excelUtils.hasDuplicates(listData)){
|
||||
throw new RestApiException(CommonCode.ERROR.getHttpStatus(), ErrorCode.DUPLICATE_EXCEL.getMessage() ); //Excel 파일을 선택해주세요.
|
||||
}
|
||||
|
||||
listData.forEach(
|
||||
item->{
|
||||
WhiteList whiteList = new WhiteList();
|
||||
//adminDB 조회
|
||||
int cnt = whiteListMapper.getCountByGuid(item.toString());
|
||||
if(cnt == 0 ){
|
||||
whiteList.setGuid(item.toString());
|
||||
}else{
|
||||
throw new RestApiException(CommonCode.ERROR.getHttpStatus(), ErrorCode.ADMINDB_EXIT_ERROR.getMessage());
|
||||
}
|
||||
//gameDB #char isWhiteUser 값 체크
|
||||
Map<String, AttributeValue> whiteAttr = dynamoDBService.getItem("char#" + item, "char#" + item);
|
||||
//guid 검증
|
||||
if(whiteAttr.size() == 0){
|
||||
throw new RestApiException(CommonCode.ERROR.getHttpStatus(), ErrorCode.WARNING_GUID_CHECK.getMessage());
|
||||
}
|
||||
//화이트리스트 확정까지 보류
|
||||
// boolean isWhiteUser = dynamoDBService.isWhiteOrBlackUser(whiteAttr.get("isWhiteUser"));
|
||||
// if (isWhiteUser) {
|
||||
// throw new RestApiException(CommonCode.ERROR.getHttpStatus(), ErrorCode.DYNAMODB_EXIT_ERROR.getMessage());
|
||||
// }
|
||||
|
||||
list.add(whiteList);
|
||||
}
|
||||
);
|
||||
return WhiteListResponse.builder()
|
||||
.resultData(WhiteListResponse.ResultData.builder()
|
||||
.list(list).message(SuccessCode.EXCEL_UPLOAD.getMessage()).build())
|
||||
.status(CommonCode.SUCCESS.getHttpStatus())
|
||||
.result(CommonCode.SUCCESS.getResult())
|
||||
.build();
|
||||
}
|
||||
|
||||
// 단일 등록
|
||||
@Transactional(transactionManager = "transactionManager")
|
||||
public WhiteListResponse postWhiteList(WhiteListRequest whiteListRequest){
|
||||
HashMap<String,Object> map = new HashMap<>();
|
||||
Admin admin = CommonUtils.getAdmin();
|
||||
map.put("status", WhiteList.STATUS.REJECT);
|
||||
map.put("createBy", admin.getId());
|
||||
|
||||
int cnt = whiteListMapper.getCountByGuid(whiteListRequest.getGuid());
|
||||
if(cnt > 0 ){
|
||||
throw new RestApiException(CommonCode.ERROR.getHttpStatus(), ErrorCode.ADMINDB_EXIT_ERROR.getMessage());
|
||||
}
|
||||
//gameDB #char isWhiteUser 값 체크
|
||||
Map<String, AttributeValue> whiteAttr = dynamoDBService.getItem("user_base#" + whiteListRequest.getGuid()
|
||||
, "empty");
|
||||
|
||||
//guid 검증
|
||||
if(whiteAttr.size() == 0){
|
||||
throw new RestApiException(CommonCode.ERROR.getHttpStatus(), ErrorCode.WARNING_GUID_CHECK.getMessage());
|
||||
}
|
||||
//화이트리스트 확정까지 보류
|
||||
// boolean isWhiteUser = dynamoDBService.isWhiteOrBlackUser(whiteAttr.get("isWhiteUser"));
|
||||
// if (isWhiteUser) {
|
||||
// throw new RestApiException(CommonCode.ERROR.getHttpStatus(), ErrorCode.DYNAMODB_EXIT_ERROR.getMessage());
|
||||
// }
|
||||
map.put("guid",whiteListRequest.getGuid());
|
||||
map.put("nickname",dynamoDBService.getNickNameByGuid(whiteListRequest.getGuid()));
|
||||
whiteListMapper.postWhiteList(map);
|
||||
|
||||
//dynamoDB char# 테이블에 isWhiteUser : true 값을 insert
|
||||
dynamoDBService.insertUpdateData(whiteListRequest.getGuid(),"isWhiteUser",true);
|
||||
return WhiteListResponse.builder()
|
||||
.resultData(WhiteListResponse.ResultData.builder()
|
||||
.message(SuccessCode.REGISTRATION.getMessage()).build())
|
||||
.status(CommonCode.SUCCESS.getHttpStatus())
|
||||
.result(CommonCode.SUCCESS.getResult())
|
||||
.build();
|
||||
}
|
||||
//복수 등록
|
||||
@Transactional(transactionManager = "transactionManager")
|
||||
public WhiteListResponse multiPost(MultipartFile file){
|
||||
HashMap<String,Object> map = new HashMap<>();
|
||||
// 파일 존재하지 않는 경우
|
||||
if (file.isEmpty()) {
|
||||
throw new RestApiException(CommonCode.ERROR.getHttpStatus(), ErrorCode.NOT_EXIT_EXCEL.getMessage() ); //Excel 파일을 선택해주세요.
|
||||
}
|
||||
|
||||
List<String> listData = excelUtils.getListData(file, 1, 0);
|
||||
|
||||
// 엑셀 파일내 중복된 데이터 있는지 체크
|
||||
if(excelUtils.hasDuplicates(listData)){
|
||||
throw new RestApiException(CommonCode.ERROR.getHttpStatus(), ErrorCode.DUPLICATE_EXCEL.getMessage() ); //Excel 파일을 선택해주세요.
|
||||
}
|
||||
|
||||
Admin admin = CommonUtils.getAdmin();
|
||||
map.put("status", WhiteList.STATUS.REJECT);
|
||||
map.put("createBy", admin.getId());
|
||||
|
||||
listData.forEach(
|
||||
item->{
|
||||
map.put("guid",item.toString());
|
||||
map.put("nickname",dynamoDBService.getNickNameByGuid(item.toString()));
|
||||
whiteListMapper.postWhiteList(map);
|
||||
|
||||
//dynamoDB char# 테이블에 isWhiteUser : true 값을 insert
|
||||
dynamoDBService.insertUpdateData(item.toString(),"isWhiteUser", true);
|
||||
}
|
||||
);
|
||||
|
||||
return WhiteListResponse.builder()
|
||||
.resultData(WhiteListResponse.ResultData.builder()
|
||||
.message(SuccessCode.REGISTRATION.getMessage()).build())
|
||||
.status(CommonCode.SUCCESS.getHttpStatus())
|
||||
.result(CommonCode.SUCCESS.getResult())
|
||||
.build();
|
||||
}
|
||||
public void excelDownLoad(HttpServletResponse response){
|
||||
|
||||
// 리스트 다시 가져옴
|
||||
List<WhiteList> whiteList = whiteListMapper.getWhiteList();
|
||||
|
||||
String sheetName = "Caliverse_whitelist";
|
||||
|
||||
String headerNames[] = new String[]{"Num","GUID","닉네임","반영상태","등록자(이메일주소)"};
|
||||
|
||||
String[][] bodyDatass = new String[whiteList.size()][5];
|
||||
for (int i = 0; i < whiteList.size(); i++) {
|
||||
WhiteList entry = whiteList.get(i);
|
||||
bodyDatass[i][0] = String.valueOf(entry.getRowNum());
|
||||
bodyDatass[i][1] = entry.getGuid();
|
||||
bodyDatass[i][2] = entry.getNickname();
|
||||
bodyDatass[i][3] = entry.getStatus().name();
|
||||
bodyDatass[i][4] = entry.getCreateBy();
|
||||
}
|
||||
String outfileName = "Caliverse_whitelist";
|
||||
try {
|
||||
excelUtils.excelDownload(sheetName, headerNames, bodyDatass ,outfileName, response);
|
||||
}catch (IOException exception){
|
||||
logger.error(exception.getMessage());
|
||||
}
|
||||
|
||||
}
|
||||
@Transactional(transactionManager = "transactionManager")
|
||||
// 승인
|
||||
public WhiteListResponse updateWhiteList(WhiteListRequest whiteListRequest){
|
||||
|
||||
whiteListRequest.getList().forEach(
|
||||
item->{
|
||||
whiteListMapper.updateStatus(item.getId());
|
||||
}
|
||||
);
|
||||
|
||||
return WhiteListResponse.builder()
|
||||
.resultData(WhiteListResponse.ResultData.builder()
|
||||
.message(SuccessCode.UPDATE.getMessage()).build())
|
||||
.status(CommonCode.SUCCESS.getHttpStatus())
|
||||
.result(CommonCode.SUCCESS.getResult())
|
||||
.build();
|
||||
}
|
||||
@Transactional(transactionManager = "transactionManager")
|
||||
public WhiteListResponse deleteWhiteList(WhiteListRequest whiteListRequest){
|
||||
Map<String,Object> map = new HashMap<>();
|
||||
whiteListRequest.getList().forEach(
|
||||
item->{
|
||||
whiteListMapper.deleteWhiteList(item.getId());
|
||||
//로그 기록
|
||||
Map<String,String> resMap = whiteListMapper.getGuidById(item.getId());
|
||||
map.put("adminId", CommonUtils.getAdmin().getId());
|
||||
map.put("name", CommonUtils.getAdmin().getName());
|
||||
map.put("mail", CommonUtils.getAdmin().getEmail());
|
||||
map.put("type", HISTORYTYPE.WHITELIST_DELETE);
|
||||
JSONObject jsonObject = new JSONObject();
|
||||
jsonObject.put("guid",resMap.get("guid"));
|
||||
jsonObject.put("name",resMap.get("nickname"));
|
||||
map.put("content",jsonObject.toString());
|
||||
historyMapper.saveLog(map);
|
||||
dynamoDBService.insertUpdateData(CommonUtils.objectToString(resMap.get("guid")),"isWhiteUser",false);
|
||||
}
|
||||
);
|
||||
|
||||
// 리스트 다시 가져옴
|
||||
List<WhiteList> whiteList = whiteListMapper.getWhiteList();
|
||||
return WhiteListResponse.builder()
|
||||
.resultData(WhiteListResponse.ResultData.builder()
|
||||
.list(whiteList).message(SuccessCode.DELETE.getMessage()).build())
|
||||
.status(CommonCode.SUCCESS.getHttpStatus())
|
||||
.result(CommonCode.SUCCESS.getResult())
|
||||
.build();
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,38 @@
|
||||
package com.caliverse.admin.dynamodb.domain.atrrib;
|
||||
|
||||
import com.caliverse.admin.dynamodb.entity.EInvenEquipType;
|
||||
import com.caliverse.admin.dynamodb.entity.EOwnerEntityType;
|
||||
import com.fasterxml.jackson.annotation.JsonProperty;
|
||||
import com.fasterxml.jackson.databind.PropertyNamingStrategies;
|
||||
import com.fasterxml.jackson.databind.annotation.JsonNaming;
|
||||
import lombok.*;
|
||||
import software.amazon.awssdk.enhanced.dynamodb.mapper.annotations.DynamoDbBean;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
@Getter
|
||||
@Setter
|
||||
@ToString(callSuper = true)
|
||||
@EqualsAndHashCode(callSuper = true)
|
||||
@NoArgsConstructor
|
||||
@DynamoDbBean
|
||||
@JsonNaming(PropertyNamingStrategies.SnakeCaseStrategy.class)
|
||||
public class ItemAttrib extends DynamoDBAttribBase{
|
||||
@JsonProperty("item_guid")
|
||||
private String itemGuid;
|
||||
@JsonProperty("item_meta_id")
|
||||
private Integer itemMetaId;
|
||||
@JsonProperty("owner_guid")
|
||||
private String ownerGuid;
|
||||
@JsonProperty("owner_entity_type")
|
||||
private EOwnerEntityType ownerEntityType;
|
||||
@JsonProperty("item_stack_count")
|
||||
private Integer itemStackCount;
|
||||
private Integer level;
|
||||
@JsonProperty("attributes")
|
||||
private List<Integer> attributes;
|
||||
@JsonProperty("equiped_inven_type")
|
||||
private EInvenEquipType equipedIvenType;
|
||||
@JsonProperty("equiped_pos")
|
||||
private Integer equipedPos;
|
||||
}
|
||||
@@ -0,0 +1,31 @@
|
||||
package com.caliverse.admin.dynamodb.domain.doc;
|
||||
|
||||
import com.caliverse.admin.global.common.constants.DynamoDBConstants;
|
||||
import com.fasterxml.jackson.annotation.JsonProperty;
|
||||
import lombok.EqualsAndHashCode;
|
||||
import lombok.NoArgsConstructor;
|
||||
import lombok.Setter;
|
||||
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 ItemDoc extends DynamoDBDocBase {
|
||||
private String itemAttrib;
|
||||
|
||||
public String getAttribFieldName() {
|
||||
return DynamoDBConstants.ATTRIB_ITEM;
|
||||
}
|
||||
|
||||
@DynamoDbAttribute(DynamoDBConstants.ATTRIB_ITEM)
|
||||
@JsonProperty(DynamoDBConstants.ATTRIB_ITEM)
|
||||
public String getAttribValue() {
|
||||
return itemAttrib;
|
||||
}
|
||||
|
||||
public void setAttribValue(String value) {
|
||||
this.itemAttrib = value;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,23 @@
|
||||
package com.caliverse.admin.dynamodb.entity;
|
||||
|
||||
|
||||
import com.caliverse.admin.domain.entity.common.ValueEnum;
|
||||
|
||||
public enum EInvenEquipType implements ValueEnum {
|
||||
None(0),
|
||||
Cloth(1),
|
||||
Tool(2),
|
||||
Tattoo(3),
|
||||
;
|
||||
|
||||
private final int value;
|
||||
|
||||
EInvenEquipType(int value) {
|
||||
this.value = value;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getValue() {
|
||||
return value;
|
||||
}
|
||||
}
|
||||
@@ -1,8 +1,10 @@
|
||||
package com.caliverse.admin.dynamodb.repository;
|
||||
|
||||
import com.caliverse.admin.domain.RabbitMq.message.AuthAdminLevelType;
|
||||
import com.caliverse.admin.domain.entity.BlackList;
|
||||
import com.caliverse.admin.dynamodb.domain.atrrib.AccountBaseAttrib;
|
||||
import com.caliverse.admin.dynamodb.domain.doc.AccountBaseDoc;
|
||||
import com.caliverse.admin.dynamodb.entity.EAuthAdminLevelType;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
@@ -10,5 +12,6 @@ public interface AccountBaseRepository extends DynamoDBRepository<AccountBaseDoc
|
||||
boolean isBlockUser(String account_id);
|
||||
void updateBlockUserStart(String account_id, BlackList blackList);
|
||||
void updateBlockUserEnd(String account_id);
|
||||
void updateAdminLevel(String accountId, EAuthAdminLevelType type);
|
||||
AccountBaseAttrib findUser(String account_id);
|
||||
}
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
package com.caliverse.admin.dynamodb.repository;
|
||||
|
||||
import com.caliverse.admin.domain.entity.EFilterOperator;
|
||||
import com.caliverse.admin.dynamodb.dto.PageResult;
|
||||
import com.caliverse.admin.dynamodb.service.DynamoDBOperations;
|
||||
import com.caliverse.admin.global.common.code.CommonCode;
|
||||
@@ -91,11 +92,31 @@ public abstract class BaseDynamoDBRepository<T> implements DynamoDBRepository<T>
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public PageResult<T> findByPaging(
|
||||
String partitionKey,
|
||||
String sortKeyPrefix,
|
||||
Map<String, AttributeValue> exclusiveStartKey
|
||||
) {
|
||||
|
||||
return operations.queryItemsPaging(
|
||||
partitionKey,
|
||||
sortKeyPrefix,
|
||||
"",
|
||||
EFilterOperator.NONE,
|
||||
"",
|
||||
exclusiveStartKey,
|
||||
false,
|
||||
entityClass
|
||||
);
|
||||
}
|
||||
|
||||
@Override
|
||||
public PageResult<T> findByPaging(
|
||||
String partitionKey,
|
||||
String sortKeyPrefix,
|
||||
String filterAttributeName,
|
||||
EFilterOperator filterOperator,
|
||||
String filterAttributeValue,
|
||||
Map<String, AttributeValue> exclusiveStartKey,
|
||||
boolean scanIndexForward
|
||||
@@ -105,6 +126,7 @@ public abstract class BaseDynamoDBRepository<T> implements DynamoDBRepository<T>
|
||||
partitionKey,
|
||||
sortKeyPrefix,
|
||||
filterAttributeName,
|
||||
filterOperator,
|
||||
filterAttributeValue,
|
||||
exclusiveStartKey,
|
||||
scanIndexForward,
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
package com.caliverse.admin.dynamodb.repository;
|
||||
|
||||
import com.caliverse.admin.domain.entity.EFilterOperator;
|
||||
import com.caliverse.admin.dynamodb.dto.PageResult;
|
||||
import software.amazon.awssdk.enhanced.dynamodb.Expression;
|
||||
import software.amazon.awssdk.enhanced.dynamodb.Key;
|
||||
@@ -20,11 +21,16 @@ public interface DynamoDBRepository<T> {
|
||||
List<T> findAllScan(String prefix);
|
||||
List<T> findAllScan(String prefix, String sortKey);
|
||||
List<T> findByPrefix(String partitionKey, String sortKeyPrefix);
|
||||
|
||||
PageResult<T> findByPaging(
|
||||
String partitionKey,
|
||||
String sortKeyPrefix,
|
||||
Map<String, AttributeValue> exclusiveStartKey
|
||||
);
|
||||
PageResult<T> findByPaging(
|
||||
String partitionKey,
|
||||
String sortKeyPrefix,
|
||||
String filterAttributeName,
|
||||
EFilterOperator filterOperator,
|
||||
String filterAttributeValue,
|
||||
Map<String, AttributeValue> exclusiveStartKey,
|
||||
boolean scanIndexForward
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
package com.caliverse.admin.dynamodb.repository.Impl;
|
||||
|
||||
import com.caliverse.admin.domain.RabbitMq.message.AuthAdminLevelType;
|
||||
import com.caliverse.admin.domain.entity.BlackList;
|
||||
import com.caliverse.admin.domain.entity.HISTORYTYPE;
|
||||
import com.caliverse.admin.dynamodb.domain.atrrib.AccountBaseAttrib;
|
||||
@@ -8,6 +9,7 @@ import com.caliverse.admin.dynamodb.domain.atrrib.UserNicknameRegistryAttrib;
|
||||
import com.caliverse.admin.dynamodb.domain.doc.AccountBaseDoc;
|
||||
import com.caliverse.admin.dynamodb.domain.doc.LandAuctionRegistryDoc;
|
||||
import com.caliverse.admin.dynamodb.domain.doc.UserNicknameRegistryDoc;
|
||||
import com.caliverse.admin.dynamodb.entity.EAuthAdminLevelType;
|
||||
import com.caliverse.admin.dynamodb.repository.AccountBaseRepository;
|
||||
import com.caliverse.admin.dynamodb.repository.BaseDynamoDBRepository;
|
||||
import com.caliverse.admin.dynamodb.repository.UserNicknameRegistryRepository;
|
||||
@@ -140,6 +142,41 @@ public class AccountBaseRepositoryImpl extends BaseDynamoDBRepository<AccountBas
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void updateAdminLevel(String accountId, EAuthAdminLevelType type) {
|
||||
try {
|
||||
Key key = Key.builder()
|
||||
.partitionValue(DynamoDBConstants.PK_KEY_ACCOUNT_BASE + accountId)
|
||||
.sortValue(DynamoDBConstants.EMPTY)
|
||||
.build();
|
||||
|
||||
AccountBaseDoc beforeDoc = findById(key);
|
||||
|
||||
if (beforeDoc != null) {
|
||||
AccountBaseDoc afterDoc = deepCopy(beforeDoc, AccountBaseDoc.class);
|
||||
|
||||
AccountBaseAttrib attrib = objectMapper.readValue(afterDoc.getAttribValue(), AccountBaseAttrib.class);
|
||||
attrib.setAuthAdminLevelType(type);
|
||||
|
||||
afterDoc.setAttribValue(objectMapper.writeValueAsString(attrib));
|
||||
afterDoc.setUpdatedDateTime(CommonUtils.convertUTCDate(LocalDateTime.now()));
|
||||
|
||||
update(afterDoc);
|
||||
|
||||
log.info("updateAdminLevel Update Success: {}", objectMapper.writeValueAsString(afterDoc));
|
||||
|
||||
dynamodbHistoryLogService.updateHistoryLog(
|
||||
HISTORYTYPE.USER_ADMIN_AUTH_UPDATE,
|
||||
HISTORYTYPE.USER_ADMIN_AUTH_UPDATE.name(),
|
||||
beforeDoc,
|
||||
afterDoc
|
||||
);
|
||||
}
|
||||
}catch (Exception e){
|
||||
throw new RestApiException(CommonCode.ERROR.getHttpStatus(), ErrorCode.DYNAMODB_CONNECTION_ERROR.getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public AccountBaseAttrib findUser(String account_id) {
|
||||
Key key = Key.builder()
|
||||
|
||||
@@ -0,0 +1,123 @@
|
||||
package com.caliverse.admin.dynamodb.repository.Impl;
|
||||
|
||||
import com.caliverse.admin.domain.entity.EFilterOperator;
|
||||
import com.caliverse.admin.domain.entity.HISTORYTYPE;
|
||||
import com.caliverse.admin.domain.entity.SEARCHTYPE;
|
||||
import com.caliverse.admin.dynamodb.domain.atrrib.ItemAttrib;
|
||||
import com.caliverse.admin.dynamodb.domain.atrrib.LandAuctionRegistryAttrib;
|
||||
import com.caliverse.admin.dynamodb.domain.doc.ItemDoc;
|
||||
import com.caliverse.admin.dynamodb.domain.doc.LandAuctionRegistryDoc;
|
||||
import com.caliverse.admin.dynamodb.dto.PageResult;
|
||||
import com.caliverse.admin.dynamodb.repository.BaseDynamoDBRepository;
|
||||
import com.caliverse.admin.dynamodb.repository.ItemRepository;
|
||||
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 software.amazon.awssdk.services.dynamodb.model.AttributeValue;
|
||||
|
||||
import java.time.LocalDateTime;
|
||||
import java.util.Map;
|
||||
|
||||
|
||||
@Component
|
||||
@Slf4j
|
||||
public class ItemRepositoryImpl extends BaseDynamoDBRepository<ItemDoc> implements ItemRepository {
|
||||
public ItemRepositoryImpl(DynamoDBOperations operations, DynamodbHistoryLogService dynamodbHistoryLogService, ObjectMapper objectMapper) {
|
||||
super(operations, ItemDoc.class, dynamodbHistoryLogService, objectMapper);
|
||||
}
|
||||
|
||||
@Override
|
||||
public PageResult<ItemDoc> getItemListWithPaging(
|
||||
String userGuid,
|
||||
String sortKeyPrefix,
|
||||
String filterAttributeName,
|
||||
EFilterOperator filterOperator,
|
||||
String filterAttributeValue,
|
||||
Map<String, AttributeValue> exclusiveStartKey,
|
||||
boolean sortIndex
|
||||
) {
|
||||
|
||||
String pk = DynamoDBConstants.PK_KEY_ITEM + userGuid;;
|
||||
|
||||
return findByPaging(
|
||||
pk,
|
||||
sortKeyPrefix,
|
||||
filterAttributeName,
|
||||
filterOperator,
|
||||
filterAttributeValue,
|
||||
exclusiveStartKey,
|
||||
sortIndex
|
||||
);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void updateItemStack(String guid, String itemGuid, int stackCount) {
|
||||
try {
|
||||
Key key = Key.builder()
|
||||
.partitionValue(DynamoDBConstants.PK_KEY_ITEM + guid)
|
||||
.sortValue(itemGuid)
|
||||
.build();
|
||||
|
||||
ItemDoc beforeDoc = findById(key);
|
||||
|
||||
if (beforeDoc != null) {
|
||||
ItemDoc afterDoc = deepCopy(beforeDoc, ItemDoc.class);
|
||||
|
||||
ItemAttrib attrib = CommonUtils.stringByObject(afterDoc.getAttribValue(), ItemAttrib.class);
|
||||
attrib.setItemStackCount(stackCount);
|
||||
|
||||
afterDoc.setAttribValue(CommonUtils.objectByString(attrib));
|
||||
afterDoc.setUpdatedDateTime(CommonUtils.convertUTCDate(LocalDateTime.now()));
|
||||
|
||||
update(afterDoc);
|
||||
|
||||
log.info("updateItemStack Update Success: {}", CommonUtils.objectByString(afterDoc));
|
||||
|
||||
dynamodbHistoryLogService.updateHistoryLog(
|
||||
HISTORYTYPE.ITEM_UPDATE,
|
||||
HISTORYTYPE.ITEM_UPDATE.name(),
|
||||
beforeDoc,
|
||||
afterDoc
|
||||
);
|
||||
}
|
||||
}catch (Exception e){
|
||||
log.error("Update Item Error: {}", e.getMessage());
|
||||
throw new RestApiException(CommonCode.ERROR.getHttpStatus(), ErrorCode.DYNAMODB_ITEM_UPDATE_ERROR.getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void deleteItem(String guid, String itemGuid) {
|
||||
try {
|
||||
Key key = Key.builder()
|
||||
.partitionValue(DynamoDBConstants.PK_KEY_ITEM + guid)
|
||||
.sortValue(itemGuid)
|
||||
.build();
|
||||
|
||||
ItemDoc beforeDoc = findById(key);
|
||||
|
||||
if (beforeDoc != null) {
|
||||
delete(key);
|
||||
|
||||
log.info("ItemDoc Delete Success: {}", CommonUtils.objectByString(beforeDoc));
|
||||
|
||||
dynamodbHistoryLogService.deleteHistoryLog(
|
||||
HISTORYTYPE.ITEM_DELETE,
|
||||
HISTORYTYPE.ITEM_DELETE.name(),
|
||||
beforeDoc
|
||||
);
|
||||
}
|
||||
}catch (Exception e){
|
||||
log.error("Update LandAuctionRegistry Error: {}", e.getMessage());
|
||||
throw new RestApiException(CommonCode.ERROR.getHttpStatus(), ErrorCode.DYNAMODB_ITEM_DELETE_ERROR.getMessage());
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -119,10 +119,7 @@ public class MailJsonRepositoryImpl extends BaseDynamoDBRepository<MailJsonDoc>
|
||||
SEARCHTYPE type,
|
||||
String userGuid,
|
||||
String sortKeyPrefix,
|
||||
String filterAttributeName,
|
||||
String filterAttributeValue,
|
||||
Map<String, AttributeValue> exclusiveStartKey,
|
||||
boolean sortIndex
|
||||
Map<String, AttributeValue> exclusiveStartKey
|
||||
) {
|
||||
|
||||
String pk;
|
||||
@@ -135,10 +132,7 @@ public class MailJsonRepositoryImpl extends BaseDynamoDBRepository<MailJsonDoc>
|
||||
return findByPaging(
|
||||
pk,
|
||||
sortKeyPrefix,
|
||||
filterAttributeName,
|
||||
filterAttributeValue,
|
||||
exclusiveStartKey,
|
||||
sortIndex
|
||||
exclusiveStartKey
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -119,10 +119,7 @@ public class MailRepositoryImpl extends BaseDynamoDBRepository<MailDoc> implemen
|
||||
SEARCHTYPE type,
|
||||
String userGuid,
|
||||
String sortKeyPrefix,
|
||||
String filterAttributeName,
|
||||
String filterAttributeValue,
|
||||
Map<String, AttributeValue> exclusiveStartKey,
|
||||
boolean sortIndex
|
||||
Map<String, AttributeValue> exclusiveStartKey
|
||||
) {
|
||||
|
||||
String pk;
|
||||
@@ -135,10 +132,7 @@ public class MailRepositoryImpl extends BaseDynamoDBRepository<MailDoc> implemen
|
||||
return findByPaging(
|
||||
pk,
|
||||
sortKeyPrefix,
|
||||
filterAttributeName,
|
||||
filterAttributeValue,
|
||||
exclusiveStartKey,
|
||||
sortIndex
|
||||
exclusiveStartKey
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -9,6 +9,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;
|
||||
@@ -33,10 +34,6 @@ public class UserBaseRepositoryImpl extends BaseDynamoDBRepository<UserBaseDoc>
|
||||
UserBaseDoc doc = findById(key);
|
||||
if(doc == null) return null;
|
||||
|
||||
try {
|
||||
return objectMapper.readValue(doc.getAttribValue(), UserBaseAttrib.class);
|
||||
} catch (JsonProcessingException e) {
|
||||
throw new RestApiException(CommonCode.ERROR.getHttpStatus(), ErrorCode.DYNAMODB_CONNECTION_ERROR.getMessage());
|
||||
}
|
||||
return CommonUtils.stringByObject(doc.getAttribValue(), UserBaseAttrib.class);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -10,6 +10,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.JsonNode;
|
||||
@@ -33,14 +34,12 @@ public class UserNicknameRegistryRepositoryImpl extends BaseDynamoDBRepository<U
|
||||
public UserNicknameRegistryAttrib findUser(String nickname) {
|
||||
Key key = Key.builder()
|
||||
.partitionValue(DynamoDBConstants.PK_KEY_USER_NICKNAME_REGISTRY)
|
||||
.sortValue(nickname)
|
||||
.build();
|
||||
|
||||
UserNicknameRegistryDoc doc = findById(key);
|
||||
try {
|
||||
return objectMapper.readValue(doc.getAttribValue(), UserNicknameRegistryAttrib.class);
|
||||
} catch (JsonProcessingException e) {
|
||||
throw new RestApiException(CommonCode.ERROR.getHttpStatus(), ErrorCode.DYNAMODB_CONNECTION_ERROR.getMessage());
|
||||
}
|
||||
if(doc == null) return null;
|
||||
return CommonUtils.stringByObject(doc.getAttribValue(), UserNicknameRegistryAttrib.class);
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -50,6 +49,7 @@ public class UserNicknameRegistryRepositoryImpl extends BaseDynamoDBRepository<U
|
||||
.build();
|
||||
|
||||
List<UserNicknameRegistryDoc> doc = findAll(key);
|
||||
if(doc == null) return null;
|
||||
|
||||
return doc.stream()
|
||||
.map(UserNicknameRegistryDoc::getAttribValue)
|
||||
|
||||
@@ -0,0 +1,23 @@
|
||||
package com.caliverse.admin.dynamodb.repository;
|
||||
|
||||
import com.caliverse.admin.domain.entity.EFilterOperator;
|
||||
import com.caliverse.admin.dynamodb.domain.doc.ItemDoc;
|
||||
import com.caliverse.admin.dynamodb.dto.PageResult;
|
||||
import software.amazon.awssdk.services.dynamodb.model.AttributeValue;
|
||||
|
||||
import java.util.Map;
|
||||
|
||||
public interface ItemRepository extends DynamoDBRepository<ItemDoc> {
|
||||
PageResult<ItemDoc> getItemListWithPaging(
|
||||
String userGuid,
|
||||
String sortKeyPrefix,
|
||||
String filterAttributeName,
|
||||
EFilterOperator filterOperator,
|
||||
String filterAttributeValue,
|
||||
Map<String, AttributeValue> exclusiveStartKey,
|
||||
boolean sortIndex
|
||||
);
|
||||
void updateItemStack(String guid, String itemGuid, int stackCount);
|
||||
void deleteItem(String userGuid, String itemGuid);
|
||||
|
||||
}
|
||||
@@ -20,9 +20,6 @@ public interface MailJsonRepository extends DynamoDBRepository<MailJsonDoc> {
|
||||
SEARCHTYPE type,
|
||||
String userGuid,
|
||||
String sortKeyPrefix,
|
||||
String filterAttributeName,
|
||||
String filterAttributeValue,
|
||||
Map<String, AttributeValue> exclusiveStartKey,
|
||||
boolean sortIndex
|
||||
Map<String, AttributeValue> exclusiveStartKey
|
||||
);
|
||||
}
|
||||
|
||||
@@ -6,6 +6,7 @@ import com.caliverse.admin.domain.entity.metadata.MetaSystemMailData;
|
||||
import com.caliverse.admin.domain.request.MailRequest;
|
||||
import com.caliverse.admin.dynamodb.domain.atrrib.MailItemAttrib;
|
||||
import com.caliverse.admin.dynamodb.domain.doc.MailDoc;
|
||||
import com.caliverse.admin.dynamodb.domain.doc.MailJsonDoc;
|
||||
import com.caliverse.admin.dynamodb.dto.PageResult;
|
||||
import com.caliverse.admin.dynamodb.entity.MailItem;
|
||||
import software.amazon.awssdk.services.dynamodb.model.AttributeValue;
|
||||
@@ -21,9 +22,6 @@ public interface MailRepository extends DynamoDBRepository<MailDoc> {
|
||||
SEARCHTYPE type,
|
||||
String userGuid,
|
||||
String sortKeyPrefix,
|
||||
String filterAttributeName,
|
||||
String filterAttributeValue,
|
||||
Map<String, AttributeValue> exclusiveStartKey,
|
||||
boolean sortIndex
|
||||
Map<String, AttributeValue> exclusiveStartKey
|
||||
);
|
||||
}
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
package com.caliverse.admin.dynamodb.service;
|
||||
|
||||
import com.caliverse.admin.domain.entity.EFilterOperator;
|
||||
import com.caliverse.admin.dynamodb.dto.PageResult;
|
||||
import com.caliverse.admin.global.common.constants.CommonConstants;
|
||||
import com.caliverse.admin.global.component.transaction.DynamoDBTransactionContext;
|
||||
@@ -296,6 +297,7 @@ public class DynamoDBOperations {
|
||||
String partitionKey,
|
||||
String sortKeyPrefix,
|
||||
String filterAttributeName,
|
||||
EFilterOperator filterOperator,
|
||||
String filterAttributeValue,
|
||||
Map<String, AttributeValue> exclusiveStartKey,
|
||||
boolean scanIndexForward,
|
||||
@@ -318,8 +320,15 @@ public class DynamoDBOperations {
|
||||
// 필터
|
||||
Expression filterExpression = null;
|
||||
if (!filterAttributeName.isEmpty() && !filterAttributeValue.isEmpty()) {
|
||||
String expressionString = switch (filterOperator) {
|
||||
case EQUALS -> "#filterAttr = :filterValue";
|
||||
case CONTAINS -> "contains(#filterAttr, :filterValue)";
|
||||
case NOT_EQUALS -> "#filterAttr <> :filterValue";
|
||||
default -> "begins_with(#filterAttr, :filterValue)";
|
||||
};
|
||||
|
||||
filterExpression = Expression.builder()
|
||||
.expression("begins_with(#filterAttr, :filterValue)")
|
||||
.expression(expressionString)
|
||||
.putExpressionName("#filterAttr", filterAttributeName)
|
||||
.putExpressionValue(":filterValue", AttributeValue.builder().s(filterAttributeValue).build())
|
||||
.build();
|
||||
|
||||
@@ -0,0 +1,105 @@
|
||||
package com.caliverse.admin.dynamodb.service;
|
||||
|
||||
import com.caliverse.admin.domain.datacomponent.MetaDataHandler;
|
||||
import com.caliverse.admin.domain.entity.EFilterOperator;
|
||||
import com.caliverse.admin.domain.entity.ITEMLARGETYPE;
|
||||
import com.caliverse.admin.domain.response.UsersResponse;
|
||||
import com.caliverse.admin.dynamodb.domain.atrrib.ItemAttrib;
|
||||
import com.caliverse.admin.dynamodb.domain.doc.ItemDoc;
|
||||
import com.caliverse.admin.dynamodb.dto.PageResult;
|
||||
import com.caliverse.admin.dynamodb.entity.KeyParam;
|
||||
import com.caliverse.admin.dynamodb.repository.*;
|
||||
import com.caliverse.admin.global.common.annotation.DynamoDBTransaction;
|
||||
import com.caliverse.admin.global.common.constants.DynamoDBConstants;
|
||||
import com.caliverse.admin.global.common.utils.CommonUtils;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.stereotype.Service;
|
||||
import software.amazon.awssdk.services.dynamodb.model.AttributeValue;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
|
||||
@Slf4j
|
||||
@Service
|
||||
@RequiredArgsConstructor
|
||||
public class DynamodbItemService {
|
||||
private final ItemRepository itemRepository;
|
||||
private final MetaDataHandler metaDataHandler;
|
||||
|
||||
public PageResult<ItemDoc> getItems(String guid, KeyParam pageKey){
|
||||
Map<String, AttributeValue> pagingKey = null;
|
||||
if(pageKey != null){
|
||||
pagingKey = new HashMap<>();
|
||||
pagingKey.put(DynamoDBConstants.PK_KEY_NAME, AttributeValue.builder().s(pageKey.getPk()).build());
|
||||
pagingKey.put(DynamoDBConstants.SK_KEY_NAME, AttributeValue.builder().s(pageKey.getSk()).build());
|
||||
}
|
||||
PageResult<ItemDoc> itemList = itemRepository.getItemListWithPaging(guid, "","",null, "", pagingKey, false);
|
||||
return itemList;
|
||||
}
|
||||
|
||||
public UsersResponse.InventoryInfo getInvenItems(String guid){
|
||||
List<UsersResponse.Item> clothList = new ArrayList<>();
|
||||
List<UsersResponse.Item> propList = new ArrayList<>();
|
||||
List<UsersResponse.Item> beautyList = new ArrayList<>();
|
||||
List<UsersResponse.Item> tattooList = new ArrayList<>();
|
||||
List<UsersResponse.Item> currencyList = new ArrayList<>();
|
||||
List<UsersResponse.Item> etcList = new ArrayList<>();
|
||||
|
||||
Map<String, AttributeValue> pageKey = null;
|
||||
do {
|
||||
PageResult<ItemDoc> itemList = itemRepository.getItemListWithPaging(guid, "", DynamoDBConstants.ATTRIB_ITEM, EFilterOperator.CONTAINS,"\"equiped_inven_type\":0", pageKey, false);
|
||||
|
||||
itemList.getItems().forEach(item -> {
|
||||
ItemAttrib attrib = CommonUtils.stringByObject(item.getAttribValue(), ItemAttrib.class);
|
||||
int item_id = attrib.getItemMetaId();
|
||||
String item_name = metaDataHandler.getTextStringData(metaDataHandler.getMetaItemNameData(item_id));
|
||||
String item_type = metaDataHandler.getMetaItemLargeTypeData(item_id);
|
||||
|
||||
UsersResponse.Item inventory = UsersResponse.Item.builder()
|
||||
.itemId(item_id)
|
||||
.itemName(item_name)
|
||||
.count(attrib.getItemStackCount())
|
||||
.itemGuid(attrib.getItemGuid())
|
||||
.build();
|
||||
|
||||
if(item_type.isEmpty()) {
|
||||
etcList.add(inventory);
|
||||
}else{
|
||||
switch (ITEMLARGETYPE.valueOf(item_type)){
|
||||
case CLOTH -> clothList.add(inventory);
|
||||
case PROP -> propList.add(inventory);
|
||||
case BEAUTY -> beautyList.add(inventory);
|
||||
case TATTOO -> tattooList.add(inventory);
|
||||
case CURRENCY -> currencyList.add(inventory);
|
||||
default -> etcList.add(inventory);
|
||||
}}
|
||||
});
|
||||
|
||||
pageKey = itemList.getLastEvaluatedKey();
|
||||
} while (pageKey != null);
|
||||
|
||||
return UsersResponse.InventoryInfo.builder()
|
||||
.cloth(clothList)
|
||||
.prop(propList)
|
||||
.beauty(beautyList)
|
||||
.tattoo(tattooList)
|
||||
.currency(currencyList)
|
||||
.etc(etcList)
|
||||
.build();
|
||||
}
|
||||
|
||||
@DynamoDBTransaction
|
||||
public void updateItemStack(String guid, String itemGuid, int stackCount){
|
||||
itemRepository.updateItemStack(guid, itemGuid, stackCount);
|
||||
}
|
||||
|
||||
@DynamoDBTransaction
|
||||
public void deleteItem(String guid, String itemGuid){
|
||||
itemRepository.deleteItem(guid, itemGuid);
|
||||
}
|
||||
}
|
||||
@@ -21,6 +21,7 @@ import com.caliverse.admin.global.common.annotation.DynamoDBTransaction;
|
||||
import com.caliverse.admin.global.common.constants.AdminConstants;
|
||||
import com.caliverse.admin.global.common.constants.CommonConstants;
|
||||
import com.caliverse.admin.global.common.constants.DynamoDBConstants;
|
||||
import com.caliverse.admin.global.common.utils.CommonUtils;
|
||||
import com.caliverse.admin.logs.Indicatordomain.StartEndTime;
|
||||
import com.caliverse.admin.logs.logservice.LogServiceHelper;
|
||||
import com.caliverse.admin.logs.logservice.indicators.IndicatorsMoneyService;
|
||||
@@ -101,14 +102,14 @@ public class DynamodbService {
|
||||
mailRepository.insertRecvSystemMail(guid, nickname, items, systemMailData, arguments);
|
||||
}
|
||||
|
||||
public PageResult<MailDoc> getMail(SEARCHTYPE type, String guid, String sortKey, String filterName, String filterValue, KeyParam pageKey, boolean sortIndex){
|
||||
public PageResult<MailDoc> getMail(SEARCHTYPE type, String guid, String sortKey, KeyParam pageKey){
|
||||
Map<String, AttributeValue> pagingKey = null;
|
||||
if(pageKey != null){
|
||||
pagingKey = new HashMap<>();
|
||||
pagingKey.put(DynamoDBConstants.PK_KEY_NAME, AttributeValue.builder().s(pageKey.getPk()).build());
|
||||
pagingKey.put(DynamoDBConstants.SK_KEY_NAME, AttributeValue.builder().s(pageKey.getSk()).build());
|
||||
}
|
||||
PageResult<MailDoc> mailList = mailRepository.getMailListWithPaging(type, guid, sortKey, filterName, filterValue, pagingKey, sortIndex);
|
||||
PageResult<MailDoc> mailList = mailRepository.getMailListWithPaging(type, guid, sortKey, pagingKey);
|
||||
return mailList;
|
||||
}
|
||||
|
||||
@@ -119,7 +120,7 @@ public class DynamodbService {
|
||||
.sortValue(sk)
|
||||
.build();
|
||||
MailJsonDoc mailDoc = mailJsonRepository.findById(key);
|
||||
return mapper.readValue(mailDoc.getAttribValue(), MailJsonAttrib.class);
|
||||
return CommonUtils.stringByObject(mailDoc.getAttribValue(), MailJsonAttrib.class);
|
||||
}catch (Exception e){
|
||||
log.error(e.getMessage());
|
||||
}
|
||||
|
||||
@@ -1,16 +1,10 @@
|
||||
package com.caliverse.admin.dynamodb.service;
|
||||
|
||||
import com.caliverse.admin.domain.entity.BlackList;
|
||||
import com.caliverse.admin.dynamodb.domain.atrrib.AccountBaseAttrib;
|
||||
import com.caliverse.admin.dynamodb.domain.atrrib.MoneyAttrib;
|
||||
import com.caliverse.admin.dynamodb.domain.atrrib.NicknameAttrib;
|
||||
import com.caliverse.admin.dynamodb.domain.atrrib.UserBaseAttrib;
|
||||
import com.caliverse.admin.dynamodb.domain.atrrib.*;
|
||||
import com.caliverse.admin.dynamodb.entity.EAuthAdminLevelType;
|
||||
import com.caliverse.admin.dynamodb.repository.*;
|
||||
import com.caliverse.admin.global.common.annotation.DynamoDBTransaction;
|
||||
import com.caliverse.admin.global.common.code.CommonCode;
|
||||
import com.caliverse.admin.global.common.code.ErrorCode;
|
||||
import com.caliverse.admin.global.common.exception.RestApiException;
|
||||
import com.fasterxml.jackson.core.JsonProcessingException;
|
||||
import com.fasterxml.jackson.databind.ObjectMapper;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
@@ -23,7 +17,7 @@ import org.springframework.stereotype.Service;
|
||||
public class DynamodbUserService {
|
||||
private final AccountBaseRepository accountBaseRepository;
|
||||
private final UserBaseRepository userBaseRepository;
|
||||
private final UserNicknameRegistryRepository registryRepository;
|
||||
private final UserNicknameRegistryRepository userNicknameRegistryRepository;
|
||||
private final NicknameRepository nicknameRepository;
|
||||
private final MoneyRepository moneyRepository;
|
||||
|
||||
@@ -34,6 +28,14 @@ public class DynamodbUserService {
|
||||
return accountBaseRepository.isBlockUser(account_id);
|
||||
}
|
||||
|
||||
public boolean isUser(String guid){
|
||||
UserBaseAttrib userBaseAttrib = userBaseRepository.findUser(guid);
|
||||
if(userBaseAttrib == null){
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
@DynamoDBTransaction
|
||||
public void updateBlockUser(BlackList.STATUSTYPE status, BlackList blackList){
|
||||
String guid = blackList.getGuid();
|
||||
@@ -67,6 +69,53 @@ public class DynamodbUserService {
|
||||
return userBaseAttrib.getAccountId();
|
||||
}
|
||||
|
||||
public String getAccountIdByGuid(String accountId){
|
||||
AccountBaseAttrib accountBaseAttrib = accountBaseRepository.findUser(accountId);
|
||||
if(accountBaseAttrib == null){
|
||||
log.error("getAccountIdByGuid accountBase Null accountId: {}", accountId);
|
||||
return "";
|
||||
}
|
||||
|
||||
return accountBaseAttrib.getUserGuid();
|
||||
}
|
||||
|
||||
public String getAccountIdByName(String accountId){
|
||||
AccountBaseAttrib accountBaseAttrib = accountBaseRepository.findUser(accountId);
|
||||
if(accountBaseAttrib == null){
|
||||
log.error("getAccountIdByName accountBase Null accountId: {}", accountId);
|
||||
return "";
|
||||
}
|
||||
|
||||
return getGuidByName(accountBaseAttrib.getUserGuid());
|
||||
}
|
||||
|
||||
public String getNameByGuid(String nickname){
|
||||
UserNicknameRegistryAttrib nicknameRegistryAttrib = userNicknameRegistryRepository.findUser(nickname);
|
||||
if(nicknameRegistryAttrib == null){
|
||||
log.error("getNameByGuid UserNicknameRegistry Null nickname: {}", nickname);
|
||||
return "";
|
||||
}
|
||||
|
||||
return nicknameRegistryAttrib.getUserGuid();
|
||||
}
|
||||
|
||||
public String getUserLanguage(String guid){
|
||||
String account_id = getGuidByAccountId(guid);
|
||||
AccountBaseAttrib accountBaseAttrib = accountBaseRepository.findUser(account_id);
|
||||
if(accountBaseAttrib == null){
|
||||
log.error("getUserLanguage accountBase Null accountId: {}", account_id);
|
||||
return "";
|
||||
}
|
||||
|
||||
return accountBaseAttrib.getLanguageType().name();
|
||||
}
|
||||
|
||||
@DynamoDBTransaction
|
||||
public void updateAdminLevel(String guid, EAuthAdminLevelType type){
|
||||
String account_id = getGuidByAccountId(guid);
|
||||
accountBaseRepository.updateAdminLevel(account_id, type);
|
||||
}
|
||||
|
||||
public AccountBaseAttrib getAccountInfo(String accountId){
|
||||
return accountBaseRepository.findUser(accountId);
|
||||
}
|
||||
|
||||
@@ -12,7 +12,7 @@ public enum ErrorCode {
|
||||
// json
|
||||
//------------------------------------------------------------------------------------------------------------------------------
|
||||
USER_GAME_LOGIN_JSON_MAPPER_PARSE_ERROR("유저 게임세션 데이터 파싱하는 도중 에러가 발생했습니다."),
|
||||
|
||||
JSON_PARSE_ERROR("데이터 파싱 에러"),
|
||||
|
||||
WRONG_TYPE_TOKEN("잘못된 타입의 토큰입니다."),
|
||||
EXPIRED_TOKEN("만료된 토큰입니다."),
|
||||
@@ -102,6 +102,7 @@ public enum ErrorCode {
|
||||
DYNAMODB_ITEM_DELETE_FAIL("아이템 삭제에 실패하였습니다."),
|
||||
DYNAMODB_CONVERT_ERROR("형변환 도중 에러가 발생하였습니다."),
|
||||
DYNAMODB_JSON_PARSE_ERROR("dynamoDB Json 변환 중 에러 발생"),
|
||||
DYNAMODB_NOT_USER("유저를 찾을수 없습니다."),
|
||||
|
||||
USER_BLOCK_REGIST_DUPLE_WARNING("이미 제재가 등록된 유저입니다."),
|
||||
|
||||
@@ -112,6 +113,9 @@ public enum ErrorCode {
|
||||
NICKNAME_SPECIALCHAR_ERROR("닉네임은 특수문자를 사용할 수 없습니다. 다시 시도해주세요."),
|
||||
NICKNAME_LANGTH_ERROR("닉네임은 최소 2글자에서 최대 12글자까지 허용 합니다. 다시 시도해주세요."),
|
||||
|
||||
//item
|
||||
DYNAMODB_ITEM_DELETE_ERROR("아이템 삭제 중 오류가 발생하였습니다."),
|
||||
DYNAMODB_ITEM_UPDATE_ERROR("아이템 수정 중 오류가 발생하였습니다."),
|
||||
|
||||
SENDMAIL_ERROR("메일 발송중 오류가 발생하였습니다. 관리자에게 문의주세요."),
|
||||
|
||||
|
||||
@@ -26,6 +26,7 @@ public class DynamoDBConstants {
|
||||
public static final String PK_KEY_NICKNAME = "nickname#";
|
||||
public static final String PK_KEY_RECV_MAIL = "recv_mail#";
|
||||
public static final String PK_KEY_SENT_MAIL = "sent_mail#";
|
||||
public static final String PK_KEY_ITEM = "item#";
|
||||
|
||||
//SK
|
||||
public static final String SK_KEY_NAME = "SK";
|
||||
@@ -43,6 +44,7 @@ public class DynamoDBConstants {
|
||||
public static final String ATTRIB_OWNED_LAND = "OwnedLandAttrib";
|
||||
public static final String ATTRIB_OWNED_BUILDING = "OwnedBuildingAttrib";
|
||||
public static final String ATTRIB_MAIL = "MailAttrib";
|
||||
public static final String ATTRIB_ITEM = "ItemAttrib";
|
||||
|
||||
//DOC
|
||||
public static final String DOC_SYSTEMMAIL = "SystemMetaMailDoc";
|
||||
@@ -56,6 +58,7 @@ public class DynamoDBConstants {
|
||||
public static final String DOC_OWNED_LAND = "OwnedLandDoc";
|
||||
public static final String DOC_OWNED_BUILDING = "OwnedBuildingDoc";
|
||||
public static final String DOC_Mail = "MailDoc";
|
||||
public static final String DOC_ITEM = "ItemDoc";
|
||||
|
||||
//SCHEMA
|
||||
public static final String SCHEMA_UPDATE_TIME = "UpdatedDateTime";
|
||||
|
||||
@@ -13,7 +13,6 @@ import com.caliverse.admin.global.common.code.CommonCode;
|
||||
import com.caliverse.admin.global.common.constants.CommonConstants;
|
||||
import com.caliverse.admin.global.common.exception.RestApiException;
|
||||
import com.fasterxml.jackson.core.JsonProcessingException;
|
||||
import com.fasterxml.jackson.core.type.TypeReference;
|
||||
import com.fasterxml.jackson.databind.ObjectMapper;
|
||||
import jakarta.servlet.http.HttpServletRequest;
|
||||
import org.slf4j.Logger;
|
||||
@@ -306,12 +305,21 @@ public class CommonUtils {
|
||||
return matcher.find();
|
||||
}
|
||||
|
||||
public static Map<String, Object> stringByObject(String string) {
|
||||
public static <T> T stringByObject(String string, Class<T> valueType) {
|
||||
try {
|
||||
ObjectMapper objectMapper = new ObjectMapper();
|
||||
return objectMapper.readValue(string, new TypeReference<>() {});
|
||||
return objectMapper.readValue(string, valueType);
|
||||
} catch (JsonProcessingException e) {
|
||||
throw new RestApiException(CommonCode.ERROR.getHttpStatus(), ErrorCode.DYNAMODB_CONNECTION_ERROR.getMessage());
|
||||
throw new RestApiException(CommonCode.ERROR.getHttpStatus(), ErrorCode.JSON_PARSE_ERROR.getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
public static String objectByString(Object object) {
|
||||
try {
|
||||
ObjectMapper objectMapper = new ObjectMapper();
|
||||
return objectMapper.writeValueAsString(object);
|
||||
} catch (JsonProcessingException e) {
|
||||
throw new RestApiException(CommonCode.ERROR.getHttpStatus(), ErrorCode.JSON_PARSE_ERROR.getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -1,51 +0,0 @@
|
||||
package com.caliverse.admin.global.configuration;
|
||||
|
||||
|
||||
import com.caliverse.admin.history.repository.MongoAdminRepository;
|
||||
import com.mongodb.client.MongoClient;
|
||||
import com.mongodb.client.MongoClients;
|
||||
import org.springframework.beans.factory.annotation.Qualifier;
|
||||
import org.springframework.beans.factory.annotation.Value;
|
||||
import org.springframework.context.annotation.Bean;
|
||||
import org.springframework.context.annotation.Configuration;
|
||||
import org.springframework.data.mongodb.MongoDatabaseFactory;
|
||||
import org.springframework.data.mongodb.core.MongoTemplate;
|
||||
import org.springframework.data.mongodb.core.SimpleMongoClientDatabaseFactory;
|
||||
import org.springframework.data.mongodb.repository.config.EnableMongoRepositories;
|
||||
|
||||
import java.net.URLEncoder;
|
||||
import java.nio.charset.StandardCharsets;
|
||||
|
||||
|
||||
@Configuration
|
||||
//@EnableMongoRepositories(basePackages = "com.caliverse.admin.history.repository", mongoTemplateRef = "mongoAdminTemplate")
|
||||
public class MongoAdminConfig {
|
||||
|
||||
@Value("${mongodb.host}")
|
||||
String businessLogHost;
|
||||
@Value("${mongodb.admin.username}")
|
||||
String username;
|
||||
@Value("${mongodb.admin.password}")
|
||||
String password;
|
||||
@Value("${mongodb.admin.db}")
|
||||
String db;
|
||||
|
||||
// @Bean(name = "mongoAdminClient")
|
||||
// public MongoClient mongoStatClient() {
|
||||
// String encodePassword = URLEncoder.encode(password, StandardCharsets.UTF_8);
|
||||
// String auth = username.isEmpty() ? "" : String.format("%s:%s@",username, encodePassword);
|
||||
// String connection = String.format("mongodb://%s%s/?authSource=%s", auth, businessLogHost, db);
|
||||
// return MongoClients.create(connection);
|
||||
// }
|
||||
|
||||
// @Bean(name = "mongoAdminFactory")
|
||||
// public MongoDatabaseFactory mongoIndicatorFactory(@Qualifier("mongoAdminClient") MongoClient mongoIndicatorClient) {
|
||||
// return new SimpleMongoClientDatabaseFactory(mongoIndicatorClient, db);
|
||||
// }
|
||||
|
||||
// @Bean(name = "mongoAdminTemplate")
|
||||
// public MongoTemplate mongoIndicatorTemplate(@Qualifier("mongoAdminFactory") MongoDatabaseFactory mongoIndicatorFactory) {
|
||||
// return new MongoTemplate(mongoIndicatorFactory);
|
||||
// }
|
||||
|
||||
}
|
||||
@@ -46,11 +46,10 @@ public class MongoBusinessLogConfig {
|
||||
String encodePassword = URLEncoder.encode(password, StandardCharsets.UTF_8);
|
||||
String auth = username.isEmpty() ? "" : String.format("%s:%s@",username, encodePassword);
|
||||
String connection;
|
||||
// if(activeProfile.equals("local") || activeProfile.equals("dev")) {
|
||||
if(!activeProfile.equals("qa")) {
|
||||
if(activeProfile.equals("local") || activeProfile.equals("dev")) {
|
||||
connection = String.format("mongodb://%s%s/?authSource=%s", auth, businessLogHost, businessLogdb);
|
||||
}else{
|
||||
connection = String.format("mongodb+srv://%s%s/%s", auth, businessLogHost, businessLogdb);
|
||||
connection = String.format("mongodb+srv://%s%s/%s?retryWrites=true&w=majority&appName=backoffice-%s", auth, businessLogHost, businessLogdb, activeProfile);
|
||||
}
|
||||
return MongoClients.create(connection);
|
||||
}
|
||||
|
||||
@@ -47,11 +47,10 @@ public class MongoIndicatorConfig {
|
||||
String encodePassword = URLEncoder.encode(password, StandardCharsets.UTF_8);
|
||||
String auth = username.isEmpty() ? "" : String.format("%s:%s@",username, encodePassword);
|
||||
String connection;
|
||||
// if(activeProfile.equals("local") || activeProfile.equals("dev")) {
|
||||
if(!activeProfile.equals("qa")) {
|
||||
if(activeProfile.equals("local") || activeProfile.equals("dev")) {
|
||||
connection = String.format("mongodb://%s%s/?authSource=%s", auth, businessLogHost, db);
|
||||
}else{
|
||||
connection = String.format("mongodb+srv://%s%s/%s", auth, businessLogHost, db);
|
||||
connection = String.format("mongodb+srv://%s%s/%s?retryWrites=true&w=majority&appName=backoffice-%s", auth, businessLogHost, db, activeProfile);
|
||||
}
|
||||
return MongoClients.create(connection);
|
||||
}
|
||||
|
||||
@@ -58,9 +58,7 @@ public class BusinessLogGenericService extends BusinessLogServiceBase {
|
||||
Criteria criteria = makeCriteria(startTime, endTime);
|
||||
List<AggregationOperation> operations = setDefaultOperation(criteria);
|
||||
|
||||
// if(activeProfile.equals("local") || activeProfile.equals("dev")) {
|
||||
if(!activeProfile.equals("qa")) {
|
||||
|
||||
if(activeProfile.equals("local") || activeProfile.equals("dev")) {
|
||||
//message json parsing
|
||||
operations.add(context ->
|
||||
new Document("$addFields",
|
||||
|
||||
@@ -29,6 +29,9 @@ public class OneTimeSchedule implements CommandLineRunner {
|
||||
@Autowired private IndicatorsDBCapacityService capacityService;
|
||||
@Autowired private IndicatorsUgqCreateService ugqCreateService;
|
||||
@Autowired private IndicatorsMetaverseServerService metaverseServerService;
|
||||
@Autowired private IndicatorsUserCreateService userCreateService;
|
||||
@Autowired private IndicatorsUserLoginService userLoginService;
|
||||
|
||||
@Autowired private DynamodbService dynamodbService;
|
||||
|
||||
@Override
|
||||
@@ -37,15 +40,17 @@ public class OneTimeSchedule implements CommandLineRunner {
|
||||
log.info("Starting OneTimeSchedule");
|
||||
// dynamodbService.saveUserMoney(); //유저별 재화 데이터 저장
|
||||
|
||||
// LocalDate startDate = LocalDate.of(2024, 11, 8);
|
||||
//// LocalDate currentDate = LocalDate.of(2024, 9, 10);
|
||||
// LocalDate currentDate = LocalDate.now();
|
||||
//
|
||||
// for (LocalDate date = startDate; !date.isAfter(currentDate); date = date.plusDays(1)) {
|
||||
// StartEndTime dayStartEndTime = LogServiceHelper.getCurrentLogSearchEndTime(date, AdminConstants.STAT_DAY_NUM);
|
||||
// StartEndTime weekStartEndTime = LogServiceHelper.getCurrentLogSearchEndTime(date, AdminConstants.STAT_WEEK_NUM);
|
||||
// StartEndTime monthStartEndTime = LogServiceHelper.getCurrentLogSearchEndTime(date, AdminConstants.STAT_MONTH_NUM);
|
||||
LocalDate startDate = LocalDate.of(2024, 8, 28);
|
||||
// LocalDate currentDate = LocalDate.of(2025, 1, 31);
|
||||
LocalDate currentDate = LocalDate.now();
|
||||
//
|
||||
for (LocalDate date = startDate; !date.isAfter(currentDate); date = date.plusDays(1)) {
|
||||
StartEndTime dayStartEndTime = LogServiceHelper.getCurrentLogSearchEndTime(date, AdminConstants.STAT_DAY_NUM);
|
||||
StartEndTime weekStartEndTime = LogServiceHelper.getCurrentLogSearchEndTime(date, AdminConstants.STAT_WEEK_NUM);
|
||||
StartEndTime monthStartEndTime = LogServiceHelper.getCurrentLogSearchEndTime(date, AdminConstants.STAT_MONTH_NUM);
|
||||
|
||||
// userLoginService.collectUserLogin(dayStartEndTime.getStartTime(), dayStartEndTime.getEndTime());
|
||||
// userCreateService.collectUserCreate(dayStartEndTime.getStartTime(), dayStartEndTime.getEndTime());
|
||||
// metaverseServerService.collectMetaverseServerCount(dayStartEndTime.getStartTime(), dayStartEndTime.getEndTime(), 13);
|
||||
// capacityService.collectDBCapacity(dayStartEndTime.getStartTime(), dayStartEndTime.getEndTime()); //체크
|
||||
// dauService.collectDailyActiveUser(dayStartEndTime.getStartTime(), dayStartEndTime.getEndTime()); //체크
|
||||
@@ -56,7 +61,7 @@ public class OneTimeSchedule implements CommandLineRunner {
|
||||
// playTimeService.collectUserPlayTime(dayStartEndTime.getStartTime(), dayStartEndTime.getEndTime()); //체크
|
||||
// dglcService.collectDailyGameLoginCount(dayStartEndTime.getStartTime(), dayStartEndTime.getEndTime()); //체크
|
||||
// ugqCreateService.collectUGQCreateCount(dayStartEndTime.getStartTime(), dayStartEndTime.getEndTime()); //체크
|
||||
// }
|
||||
}
|
||||
|
||||
|
||||
}catch (Exception e){
|
||||
|
||||
@@ -1,8 +0,0 @@
|
||||
package com.caliverse.admin.scheduler.entity;
|
||||
|
||||
public enum ScheduleType {
|
||||
IMMEDIATE, //즉시 실행
|
||||
DELAYED, //지연 실행
|
||||
RECURRING, //반복 실행
|
||||
PERIODIC //특정 시간
|
||||
}
|
||||
@@ -39,7 +39,7 @@
|
||||
AND a.deleted = 0
|
||||
|
||||
<if test="search_data != null and search_data != ''">
|
||||
AND a.title LIKE CONCAT('%',#{search_data},'%')
|
||||
AND a.title LIKE CONCAT('%',#{searchData},'%')
|
||||
</if>
|
||||
|
||||
<if test="status != null and status != ''">
|
||||
@@ -51,8 +51,8 @@
|
||||
</if>
|
||||
|
||||
<if test="start_dt != null and start_dt != '' and end_dt !=null and end_dt!= ''">
|
||||
AND a.start_dt >= #{start_dt, jdbcType=TIMESTAMP}
|
||||
AND a.end_dt <= #{end_dt, jdbcType=TIMESTAMP}
|
||||
AND a.start_dt >= #{startDate, jdbcType=TIMESTAMP}
|
||||
AND a.end_dt <= #{endDate, jdbcType=TIMESTAMP}
|
||||
</if>
|
||||
|
||||
ORDER BY a.create_dt
|
||||
|
||||
@@ -1,59 +0,0 @@
|
||||
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
||||
"http://mybatis.org/dtd/mybatis-3-mapper.dtd">
|
||||
<mapper namespace="com.caliverse.admin.domain.dao.admin.WhiteListMapper">
|
||||
<resultMap id="WhiteListResultMap" type="com.caliverse.admin.domain.entity.WhiteList">
|
||||
<id property="id" column="id"/>
|
||||
<result property="rowNum" column="row_num"/>
|
||||
<result property="guid" column="guid"/>
|
||||
<result property="nickname" column="nickname"/>
|
||||
<result property="status" column="status"/>
|
||||
<result property="createBy" column="create_by"/>
|
||||
</resultMap>
|
||||
<!--사용 이력 리스트 조회-->
|
||||
<select id="getWhiteList" parameterType="map" resultMap="WhiteListResultMap">
|
||||
SELECT
|
||||
(@row_number:=@row_number + 1) AS row_num
|
||||
, a.id
|
||||
, a.guid
|
||||
, a.nickname
|
||||
, a.status
|
||||
, (SELECT email FROM admin WHERE id = a.create_by ) AS create_by
|
||||
FROM white_list a
|
||||
, (SELECT @row_number:=0) AS t
|
||||
WHERE 1 = 1
|
||||
AND a.deleted = 0
|
||||
ORDER BY a.create_dt desc
|
||||
</select>
|
||||
<select id="getCountByGuid" parameterType="java.lang.String" resultType="java.lang.Integer">
|
||||
SELECT
|
||||
Count(*)
|
||||
FROM white_list
|
||||
WHERE guid = #{guid}
|
||||
AND status = 'PERMITTED'
|
||||
AND deleted = 0
|
||||
</select>
|
||||
<select id="getGuidById" parameterType="java.lang.Long" resultType="map">
|
||||
SELECT
|
||||
guid, nickname
|
||||
FROM white_list
|
||||
WHERE id = #{id}
|
||||
</select>
|
||||
|
||||
<insert id="postWhiteList" parameterType="com.caliverse.admin.domain.request.WhiteListRequest">
|
||||
INSERT INTO white_list (guid,nickname, status, create_by)
|
||||
VALUES (#{guid},#{nickname}, #{status},#{createBy})
|
||||
</insert>
|
||||
|
||||
<update id="updateStatus" parameterType="java.lang.Long">
|
||||
UPDATE white_list SET status = 'PERMITTED' , update_dt = NOW()
|
||||
WHERE id = #{id}
|
||||
</update>
|
||||
|
||||
<update id="deleteWhiteList" parameterType="java.lang.Long">
|
||||
UPDATE white_list SET deleted = 1
|
||||
WHERE id = #{id}
|
||||
</update>
|
||||
|
||||
|
||||
|
||||
</mapper>
|
||||
Reference in New Issue
Block a user