공지 정렬 수정
히스토리 caliverse_meta_data 제거
This commit is contained in:
@@ -11,8 +11,10 @@ import com.caliverse.admin.domain.response.AdminResponse;
|
||||
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.constants.MysqlConstants;
|
||||
import com.caliverse.admin.global.common.exception.RestApiException;
|
||||
import com.caliverse.admin.global.common.utils.CommonUtils;
|
||||
import com.caliverse.admin.mongodb.service.MysqlHistoryLogService;
|
||||
import jakarta.mail.internet.MimeMessage;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
@@ -37,6 +39,7 @@ import java.util.*;
|
||||
public class AdminService {
|
||||
private static final Logger logger = LoggerFactory.getLogger(AdminService.class);
|
||||
|
||||
private final MysqlHistoryLogService mysqlHistoryLogService;
|
||||
private final AdminMapper adminMapper;
|
||||
private final GroupMapper groupMapper;
|
||||
private final PasswordEncoder passwordEncoder;
|
||||
@@ -170,8 +173,9 @@ public class AdminService {
|
||||
Map<String , Object> map = new HashMap<>();
|
||||
adminRequest.getList().forEach(
|
||||
item -> {
|
||||
|
||||
map.put("email", item.getEmail());
|
||||
String email = item.getEmail();
|
||||
Optional<Admin> info = adminMapper.findByEmail(email);
|
||||
map.put("email", email);
|
||||
map.put("id", CommonUtils.getAdmin().getId());
|
||||
|
||||
if(item.getIsApprove().equals(AdminRequest.Approve.APPROVE)){
|
||||
@@ -184,18 +188,13 @@ public class AdminService {
|
||||
//로그인 승인
|
||||
adminMapper.updateStatus(map);
|
||||
|
||||
//로그 기록
|
||||
Optional<Admin> admin = adminMapper.findByEmail(item.getEmail());
|
||||
// map.put("adminId", admin.get().getId());
|
||||
// map.put("name", CommonUtils.getAdmin().getName());
|
||||
// map.put("mail", CommonUtils.getAdmin().getEmail());
|
||||
// map.put("type", HISTORYTYPE.LOGIN_PERMITTED);
|
||||
JSONObject jsonObject = new JSONObject();
|
||||
jsonObject.put("name",admin.get().getName());
|
||||
jsonObject.put("email",item.getEmail());
|
||||
// map.put("content",jsonObject.toString());
|
||||
// historyMapper.saveLog(map);
|
||||
historyService.setLog(HISTORYTYPEDETAIL.LOGIN_PERMITTED, jsonObject);
|
||||
mysqlHistoryLogService.updateHistoryLog(
|
||||
HISTORYTYPEDETAIL.LOGIN_PERMITTED,
|
||||
MysqlConstants.TABLE_NAME_ADMIN,
|
||||
HISTORYTYPEDETAIL.LOGIN_PERMITTED.name(),
|
||||
info.get(),
|
||||
adminMapper.findByEmail(email)
|
||||
);
|
||||
}
|
||||
);
|
||||
|
||||
@@ -214,32 +213,24 @@ public class AdminService {
|
||||
Map<String , Object> map = new HashMap<>();
|
||||
adminRequest.getList().forEach(
|
||||
item -> {
|
||||
map.put("email", item.getEmail());
|
||||
String email = item.getEmail();
|
||||
map.put("email", email);
|
||||
map.put("group_id", item.getGroupId());
|
||||
map.put("id", CommonUtils.getAdmin().getId());
|
||||
|
||||
//변경전 그룹 명세 조회
|
||||
Optional<Admin> admin = adminMapper.findByEmail(item.getEmail());
|
||||
Optional<Admin> info = adminMapper.findByEmail(email);
|
||||
|
||||
Map<String, String> beforeGroup = groupMapper.getGroupInfo(admin.get().getGroupId());
|
||||
//쿼리 실행
|
||||
adminMapper.updateGroup(map);
|
||||
//로그 기록
|
||||
//변경후 그룹 명세 조회
|
||||
Map<String, String> afterGroup = groupMapper.getGroupInfo(item.getGroupId());
|
||||
|
||||
// map.put("adminId", CommonUtils.getAdmin().getId());
|
||||
// map.put("name", CommonUtils.getAdmin().getName());
|
||||
// map.put("mail", CommonUtils.getAdmin().getEmail());
|
||||
// map.put("type", HISTORYTYPE.ADMIN_INFO_UPDATE);
|
||||
JSONObject jsonObject = new JSONObject();
|
||||
jsonObject.put("name",admin.get().getName());
|
||||
jsonObject.put("email",item.getEmail());
|
||||
jsonObject.put("Authority(Before)", beforeGroup != null?beforeGroup.get("name"):"");
|
||||
jsonObject.put("Authority(after)", afterGroup != null? afterGroup.get("name"):"");
|
||||
// map.put("content",jsonObject.toString());
|
||||
// historyMapper.saveLog(map);
|
||||
historyService.setLog(HISTORYTYPEDETAIL.ADMIN_INFO_UPDATE, jsonObject);
|
||||
mysqlHistoryLogService.updateHistoryLog(
|
||||
HISTORYTYPEDETAIL.ADMIN_INFO_UPDATE,
|
||||
MysqlConstants.TABLE_NAME_ADMIN,
|
||||
HISTORYTYPEDETAIL.ADMIN_INFO_UPDATE.name(),
|
||||
info.get(),
|
||||
adminMapper.findByEmail(email)
|
||||
);
|
||||
}
|
||||
);
|
||||
|
||||
@@ -260,21 +251,17 @@ public class AdminService {
|
||||
map.put("email", item.getEmail());
|
||||
map.put("deleted", String.valueOf(1));
|
||||
//로그 기록
|
||||
Optional<Admin> admin = adminMapper.findByEmail(item.getEmail());
|
||||
Optional<Admin> info = adminMapper.findByEmail(item.getEmail());
|
||||
|
||||
//쿼리 실행
|
||||
adminMapper.deleteAdmin(map);
|
||||
|
||||
// map.put("adminId", CommonUtils.getAdmin().getId());
|
||||
// map.put("name", CommonUtils.getAdmin().getName());
|
||||
// map.put("mail", CommonUtils.getAdmin().getEmail());
|
||||
// map.put("type", HISTORYTYPE.ADMIN_INFO_DELETE);
|
||||
JSONObject jsonObject = new JSONObject();
|
||||
jsonObject.put("name",admin.get().getName());
|
||||
jsonObject.put("email",item.getEmail());
|
||||
// map.put("content",jsonObject.toString());
|
||||
// historyMapper.saveLog(map);
|
||||
historyService.setLog(HISTORYTYPEDETAIL.ADMIN_INFO_DELETE, jsonObject);
|
||||
mysqlHistoryLogService.deleteHistoryLog(
|
||||
HISTORYTYPEDETAIL.ADMIN_INFO_DELETE,
|
||||
MysqlConstants.TABLE_NAME_ADMIN,
|
||||
HISTORYTYPEDETAIL.ADMIN_INFO_DELETE.name(),
|
||||
info.get()
|
||||
);
|
||||
}
|
||||
);
|
||||
log.info("deleteAdmin Deleted Admin: {}", map);
|
||||
|
||||
@@ -7,6 +7,7 @@ import com.caliverse.admin.domain.entity.web3.ResponseErrorCode;
|
||||
import com.caliverse.admin.domain.entity.web3.ResponseRequestData;
|
||||
import com.caliverse.admin.domain.entity.web3.ResponseWithdrawableData;
|
||||
import com.caliverse.admin.domain.request.CaliumRequest;
|
||||
import com.caliverse.admin.domain.request.LogGenericRequest;
|
||||
import com.caliverse.admin.domain.request.Web3Request;
|
||||
import com.caliverse.admin.domain.response.CaliumResponse;
|
||||
import com.caliverse.admin.domain.response.Web3Response;
|
||||
@@ -17,6 +18,9 @@ import com.caliverse.admin.global.common.code.SuccessCode;
|
||||
import com.caliverse.admin.global.common.constants.MysqlConstants;
|
||||
import com.caliverse.admin.global.common.constants.Web3Constants;
|
||||
import com.caliverse.admin.global.common.utils.CommonUtils;
|
||||
import com.caliverse.admin.logs.Indicatordomain.GenericMongoLog;
|
||||
import com.caliverse.admin.logs.entity.LogAction;
|
||||
import com.caliverse.admin.logs.logservice.businesslogservice.BusinessLogGenericService;
|
||||
import com.caliverse.admin.mongodb.service.MysqlHistoryLogService;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
@@ -25,6 +29,7 @@ import org.springframework.http.HttpMethod;
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
|
||||
import java.time.LocalDateTime;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
@@ -41,6 +46,7 @@ public class CaliumService {
|
||||
// private final DynamoDBService dynamoDBService;
|
||||
private final DynamodbCaliumService dynamodbCaliumService;
|
||||
private final MysqlHistoryLogService mysqlHistoryLogService;
|
||||
private final BusinessLogGenericService businessLogGenericService;
|
||||
|
||||
public CaliumResponse getCaliumLimit(){
|
||||
Web3Response<ResponseWithdrawableData> web3Response = web3Service.get(
|
||||
@@ -82,6 +88,13 @@ public class CaliumService {
|
||||
double allCnt = caliumMapper.getCaliumTotal();
|
||||
double stock_qty = dynamodbCaliumService.getCaliumTotal();
|
||||
|
||||
LogGenericRequest logGenericRequest = new LogGenericRequest();
|
||||
logGenericRequest.setLogAction(LogAction.FailCaliumEchoSystem);
|
||||
logGenericRequest.setStartDt(LocalDateTime.now().minusDays(1));
|
||||
logGenericRequest.setEndDt(LocalDateTime.now());
|
||||
logGenericRequest.setOrderBy("ASC");
|
||||
List<GenericMongoLog> failList = businessLogGenericService.loadBusinessLogData(logGenericRequest, GenericMongoLog.class);
|
||||
|
||||
return CaliumResponse.builder()
|
||||
.status(CommonCode.SUCCESS.getHttpStatus())
|
||||
.result(CommonCode.SUCCESS.getResult())
|
||||
@@ -89,6 +102,7 @@ public class CaliumService {
|
||||
.caliumList(list)
|
||||
.total(stock_qty)
|
||||
.totalAll(allCnt)
|
||||
.failCount(failList.size())
|
||||
.pageNo(requestParam.get("page_no")!=null?
|
||||
Integer.parseInt(requestParam.get("page_no").toString()):1)
|
||||
.build()
|
||||
@@ -153,13 +167,6 @@ public class CaliumService {
|
||||
calium
|
||||
);
|
||||
|
||||
//로그 기록
|
||||
JSONObject jsonObject = new JSONObject();
|
||||
jsonObject.put("dept",caliumRequest.getDept());
|
||||
jsonObject.put("count",caliumRequest.getCount());
|
||||
jsonObject.put("content",caliumRequest.getContent());
|
||||
historyService.setLog(HISTORYTYPEDETAIL.CALIUM_ADD, jsonObject);
|
||||
|
||||
return CaliumResponse.builder()
|
||||
.status(CommonCode.SUCCESS.getHttpStatus())
|
||||
.result(CommonCode.SUCCESS.getResult())
|
||||
@@ -173,10 +180,10 @@ public class CaliumService {
|
||||
public CaliumResponse updateCaliumCharged(CaliumRequest caliumRequest){
|
||||
log.info("updateCaliumCharged calium Request: {}", caliumRequest);
|
||||
Calium calium = caliumMapper.getCaliumRequestDetail(caliumRequest.getId());
|
||||
Long id = CommonUtils.getAdmin().getId();
|
||||
Long userId = CommonUtils.getAdmin().getId();
|
||||
// 상태가 승인완료거나 요청한 본인이 아니면 에러처리
|
||||
if(!calium.getStatus().equals(Calium.CALIUMREQUESTSTATUS.COMPLETE) || !calium.getCreateBy().equals(id.toString())){
|
||||
log.error("updateCaliumCharged Calium Request Status or User Not Match status: {}, id: {}", calium.getStatus(), id);
|
||||
if(!calium.getStatus().equals(Calium.CALIUMREQUESTSTATUS.COMPLETE) || !calium.getCreateBy().equals(userId.toString())){
|
||||
log.error("updateCaliumCharged Calium Request Status or User Not Match status: {}, id: {}", calium.getStatus(), userId);
|
||||
return CaliumResponse.builder()
|
||||
.status(CommonCode.ERROR.getHttpStatus())
|
||||
.result(ErrorCode.ERROR_CALIUM_FINISH.toString())
|
||||
@@ -186,14 +193,24 @@ public class CaliumService {
|
||||
.build();
|
||||
}
|
||||
|
||||
Calium info = caliumMapper.getCaliumRequestDetail(caliumRequest.getId());
|
||||
|
||||
dynamodbCaliumService.updateCaliumTotal(caliumRequest.getCount());
|
||||
|
||||
updateCaliumRequest(caliumRequest.getId(), Calium.CALIUMREQUESTSTATUS.FINISH);
|
||||
|
||||
JSONObject jsonObject = new JSONObject();
|
||||
mysqlHistoryLogService.updateHistoryLog(
|
||||
HISTORYTYPEDETAIL.CALIUM_TOTAL_UPDATE,
|
||||
MysqlConstants.TABLE_NAME_CALIUM_REQUEST,
|
||||
HISTORYTYPEDETAIL.CALIUM_TOTAL_UPDATE.name(),
|
||||
info,
|
||||
caliumMapper.getCaliumRequestDetail(caliumRequest.getId())
|
||||
);
|
||||
|
||||
// JSONObject jsonObject = new JSONObject();
|
||||
// jsonObject.put("dynamoDB_update",dynamoResult);
|
||||
|
||||
historyService.setLog(HISTORYTYPEDETAIL.CALIUM_TOTAL_UPDATE, jsonObject);
|
||||
// historyService.setLog(HISTORYTYPEDETAIL.CALIUM_TOTAL_UPDATE, jsonObject);
|
||||
|
||||
return CaliumResponse.builder()
|
||||
.status(CommonCode.SUCCESS.getHttpStatus())
|
||||
|
||||
@@ -225,20 +225,6 @@ public class EventService {
|
||||
HISTORYTYPEDETAIL.EVENT_DELETE.name(),
|
||||
event
|
||||
);
|
||||
|
||||
JSONObject jsonObject = new JSONObject();
|
||||
// if(result == 1){
|
||||
// String dynamoResult = dynamoDBService.deleteSystemMail(item.getId().toString());
|
||||
// jsonObject.put("dynamoDB_data",dynamoResult);
|
||||
// log.info("updateEvent dynamoDB Delete Complete: {}", dynamoResult);
|
||||
// }
|
||||
|
||||
//로그 기록
|
||||
List<Message> message = eventMapper.getMessage(item.getId());
|
||||
if(!message.isEmpty()){
|
||||
jsonObject.put("message",message.get(0).getTitle());
|
||||
}
|
||||
historyService.setLog(HISTORYTYPEDETAIL.EVENT_DELETE, jsonObject);
|
||||
}
|
||||
);
|
||||
|
||||
|
||||
@@ -85,7 +85,7 @@ public class GroupService {
|
||||
|
||||
//권한 그룹 등록
|
||||
public GroupResponse postAdminGroup(GroupRequest groupRequest){
|
||||
List<Integer> authList = Arrays.asList(1, 5, 6, 9, 10, 11, 13, 14, 15, 16, 19, 22, 24, 26, 32); //그룹 초기 권한
|
||||
List<Integer> authList = Arrays.asList(1, 5, 6, 9, 10, 11, 13, 14, 15, 16, 19, 22, 24, 26, 32, 36, 41,46, 49); //그룹 초기 권한
|
||||
Map<String, Object> map = new HashMap<>();
|
||||
groupRequest.setCreateBy(CommonUtils.getAdmin().getId());
|
||||
|
||||
|
||||
@@ -107,57 +107,6 @@ public class HistoryService {
|
||||
.build();
|
||||
}
|
||||
|
||||
|
||||
|
||||
private void insertMetaData(File file) {
|
||||
try {
|
||||
// Read the JSON data from the file
|
||||
String jsonData = FileUtils.readFileToString(file, StandardCharsets.UTF_8);
|
||||
|
||||
// Parse the JSON data into a JSONArray
|
||||
JSONArray jsonArray = new JSONArray(jsonData);
|
||||
|
||||
|
||||
// Iterate over the elements in the JSONArray
|
||||
for (int i = 0; i < jsonArray.length(); i++) {
|
||||
// Get the current element as a JSONObject
|
||||
JSONObject jsonObject = jsonArray.getJSONObject(i);
|
||||
|
||||
// Extract the values from the JSONObject
|
||||
Integer itemId = Integer.valueOf(jsonObject.getInt("item_id"));
|
||||
|
||||
|
||||
Map<String, Object> item = new HashMap<>();
|
||||
item.put("fileName", file.getName());
|
||||
item.put("dataId", itemId);
|
||||
item.put("jsonData", jsonObject.toString());
|
||||
|
||||
|
||||
// Insert the values into MariaDB
|
||||
|
||||
historyMapper.insertMetaData(item);
|
||||
|
||||
|
||||
|
||||
}
|
||||
} catch (java.io.IOException e) {
|
||||
log.error("insertMetaData IOException: {}", e.getMessage());
|
||||
} catch (JSONException e) {
|
||||
log.error("insertMetaData JSONException: {}", e.getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
public void setLog(HISTORYTYPEDETAIL type, JSONObject content){
|
||||
//로그 기록
|
||||
Map<String, Object> logMap = new HashMap<>();
|
||||
logMap.put("adminId", CommonUtils.getAdmin().getId());
|
||||
logMap.put("name", CommonUtils.getAdmin().getName());
|
||||
logMap.put("mail", CommonUtils.getAdmin().getEmail());
|
||||
logMap.put("type", type);
|
||||
logMap.put("content",content.toString());
|
||||
historyMapper.saveLog(logMap);
|
||||
}
|
||||
|
||||
public void setScheduleLog(HISTORYTYPEDETAIL type, String message){
|
||||
//스케줄 로그 기록
|
||||
Map<String, Object> logMap = new HashMap<>();
|
||||
|
||||
@@ -627,17 +627,6 @@ public class LandService {
|
||||
);
|
||||
|
||||
dynamodbLandAuctionService.cancelLandAuction(auction_info);
|
||||
|
||||
JSONObject jsonObject = new JSONObject();
|
||||
|
||||
//로그 기록
|
||||
List<Message> message = landMapper.getMessage(item.getId());
|
||||
if(!message.isEmpty()){
|
||||
jsonObject.put("message",message.get(0).getTitle());
|
||||
}
|
||||
jsonObject.put("auction_info", auction_info);
|
||||
// jsonObject.put("dynamoDB_result",land_auction_registry_result);
|
||||
historyService.setLog(HISTORYTYPEDETAIL.LAND_AUCTION_DELETE, jsonObject);
|
||||
}
|
||||
);
|
||||
|
||||
|
||||
@@ -11,6 +11,7 @@ import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.data.mongodb.UncategorizedMongoDbException;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import java.time.LocalDateTime;
|
||||
import java.util.*;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
@@ -31,6 +32,11 @@ public class LogService {
|
||||
// logGenericRequest.setEndDt(endDt);
|
||||
|
||||
// List<Map<String, Object>> logList = businessLogGenericService.loadBusinessLogData(logGenericRequest);
|
||||
LocalDateTime startDt = logGenericRequest.getStartDt().plusHours(9);
|
||||
LocalDateTime endDt = logGenericRequest.getEndDt().plusHours(9).plusDays(1);
|
||||
logGenericRequest.setStartDt(startDt);
|
||||
logGenericRequest.setEndDt(endDt);
|
||||
|
||||
List<GenericMongoLog> logList = new ArrayList<>();
|
||||
try{
|
||||
logList = businessLogGenericService.loadBusinessLogData(logGenericRequest, GenericMongoLog.class);
|
||||
|
||||
@@ -105,16 +105,6 @@ public class NoticeService {
|
||||
noticeMapper.getNoticeDetail(noticeRequest.getId())
|
||||
);
|
||||
|
||||
//로그 기록
|
||||
// JSONObject jsonObject = new JSONObject();
|
||||
// jsonObject.put("message_type",noticeRequest.getMessageType());
|
||||
// jsonObject.put("repeat_type",noticeRequest.getRepeatType());
|
||||
// jsonObject.put("repeat_cnt",noticeRequest.getRepeatCnt());
|
||||
// jsonObject.put("repeat_dt",noticeRequest.getRepeatDt());
|
||||
// jsonObject.put("send_dt",noticeRequest.getSendDt());
|
||||
// jsonObject.put("end_dt",noticeRequest.getEndDt());
|
||||
// jsonObject.put("message",noticeRequest.getGameMessages().toString());
|
||||
// historyService.setLog(HISTORYTYPE.NOTICE_ADD, jsonObject);
|
||||
|
||||
return NoticeResponse.builder()
|
||||
.resultData(NoticeResponse.ResultData.builder().message(SuccessCode.REGISTRATION.getMessage()).build())
|
||||
@@ -196,15 +186,6 @@ public class NoticeService {
|
||||
noticeMapper.getNoticeDetail(item.getMessageId())
|
||||
);
|
||||
|
||||
//로그 기록
|
||||
// map.put("adminId", CommonUtils.getAdmin().getId());
|
||||
// map.put("name", CommonUtils.getAdmin().getName());
|
||||
// map.put("mail", CommonUtils.getAdmin().getEmail());
|
||||
// map.put("type", HISTORYTYPE.NOTICE_DELETE);
|
||||
// JSONObject jsonObject = new JSONObject();
|
||||
// jsonObject.put("message",message);
|
||||
// map.put("content",jsonObject.toString());
|
||||
// historyMapper.saveLog(map);
|
||||
}
|
||||
);
|
||||
log.info("deleteInGameMessage notice: {}", noticeRequest);
|
||||
|
||||
Reference in New Issue
Block a user