에러 반환 타입변경

유저 정보 조회 수정
This commit is contained in:
2025-04-25 15:46:29 +09:00
parent 031e97d305
commit d7c6ce3277
11 changed files with 149 additions and 111 deletions

View File

@@ -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.ELanguageType;
import com.fasterxml.jackson.annotation.JsonInclude;
import com.fasterxml.jackson.annotation.JsonProperty;
import lombok.AllArgsConstructor;
@@ -74,7 +75,7 @@ public class UsersResponse {
private String aid;
@JsonProperty("user_id")
private String userId;
private LANGUAGETYPE nation;
private ELanguageType nation;
private String membership;
//친구 추천코드
@JsonProperty("friend_code")
@@ -108,16 +109,16 @@ public class UsersResponse {
private String level;
//골드
@JsonProperty("gold_cali")
private String goldCali;
private Double goldCali;
//사파이어
@JsonProperty("blue_cali")
private String blueCali;
private Double blueCali;
//칼리움
@JsonProperty("red_cali")
private String redCali;
private Double redCali;
//루비
@JsonProperty("black_cali")
private String blackCali;
private Double blackCali;
}
@Data

View File

@@ -158,12 +158,12 @@ public class BlackListService {
if(item.getGuid() != null){
String guid = item.getGuid();
if(dynamoDBService.isGuidChecked(guid)){
throw new RestApiException(CommonCode.ERROR.getHttpStatus(), ErrorCode.GUID_CHECK.getMessage());
throw new RestApiException(CommonCode.ERROR.getHttpStatus(), ErrorCode.WARNING_GUID_CHECK.toString());
}
// boolean isBlackUser = dynamoDBService.isWhiteOrBlackUser(guid);
boolean isBlackUser = dynamodbUserService.isBlockUser(guid);
if(isBlackUser){
throw new RestApiException(CommonCode.ERROR.getHttpStatus(), ErrorCode.DYNAMODB_EXIT_ERROR.getMessage());
throw new RestApiException(CommonCode.ERROR.getHttpStatus(), ErrorCode.USER_BLOCK_REGIST_DUPLE_WARNING.toString());
}
blackListRequest.setGuid(guid);
blackListRequest.setNickname(item.getNickname());
@@ -180,15 +180,15 @@ public class BlackListService {
//adminDB 에 데이터 있는지 체크
int cnt = blackListMapper.getCountByGuid(item.getGuid());
if(cnt > 0){
throw new RestApiException(CommonCode.ERROR.getHttpStatus(), ErrorCode.ADMINDB_EXIT_ERROR.getMessage());
throw new RestApiException(CommonCode.ERROR.getHttpStatus(), ErrorCode.USER_BLOCK_REGIST_DUPLE_WARNING.toString());
}
if(dynamoDBService.isGuidChecked(item.getGuid())){
throw new RestApiException(CommonCode.ERROR.getHttpStatus(), ErrorCode.GUID_CHECK.getMessage());
throw new RestApiException(CommonCode.ERROR.getHttpStatus(), ErrorCode.WARNING_GUID_CHECK.toString());
}
// boolean isBlackUser = dynamoDBService.isWhiteOrBlackUser(item.getGuid());
boolean isBlackUser = dynamodbUserService.isBlockUser(item.getGuid());
if(isBlackUser){
throw new RestApiException(CommonCode.ERROR.getHttpStatus(), ErrorCode.DYNAMODB_EXIT_ERROR.getMessage());
throw new RestApiException(CommonCode.ERROR.getHttpStatus(), ErrorCode.USER_BLOCK_REGIST_DUPLE_WARNING.toString());
}
blackListRequest.setGuid(item.getGuid());
blackListRequest.setNickname(dynamodbUserService.getGuidByName(item.getGuid()));

View File

@@ -325,92 +325,92 @@ public class DynamoDBService {
}
public Map<String, Object> getAccountInfo(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("account_base#"+guid).build()
,":skValue", AttributeValue.builder().s("empty").build());
try {
// 쿼리 실행
QueryResponse response = executeQuery(key, values);
// 응답에서 원하는 속성을 가져옵니다.
for (Map<String, AttributeValue> item : response.items()) {
AttributeValue attrValue = item.get("AccountBaseAttrib");
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>>() {});
resMap.put("userInfo", UsersResponse.UserInfo.builder()
.aid(CommonUtils.objectToString(attrMap.get("user_guid")))
.userId(CommonUtils.objectToString(attrMap.get("account_id")))
.nation(LANGUAGETYPE.values()[CommonUtils.objectToInteger(attrMap.get("language_type"))])
//
.membership(CommonUtils.objectToString(null))
//todo 친구 추천 코드 임시 null 값으로 셋팅 23.09.20
.friendCode(CommonUtils.objectToString(null))
.createDt(CommonUtils.objectToString(attrMap.get("created_datetime")))
.accessDt(CommonUtils.objectToString(attrMap.get("login_datetime")))
.endDt(CommonUtils.objectToString(attrMap.get("logout_datetime")))
.walletUrl(CommonUtils.objectToString(attrMap.get("connect_facewallet")))
.adminLevel(CommonUtils.objectToString(attrMap.get("auth_amdin_level_type")))
//todo 예비슬롯 임시 null 값으로 셋팅 23.09.20
.spareSlot(CommonUtils.objectToString(null))
.build());
}
}
log.info("getAccountInfo UserInfo: {}", resMap);
return resMap;
} 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());
}
}
// public Map<String, Object> getAccountInfo(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("account_base#"+guid).build()
// ,":skValue", AttributeValue.builder().s("empty").build());
//
// try {
// // 쿼리 실행
// QueryResponse response = executeQuery(key, values);
//
// // 응답에서 원하는 속성을 가져옵니다.
// for (Map<String, AttributeValue> item : response.items()) {
// AttributeValue attrValue = item.get("AccountBaseAttrib");
// 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>>() {});
//
// resMap.put("userInfo", UsersResponse.UserInfo.builder()
// .aid(CommonUtils.objectToString(attrMap.get("user_guid")))
// .userId(CommonUtils.objectToString(attrMap.get("account_id")))
// .nation(LANGUAGETYPE.values()[CommonUtils.objectToInteger(attrMap.get("language_type"))])
// //
// .membership(CommonUtils.objectToString(null))
// //todo 친구 추천 코드 임시 null 값으로 셋팅 23.09.20
// .friendCode(CommonUtils.objectToString(null))
// .createDt(CommonUtils.objectToString(attrMap.get("created_datetime")))
// .accessDt(CommonUtils.objectToString(attrMap.get("login_datetime")))
// .endDt(CommonUtils.objectToString(attrMap.get("logout_datetime")))
// .walletUrl(CommonUtils.objectToString(attrMap.get("connect_facewallet")))
// .adminLevel(CommonUtils.objectToString(attrMap.get("auth_amdin_level_type")))
// //todo 예비슬롯 임시 null 값으로 셋팅 23.09.20
// .spareSlot(CommonUtils.objectToString(null))
// .build());
// }
// }
// log.info("getAccountInfo UserInfo: {}", resMap);
//
// return resMap;
// } 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());
// }
// }
// 유저조회 - 아바타
public Map<String, Object> getAvatarInfo(String guid){

View File

@@ -38,7 +38,6 @@ import java.util.*;
import java.util.concurrent.atomic.AtomicBoolean;
import static com.caliverse.admin.global.common.utils.CommonUtils.convertIsoByDatetime;
import static com.caliverse.admin.global.common.utils.DateUtils.stringToDateTime;
import static com.caliverse.admin.global.common.utils.DateUtils.stringISOToLocalDateTime;
@Service
@@ -445,7 +444,7 @@ public class LandService {
if(nickname.isEmpty() || !nickname.equals(landRequest.getUserName())){
return LandResponse.builder()
.status(CommonCode.ERROR.getHttpStatus())
.result(ErrorCode.GUID_CHECK.toString())
.result(ErrorCode.WARNING_GUID_CHECK.toString())
.build();
}

View File

@@ -180,7 +180,7 @@ public class MailService {
if(mailRequest.getGuid() != null){
if(mailRequest.getUserType().equals(Mail.USERTYPE.GUID) && dynamoDBService.isGuidChecked(mailRequest.getGuid())){
log.error("postMail RECEIVETYPE Single Guid Find Fail");
throw new RestApiException(CommonCode.ERROR.getHttpStatus(), ErrorCode.GUID_CHECK.getMessage());
throw new RestApiException(CommonCode.ERROR.getHttpStatus(), ErrorCode.WARNING_GUID_CHECK.getMessage());
}
String guid = mailRequest.getGuid();
// 닉네임이면 guid로 바꾼다
@@ -213,7 +213,7 @@ public class MailService {
case "GUID" -> {
if (dynamoDBService.isGuidChecked(excel.getUser())) {
log.error("postMail Multi Guid({}) Find Fail", excel.getUser());
throw new RestApiException(CommonCode.ERROR.getHttpStatus(), ErrorCode.GUID_CHECK.toString());
throw new RestApiException(CommonCode.ERROR.getHttpStatus(), ErrorCode.WARNING_GUID_CHECK.toString());
}
}
case "NICKNAME" -> {

View File

@@ -9,11 +9,14 @@ import java.util.stream.Collectors;
import com.caliverse.admin.domain.entity.FriendRequest;
import com.caliverse.admin.domain.entity.HISTORYTYPE;
import com.caliverse.admin.domain.request.MailRequest;
import com.caliverse.admin.dynamodb.domain.atrrib.AccountBaseAttrib;
import com.caliverse.admin.dynamodb.domain.atrrib.MailAttrib;
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.DynamodbService;
import com.caliverse.admin.dynamodb.service.DynamodbUserService;
import com.caliverse.admin.global.common.utils.DynamodbUtil;
import com.caliverse.admin.redis.service.RedisUserInfoService;
import com.fasterxml.jackson.databind.ObjectMapper;
@@ -54,6 +57,8 @@ public class UsersService {
@Qualifier("objectMapper")
@Autowired
private ObjectMapper objectMapper;
@Autowired
private DynamodbUserService dynamodbUserService;
// 닉네임 변경
public UsersResponse changeNickname(UsersRequest usersRequest){
@@ -138,20 +143,41 @@ public class UsersService {
public UsersResponse getBasicInfo(String guid){
String account_id = dynamoDBService.getGuidByAccountId(guid);
//userInfo
Map<String, Object> userInfo = dynamoDBService.getAccountInfo(account_id);
String account_id = dynamodbUserService.getGuidByAccountId(guid);
AccountBaseAttrib accountBaseAttrib = dynamodbUserService.getAccountInfo(account_id);
UsersResponse.UserInfo userInfo = UsersResponse.UserInfo.builder()
.aid(accountBaseAttrib.getUserGuid())
.userId(accountBaseAttrib.getAccountId())
.nation(accountBaseAttrib.getLanguageType())
.membership("")
.friendCode("")
.createDt(accountBaseAttrib.getCreatedDateTime())
.accessDt(accountBaseAttrib.getLoginDateTime())
.endDt(accountBaseAttrib.getLogoutDateTime())
.walletUrl("")
.adminLevel(accountBaseAttrib.getAuthAdminLevelType().name())
.spareSlot("")
.build();
// charInfo
Map<String, Object> charInfo = dynamoDBService.getCharInfo(guid);
MoneyAttrib moneyAttrib = dynamodbUserService.getMoneyInfo(guid);
UsersResponse.CharInfo charInfo = UsersResponse.CharInfo.builder()
.characterName(dynamodbUserService.getGuidByName(guid))
.level("")
.goldCali(moneyAttrib.getGold())
.redCali(moneyAttrib.getCalium())
.blackCali(moneyAttrib.getRuby())
.blueCali(moneyAttrib.getSapphire())
.build();
boolean userSession = userGameSessionService.userSession(guid);
return UsersResponse.builder()
.resultData(
UsersResponse.ResultData.builder()
.charInfo((UsersResponse.CharInfo) charInfo.get("charInfo"))
.userInfo((UsersResponse.UserInfo) userInfo.get("userInfo"))
.charInfo(charInfo)
.userInfo(userInfo)
.userSession(userSession)
.build()
)

View File

@@ -79,7 +79,7 @@ public class WhiteListService {
Map<String, AttributeValue> whiteAttr = dynamoDBService.getItem("char#" + item, "char#" + item);
//guid 검증
if(whiteAttr.size() == 0){
throw new RestApiException(CommonCode.ERROR.getHttpStatus(), ErrorCode.GUID_CHECK.getMessage());
throw new RestApiException(CommonCode.ERROR.getHttpStatus(), ErrorCode.WARNING_GUID_CHECK.getMessage());
}
//화이트리스트 확정까지 보류
// boolean isWhiteUser = dynamoDBService.isWhiteOrBlackUser(whiteAttr.get("isWhiteUser"));
@@ -116,7 +116,7 @@ public class WhiteListService {
//guid 검증
if(whiteAttr.size() == 0){
throw new RestApiException(CommonCode.ERROR.getHttpStatus(), ErrorCode.GUID_CHECK.getMessage());
throw new RestApiException(CommonCode.ERROR.getHttpStatus(), ErrorCode.WARNING_GUID_CHECK.getMessage());
}
//화이트리스트 확정까지 보류
// boolean isWhiteUser = dynamoDBService.isWhiteOrBlackUser(whiteAttr.get("isWhiteUser"));

View File

@@ -10,5 +10,5 @@ public interface AccountBaseRepository extends DynamoDBRepository<AccountBaseDoc
boolean isBlockUser(String account_id);
void updateBlockUserStart(String account_id, BlackList blackList);
void updateBlockUserEnd(String account_id);
AccountBaseAttrib findUser(Long account_id);
AccountBaseAttrib findUser(String account_id);
}

View File

@@ -141,7 +141,7 @@ public class AccountBaseRepositoryImpl extends BaseDynamoDBRepository<AccountBas
}
@Override
public AccountBaseAttrib findUser(Long account_id) {
public AccountBaseAttrib findUser(String account_id) {
Key key = Key.builder()
.partitionValue(DynamoDBConstants.PK_KEY_ACCOUNT_BASE + account_id)
.sortValue(DynamoDBConstants.EMPTY)

View File

@@ -1,6 +1,8 @@
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.repository.*;
@@ -23,6 +25,7 @@ public class DynamodbUserService {
private final UserBaseRepository userBaseRepository;
private final UserNicknameRegistryRepository registryRepository;
private final NicknameRepository nicknameRepository;
private final MoneyRepository moneyRepository;
private final ObjectMapper mapper = new ObjectMapper();
@@ -64,4 +67,12 @@ public class DynamodbUserService {
return userBaseAttrib.getAccountId();
}
public AccountBaseAttrib getAccountInfo(String accountId){
return accountBaseRepository.findUser(accountId);
}
public MoneyAttrib getMoneyInfo(String guid){
return moneyRepository.findAttrib(guid);
}
}

View File

@@ -88,7 +88,7 @@ public enum ErrorCode {
//------------------------------------------------------------------------------------------------------------------------------
// DyanamoDB
//------------------------------------------------------------------------------------------------------------------------------
GUID_CHECK("Guid를 확인해주세요."),
WARNING_GUID_CHECK("Guid를 확인해주세요."),
EMAIL_CHECK("Email을 확인해주세요"),
GUID_LENGTH_CHECK("guid(32자)를 확인해주세요."),
NICKNAME_CHECK("gameDB에 닉네임이 없습니다."),
@@ -103,6 +103,7 @@ public enum ErrorCode {
DYNAMODB_CONVERT_ERROR("형변환 도중 에러가 발생하였습니다."),
DYNAMODB_JSON_PARSE_ERROR("dynamoDB Json 변환 중 에러 발생"),
USER_BLOCK_REGIST_DUPLE_WARNING("이미 제재가 등록된 유저입니다."),
ADMINDB_EXIT_ERROR("admindb_exit_error"),