260212_01_DOC: 프로젝트 전체에 구글 java 스타일 적용

This commit is contained in:
2026-02-12 11:23:15 +09:00
parent 4948faa28a
commit b07a4389d1
84 changed files with 3176 additions and 2891 deletions

View File

@@ -7,11 +7,15 @@ import com.kri.contact.server.service.SystemEventLogService;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.tags.Tag;
import jakarta.validation.Valid;
import lombok.RequiredArgsConstructor;
import org.springframework.web.bind.annotation.*;
import java.time.LocalDateTime;
import java.util.List;
import lombok.RequiredArgsConstructor;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
@RestController
@RequestMapping("/api/v1/assign")
@@ -19,30 +23,31 @@ import java.util.List;
@Tag(name = "Assign", description = "배정 API")
public class AssignController {
private final SystemEventLogService systemEventLogService;
private final AssignService assignService;
private final SystemEventLogService systemEventLogService;
private final AssignService assignService;
@Operation(summary = "배정된 외주사 조회")
@GetMapping("/prjct-outsource/{prjctIdx}")
public List<String> getPrjctOutsourceAssign(@PathVariable Long prjctIdx) {
return assignService.getPrjctOutsourceAssign(prjctIdx);
}
@Operation(summary = "배정된 컨택원/면접원 조회")
@GetMapping("/prjct-fieldwork/{prjctIdx}")
public List<String> getPrjctFieldworkAssign(@PathVariable Long prjctIdx) {
return assignService.getPrjctFieldworkAssign(prjctIdx);
}
@Operation(summary = "배정된 외주사 조회")
@GetMapping("/prjct-outsource/{prjctIdx}")
public List<String> getPrjctOutsourceAssign(@PathVariable Long prjctIdx) {
return assignService.getPrjctOutsourceAssign(prjctIdx);
}
@Operation(summary = "컨택원/면접원 배정")
@PutMapping("/prjct-fieldwork/{prjctIdx}")
public void upsertPrjctFieldworkAssign(
@PathVariable Long prjctIdx,
@Valid @RequestBody List<String> assignUserIdList,
RequestUserContext ctx
) {
final LocalDateTime now = DateTimeUtil.nowKstLocalDateTime();
assignService.upsertPrjctFieldworkAssign(prjctIdx, assignUserIdList, ctx.getUserId(), now);
systemEventLogService.writeAssignUserProject(ctx.getUserId(), now, ctx.getClientIp(), prjctIdx, assignUserIdList);
}
@Operation(summary = "배정된 컨택원/면접원 조회")
@GetMapping("/prjct-fieldwork/{prjctIdx}")
public List<String> getPrjctFieldworkAssign(@PathVariable Long prjctIdx) {
return assignService.getPrjctFieldworkAssign(prjctIdx);
}
@Operation(summary = "컨택원/면접원 배정")
@PutMapping("/prjct-fieldwork/{prjctIdx}")
public void upsertPrjctFieldworkAssign(
@PathVariable Long prjctIdx,
@Valid @RequestBody List<String> assignUserIdList,
RequestUserContext ctx
) {
final LocalDateTime now = DateTimeUtil.nowKstLocalDateTime();
assignService.upsertPrjctFieldworkAssign(prjctIdx, assignUserIdList, ctx.getUserId(), now);
systemEventLogService.writeAssignUserProject(ctx.getUserId(), now, ctx.getClientIp(), prjctIdx,
assignUserIdList);
}
}

View File

@@ -9,40 +9,44 @@ import com.kri.contact.server.service.SystemEventLogService;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.tags.Tag;
import jakarta.validation.Valid;
import lombok.RequiredArgsConstructor;
import org.springframework.web.bind.annotation.*;
import java.time.LocalDateTime;
import lombok.RequiredArgsConstructor;
import org.springframework.web.bind.annotation.PathVariable;
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.RestController;
@RestController
@RequestMapping("/api/v1/auth")
@RequiredArgsConstructor
@Tag(name = "Auth", description = "인증 API")
public class AuthController {
private final AuthService authService;
private final SystemEventLogService systemEventLogService;
@Operation(summary = "로그인 요청")
@PostMapping("/login")
public LoginResponseDto tryLogin(
@Valid @RequestBody LoginRequestDto request,
RequestUserContext ctx
) {
final LocalDateTime now = DateTimeUtil.nowKstLocalDateTime();
private final AuthService authService;
private final SystemEventLogService systemEventLogService;
LoginResponseDto response = authService.tryLogin(request);
systemEventLogService.writeLoginLog(response.getUser().getUserId(), now, ctx.getClientIp());
@Operation(summary = "로그인 요청")
@PostMapping("/login")
public LoginResponseDto tryLogin(
@Valid @RequestBody LoginRequestDto request,
RequestUserContext ctx
) {
final LocalDateTime now = DateTimeUtil.nowKstLocalDateTime();
return response;
}
LoginResponseDto response = authService.tryLogin(request);
systemEventLogService.writeLoginLog(response.getUser().getUserId(), now, ctx.getClientIp());
@Operation(summary = "로그아웃 요청")
@PostMapping("/logout/{userId}")
public boolean logout(@PathVariable String userId, RequestUserContext ctx) {
final LocalDateTime now = DateTimeUtil.nowKstLocalDateTime();
return response;
}
systemEventLogService.writeLogoutLog(userId, now, ctx.getClientIp());
@Operation(summary = "로그아웃 요청")
@PostMapping("/logout/{userId}")
public boolean logout(@PathVariable String userId, RequestUserContext ctx) {
final LocalDateTime now = DateTimeUtil.nowKstLocalDateTime();
return true;
}
systemEventLogService.writeLogoutLog(userId, now, ctx.getClientIp());
return true;
}
}

View File

@@ -4,19 +4,32 @@ import com.kri.common.datetime.DateTimeUtil;
import com.kri.common.webmvc.RequestUserContext;
import com.kri.common.webmvc.page.PageResponseDto;
import com.kri.contact.server.common.enums.ChannelType;
import com.kri.contact.server.dto.*;
import com.kri.contact.server.dto.ProjectCreateRequestDto;
import com.kri.contact.server.dto.ProjectInfoDto;
import com.kri.contact.server.dto.ProjectMainTemplateUpdateRequestDto;
import com.kri.contact.server.dto.ProjectOwnerResponseDto;
import com.kri.contact.server.dto.ProjectSearchRequestDto;
import com.kri.contact.server.dto.ProjectUpdateRequestDto;
import com.kri.contact.server.service.FileService;
import com.kri.contact.server.service.ProjectService;
import com.kri.contact.server.service.SystemEventLogService;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.tags.Tag;
import jakarta.validation.Valid;
import lombok.RequiredArgsConstructor;
import org.springframework.web.bind.annotation.*;
import org.springframework.web.multipart.MultipartFile;
import java.time.LocalDateTime;
import java.util.List;
import lombok.RequiredArgsConstructor;
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.PathVariable;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
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;
@RestController
@RequestMapping("/api/v1/project")
@@ -24,109 +37,113 @@ import java.util.List;
@Tag(name = "Project", description = "프로젝트 API")
public class ProjectController {
private final SystemEventLogService systemEventLogService;
private final ProjectService projectService;
private final FileService fileService;
private final SystemEventLogService systemEventLogService;
private final ProjectService projectService;
private final FileService fileService;
@Operation(summary = "프로젝트 조회")
@GetMapping("/{prjctIdx}")
public ProjectInfoDto getProject(@PathVariable Long prjctIdx) {
return projectService.getProject(prjctIdx);
}
@Operation(summary = "프로젝트 조회")
@GetMapping("/{prjctIdx}")
public ProjectInfoDto getProject(@PathVariable Long prjctIdx) {
return projectService.getProject(prjctIdx);
}
@Operation(summary = "상위 프로젝트 조회(생성일자 늦은 순)")
@GetMapping("/top/{topCount}")
public List<ProjectInfoDto> getTopProject(
@PathVariable int topCount,
@RequestParam(required = false) String keyword,
RequestUserContext ctx
) {
return projectService.getTopProject(topCount, keyword, ctx.getUserId(), ctx.getUserRole());
}
@Operation(summary = "상위 프로젝트 조회(생성일자 늦은 순)")
@GetMapping("/top/{topCount}")
public List<ProjectInfoDto> getTopProject(
@PathVariable int topCount,
@RequestParam(required = false) String keyword,
RequestUserContext ctx
) {
return projectService.getTopProject(topCount, keyword, ctx.getUserId(), ctx.getUserRole());
}
@Operation(summary = "프로젝트 목록 조회")
@PostMapping("/list")
public PageResponseDto<ProjectInfoDto> searchProject(
@Valid @RequestBody ProjectSearchRequestDto req,
RequestUserContext ctx
) {
return projectService.searchProject(req, ctx.getUserId(), ctx.getUserRole());
}
@Operation(summary = "프로젝트 목록 조회")
@PostMapping("/list")
public PageResponseDto<ProjectInfoDto> searchProject(
@Valid @RequestBody ProjectSearchRequestDto req,
RequestUserContext ctx
) {
return projectService.searchProject(req, ctx.getUserId(), ctx.getUserRole());
}
@Operation(summary = "프로젝트를 소유하고 있는 모든 부서/실사 목록 조회")
@GetMapping("/owner-list")
public ProjectOwnerResponseDto getOwnerList(RequestUserContext ctx) {
return projectService.getOwnerList(ctx.getUserRole());
}
//프로젝트 메인 발송 템플릿 조회 시 살아있는 템플릿인지 한번 검사하기
@Operation(summary = "프로젝트 대표 발송 템플릿 조회")
@GetMapping("/main-template/{prjctIdx}/{chnnlTy}")
public Long getMainTemplateIdx(
@PathVariable Long prjctIdx,
@PathVariable ChannelType chnnlTy
){
return projectService.getMainTemplateIdx(prjctIdx, chnnlTy.getCode());
}
@Operation(summary = "프로젝트를 소유하고 있는 모든 부서/실사 목록 조회")
@GetMapping("/owner-list")
public ProjectOwnerResponseDto getOwnerList(RequestUserContext ctx) {
return projectService.getOwnerList(ctx.getUserRole());
}
@Operation(summary = "프로젝트 생성")
@PutMapping()
public ProjectInfoDto createProject(
@Valid @RequestBody ProjectCreateRequestDto req,
RequestUserContext ctx
) {
final LocalDateTime now = DateTimeUtil.nowKstLocalDateTime();
//프로젝트 메인 발송 템플릿 조회 시 살아있는 템플릿인지 한번 검사하기
@Operation(summary = "프로젝트 대표 발송 템플릿 조회")
@GetMapping("/main-template/{prjctIdx}/{chnnlTy}")
public Long getMainTemplateIdx(
@PathVariable Long prjctIdx,
@PathVariable ChannelType chnnlTy
) {
return projectService.getMainTemplateIdx(prjctIdx, chnnlTy.getCode());
}
ProjectInfoDto prjctInfo = projectService.createProject(req, ctx.getUserId(), now);
systemEventLogService.writeCreateProject(ctx.getUserId(), now, ctx.getClientIp(), prjctInfo.getPrjctIdx(), req);
@Operation(summary = "프로젝트 생성")
@PutMapping()
public ProjectInfoDto createProject(
@Valid @RequestBody ProjectCreateRequestDto req,
RequestUserContext ctx
) {
final LocalDateTime now = DateTimeUtil.nowKstLocalDateTime();
return prjctInfo;
}
ProjectInfoDto prjctInfo = projectService.createProject(req, ctx.getUserId(), now);
systemEventLogService.writeCreateProject(ctx.getUserId(), now, ctx.getClientIp(),
prjctInfo.getPrjctIdx(), req);
@Operation(summary = "시나리오 이미지 업로드")
@PutMapping("/senario-image/{prjctCd}")
public String uploadContactSenarioImage(@PathVariable String prjctCd, @RequestParam("file") MultipartFile file) {
return fileService.storeTempFile(prjctCd, file);
}
return prjctInfo;
}
@Operation(summary = "프로젝트 수정")
@PatchMapping("/{prjctIdx}")
public void updateProject(
@PathVariable long prjctIdx,
@Valid @RequestBody ProjectUpdateRequestDto req,
RequestUserContext ctx
) {
final LocalDateTime now = DateTimeUtil.nowKstLocalDateTime();
@Operation(summary = "시나리오 이미지 업로드")
@PutMapping("/senario-image/{prjctCd}")
public String uploadContactSenarioImage(@PathVariable String prjctCd,
@RequestParam("file") MultipartFile file) {
return fileService.storeTempFile(prjctCd, file);
}
String newHtml = fileService.syncOnSave(
req.getProjectInfo().getPrjctCd(),
req.getProjectInfo().getContactSenario()
);
req.getProjectInfo().setContactSenario(newHtml);
@Operation(summary = "프로젝트 수정")
@PatchMapping("/{prjctIdx}")
public void updateProject(
@PathVariable long prjctIdx,
@Valid @RequestBody ProjectUpdateRequestDto req,
RequestUserContext ctx
) {
final LocalDateTime now = DateTimeUtil.nowKstLocalDateTime();
projectService.updateProject(prjctIdx, req, ctx.getUserId(), now);
String newHtml = fileService.syncOnSave(
req.getProjectInfo().getPrjctCd(),
req.getProjectInfo().getContactSenario()
);
req.getProjectInfo().setContactSenario(newHtml);
systemEventLogService.writeUpdateProject(ctx.getUserId(), now, ctx.getClientIp(), prjctIdx, req);
}
projectService.updateProject(prjctIdx, req, ctx.getUserId(), now);
@Operation(summary = "프로젝트 대표 발송 템플릿 지정")
@PatchMapping("/main-template")
public void updateProjectMainTemplate(
@Valid @RequestBody ProjectMainTemplateUpdateRequestDto req,
RequestUserContext ctx
) {
final LocalDateTime now = DateTimeUtil.nowKstLocalDateTime();
systemEventLogService.writeUpdateProject(ctx.getUserId(), now, ctx.getClientIp(), prjctIdx,
req);
}
projectService.updateProjectMainTemplate(req, ctx.getUserId(), now);
systemEventLogService.writeUpdateDefaultMessageTemplate(ctx.getUserId(), now, ctx.getClientIp(), req);
}
@Operation(summary = "프로젝트 대표 발송 템플릿 지정")
@PatchMapping("/main-template")
public void updateProjectMainTemplate(
@Valid @RequestBody ProjectMainTemplateUpdateRequestDto req,
RequestUserContext ctx
) {
final LocalDateTime now = DateTimeUtil.nowKstLocalDateTime();
@Operation(summary = "프로젝트 삭제(소프트 삭제)")
@DeleteMapping("/{prjctIdx}")
public void deleteProject(@PathVariable Long prjctIdx, RequestUserContext ctx) {
final LocalDateTime now = DateTimeUtil.nowKstLocalDateTime();
projectService.updateProjectMainTemplate(req, ctx.getUserId(), now);
systemEventLogService.writeUpdateDefaultMessageTemplate(ctx.getUserId(), now, ctx.getClientIp(),
req);
}
projectService.deleteProject(prjctIdx, ctx.getUserId(), now);
systemEventLogService.writeDeleteProject(ctx.getUserId(), now, ctx.getClientIp(), prjctIdx);
}
@Operation(summary = "프로젝트 삭제(소프트 삭제)")
@DeleteMapping("/{prjctIdx}")
public void deleteProject(@PathVariable Long prjctIdx, RequestUserContext ctx) {
final LocalDateTime now = DateTimeUtil.nowKstLocalDateTime();
projectService.deleteProject(prjctIdx, ctx.getUserId(), now);
systemEventLogService.writeDeleteProject(ctx.getUserId(), now, ctx.getClientIp(), prjctIdx);
}
}

View File

@@ -1,16 +1,18 @@
package com.kri.contact.server.controller;
import com.kri.common.webmvc.RequestUserContext;
import com.kri.contact.server.common.enums.ResultCodeType;
import com.kri.contact.server.dto.ResultCodeDto;
import com.kri.contact.server.service.ResultCodeService;
import com.kri.contact.server.service.SystemEventLogService;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.tags.Tag;
import lombok.RequiredArgsConstructor;
import org.springframework.web.bind.annotation.*;
import java.util.List;
import lombok.RequiredArgsConstructor;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;
@RestController
@RequestMapping("/api/v1/result-code")
@@ -18,15 +20,15 @@ import java.util.List;
@Tag(name = "Result Code", description = "결과 코드 API")
public class ResultCodeController {
private final SystemEventLogService systemEventLogService;
private final ResultCodeService resultCodeService;
private final SystemEventLogService systemEventLogService;
private final ResultCodeService resultCodeService;
@Operation(summary = "결과 코드 조회")
@GetMapping("/{prjctIdx}")
public List<ResultCodeDto> getResultCodeList(
@PathVariable long prjctIdx,
@RequestParam(required = false) ResultCodeType resultCdTy
) {
return resultCodeService.getResultCode(prjctIdx, resultCdTy);
}
@Operation(summary = "결과 코드 조회")
@GetMapping("/{prjctIdx}")
public List<ResultCodeDto> getResultCodeList(
@PathVariable long prjctIdx,
@RequestParam(required = false) ResultCodeType resultCdTy
) {
return resultCodeService.getResultCode(prjctIdx, resultCdTy);
}
}

View File

@@ -5,23 +5,23 @@ import com.kri.contact.server.dto.RoleInfoDto;
import com.kri.contact.server.service.RoleService;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.tags.Tag;
import java.util.List;
import lombok.RequiredArgsConstructor;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import java.util.List;
@RestController
@RequestMapping("/api/v1/role")
@RequiredArgsConstructor
@Tag(name = "Role", description = "권한 관리 API")
public class RoleController {
private final RoleService roleService;
@Operation(summary = "권한 목록 조회")
@GetMapping()
public List<RoleInfoDto> getRoleList(RequestUserContext ctx) {
return roleService.getRoleList(ctx.getUserRole());
}
private final RoleService roleService;
@Operation(summary = "권한 목록 조회")
@GetMapping()
public List<RoleInfoDto> getRoleList(RequestUserContext ctx) {
return roleService.getRoleList(ctx.getUserRole());
}
}

View File

@@ -12,149 +12,159 @@ import com.kri.contact.server.service.UserService;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.tags.Tag;
import jakarta.validation.Valid;
import java.time.LocalDateTime;
import java.util.Collections;
import java.util.List;
import lombok.RequiredArgsConstructor;
import org.springframework.http.HttpHeaders;
import org.springframework.http.MediaType;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.*;
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.PathVariable;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
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.RequestPart;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.multipart.MultipartFile;
import java.time.LocalDateTime;
import java.util.Collections;
import java.util.List;
@RestController
@RequestMapping("/api/v1/user")
@RequiredArgsConstructor
@Tag(name = "User", description = "사용자 관리 API")
public class UserController {
private final UserService userService;
private final SystemEventLogService systemEventLogService;
@Operation(summary = "ID 가용 여부 검사")
@GetMapping("/check-user-id")
public DataVerificationDto checkUserId(@RequestParam String userId) {
return userService.checkUserId(userId);
private final UserService userService;
private final SystemEventLogService systemEventLogService;
@Operation(summary = "ID 가용 여부 검사")
@GetMapping("/check-user-id")
public DataVerificationDto checkUserId(@RequestParam String userId) {
return userService.checkUserId(userId);
}
@Operation(summary = "사용자 정보 조회")
@GetMapping("/{userId}")
public UserInfoDto getUser(@PathVariable String userId) {
return userService.getUser(userId);
}
@Operation(summary = "사용자 목록 조회")
@GetMapping()
public List<UserInfoDto> getUserList(RequestUserContext ctx) {
String searchCmpn = ctx.getUserCmpn();
if (ctx.getUserRole() < ContactConstant.OUTSOURCE_USER_ROLE) {
return userService.getUserList();
} else {
return userService.getFieldworkUserListWithCmpn(searchCmpn);
}
}
@Operation(summary = "컨택원/면접원 목록 조회")
@GetMapping("fieldwork")
public List<UserInfoDto> getFiledoworkUserList(RequestUserContext ctx) {
String searchCmpn = ctx.getUserCmpn();
if (ctx.getUserRole() < ContactConstant.OUTSOURCE_USER_ROLE) {
searchCmpn = "";
}
@Operation(summary = "사용자 정보 조회")
@GetMapping("/{userId}")
public UserInfoDto getUser(@PathVariable String userId) {
return userService.getUser(userId);
return userService.getFieldworkUserListWithCmpn(searchCmpn);
}
@Operation(summary = "외주사 목록 조회")
@GetMapping("outsource")
List<UserInfoDto> getOutsourceList() {
return userService.getOutsourceList();
}
@Operation(summary = "사용자 회사 목록 조회")
@GetMapping("cmpn")
public List<String> getUserCmpnList(RequestUserContext ctx) {
if (ctx.getUserRole() < ContactConstant.OUTSOURCE_USER_ROLE) {
return userService.getUserCmpnList();
}
@Operation(summary = "사용자 목록 조회")
@GetMapping()
public List<UserInfoDto> getUserList(RequestUserContext ctx) {
String searchCmpn = ctx.getUserCmpn();
if(ctx.getUserRole() < ContactConstant.OUTSOURCE_USER_ROLE) {
return userService.getUserList();
}
else{
return userService.getFieldworkUserListWithCmpn(searchCmpn);
}
}
return Collections.emptyList();
}
@Operation(summary = "컨택원/면접원 목록 조회")
@GetMapping("fieldwork")
public List<UserInfoDto> getFiledoworkUserList(RequestUserContext ctx) {
String searchCmpn = ctx.getUserCmpn();
if(ctx.getUserRole() < ContactConstant.OUTSOURCE_USER_ROLE) {
searchCmpn = "";
}
@Operation(summary = "사용자 생성")
@PutMapping
public void createUser(
@Valid @RequestBody UserInfoDto userInfo,
RequestUserContext ctx
) {
String regId = ctx.getUserId();
String clientIp = ctx.getClientIp();
final LocalDateTime now = DateTimeUtil.nowKstLocalDateTime();
return userService.getFieldworkUserListWithCmpn(searchCmpn);
}
userService.createUser(userInfo, regId, now);
systemEventLogService.writeCreateUserLog(regId, now, clientIp, userInfo);
}
@Operation(summary = "외주사 목록 조회")
@GetMapping("outsource")
List<UserInfoDto> getOutsourceList() {
return userService.getOutsourceList();
}
@Operation(summary = "사용자 일괄 생성(엑셀 업로드)")
@PostMapping("/excel")
public ExcelUploadResponseDto createUserFromExcel(
@RequestPart("file") MultipartFile file,
RequestUserContext ctx
) {
String regId = ctx.getUserId();
String clientIp = ctx.getClientIp();
final LocalDateTime now = DateTimeUtil.nowKstLocalDateTime();
//외주사급이 업로드로 계정을 생성하는 경우 자신의 회사명으로 고정
String forceCmpn =
ctx.getUserRole() < ContactConstant.OUTSOURCE_USER_ROLE ? "" : ctx.getUserCmpn();
@Operation(summary = "사용자 회사 목록 조회")
@GetMapping("cmpn")
public List<String> getUserCmpnList(RequestUserContext ctx) {
if(ctx.getUserRole() < ContactConstant.OUTSOURCE_USER_ROLE) {
return userService.getUserCmpnList();
}
ExcelUploadResponseDto result = userService.createUsersFromExcel(file, regId, now, forceCmpn);
return Collections.emptyList();
}
UploadUserContentDto content = new UploadUserContentDto(
file.getOriginalFilename(),
file.getContentType(),
file.getSize()
);
systemEventLogService.writeUploadUserLog(regId, now, clientIp, content);
@Operation(summary = "사용자 생성")
@PutMapping
public void createUser(
@Valid @RequestBody UserInfoDto userInfo,
RequestUserContext ctx
) {
String regId = ctx.getUserId();
String clientIp = ctx.getClientIp();
final LocalDateTime now = DateTimeUtil.nowKstLocalDateTime();
return result;
}
userService.createUser(userInfo, regId, now);
systemEventLogService.writeCreateUserLog(regId, now, clientIp, userInfo);
}
@Operation(summary = "사용자 일괄 생성 양식 다운로드")
@PostMapping("/excel/template")
public ResponseEntity<byte[]> exportUserTemplate() {
byte[] bytes = userService.exportUserTemplate();
@Operation(summary = "사용자 일괄 생성(엑셀 업로드)")
@PostMapping("/excel")
public ExcelUploadResponseDto createUserFromExcel(
@RequestPart("file") MultipartFile file,
RequestUserContext ctx
) {
String regId = ctx.getUserId();
String clientIp = ctx.getClientIp();
final LocalDateTime now = DateTimeUtil.nowKstLocalDateTime();
//외주사급이 업로드로 계정을 생성하는 경우 자신의 회사명으로 고정
String forceCmpn = ctx.getUserRole() < ContactConstant.OUTSOURCE_USER_ROLE? "" : ctx.getUserCmpn();
return ResponseEntity.ok()
.header(HttpHeaders.CONTENT_DISPOSITION,
"attachment; filename=\"user_upload_template.xlsx\"")
.contentType(MediaType.parseMediaType(
"application/vnd.openxmlformats-officedocument.spreadsheetml.sheet"))
.body(bytes);
}
ExcelUploadResponseDto result = userService.createUsersFromExcel(file, regId, now, forceCmpn);
@Operation(summary = "사용자 정보 수정")
@PatchMapping()
public void updateUser(
@Valid @RequestBody UserInfoDto dto,
RequestUserContext ctx
) {
String modId = ctx.getUserId();
String clientIp = ctx.getClientIp();
final LocalDateTime now = DateTimeUtil.nowKstLocalDateTime();
UploadUserContentDto content = new UploadUserContentDto(
file.getOriginalFilename(),
file.getContentType(),
file.getSize()
);
systemEventLogService.writeUploadUserLog(regId, now, clientIp, content);
userService.updateUser(dto, modId, now);
systemEventLogService.writeUpdateUserLog(modId, now, clientIp, dto);
}
return result;
}
@Operation(summary = "사용자 삭제(소프트 삭제)")
@DeleteMapping("/{userId}")
public void deleteUser(@PathVariable String userId, RequestUserContext ctx) {
String regId = ctx.getUserId();
String clientIp = ctx.getClientIp();
final LocalDateTime now = DateTimeUtil.nowKstLocalDateTime();
@Operation(summary = "사용자 일괄 생성 양식 다운로드")
@PostMapping("/excel/template")
public ResponseEntity<byte[]> exportUserTemplate() {
byte[] bytes = userService.exportUserTemplate();
return ResponseEntity.ok()
.header(HttpHeaders.CONTENT_DISPOSITION,
"attachment; filename=\"user_upload_template.xlsx\"")
.contentType(MediaType.parseMediaType(
"application/vnd.openxmlformats-officedocument.spreadsheetml.sheet"))
.body(bytes);
}
@Operation(summary = "사용자 정보 수정")
@PatchMapping()
public void updateUser(
@Valid @RequestBody UserInfoDto dto,
RequestUserContext ctx
) {
String modId = ctx.getUserId();
String clientIp = ctx.getClientIp();
final LocalDateTime now = DateTimeUtil.nowKstLocalDateTime();
userService.updateUser(dto, modId, now);
systemEventLogService.writeUpdateUserLog(modId, now, clientIp, dto);
}
@Operation(summary = "사용자 삭제(소프트 삭제)")
@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, now, clientIp, userId);
}
userService.deleteUser(userId, regId);
systemEventLogService.writeDeleteUserLog(regId, now, clientIp, userId);
}
}