260615_01_FST: First Commit
This commit is contained in:
@@ -0,0 +1,31 @@
|
||||
package com.kri.gwcf.review.back.controller;
|
||||
|
||||
import com.kri.common.feature.datetime.DateTimeUtil;
|
||||
import com.kri.common.feature.web.RequestUserContext;
|
||||
import com.kri.gwcf.review.back.service.common.SystemEventLogService;
|
||||
import io.swagger.v3.oas.annotations.Operation;
|
||||
import io.swagger.v3.oas.annotations.tags.Tag;
|
||||
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.RequestMapping;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
|
||||
@RestController
|
||||
@RequestMapping("/api/v1/assign")
|
||||
@RequiredArgsConstructor
|
||||
@Tag(name = "Assign", description = "배정 API")
|
||||
public class AssignController {
|
||||
|
||||
private final SystemEventLogService systemEventLogService;
|
||||
|
||||
@Operation(summary = "참여 동의")
|
||||
@PostMapping("/confirm/{userId}")
|
||||
public boolean assignConfirm(@PathVariable String userId, RequestUserContext ctx) {
|
||||
final LocalDateTime now = DateTimeUtil.nowKstLocalDateTime();
|
||||
|
||||
systemEventLogService.writeAssignConfirmLog(userId, now, ctx.getClientIp());
|
||||
return false;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,52 @@
|
||||
package com.kri.gwcf.review.back.controller;
|
||||
|
||||
import com.kri.common.feature.datetime.DateTimeUtil;
|
||||
import com.kri.common.feature.web.RequestUserContext;
|
||||
import com.kri.gwcf.review.back.dto.auth.LoginRequestDto;
|
||||
import com.kri.gwcf.review.back.dto.auth.LoginResponseDto;
|
||||
import com.kri.gwcf.review.back.service.AuthService;
|
||||
import com.kri.gwcf.review.back.service.common.SystemEventLogService;
|
||||
import io.swagger.v3.oas.annotations.Operation;
|
||||
import io.swagger.v3.oas.annotations.tags.Tag;
|
||||
import jakarta.validation.Valid;
|
||||
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();
|
||||
|
||||
LoginResponseDto response = authService.tryLogin(request);
|
||||
systemEventLogService.writeLoginLog(response.getUser().getUserId(), now, ctx.getClientIp());
|
||||
|
||||
return response;
|
||||
}
|
||||
|
||||
@Operation(summary = "로그아웃 요청")
|
||||
@PostMapping("/logout/{userId}")
|
||||
public boolean logout(@PathVariable String userId, RequestUserContext ctx) {
|
||||
final LocalDateTime now = DateTimeUtil.nowKstLocalDateTime();
|
||||
|
||||
systemEventLogService.writeLogoutLog(userId, now, ctx.getClientIp());
|
||||
|
||||
return true;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,112 @@
|
||||
package com.kri.gwcf.review.back.controller;
|
||||
|
||||
import static com.kri.gwcf.review.back.common.util.ExcelResponseBuilder.buildExcelResponse;
|
||||
|
||||
import com.kri.common.feature.datetime.DateTimeUtil;
|
||||
import com.kri.common.feature.web.RequestUserContext;
|
||||
import com.kri.gwcf.review.back.dto.excel.ExcelUploadResultDto;
|
||||
import com.kri.gwcf.review.back.dto.performance.PerformanceCompactDto;
|
||||
import com.kri.gwcf.review.back.dto.performance.PerformanceFullDto;
|
||||
import com.kri.gwcf.review.back.dto.systemlog.UploadContentDto;
|
||||
import com.kri.gwcf.review.back.service.PerformanceService;
|
||||
import com.kri.gwcf.review.back.service.common.SystemEventLogService;
|
||||
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.List;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import org.springframework.http.MediaType;
|
||||
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.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.RequestParam;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
import org.springframework.web.multipart.MultipartFile;
|
||||
|
||||
@RestController
|
||||
@RequestMapping("/api/v1/performance")
|
||||
@RequiredArgsConstructor
|
||||
@Tag(name = "Performance", description = "Performance API")
|
||||
public class PerformanceController {
|
||||
|
||||
private final SystemEventLogService systemEventLogService;
|
||||
private final PerformanceService performanceService;
|
||||
|
||||
@Operation(summary = "공연 조회")
|
||||
@GetMapping("/{performanceId}")
|
||||
public PerformanceFullDto getPerformance(@PathVariable Integer performanceId) {
|
||||
return performanceService.getPerformance(performanceId);
|
||||
}
|
||||
|
||||
@Operation(summary = "공연 목록 조회")
|
||||
@GetMapping("/list")
|
||||
public List<PerformanceFullDto> getPerformanceList() {
|
||||
return performanceService.getPerformanceList();
|
||||
}
|
||||
|
||||
@Operation(summary = "공연 목록 조회(간소화된 정보)")
|
||||
@GetMapping("/list/compact")
|
||||
public List<PerformanceCompactDto> getPerformanceCompactList() {
|
||||
return performanceService.getPerformanceCompactList();
|
||||
}
|
||||
|
||||
@Operation(summary = "공연정보 일괄 생성 양식 다운로드")
|
||||
@PostMapping("/excel/template")
|
||||
public ResponseEntity<byte[]> exportPerformanceTemplate() {
|
||||
byte[] bytes = performanceService.exportPerformanceTemplate();
|
||||
|
||||
return buildExcelResponse("performance_upload_template.xlsx", bytes);
|
||||
}
|
||||
|
||||
@Operation(
|
||||
summary = "공연 일괄 생성(엑셀 업로드)",
|
||||
description = "성공하면 JSON, 실패가 있으면 실패 내역 엑셀(xlsx) 반환"
|
||||
)
|
||||
@PostMapping(value = "/excel/upload", consumes = MediaType.MULTIPART_FORM_DATA_VALUE)
|
||||
public ExcelUploadResultDto createPerformanceFromExcel(
|
||||
@RequestParam("file") MultipartFile file,
|
||||
RequestUserContext ctx
|
||||
) {
|
||||
String regId = ctx.getUserId();
|
||||
String clientIp = ctx.getClientIp();
|
||||
final LocalDateTime now = DateTimeUtil.nowKstLocalDateTime();
|
||||
|
||||
ExcelUploadResultDto result = performanceService.createPerformancesFromExcel(file, regId, now);
|
||||
|
||||
systemEventLogService.writeUploadPerformanceLog(regId, now, clientIp, UploadContentDto.from(file));
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
@Operation(summary = "공연 정보 수정")
|
||||
@PatchMapping()
|
||||
public void updatePerformance(
|
||||
@Valid @RequestBody PerformanceCompactDto dto,
|
||||
RequestUserContext ctx
|
||||
) {
|
||||
String modId = ctx.getUserId();
|
||||
final LocalDateTime now = DateTimeUtil.nowKstLocalDateTime();
|
||||
|
||||
performanceService.updatePerformance(dto, modId, now);
|
||||
systemEventLogService.writeUpdatePerformanceLog(modId, now, ctx.getClientIp(), dto);
|
||||
}
|
||||
|
||||
@Operation(summary = "공연 삭제")
|
||||
@DeleteMapping("/{performanceId}")
|
||||
public void deletePerformance(
|
||||
@PathVariable Integer performanceId,
|
||||
RequestUserContext ctx
|
||||
) {
|
||||
String delId = ctx.getUserId();
|
||||
final LocalDateTime now = DateTimeUtil.nowKstLocalDateTime();
|
||||
|
||||
performanceService.deletePerformance(performanceId, delId);
|
||||
systemEventLogService.writeDeletePerformanceLog(delId, now, ctx.getClientIp(), performanceId);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,107 @@
|
||||
package com.kri.gwcf.review.back.controller;
|
||||
|
||||
import static com.kri.gwcf.review.back.common.util.ExcelResponseBuilder.buildExcelResponse;
|
||||
|
||||
import com.kri.common.feature.datetime.DateTimeUtil;
|
||||
import com.kri.common.feature.web.RequestUserContext;
|
||||
import com.kri.gwcf.review.back.dto.excel.ExcelUploadResultDto;
|
||||
import com.kri.gwcf.review.back.dto.systemlog.UploadContentDto;
|
||||
import com.kri.gwcf.review.back.dto.user.UserFullDto;
|
||||
import com.kri.gwcf.review.back.service.UserService;
|
||||
import com.kri.gwcf.review.back.service.common.SystemEventLogService;
|
||||
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.List;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import org.springframework.http.MediaType;
|
||||
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.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.RequestParam;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
import org.springframework.web.multipart.MultipartFile;
|
||||
|
||||
@RestController
|
||||
@RequestMapping("/api/v1/user")
|
||||
@RequiredArgsConstructor
|
||||
@Tag(name = "User", description = "사용자 API")
|
||||
public class UserController {
|
||||
|
||||
private final UserService userService;
|
||||
private final SystemEventLogService systemEventLogService;
|
||||
|
||||
@Operation(summary = "사용자 조회")
|
||||
@GetMapping("{userId}")
|
||||
public UserFullDto getUser(@PathVariable String userId) {
|
||||
return userService.getUser(userId);
|
||||
}
|
||||
|
||||
@Operation(summary = "사용자 목록 조회")
|
||||
@GetMapping("/list/{userRole}")
|
||||
public List<UserFullDto> getUserList(@PathVariable Integer userRole) {
|
||||
return userService.getUserList(userRole);
|
||||
}
|
||||
|
||||
@Operation(summary = "사용자 일괄 생성 양식 다운로드")
|
||||
@PostMapping("/excel/template/{userRole}")
|
||||
public ResponseEntity<byte[]> exportUserTemplate(
|
||||
@PathVariable Integer userRole
|
||||
) {
|
||||
byte[] bytes = userService.exportUserTemplate(userRole);
|
||||
|
||||
return buildExcelResponse("user_upload_template.xlsx", bytes);
|
||||
}
|
||||
|
||||
@Operation(
|
||||
summary = "사용자 일괄 생성(엑셀 업로드)",
|
||||
description = "성공하면 JSON, 실패가 있으면 실패 내역 엑셀(xlsx) 반환"
|
||||
)
|
||||
@PostMapping(value = "/excel/upload/{userRole}", consumes = MediaType.MULTIPART_FORM_DATA_VALUE)
|
||||
public ExcelUploadResultDto createUserFromExcel(
|
||||
@PathVariable Integer userRole,
|
||||
@RequestParam("file") MultipartFile file,
|
||||
RequestUserContext ctx
|
||||
) {
|
||||
String regId = ctx.getUserId();
|
||||
String clientIp = ctx.getClientIp();
|
||||
final LocalDateTime now = DateTimeUtil.nowKstLocalDateTime();
|
||||
|
||||
ExcelUploadResultDto result = userService.createUsersFromExcel(userRole, file, regId, now);
|
||||
|
||||
systemEventLogService.writeUploadUserLog(regId, now, clientIp, UploadContentDto.from(file));
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
@Operation(summary = "사용자 정보 수정")
|
||||
@PatchMapping()
|
||||
public void updateUser(
|
||||
@Valid @RequestBody UserFullDto 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);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user