사용안하는 모듈 제거

This commit is contained in:
2025-05-01 07:07:00 +09:00
parent 45e6b05cab
commit c8f76004ed
7 changed files with 0 additions and 505 deletions

View File

@@ -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));
}
}

View File

@@ -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);
}

View File

@@ -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
;
}
}

View File

@@ -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;
}
}

View File

@@ -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 ;
}
}

View File

@@ -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();
}
}

View File

@@ -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>