251222_03_ENH : 객체 생성 시간과 시스템 로그 시간 맞추기 위해 Controller로 시간 변수 이동
This commit is contained in:
@@ -1,5 +1,6 @@
|
||||
package com.kri.contact.server.controller;
|
||||
|
||||
import com.kri.common.datetime.DateTimeUtil;
|
||||
import com.kri.common.webmvc.RequestUserContext;
|
||||
import com.kri.contact.server.service.AssignService;
|
||||
import com.kri.contact.server.service.SystemEventLogService;
|
||||
@@ -7,6 +8,7 @@ import io.swagger.v3.oas.annotations.tags.Tag;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
|
||||
import java.time.LocalDateTime;
|
||||
import java.util.List;
|
||||
|
||||
@RestController
|
||||
@@ -30,7 +32,8 @@ public class AssignController {
|
||||
|
||||
@PutMapping("/prjct-fieldwork/{prjctIdx}")
|
||||
public void upsertPrjctFieldworkAssign(@PathVariable Long prjctIdx, @RequestBody List<String> assignUserIdList, RequestUserContext ctx){
|
||||
assignService.upsertPrjctFieldworkAssign(prjctIdx, assignUserIdList, ctx.getUserId());
|
||||
systemEventLogService.writeAssignUserProject(ctx.getUserId(), ctx.getClientIp(), prjctIdx, assignUserIdList);
|
||||
final LocalDateTime now = DateTimeUtil.nowKstLocalDateTime();
|
||||
assignService.upsertPrjctFieldworkAssign(prjctIdx, assignUserIdList, ctx.getUserId(), now);
|
||||
systemEventLogService.writeAssignUserProject(ctx.getUserId(), now, ctx.getClientIp(), prjctIdx, assignUserIdList);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
package com.kri.contact.server.controller;
|
||||
|
||||
import com.kri.common.datetime.DateTimeUtil;
|
||||
import com.kri.common.webmvc.RequestUserContext;
|
||||
import com.kri.contact.server.dto.LoginRequestDto;
|
||||
import com.kri.contact.server.dto.LoginResponseDto;
|
||||
@@ -9,6 +10,8 @@ import io.swagger.v3.oas.annotations.tags.Tag;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
|
||||
import java.time.LocalDateTime;
|
||||
|
||||
@RestController
|
||||
@RequestMapping("/api/v1/auth")
|
||||
@RequiredArgsConstructor
|
||||
@@ -19,15 +22,19 @@ public class AuthController {
|
||||
|
||||
@PostMapping("/login")
|
||||
public LoginResponseDto tryLogin(@RequestBody LoginRequestDto request, RequestUserContext ctx){
|
||||
final LocalDateTime now = DateTimeUtil.nowKstLocalDateTime();
|
||||
|
||||
LoginResponseDto response = authService.tryLogin(request);
|
||||
systemEventLogService.writeLoginLog(response.getUser().getUserId(), ctx.getClientIp());
|
||||
systemEventLogService.writeLoginLog(response.getUser().getUserId(), now, ctx.getClientIp());
|
||||
|
||||
return response;
|
||||
}
|
||||
|
||||
@PostMapping("/logout/{userId}")
|
||||
public boolean logout(@PathVariable String userId, RequestUserContext ctx){
|
||||
systemEventLogService.writeLogoutLog(userId, ctx.getClientIp());
|
||||
final LocalDateTime now = DateTimeUtil.nowKstLocalDateTime();
|
||||
|
||||
systemEventLogService.writeLogoutLog(userId, now, ctx.getClientIp());
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
package com.kri.contact.server.controller;
|
||||
|
||||
import com.kri.common.datetime.DateTimeUtil;
|
||||
import com.kri.common.webmvc.RequestUserContext;
|
||||
import com.kri.contact.server.dto.*;
|
||||
import com.kri.contact.server.dto.common.PageResponseDto;
|
||||
@@ -11,6 +12,7 @@ import lombok.RequiredArgsConstructor;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
import org.springframework.web.multipart.MultipartFile;
|
||||
|
||||
import java.time.LocalDateTime;
|
||||
import java.util.List;
|
||||
|
||||
@RestController
|
||||
@@ -55,8 +57,10 @@ public class ProjectController {
|
||||
@RequestBody ProjectCreateRequestDto req,
|
||||
RequestUserContext ctx
|
||||
) {
|
||||
ProjectInfoDto prjctInfo = projectService.createProject(req, ctx.getUserId());
|
||||
systemEventLogService.writeCreateProject(ctx.getUserId(), ctx.getClientIp(), prjctInfo.getPrjctIdx(), req);
|
||||
final LocalDateTime now = DateTimeUtil.nowKstLocalDateTime();
|
||||
|
||||
ProjectInfoDto prjctInfo = projectService.createProject(req, ctx.getUserId(), now);
|
||||
systemEventLogService.writeCreateProject(ctx.getUserId(), now, ctx.getClientIp(), prjctInfo.getPrjctIdx(), req);
|
||||
|
||||
return prjctInfo;
|
||||
}
|
||||
@@ -72,20 +76,24 @@ public class ProjectController {
|
||||
@RequestBody ProjectUpdateRequestDto req,
|
||||
RequestUserContext ctx
|
||||
){
|
||||
final LocalDateTime now = DateTimeUtil.nowKstLocalDateTime();
|
||||
|
||||
String newHtml = fileService.syncOnSave(
|
||||
req.getProjectInfo().getPrjctCd(),
|
||||
req.getProjectInfo().getContactSenario()
|
||||
);
|
||||
req.getProjectInfo().setContactSenario(newHtml);
|
||||
|
||||
projectService.updateProject(prjctIdx, req, ctx.getUserId());
|
||||
projectService.updateProject(prjctIdx, req, ctx.getUserId(), now);
|
||||
|
||||
systemEventLogService.writeUpdateProject(ctx.getUserId(), ctx.getClientIp(), prjctIdx, req);
|
||||
systemEventLogService.writeUpdateProject(ctx.getUserId(), now, ctx.getClientIp(), prjctIdx, req);
|
||||
}
|
||||
|
||||
@DeleteMapping("/{prjctIdx}")
|
||||
public void deleteProject(@PathVariable Long prjctIdx, RequestUserContext ctx){
|
||||
projectService.deleteProject(prjctIdx, ctx.getUserId());
|
||||
systemEventLogService.writeDeleteProject(ctx.getUserId(), ctx.getClientIp(), prjctIdx);
|
||||
final LocalDateTime now = DateTimeUtil.nowKstLocalDateTime();
|
||||
|
||||
projectService.deleteProject(prjctIdx, ctx.getUserId(), now);
|
||||
systemEventLogService.writeDeleteProject(ctx.getUserId(), now, ctx.getClientIp(), prjctIdx);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
package com.kri.contact.server.controller;
|
||||
|
||||
import com.kri.common.datetime.DateTimeUtil;
|
||||
import com.kri.common.webmvc.RequestUserContext;
|
||||
import com.kri.contact.server.common.consts.ContactConstant;
|
||||
import com.kri.contact.server.dto.DataVerificationDto;
|
||||
@@ -16,6 +17,7 @@ import org.springframework.http.ResponseEntity;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
import org.springframework.web.multipart.MultipartFile;
|
||||
|
||||
import java.time.LocalDateTime;
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
|
||||
@@ -76,9 +78,10 @@ public class UserController {
|
||||
public void createUser(@RequestBody UserInfoDto userInfo, RequestUserContext ctx){
|
||||
String regId = ctx.getUserId();
|
||||
String clientIp = ctx.getClientIp();
|
||||
final LocalDateTime now = DateTimeUtil.nowKstLocalDateTime();
|
||||
|
||||
userService.createUser(userInfo, regId);
|
||||
systemEventLogService.writeCreateUserLog(regId, clientIp, userInfo);
|
||||
userService.createUser(userInfo, regId, now);
|
||||
systemEventLogService.writeCreateUserLog(regId, now, clientIp, userInfo);
|
||||
}
|
||||
|
||||
@PostMapping("/excel")
|
||||
@@ -88,17 +91,18 @@ public class UserController {
|
||||
) {
|
||||
String regId = ctx.getUserId();
|
||||
String clientIp = ctx.getClientIp();
|
||||
final LocalDateTime now = DateTimeUtil.nowKstLocalDateTime();
|
||||
//외주사급이 업로드로 계정을 생성하는 경우 자신의 회사명으로 고정
|
||||
String forceCmpn = ctx.getUserRole() < ContactConstant.OUTSOURCE_USER_ROLE? "" : ctx.getUserCmpn();
|
||||
|
||||
ExcelUploadResponseDto result = userService.createUsersFromExcel(file, regId, forceCmpn);
|
||||
ExcelUploadResponseDto result = userService.createUsersFromExcel(file, regId, now, forceCmpn);
|
||||
|
||||
UploadUserContentDto content = new UploadUserContentDto(
|
||||
file.getOriginalFilename(),
|
||||
file.getContentType(),
|
||||
file.getSize()
|
||||
);
|
||||
systemEventLogService.writeUploadUserLog(regId, clientIp, content);
|
||||
systemEventLogService.writeUploadUserLog(regId, now, clientIp, content);
|
||||
|
||||
return result;
|
||||
}
|
||||
@@ -119,17 +123,19 @@ public class UserController {
|
||||
public void updateUser(@RequestBody UserInfoDto dto, RequestUserContext ctx){
|
||||
String modId = ctx.getUserId();
|
||||
String clientIp = ctx.getClientIp();
|
||||
final LocalDateTime now = DateTimeUtil.nowKstLocalDateTime();
|
||||
|
||||
userService.updateUser(dto, modId);
|
||||
systemEventLogService.writeUpdateUserLog(modId, clientIp, dto);
|
||||
userService.updateUser(dto, modId, now);
|
||||
systemEventLogService.writeUpdateUserLog(modId, now, clientIp, dto);
|
||||
}
|
||||
|
||||
@DeleteMapping("/{userId}")
|
||||
public void deleteUser(@PathVariable String userId, RequestUserContext ctx){
|
||||
String regId = ctx.getUserId();
|
||||
String clientIp = ctx.getClientIp();
|
||||
final LocalDateTime now = DateTimeUtil.nowKstLocalDateTime();
|
||||
|
||||
userService.deleteUser(userId, regId);
|
||||
systemEventLogService.writeDeleteUserLog(regId, clientIp, userId);
|
||||
systemEventLogService.writeDeleteUserLog(regId, now, clientIp, userId);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -131,7 +131,7 @@ public class TPrjctEntity {
|
||||
.build();
|
||||
}
|
||||
|
||||
public static TPrjctEntity create(ProjectCreateRequestDto req, String prjctCd, String regUser){
|
||||
public static TPrjctEntity create(ProjectCreateRequestDto req, String prjctCd, String regUser, LocalDateTime regDt){
|
||||
return TPrjctEntity.builder()
|
||||
.prjctCd(prjctCd)
|
||||
.prjctNm(req.getPrjctName())
|
||||
@@ -139,11 +139,11 @@ public class TPrjctEntity {
|
||||
.ownerDept(req.getOwnerDept())
|
||||
.ownerFw(req.getOwnerFw())
|
||||
.regUser(regUser)
|
||||
.regDt(DateTimeUtil.nowKstLocalDateTime())
|
||||
.regDt(regDt)
|
||||
.build();
|
||||
}
|
||||
|
||||
public void updateFrom(ProjectInfoDto dto, String modUser) {
|
||||
public void updateFrom(ProjectInfoDto dto, String modUser, LocalDateTime modDt) {
|
||||
this.prjctNm = dto.getPrjctName();
|
||||
this.prjctStatus = dto.getPrjctStatus().getCode();
|
||||
this.ownerDept = dto.getOwnerDept();
|
||||
@@ -156,6 +156,6 @@ public class TPrjctEntity {
|
||||
this.contactSenario = dto.getContactSenario();
|
||||
|
||||
this.modUser = modUser;
|
||||
this.modDt = DateTimeUtil.nowKstLocalDateTime();
|
||||
this.modDt = modDt;
|
||||
}
|
||||
}
|
||||
@@ -55,22 +55,23 @@ public class TResultCodeEntity {
|
||||
public static TResultCodeEntity copyFromDefault(
|
||||
TResultCodeEntity src,
|
||||
Long prjctIdx,
|
||||
String regUser
|
||||
String regUser,
|
||||
LocalDateTime regDt
|
||||
) {
|
||||
return TResultCodeEntity.builder()
|
||||
.id(TResultCodeEntityId.create(prjctIdx, src.getResultCdTy(), src.getResultCd()))
|
||||
.resultCdLbl(src.getResultCdLbl())
|
||||
.regUser(regUser)
|
||||
.regDt(DateTimeUtil.nowKstLocalDateTime())
|
||||
.regDt(regDt)
|
||||
.build();
|
||||
}
|
||||
|
||||
public static TResultCodeEntity fromDto(Long prjctIdx, ResultCodeType resultCdTy, ResultCodeDto req, String regUser) {
|
||||
public static TResultCodeEntity fromDto(Long prjctIdx, ResultCodeType resultCdTy, ResultCodeDto req, String regUser, LocalDateTime regDt) {
|
||||
return TResultCodeEntity.builder()
|
||||
.id(TResultCodeEntityId.create(prjctIdx, resultCdTy, req.getResultCd()))
|
||||
.resultCdLbl(req.getResultCdLbl())
|
||||
.regUser(regUser)
|
||||
.regDt(DateTimeUtil.nowKstLocalDateTime())
|
||||
.regDt(regDt)
|
||||
.build();
|
||||
|
||||
}
|
||||
|
||||
@@ -64,7 +64,8 @@ public class TSysEventLogEntity {
|
||||
Map<String, Object> logContent,
|
||||
Long prjctIdx,
|
||||
String ip,
|
||||
String regUser
|
||||
String regUser,
|
||||
LocalDateTime regDt
|
||||
) {
|
||||
return TSysEventLogEntity.builder()
|
||||
.eventTy(eventTy.getCode())
|
||||
@@ -73,7 +74,7 @@ public class TSysEventLogEntity {
|
||||
.prjctIdx(prjctIdx)
|
||||
.ip(ip)
|
||||
.regUser(regUser)
|
||||
.regDt(DateTimeUtil.nowKstLocalDateTime())
|
||||
.regDt(regDt)
|
||||
.build();
|
||||
}
|
||||
}
|
||||
@@ -88,7 +88,7 @@ public class TUserEntity {
|
||||
@Column(name = "del_dt")
|
||||
private LocalDateTime delDt;
|
||||
|
||||
public static TUserEntity fromDto(UserInfoDto dto, String regUser) {
|
||||
public static TUserEntity fromDto(UserInfoDto dto, String regUser, LocalDateTime regDt) {
|
||||
return TUserEntity.builder()
|
||||
.userId(dto.getUserId())
|
||||
.userPw(dto.getUserPw())
|
||||
@@ -102,11 +102,11 @@ public class TUserEntity {
|
||||
.userRole(dto.getUserRole())
|
||||
.memo(dto.getMemo() != null ? dto.getMemo() : "")
|
||||
.regUser(regUser)
|
||||
.regDt(DateTimeUtil.nowKstLocalDateTime())
|
||||
.regDt(regDt)
|
||||
.build();
|
||||
}
|
||||
|
||||
public void updateFromDto(UserInfoDto dto, String modUser) {
|
||||
public void updateFromDto(UserInfoDto dto, String modUser, LocalDateTime modDt) {
|
||||
// 비번은 값이 있을 때만 변경
|
||||
if (dto.getUserPw() != null && !dto.getUserPw().isBlank()) {
|
||||
this.userPw = dto.getUserPw();
|
||||
@@ -117,6 +117,6 @@ public class TUserEntity {
|
||||
this.memo = (dto.getMemo() != null) ? dto.getMemo() : "";
|
||||
|
||||
this.modUser = modUser;
|
||||
this.modDt = DateTimeUtil.nowKstLocalDateTime();
|
||||
this.modDt = modDt;
|
||||
}
|
||||
}
|
||||
@@ -34,28 +34,28 @@ public class AssignService {
|
||||
}
|
||||
|
||||
@Transactional
|
||||
public void upsertPrjctOutsourceAssign(Long prjctIdx, List<String> assignUserIdList, String regUser){
|
||||
public void upsertPrjctOutsourceAssign(Long prjctIdx, List<String> assignUserIdList, String regUser, LocalDateTime regDt){
|
||||
projectAssignRepository.deleteAssignByPrjctIdxAndRoleRange(
|
||||
prjctIdx,
|
||||
ContactConstant.OUTSOURCE_USER_ROLE,
|
||||
ContactConstant.OUTSOURCE_USER_ROLE + 1000
|
||||
);
|
||||
|
||||
insertPrjctAssign(prjctIdx, assignUserIdList, regUser);
|
||||
insertPrjctAssign(prjctIdx, assignUserIdList, regUser, regDt);
|
||||
}
|
||||
|
||||
@Transactional
|
||||
public void upsertPrjctFieldworkAssign(Long prjctIdx, List<String> assignUserIdList, String regUser){
|
||||
public void upsertPrjctFieldworkAssign(Long prjctIdx, List<String> assignUserIdList, String regUser, LocalDateTime regDt){
|
||||
projectAssignRepository.deleteAssignByPrjctIdxAndRoleRange(
|
||||
prjctIdx,
|
||||
ContactConstant.FIELDWORK_USER_ROLE,
|
||||
ContactConstant.FIELDWORK_USER_ROLE + 1000
|
||||
);
|
||||
|
||||
insertPrjctAssign(prjctIdx, assignUserIdList, regUser);
|
||||
insertPrjctAssign(prjctIdx, assignUserIdList, regUser, regDt);
|
||||
}
|
||||
|
||||
private void insertPrjctAssign(Long prjctIdx, List<String> assignUserIdList, String regUser){
|
||||
private void insertPrjctAssign(Long prjctIdx, List<String> assignUserIdList, String regUser, LocalDateTime regDt){
|
||||
if (assignUserIdList == null || assignUserIdList.isEmpty()) {
|
||||
return;
|
||||
}
|
||||
@@ -68,10 +68,8 @@ public class AssignService {
|
||||
|
||||
if (normalized.isEmpty()) return;
|
||||
|
||||
final LocalDateTime now = DateTimeUtil.nowKstLocalDateTime();
|
||||
|
||||
List<TPrjctAssignEntity> entities = normalized.stream()
|
||||
.map(uid -> TPrjctAssignEntity.create(prjctIdx, uid, regUser, now))
|
||||
.map(uid -> TPrjctAssignEntity.create(prjctIdx, uid, regUser, regDt))
|
||||
.toList();
|
||||
|
||||
projectAssignRepository.saveAll(entities);
|
||||
|
||||
@@ -16,6 +16,7 @@ import org.springframework.data.jpa.domain.Specification;
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
|
||||
import java.time.LocalDateTime;
|
||||
import java.util.*;
|
||||
|
||||
@Service
|
||||
@@ -29,15 +30,15 @@ public class ProjectService {
|
||||
private static final List<Short> STATUS_1 = List.of((short) 1);
|
||||
|
||||
@Transactional
|
||||
public ProjectInfoDto createProject(ProjectCreateRequestDto req, String regUser) {
|
||||
public ProjectInfoDto createProject(ProjectCreateRequestDto req, String regUser, LocalDateTime regDt) {
|
||||
String itrnt = req.getItrntPrjctCd();
|
||||
|
||||
try {
|
||||
String prjctCd = this.makePrjctCd(itrnt);
|
||||
TPrjctEntity entity = TPrjctEntity.create(req, prjctCd, regUser);
|
||||
TPrjctEntity entity = TPrjctEntity.create(req, prjctCd, regUser, regDt);
|
||||
|
||||
ProjectInfoDto savedProject = ProjectInfoDto.from(projectRepository.save(entity));
|
||||
resultCodeService.copyResultCodeFromDefault(savedProject.getPrjctIdx(), regUser);
|
||||
resultCodeService.copyResultCodeFromDefault(savedProject.getPrjctIdx(), regUser, regDt);
|
||||
|
||||
return savedProject;
|
||||
} catch (DataIntegrityViolationException e) {
|
||||
@@ -132,7 +133,7 @@ public class ProjectService {
|
||||
}
|
||||
|
||||
@Transactional
|
||||
public void updateProject(long prjctIdx, ProjectUpdateRequestDto req, String modUser){
|
||||
public void updateProject(long prjctIdx, ProjectUpdateRequestDto req, String modUser, LocalDateTime modDt){
|
||||
// dirty checking 업데이트
|
||||
TPrjctEntity entity = projectRepository.findById(prjctIdx)
|
||||
.orElseThrow(() ->
|
||||
@@ -140,15 +141,15 @@ public class ProjectService {
|
||||
.with("prjctIdx", prjctIdx)
|
||||
);
|
||||
|
||||
entity.updateFrom(req.getProjectInfo(), modUser);
|
||||
entity.updateFrom(req.getProjectInfo(), modUser, modDt);
|
||||
|
||||
assignService.upsertPrjctOutsourceAssign(prjctIdx, req.getAssignUserIdList(), modUser);
|
||||
resultCodeService.updateResultCode(prjctIdx, req.getResultCodeList(), modUser);
|
||||
assignService.upsertPrjctOutsourceAssign(prjctIdx, req.getAssignUserIdList(), modUser, modDt);
|
||||
resultCodeService.updateResultCode(prjctIdx, req.getResultCodeList(), modUser, modDt);
|
||||
}
|
||||
|
||||
@Transactional
|
||||
public void deleteProject(Long prjctIdx, String delUser){
|
||||
int deleteCount = projectRepository.softDeleteByPrjctIdx(prjctIdx, delUser, DateTimeUtil.nowKstLocalDateTime());
|
||||
public void deleteProject(Long prjctIdx, String delUser, LocalDateTime delDt){
|
||||
int deleteCount = projectRepository.softDeleteByPrjctIdx(prjctIdx, delUser, delDt);
|
||||
|
||||
if(deleteCount == 0){
|
||||
throw BusinessException.notFound("PROJECT_NOT_FOUND", "프로젝트를 찾을 수 없습니다.")
|
||||
|
||||
@@ -11,6 +11,7 @@ import lombok.RequiredArgsConstructor;
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
|
||||
import java.time.LocalDateTime;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.stream.Collectors;
|
||||
@@ -21,11 +22,11 @@ public class ResultCodeService {
|
||||
|
||||
private final ResultCodeRepository resultCodeRepository;
|
||||
|
||||
public void copyResultCodeFromDefault(long prjctIdx, String regUser){
|
||||
public void copyResultCodeFromDefault(long prjctIdx, String regUser, LocalDateTime regDt){
|
||||
List<TResultCodeEntity> defaultCodeList = resultCodeRepository.findDefault();
|
||||
|
||||
List<TResultCodeEntity> copyCodeList = defaultCodeList.stream()
|
||||
.map(src -> TResultCodeEntity.copyFromDefault(src, prjctIdx, regUser))
|
||||
.map(src -> TResultCodeEntity.copyFromDefault(src, prjctIdx, regUser, regDt))
|
||||
.toList();
|
||||
|
||||
resultCodeRepository.saveAll(copyCodeList);
|
||||
@@ -44,24 +45,24 @@ public class ResultCodeService {
|
||||
}
|
||||
|
||||
@Transactional
|
||||
public void updateResultCode(long prjctIdx, List<ResultCodeDto> resultCodeDtoList, String modUser){
|
||||
public void updateResultCode(long prjctIdx, List<ResultCodeDto> resultCodeDtoList, String modUser, LocalDateTime modDt){
|
||||
if (resultCodeDtoList != null && !resultCodeDtoList.isEmpty()) {
|
||||
Map<ResultCodeType, List<ResultCodeDto>> dtoGroupByType = resultCodeDtoList.stream()
|
||||
.filter(dto -> dto.getResultCdTy() != null)
|
||||
.collect(Collectors.groupingBy(ResultCodeDto::getResultCdTy));
|
||||
|
||||
dtoGroupByType.forEach((resultCdTy, dtos) ->
|
||||
replaceResultCodes(prjctIdx, resultCdTy, dtos, modUser)
|
||||
replaceResultCodes(prjctIdx, resultCdTy, dtos, modUser, modDt)
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
/*************************private************************************/
|
||||
private void replaceResultCodes(long prjctIdx, ResultCodeType resultCdTy, List<ResultCodeDto> dtos, String userId) {
|
||||
private void replaceResultCodes(long prjctIdx, ResultCodeType resultCdTy, List<ResultCodeDto> dtos, String userId, LocalDateTime modDt) {
|
||||
resultCodeRepository.deleteByIdPrjctIdxAndIdResultCdTy(prjctIdx, resultCdTy);
|
||||
|
||||
List<TResultCodeEntity> entities = dtos.stream()
|
||||
.map(dto -> TResultCodeEntity.fromDto(prjctIdx, resultCdTy, dto, userId))
|
||||
.map(dto -> TResultCodeEntity.fromDto(prjctIdx, resultCdTy, dto, userId, modDt))
|
||||
.toList();
|
||||
|
||||
resultCodeRepository.saveAll(entities);
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
package com.kri.contact.server.service;
|
||||
|
||||
import com.fasterxml.jackson.databind.ObjectMapper;
|
||||
import com.kri.common.datetime.DateTimeUtil;
|
||||
import com.kri.contact.server.dto.*;
|
||||
import com.kri.contact.server.dto.systemlog.UploadUserContentDto;
|
||||
import com.kri.contact.server.common.enums.SystemEventType;
|
||||
@@ -9,6 +10,7 @@ import com.kri.contact.server.persistence.repository.SystemEventLogRepository;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import java.time.LocalDateTime;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
@@ -20,80 +22,85 @@ public class SystemEventLogService {
|
||||
private final ObjectMapper objectMapper;
|
||||
private final SystemEventLogRepository systemEventLogRepository;
|
||||
|
||||
public void writeLoginLog(String userId, String clientIp) {
|
||||
public void writeLoginLog(String userId, LocalDateTime regDt, String clientIp) {
|
||||
writeSystemLog(
|
||||
SystemEventType.LOGIN,
|
||||
"Login",
|
||||
null,
|
||||
userId,
|
||||
regDt,
|
||||
clientIp,
|
||||
"userId",
|
||||
userId
|
||||
);
|
||||
}
|
||||
|
||||
public void writeLogoutLog(String userId, String clientIp) {
|
||||
public void writeLogoutLog(String userId, LocalDateTime regDt, String clientIp) {
|
||||
writeSystemLog(
|
||||
SystemEventType.LOGOUT,
|
||||
"Logout",
|
||||
null,
|
||||
userId,
|
||||
regDt,
|
||||
clientIp,
|
||||
"userId",
|
||||
userId
|
||||
);
|
||||
}
|
||||
|
||||
public void writeCreateUserLog(String regId, String clientIp, UserInfoDto userInfo){
|
||||
writeSystemLog(SystemEventType.CREATE_USER, "Create User", null, regId, clientIp, userInfo);
|
||||
public void writeCreateUserLog(String regId, LocalDateTime regDt, String clientIp, UserInfoDto userInfo){
|
||||
writeSystemLog(SystemEventType.CREATE_USER, "Create User", null, regId, regDt, clientIp, userInfo);
|
||||
}
|
||||
|
||||
public void writeUploadUserLog(String regId, String clientIp, UploadUserContentDto content){
|
||||
writeSystemLog(SystemEventType.UPLOAD_USER, "Upload User", null, regId, clientIp, content);
|
||||
public void writeUploadUserLog(String regId, LocalDateTime regDt, String clientIp, UploadUserContentDto content){
|
||||
writeSystemLog(SystemEventType.UPLOAD_USER, "Upload User", null, regId, regDt, clientIp, content);
|
||||
}
|
||||
|
||||
public void writeUpdateUserLog(String regId, String clientIp, UserInfoDto userInfo){
|
||||
writeSystemLog(SystemEventType.UPDATE_USER, "Update User", null, regId, clientIp, userInfo);
|
||||
public void writeUpdateUserLog(String regId, LocalDateTime regDt, String clientIp, UserInfoDto userInfo){
|
||||
writeSystemLog(SystemEventType.UPDATE_USER, "Update User", null, regId, regDt, clientIp, userInfo);
|
||||
}
|
||||
|
||||
public void writeDeleteUserLog(String regId, String clientIp, String userId){
|
||||
public void writeDeleteUserLog(String regId, LocalDateTime regDt, String clientIp, String userId){
|
||||
writeSystemLog(
|
||||
SystemEventType.DELETE_USER,
|
||||
"Delete User",
|
||||
null,
|
||||
regId,
|
||||
regDt,
|
||||
clientIp,
|
||||
"userId",
|
||||
userId
|
||||
);
|
||||
}
|
||||
|
||||
public void writeCreateProject(String regId, String clientIp, Long prjctIdx, ProjectCreateRequestDto req){
|
||||
writeSystemLog(SystemEventType.CREATE_PROJECT, "Create Project", prjctIdx, regId, clientIp, req);
|
||||
public void writeCreateProject(String regId, LocalDateTime regDt, String clientIp, Long prjctIdx, ProjectCreateRequestDto req){
|
||||
writeSystemLog(SystemEventType.CREATE_PROJECT, "Create Project", prjctIdx, regId, regDt, clientIp, req);
|
||||
}
|
||||
|
||||
public void writeUpdateProject(String regId, String clientIp, Long prjctIdx, ProjectUpdateRequestDto req){
|
||||
writeSystemLog(SystemEventType.UPDATE_PROJECT, "Update Project", prjctIdx, regId, clientIp, req);
|
||||
public void writeUpdateProject(String regId, LocalDateTime regDt, String clientIp, Long prjctIdx, ProjectUpdateRequestDto req){
|
||||
writeSystemLog(SystemEventType.UPDATE_PROJECT, "Update Project", prjctIdx, regId, regDt, clientIp, req);
|
||||
}
|
||||
|
||||
public void writeDeleteProject(String regId, String clientIp, Long prjctIdx){
|
||||
public void writeDeleteProject(String regId, LocalDateTime regDt, String clientIp, Long prjctIdx){
|
||||
writeSystemLog(
|
||||
SystemEventType.DELETE_PROJECT,
|
||||
"Delete Project",
|
||||
prjctIdx,
|
||||
regId,
|
||||
regDt,
|
||||
clientIp,
|
||||
"prjctIdx",
|
||||
prjctIdx
|
||||
);
|
||||
}
|
||||
|
||||
public void writeAssignUserProject(String regId, String clientIp, Long prjctIdx, List<String> assignUserIdList){
|
||||
public void writeAssignUserProject(String regId, LocalDateTime regDt, String clientIp, Long prjctIdx, List<String> assignUserIdList){
|
||||
writeSystemLog(
|
||||
SystemEventType.ASSIGN_PROJECT_USER,
|
||||
"Assign Project FW User",
|
||||
prjctIdx,
|
||||
regId,
|
||||
regDt,
|
||||
clientIp,
|
||||
"assignUserIdList",
|
||||
assignUserIdList
|
||||
@@ -105,12 +112,13 @@ public class SystemEventLogService {
|
||||
String title,
|
||||
Long prjctIdx,
|
||||
String regId,
|
||||
LocalDateTime regDt,
|
||||
String clientIp,
|
||||
T content
|
||||
) {
|
||||
Map<String, Object> contentMap = toMap(objectMapper, content);
|
||||
|
||||
saveLog(eventType, title, prjctIdx, regId, clientIp, contentMap);
|
||||
saveLog(eventType, title, prjctIdx, regId, regDt, clientIp, contentMap);
|
||||
}
|
||||
|
||||
protected <T> void writeSystemLog(
|
||||
@@ -118,12 +126,13 @@ public class SystemEventLogService {
|
||||
String title,
|
||||
Long prjctIdx,
|
||||
String regId,
|
||||
LocalDateTime regDt,
|
||||
String clientIp,
|
||||
String contentKey,
|
||||
T content
|
||||
) {
|
||||
Map<String, Object> contentMap = Map.of(contentKey, content);
|
||||
saveLog(eventType, title, prjctIdx, regId, clientIp, contentMap);
|
||||
saveLog(eventType, title, prjctIdx, regId, regDt, clientIp, contentMap);
|
||||
}
|
||||
|
||||
private void saveLog(
|
||||
@@ -131,6 +140,7 @@ public class SystemEventLogService {
|
||||
String title,
|
||||
Long prjctIdx,
|
||||
String regId,
|
||||
LocalDateTime regDt,
|
||||
String clientIp,
|
||||
Map<String, Object> contentMap
|
||||
){
|
||||
@@ -140,7 +150,8 @@ public class SystemEventLogService {
|
||||
contentMap,
|
||||
prjctIdx,
|
||||
clientIp,
|
||||
regId
|
||||
regId,
|
||||
regDt
|
||||
);
|
||||
|
||||
systemEventLogRepository.save(log);
|
||||
|
||||
@@ -21,6 +21,7 @@ import org.springframework.transaction.annotation.Transactional;
|
||||
import org.springframework.web.multipart.MultipartFile;
|
||||
|
||||
import java.io.ByteArrayOutputStream;
|
||||
import java.time.LocalDateTime;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
@@ -33,7 +34,7 @@ public class UserService {
|
||||
private final UserRepository userRepository;
|
||||
|
||||
@Transactional
|
||||
public void createUser(UserInfoDto userInfo, String regUser){
|
||||
public void createUser(UserInfoDto userInfo, String regUser, LocalDateTime regDt){
|
||||
List<RoleInfoDto> roleList = roleService.getRoleList();
|
||||
List<String> intranetUserList = intranetExtensionApiClient.getUserIdArray();
|
||||
|
||||
@@ -45,13 +46,13 @@ public class UserService {
|
||||
throw BusinessException.badRequest("WRONG_USER_DATA", firstFail.getErrMessage());
|
||||
}
|
||||
|
||||
TUserEntity entity = TUserEntity.fromDto(userInfo, regUser);
|
||||
TUserEntity entity = TUserEntity.fromDto(userInfo, regUser, regDt);
|
||||
|
||||
userRepository.save(entity);
|
||||
}
|
||||
|
||||
@Transactional
|
||||
public ExcelUploadResponseDto createUsersFromExcel(MultipartFile file, String regUser, String forceCmpn) {
|
||||
public ExcelUploadResponseDto createUsersFromExcel(MultipartFile file, String regUser, LocalDateTime regDt, String forceCmpn) {
|
||||
if (file == null || file.isEmpty()) {
|
||||
throw BusinessException.badRequest("EMPTY_FILE", "업로드된 파일이 없습니다.");
|
||||
}
|
||||
@@ -95,7 +96,7 @@ public class UserService {
|
||||
|
||||
// 2) 실제 DB 저장
|
||||
try {
|
||||
this.createUserInternal(dto, regUser);
|
||||
this.createUserInternal(dto, regUser, regDt);
|
||||
successCount++;
|
||||
} catch (BusinessException ex) {
|
||||
// 시스템/비즈니스 예외도 에러 목록에 추가
|
||||
@@ -191,7 +192,7 @@ public class UserService {
|
||||
}
|
||||
|
||||
@Transactional
|
||||
public void updateUser(UserInfoDto dto, String modUser){
|
||||
public void updateUser(UserInfoDto dto, String modUser, LocalDateTime modDt){
|
||||
// dirty checking 업데이트
|
||||
TUserEntity entity = userRepository.findByUserIdAndDelFalse(dto.getUserId())
|
||||
.orElseThrow(() ->
|
||||
@@ -199,7 +200,7 @@ public class UserService {
|
||||
.with("userId", dto.getUserId())
|
||||
);
|
||||
|
||||
entity.updateFromDto(dto, modUser);// 기존 엔티티에 적용
|
||||
entity.updateFromDto(dto, modUser, modDt);// 기존 엔티티에 적용
|
||||
}
|
||||
|
||||
@Transactional
|
||||
@@ -336,11 +337,11 @@ public class UserService {
|
||||
return errors;
|
||||
}
|
||||
|
||||
private void createUserInternal(UserInfoDto userInfo, String regUser) {
|
||||
private void createUserInternal(UserInfoDto userInfo, String regUser, LocalDateTime regDt) {
|
||||
userInfo.setUserId(userInfo.getUserId().toLowerCase());
|
||||
userInfo.setUserTeam("S101");
|
||||
|
||||
TUserEntity entity = TUserEntity.fromDto(userInfo, regUser);
|
||||
TUserEntity entity = TUserEntity.fromDto(userInfo, regUser, regDt);
|
||||
userRepository.save(entity);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user