261016_01_ENH: 1차 마이그레이션 완료
This commit is contained in:
@@ -0,0 +1,27 @@
|
||||
package com.kri.kart.server.controller;
|
||||
|
||||
import com.kri.common.feature.web.RequestUserContext;
|
||||
import com.kri.kart.server.dto.auth.LoginRequestDto;
|
||||
import com.kri.kart.server.dto.auth.LoginResponseDto;
|
||||
import com.kri.kart.server.service.AuthService;
|
||||
import jakarta.validation.Valid;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty;
|
||||
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
|
||||
@ConditionalOnProperty(prefix = "kri.kart.database", name = "enabled", havingValue = "true")
|
||||
public class AuthController {
|
||||
private final AuthService authService;
|
||||
|
||||
@PostMapping("/login")
|
||||
public LoginResponseDto login(
|
||||
@Valid @RequestBody LoginRequestDto request, RequestUserContext ctx) {
|
||||
return authService.login(request, ctx.getClientIp());
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,71 @@
|
||||
package com.kri.kart.server.controller;
|
||||
|
||||
import com.kri.common.feature.web.RequestUserContext;
|
||||
import com.kri.kart.server.common.enums.ProjectType;
|
||||
import com.kri.kart.server.dto.bookmark.BookmarkDto;
|
||||
import com.kri.kart.server.dto.bookmark.BookmarkSaveRequestDto;
|
||||
import com.kri.kart.server.dto.project.ProjectRefDto;
|
||||
import com.kri.kart.server.service.BookmarkService;
|
||||
import io.swagger.v3.oas.annotations.Parameter;
|
||||
import jakarta.validation.Valid;
|
||||
import jakarta.validation.groups.Default;
|
||||
import java.util.List;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty;
|
||||
import org.springframework.http.MediaType;
|
||||
import org.springframework.validation.annotation.Validated;
|
||||
import org.springframework.web.bind.annotation.DeleteMapping;
|
||||
import org.springframework.web.bind.annotation.GetMapping;
|
||||
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;
|
||||
|
||||
@RestController
|
||||
@RequestMapping("/api/v1/project/{projectType}/{pkey}/bookmark")
|
||||
@RequiredArgsConstructor
|
||||
@ConditionalOnProperty(prefix = "kri.kart.database", name = "enabled", havingValue = "true")
|
||||
public class BookmarkController {
|
||||
private final BookmarkService bookmarkService;
|
||||
|
||||
@GetMapping("/list")
|
||||
public List<BookmarkDto> list(
|
||||
@PathVariable ProjectType projectType,
|
||||
@PathVariable String pkey,
|
||||
@RequestParam String page,
|
||||
@Parameter(hidden = true) RequestUserContext ctx) {
|
||||
return bookmarkService.list(new ProjectRefDto(projectType, pkey), page, ctx.getUserId());
|
||||
}
|
||||
|
||||
@PostMapping(produces = MediaType.TEXT_PLAIN_VALUE)
|
||||
public String create(
|
||||
@PathVariable ProjectType projectType,
|
||||
@PathVariable String pkey,
|
||||
@Validated({Default.class, BookmarkSaveRequestDto.Create.class}) @RequestBody
|
||||
BookmarkSaveRequestDto request,
|
||||
@Parameter(hidden = true) RequestUserContext ctx) {
|
||||
return bookmarkService.create(new ProjectRefDto(projectType, pkey), request, ctx);
|
||||
}
|
||||
|
||||
@PutMapping(value = "/{bookmarkId}", produces = MediaType.TEXT_PLAIN_VALUE)
|
||||
public String update(
|
||||
@PathVariable ProjectType projectType,
|
||||
@PathVariable String pkey,
|
||||
@PathVariable String bookmarkId,
|
||||
@Valid @RequestBody BookmarkSaveRequestDto request,
|
||||
@Parameter(hidden = true) RequestUserContext ctx) {
|
||||
return bookmarkService.update(new ProjectRefDto(projectType, pkey), bookmarkId, request, ctx);
|
||||
}
|
||||
|
||||
@DeleteMapping(value = "/{bookmarkId}", produces = MediaType.APPLICATION_JSON_VALUE)
|
||||
public boolean delete(
|
||||
@PathVariable ProjectType projectType,
|
||||
@PathVariable String pkey,
|
||||
@PathVariable String bookmarkId,
|
||||
@Parameter(hidden = true) RequestUserContext ctx) {
|
||||
return bookmarkService.delete(new ProjectRefDto(projectType, pkey), bookmarkId, ctx);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,91 @@
|
||||
package com.kri.kart.server.controller;
|
||||
|
||||
import com.kri.common.feature.web.RequestUserContext;
|
||||
import com.kri.kart.server.common.enums.ProjectType;
|
||||
import com.kri.kart.server.dto.derived.DerivedCalculationDto;
|
||||
import com.kri.kart.server.dto.derived.DerivedSaveRequestDto;
|
||||
import com.kri.kart.server.dto.derived.DerivedVariableDto;
|
||||
import com.kri.kart.server.dto.project.ProjectRefDto;
|
||||
import com.kri.kart.server.service.DerivedManagementService;
|
||||
import com.kri.kart.server.service.DerivedService;
|
||||
import jakarta.validation.Valid;
|
||||
import java.util.List;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty;
|
||||
import org.springframework.web.bind.annotation.DeleteMapping;
|
||||
import org.springframework.web.bind.annotation.GetMapping;
|
||||
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.RestController;
|
||||
|
||||
@RestController
|
||||
@RequestMapping("/api/v1/project/{projectType}/{pkey}/derived")
|
||||
@RequiredArgsConstructor
|
||||
@ConditionalOnProperty(prefix = "kri.kart.database", name = "enabled", havingValue = "true")
|
||||
public class DerivedController {
|
||||
private final DerivedService derivedService;
|
||||
private final DerivedManagementService derivedManagementService;
|
||||
|
||||
@GetMapping("/list")
|
||||
public List<DerivedVariableDto> list(
|
||||
@PathVariable ProjectType projectType, @PathVariable String pkey, RequestUserContext ctx) {
|
||||
return derivedService.list(new ProjectRefDto(projectType, pkey), ctx);
|
||||
}
|
||||
|
||||
@PostMapping
|
||||
public String create(
|
||||
@PathVariable ProjectType projectType,
|
||||
@PathVariable String pkey,
|
||||
@Valid @RequestBody DerivedSaveRequestDto request,
|
||||
RequestUserContext ctx) {
|
||||
return derivedManagementService.save(new ProjectRefDto(projectType, pkey), null, request, ctx);
|
||||
}
|
||||
|
||||
@PutMapping("/{variableId}")
|
||||
public String update(
|
||||
@PathVariable ProjectType projectType,
|
||||
@PathVariable String pkey,
|
||||
@PathVariable String variableId,
|
||||
@Valid @RequestBody DerivedSaveRequestDto request,
|
||||
RequestUserContext ctx) {
|
||||
return derivedManagementService.save(
|
||||
new ProjectRefDto(projectType, pkey), variableId, request, ctx);
|
||||
}
|
||||
|
||||
@DeleteMapping("/{variableId}")
|
||||
public boolean delete(
|
||||
@PathVariable ProjectType projectType,
|
||||
@PathVariable String pkey,
|
||||
@PathVariable String variableId,
|
||||
RequestUserContext ctx) {
|
||||
return derivedManagementService.delete(new ProjectRefDto(projectType, pkey), variableId, ctx);
|
||||
}
|
||||
|
||||
@PostMapping("/{variableId}/recalculate")
|
||||
public DerivedCalculationDto recalculate(
|
||||
@PathVariable ProjectType projectType,
|
||||
@PathVariable String pkey,
|
||||
@PathVariable String variableId,
|
||||
RequestUserContext ctx) {
|
||||
return derivedManagementService.recalculate(
|
||||
new ProjectRefDto(projectType, pkey), variableId, ctx);
|
||||
}
|
||||
|
||||
@PostMapping("/respondent/{respondentId}/recalculate")
|
||||
public DerivedCalculationDto recalculateRespondent(
|
||||
@PathVariable ProjectType projectType,
|
||||
@PathVariable String pkey,
|
||||
@PathVariable String respondentId) {
|
||||
return derivedManagementService.recalculateRespondent(
|
||||
new ProjectRefDto(projectType, pkey), respondentId);
|
||||
}
|
||||
|
||||
@PostMapping("/recalculate")
|
||||
public DerivedCalculationDto recalculateAll(
|
||||
@PathVariable ProjectType projectType, @PathVariable String pkey, RequestUserContext ctx) {
|
||||
return derivedManagementService.recalculate(new ProjectRefDto(projectType, pkey), null, ctx);
|
||||
}
|
||||
}
|
||||
@@ -1,38 +0,0 @@
|
||||
package com.kri.kart.server.controller;
|
||||
|
||||
import com.kri.kart.server.dto.request.CreateExampleRequest;
|
||||
import com.kri.kart.server.dto.response.ExampleResponse;
|
||||
import com.kri.kart.server.service.ExampleService;
|
||||
import jakarta.validation.Valid;
|
||||
import java.util.List;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import org.springframework.http.HttpStatus;
|
||||
import org.springframework.web.bind.annotation.GetMapping;
|
||||
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.ResponseStatus;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
|
||||
@RestController
|
||||
@RequiredArgsConstructor
|
||||
@RequestMapping("/api/v1/examples")
|
||||
public class ExampleController {
|
||||
|
||||
private final ExampleService exampleService;
|
||||
|
||||
@GetMapping
|
||||
public List<ExampleResponse> search(
|
||||
@RequestParam(defaultValue = "") String keyword,
|
||||
@RequestParam(defaultValue = "20") int limit
|
||||
) {
|
||||
return exampleService.search(keyword, limit);
|
||||
}
|
||||
|
||||
@PostMapping
|
||||
@ResponseStatus(HttpStatus.CREATED)
|
||||
public ExampleResponse create(@Valid @RequestBody CreateExampleRequest request) {
|
||||
return exampleService.create(request);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,120 @@
|
||||
package com.kri.kart.server.controller;
|
||||
|
||||
import com.kri.common.feature.file.FileUtil;
|
||||
import com.kri.common.feature.web.RequestUserContext;
|
||||
import com.kri.kart.server.common.enums.ProjectType;
|
||||
import com.kri.kart.server.dto.export.AggregateExcelRequestDto;
|
||||
import com.kri.kart.server.dto.export.ExportFileDto;
|
||||
import com.kri.kart.server.dto.export.RawDataExportRequestDto;
|
||||
import com.kri.kart.server.dto.project.ProjectRefDto;
|
||||
import com.kri.kart.server.service.AggregateExcelService;
|
||||
import com.kri.kart.server.service.ExportService;
|
||||
import io.swagger.v3.oas.annotations.Parameter;
|
||||
import io.swagger.v3.oas.annotations.media.Content;
|
||||
import io.swagger.v3.oas.annotations.media.Schema;
|
||||
import io.swagger.v3.oas.annotations.responses.ApiResponse;
|
||||
import jakarta.validation.Valid;
|
||||
import java.nio.charset.StandardCharsets;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty;
|
||||
import org.springframework.http.ContentDisposition;
|
||||
import org.springframework.http.HttpHeaders;
|
||||
import org.springframework.http.MediaType;
|
||||
import org.springframework.http.ResponseEntity;
|
||||
import org.springframework.web.bind.annotation.GetMapping;
|
||||
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")
|
||||
@RequiredArgsConstructor
|
||||
@ConditionalOnProperty(prefix = "kri.kart.database", name = "enabled", havingValue = "true")
|
||||
@ApiResponse(
|
||||
responseCode = "200",
|
||||
content =
|
||||
@Content(
|
||||
mediaType = "application/octet-stream",
|
||||
schema = @Schema(type = "string", format = "binary")))
|
||||
public class ExportController {
|
||||
private final ExportService exportService;
|
||||
private final AggregateExcelService aggregateExcelService;
|
||||
|
||||
@PostMapping("/project/{projectType}/{pkey}/export/excel/table")
|
||||
public ResponseEntity<byte[]> reportExcel(
|
||||
@PathVariable ProjectType projectType,
|
||||
@PathVariable String pkey,
|
||||
@Valid @RequestBody AggregateExcelRequestDto request) {
|
||||
return download(aggregateExcelService.report(new ProjectRefDto(projectType, pkey), request));
|
||||
}
|
||||
|
||||
@PostMapping("/quota/{projectType}/{pkey}/export/excel")
|
||||
public ResponseEntity<byte[]> quotaExcel(
|
||||
@PathVariable ProjectType projectType,
|
||||
@PathVariable String pkey,
|
||||
@Valid @RequestBody AggregateExcelRequestDto request) {
|
||||
return download(aggregateExcelService.quota(new ProjectRefDto(projectType, pkey), request));
|
||||
}
|
||||
|
||||
@GetMapping(value = "/export/form/question", produces = MediaType.APPLICATION_OCTET_STREAM_VALUE)
|
||||
public ResponseEntity<byte[]> questionForm() {
|
||||
return download(exportService.questionForm());
|
||||
}
|
||||
|
||||
@GetMapping(
|
||||
value = "/project/{projectType}/{pkey}/export/form/data",
|
||||
produces = MediaType.APPLICATION_OCTET_STREAM_VALUE)
|
||||
public ResponseEntity<byte[]> dataForm(
|
||||
@PathVariable ProjectType projectType,
|
||||
@PathVariable String pkey,
|
||||
@Parameter(hidden = true) RequestUserContext ctx) {
|
||||
return download(
|
||||
exportService.dataForm(new ProjectRefDto(projectType, pkey), ctx.getUserRole()));
|
||||
}
|
||||
|
||||
@GetMapping(
|
||||
value = "/project/{projectType}/{pkey}/export/form/title",
|
||||
produces = MediaType.APPLICATION_OCTET_STREAM_VALUE)
|
||||
public ResponseEntity<byte[]> titleForm(
|
||||
@PathVariable ProjectType projectType, @PathVariable String pkey) {
|
||||
return download(exportService.titleForm(new ProjectRefDto(projectType, pkey)));
|
||||
}
|
||||
|
||||
@GetMapping(
|
||||
value = "/project/{projectType}/{pkey}/export/guide",
|
||||
produces = MediaType.APPLICATION_OCTET_STREAM_VALUE)
|
||||
public ResponseEntity<byte[]> guide(
|
||||
@PathVariable ProjectType projectType, @PathVariable String pkey) {
|
||||
return download(exportService.guide(new ProjectRefDto(projectType, pkey)));
|
||||
}
|
||||
|
||||
@PostMapping(
|
||||
value = "/project/{projectType}/{pkey}/export/data",
|
||||
produces = MediaType.APPLICATION_OCTET_STREAM_VALUE)
|
||||
public ResponseEntity<byte[]> data(
|
||||
@PathVariable ProjectType projectType,
|
||||
@PathVariable String pkey,
|
||||
@Valid @RequestBody RawDataExportRequestDto request,
|
||||
@Parameter(hidden = true) RequestUserContext ctx) {
|
||||
return download(
|
||||
exportService.data(new ProjectRefDto(projectType, pkey), ctx.getUserRole(), request));
|
||||
}
|
||||
|
||||
private ResponseEntity<byte[]> download(ExportFileDto file) {
|
||||
String fileName =
|
||||
FileUtil.extractFileNameFromPath(file.getFileName())
|
||||
.replaceAll("[\\p{Cntrl}\\\\/:*?\"<>|]", "_");
|
||||
String disposition =
|
||||
ContentDisposition.attachment()
|
||||
.filename(fileName, StandardCharsets.UTF_8)
|
||||
.build()
|
||||
.toString();
|
||||
return ResponseEntity.ok()
|
||||
.contentType(MediaType.APPLICATION_OCTET_STREAM)
|
||||
.header(HttpHeaders.CONTENT_DISPOSITION, disposition)
|
||||
.header(HttpHeaders.CACHE_CONTROL, "no-store")
|
||||
.body(file.getContent());
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,28 @@
|
||||
package com.kri.kart.server.controller;
|
||||
|
||||
import com.kri.common.feature.web.RequestUserContext;
|
||||
import com.kri.kart.server.dto.share.ExternalLoginResponseDto;
|
||||
import com.kri.kart.server.service.ShareLinkService;
|
||||
import io.swagger.v3.oas.annotations.Operation;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty;
|
||||
import org.springframework.http.ResponseEntity;
|
||||
import org.springframework.web.bind.annotation.PathVariable;
|
||||
import org.springframework.web.bind.annotation.PostMapping;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
|
||||
@RestController
|
||||
@RequiredArgsConstructor
|
||||
@ConditionalOnProperty(prefix = "kri.kart.database", name = "enabled", havingValue = "true")
|
||||
public class ExternalController {
|
||||
private final ShareLinkService shareLinkService;
|
||||
|
||||
@PostMapping("/api/v1/external/{urlKey}/login")
|
||||
@Operation(summary = "공유 링크 전용 인증 발급", description = "검증된 링크의 프로젝트·페이지 범위에 제한되는 24시간 인증")
|
||||
public ResponseEntity<ExternalLoginResponseDto> login(
|
||||
@PathVariable String urlKey, RequestUserContext ctx) {
|
||||
return ResponseEntity.ok()
|
||||
.header("Cache-Control", "no-store")
|
||||
.body(shareLinkService.login(urlKey, ctx.getClientIp()));
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,52 @@
|
||||
package com.kri.kart.server.controller;
|
||||
|
||||
import com.kri.common.feature.web.RequestUserContext;
|
||||
import com.kri.kart.server.common.enums.ProjectType;
|
||||
import com.kri.kart.server.dto.project.ProjectRefDto;
|
||||
import com.kri.kart.server.dto.upload.ImportResultDto;
|
||||
import com.kri.kart.server.service.ImportService;
|
||||
import io.swagger.v3.oas.annotations.Parameter;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty;
|
||||
import org.springframework.http.MediaType;
|
||||
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.RequestPart;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
import org.springframework.web.multipart.MultipartFile;
|
||||
|
||||
@RestController
|
||||
@RequiredArgsConstructor
|
||||
@RequestMapping("/api/v1/project/{projectType}/{pkey}/import")
|
||||
@ConditionalOnProperty(prefix = "kri.kart.database", name = "enabled", havingValue = "true")
|
||||
public class ImportController {
|
||||
private final ImportService importService;
|
||||
|
||||
@PostMapping(value = "/title", consumes = MediaType.MULTIPART_FORM_DATA_VALUE)
|
||||
public ImportResultDto titles(
|
||||
@PathVariable ProjectType projectType,
|
||||
@PathVariable String pkey,
|
||||
@RequestPart(value = "file", required = false) MultipartFile file,
|
||||
@Parameter(hidden = true) RequestUserContext ctx) {
|
||||
return importService.titles(new ProjectRefDto(projectType, pkey), file, ctx);
|
||||
}
|
||||
|
||||
@PostMapping(value = "/question", consumes = MediaType.MULTIPART_FORM_DATA_VALUE)
|
||||
public ImportResultDto questions(
|
||||
@PathVariable ProjectType projectType,
|
||||
@PathVariable String pkey,
|
||||
@RequestPart(value = "file", required = false) MultipartFile file,
|
||||
@Parameter(hidden = true) RequestUserContext ctx) {
|
||||
return importService.questions(new ProjectRefDto(projectType, pkey), file, ctx);
|
||||
}
|
||||
|
||||
@PostMapping(value = "/data", consumes = MediaType.MULTIPART_FORM_DATA_VALUE)
|
||||
public ImportResultDto data(
|
||||
@PathVariable ProjectType projectType,
|
||||
@PathVariable String pkey,
|
||||
@RequestPart(value = "file", required = false) MultipartFile file,
|
||||
@Parameter(hidden = true) RequestUserContext ctx) {
|
||||
return importService.data(new ProjectRefDto(projectType, pkey), file, ctx);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,43 @@
|
||||
package com.kri.kart.server.controller;
|
||||
|
||||
import com.kri.common.feature.web.BusinessException;
|
||||
import com.kri.common.feature.web.RequestUserContext;
|
||||
import com.kri.kart.server.dto.log.VisitLogRequestDto;
|
||||
import com.kri.kart.server.dto.share.ShareLinkDto;
|
||||
import com.kri.kart.server.service.LogService;
|
||||
import com.kri.kart.server.service.ShareLinkService;
|
||||
import io.swagger.v3.oas.annotations.Parameter;
|
||||
import jakarta.servlet.http.HttpServletRequest;
|
||||
import jakarta.validation.Valid;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty;
|
||||
import org.springframework.http.MediaType;
|
||||
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/log")
|
||||
@RequiredArgsConstructor
|
||||
@ConditionalOnProperty(prefix = "kri.kart.database", name = "enabled", havingValue = "true")
|
||||
public class LogController {
|
||||
private final LogService logService;
|
||||
|
||||
@PostMapping(value = "/visit", produces = MediaType.TEXT_PLAIN_VALUE)
|
||||
public String visit(
|
||||
@Valid @RequestBody VisitLogRequestDto request,
|
||||
@Parameter(hidden = true) RequestUserContext ctx,
|
||||
HttpServletRequest servletRequest) {
|
||||
ShareLinkDto link =
|
||||
(ShareLinkDto) servletRequest.getAttribute(ShareLinkService.REQUEST_LINK_ATTRIBUTE);
|
||||
if (link != null
|
||||
&& (link.getProjectType() != request.getProjectType()
|
||||
|| !link.getPkey().equals(request.getPkey()))) {
|
||||
throw BusinessException.forbidden("EXTERNAL_SCOPE_DENIED", "공유 프로젝트의 방문 로그만 기록할 수 있습니다.");
|
||||
}
|
||||
logService.writeVisitLog(
|
||||
request.getProjectType(), request.getPkey(), request.getLogContent(), ctx);
|
||||
return "PASS";
|
||||
}
|
||||
}
|
||||
@@ -1,14 +0,0 @@
|
||||
package com.kri.kart.server.controller;
|
||||
|
||||
import java.util.Map;
|
||||
import org.springframework.web.bind.annotation.GetMapping;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
|
||||
@RestController
|
||||
public class PingController {
|
||||
|
||||
@GetMapping("/ping")
|
||||
public Map<String, String> ping() {
|
||||
return Map.of("status", "ok");
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,84 @@
|
||||
package com.kri.kart.server.controller;
|
||||
|
||||
import com.kri.common.feature.web.RequestUserContext;
|
||||
import com.kri.kart.server.common.enums.ProjectType;
|
||||
import com.kri.kart.server.dto.project.CustomProgressDto;
|
||||
import com.kri.kart.server.dto.project.LoiDto;
|
||||
import com.kri.kart.server.dto.project.ProgressDayDto;
|
||||
import com.kri.kart.server.dto.project.ProgressScreenDto;
|
||||
import com.kri.kart.server.dto.project.ProgressSearchDto;
|
||||
import com.kri.kart.server.dto.project.ProgressTypeDto;
|
||||
import com.kri.kart.server.dto.project.ProjectLinkSearchDto;
|
||||
import com.kri.kart.server.dto.project.ProjectListDto;
|
||||
import com.kri.kart.server.dto.project.ProjectRefDto;
|
||||
import com.kri.kart.server.dto.project.ProjectSummaryDto;
|
||||
import com.kri.kart.server.service.CustomProgressService;
|
||||
import com.kri.kart.server.service.ProgressService;
|
||||
import com.kri.kart.server.service.ProjectService;
|
||||
import jakarta.validation.Valid;
|
||||
import java.util.List;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import org.springdoc.core.annotations.ParameterObject;
|
||||
import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty;
|
||||
import org.springframework.web.bind.annotation.GetMapping;
|
||||
import org.springframework.web.bind.annotation.ModelAttribute;
|
||||
import org.springframework.web.bind.annotation.PathVariable;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
|
||||
@RestController
|
||||
@RequestMapping("/api/v1/project")
|
||||
@RequiredArgsConstructor
|
||||
@ConditionalOnProperty(prefix = "kri.kart.database", name = "enabled", havingValue = "true")
|
||||
public class ProjectController {
|
||||
private final ProjectService projectService;
|
||||
private final ProgressService progressService;
|
||||
private final CustomProgressService customProgressService;
|
||||
|
||||
@GetMapping("/list")
|
||||
public List<ProjectListDto> list(
|
||||
@Valid @ParameterObject @ModelAttribute ProjectLinkSearchDto search, RequestUserContext ctx) {
|
||||
return projectService.list(search, ctx);
|
||||
}
|
||||
|
||||
@GetMapping("/summary")
|
||||
public List<ProjectSummaryDto> summary(RequestUserContext ctx) {
|
||||
return projectService.summary(ctx);
|
||||
}
|
||||
|
||||
@GetMapping("/{projectType}/{pkey}/progress/day")
|
||||
public List<ProgressDayDto> daily(
|
||||
@PathVariable ProjectType projectType, @PathVariable String pkey) {
|
||||
return progressService.daily(new ProjectRefDto(projectType, pkey));
|
||||
}
|
||||
|
||||
@GetMapping("/{projectType}/{pkey}/progress/type")
|
||||
public List<ProgressTypeDto> type(
|
||||
@PathVariable ProjectType projectType,
|
||||
@PathVariable String pkey,
|
||||
@Valid @ParameterObject @ModelAttribute ProgressSearchDto search) {
|
||||
return progressService.type(new ProjectRefDto(projectType, pkey), search);
|
||||
}
|
||||
|
||||
@GetMapping("/{projectType}/{pkey}/progress/loi")
|
||||
public List<LoiDto> loi(
|
||||
@PathVariable ProjectType projectType,
|
||||
@PathVariable String pkey,
|
||||
@Valid @ParameterObject @ModelAttribute ProgressSearchDto search) {
|
||||
return progressService.loi(new ProjectRefDto(projectType, pkey), search);
|
||||
}
|
||||
|
||||
@GetMapping("/{projectType}/{pkey}/progress/screen")
|
||||
public List<ProgressScreenDto> screen(
|
||||
@PathVariable ProjectType projectType,
|
||||
@PathVariable String pkey,
|
||||
@Valid @ParameterObject @ModelAttribute ProgressSearchDto search) {
|
||||
return progressService.screen(new ProjectRefDto(projectType, pkey), search);
|
||||
}
|
||||
|
||||
@GetMapping("/{projectType}/{pkey}/progress/custom")
|
||||
public List<CustomProgressDto> custom(
|
||||
@PathVariable ProjectType projectType, @PathVariable String pkey) {
|
||||
return customProgressService.list(new ProjectRefDto(projectType, pkey));
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,40 @@
|
||||
package com.kri.kart.server.controller;
|
||||
|
||||
import com.kri.common.feature.web.RequestUserContext;
|
||||
import com.kri.kart.server.common.enums.ProjectType;
|
||||
import com.kri.kart.server.dto.project.ProjectRefDto;
|
||||
import com.kri.kart.server.dto.question.QuestionDto;
|
||||
import com.kri.kart.server.service.QuestionService;
|
||||
import io.swagger.v3.oas.annotations.Parameter;
|
||||
import java.util.List;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty;
|
||||
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.RestController;
|
||||
|
||||
@RestController
|
||||
@RequestMapping("/api/v1/project/{projectType}/{pkey}/question")
|
||||
@RequiredArgsConstructor
|
||||
@ConditionalOnProperty(prefix = "kri.kart.database", name = "enabled", havingValue = "true")
|
||||
public class QuestionController {
|
||||
private final QuestionService questionService;
|
||||
|
||||
@GetMapping("/list")
|
||||
public List<QuestionDto> list(
|
||||
@PathVariable ProjectType projectType,
|
||||
@PathVariable String pkey,
|
||||
@Parameter(hidden = true) RequestUserContext ctx) {
|
||||
return questionService.list(new ProjectRefDto(projectType, pkey), ctx.getUserRole());
|
||||
}
|
||||
|
||||
@GetMapping("/{qid}")
|
||||
public List<QuestionDto> detail(
|
||||
@PathVariable ProjectType projectType,
|
||||
@PathVariable String pkey,
|
||||
@PathVariable String qid,
|
||||
@Parameter(hidden = true) RequestUserContext ctx) {
|
||||
return questionService.detail(new ProjectRefDto(projectType, pkey), qid, ctx.getUserRole());
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,45 @@
|
||||
package com.kri.kart.server.controller;
|
||||
|
||||
import com.kri.common.feature.web.RequestUserContext;
|
||||
import com.kri.kart.server.common.enums.ProjectType;
|
||||
import com.kri.kart.server.dto.project.ProjectRefDto;
|
||||
import com.kri.kart.server.dto.quota.QuotaResultDto;
|
||||
import com.kri.kart.server.dto.quota.QuotaResultRequestDto;
|
||||
import com.kri.kart.server.dto.quota.QuotaSetDto;
|
||||
import com.kri.kart.server.service.QuotaService;
|
||||
import io.swagger.v3.oas.annotations.Operation;
|
||||
import io.swagger.v3.oas.annotations.Parameter;
|
||||
import jakarta.validation.Valid;
|
||||
import java.util.List;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty;
|
||||
import org.springframework.web.bind.annotation.GetMapping;
|
||||
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/quota")
|
||||
@RequiredArgsConstructor
|
||||
@ConditionalOnProperty(prefix = "kri.kart.database", name = "enabled", havingValue = "true")
|
||||
public class QuotaController {
|
||||
private final QuotaService quotaService;
|
||||
|
||||
@GetMapping("/{projectType}/{pkey}/list")
|
||||
public List<QuotaSetDto> list(@PathVariable ProjectType projectType, @PathVariable String pkey) {
|
||||
return quotaService.list(new ProjectRefDto(projectType, pkey));
|
||||
}
|
||||
|
||||
@PostMapping("/{projectType}/{pkey}/{quotaOrder}/result")
|
||||
@Operation(summary = "저장된 쿼터 설정의 집계 결과", description = "첫 ROW·COL·FILTER로 집계하고 완료수/목표수/달성률 반환")
|
||||
public QuotaResultDto result(
|
||||
@PathVariable ProjectType projectType,
|
||||
@PathVariable String pkey,
|
||||
@PathVariable int quotaOrder,
|
||||
@Valid @RequestBody QuotaResultRequestDto request,
|
||||
@Parameter(hidden = true) RequestUserContext ctx) {
|
||||
return quotaService.result(new ProjectRefDto(projectType, pkey), quotaOrder, request, ctx);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,40 @@
|
||||
package com.kri.kart.server.controller;
|
||||
|
||||
import com.kri.common.feature.web.RequestUserContext;
|
||||
import com.kri.kart.server.common.enums.ProjectType;
|
||||
import com.kri.kart.server.dto.project.ProjectRefDto;
|
||||
import com.kri.kart.server.dto.share.ShareLinkDto;
|
||||
import com.kri.kart.server.dto.share.ShareLinkRequestDto;
|
||||
import com.kri.kart.server.service.ShareLinkService;
|
||||
import io.swagger.v3.oas.annotations.Operation;
|
||||
import jakarta.validation.Valid;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty;
|
||||
import org.springframework.web.bind.annotation.GetMapping;
|
||||
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.RestController;
|
||||
|
||||
@RestController
|
||||
@RequiredArgsConstructor
|
||||
@ConditionalOnProperty(prefix = "kri.kart.database", name = "enabled", havingValue = "true")
|
||||
public class ShareLinkController {
|
||||
private final ShareLinkService shareLinkService;
|
||||
|
||||
@PostMapping("/api/v1/project/{projectType}/{pkey}/share")
|
||||
@Operation(summary = "공유 링크 발급 또는 재사용")
|
||||
public ShareLinkDto create(
|
||||
@PathVariable ProjectType projectType,
|
||||
@PathVariable String pkey,
|
||||
@Valid @RequestBody ShareLinkRequestDto request,
|
||||
RequestUserContext ctx) {
|
||||
return shareLinkService.create(new ProjectRefDto(projectType, pkey), request, ctx);
|
||||
}
|
||||
|
||||
@GetMapping("/api/v1/share/{urlKey}")
|
||||
@Operation(summary = "공유 링크 정보 조회", description = "내부 인증 필요. 랜딩 횟수를 증가시키지 않는다.")
|
||||
public ShareLinkDto lookup(@PathVariable String urlKey) {
|
||||
return shareLinkService.lookup(urlKey);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,93 @@
|
||||
package com.kri.kart.server.controller;
|
||||
|
||||
import com.kri.common.feature.web.BusinessException;
|
||||
import com.kri.common.feature.web.RequestUserContext;
|
||||
import com.kri.kart.server.common.enums.ProjectType;
|
||||
import com.kri.kart.server.dto.project.ProjectRefDto;
|
||||
import com.kri.kart.server.dto.share.ShareLinkDto;
|
||||
import com.kri.kart.server.dto.statistics.StatisticsBatchDto;
|
||||
import com.kri.kart.server.dto.statistics.StatisticsBatchRequestDto;
|
||||
import com.kri.kart.server.dto.statistics.StatisticsStreamEventDto;
|
||||
import com.kri.kart.server.service.ShareLinkService;
|
||||
import com.kri.kart.server.service.StatisticsService;
|
||||
import com.kri.kart.server.service.statistics.StatisticsStreamService;
|
||||
import io.swagger.v3.oas.annotations.Operation;
|
||||
import io.swagger.v3.oas.annotations.Parameter;
|
||||
import io.swagger.v3.oas.annotations.media.Content;
|
||||
import io.swagger.v3.oas.annotations.media.Schema;
|
||||
import io.swagger.v3.oas.annotations.responses.ApiResponse;
|
||||
import jakarta.servlet.http.HttpServletRequest;
|
||||
import jakarta.servlet.http.HttpServletResponse;
|
||||
import jakarta.validation.Valid;
|
||||
import java.net.URI;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty;
|
||||
import org.springframework.http.ResponseEntity;
|
||||
import org.springframework.security.core.context.SecurityContextHolder;
|
||||
import org.springframework.security.web.context.RequestAttributeSecurityContextRepository;
|
||||
import org.springframework.security.web.context.SecurityContextRepository;
|
||||
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;
|
||||
import org.springframework.web.servlet.mvc.method.annotation.ResponseBodyEmitter;
|
||||
|
||||
@RestController
|
||||
@RequestMapping("/api/v1/project/{projectType}/{pkey}/statistics")
|
||||
@RequiredArgsConstructor
|
||||
@ConditionalOnProperty(prefix = "kri.kart.database", name = "enabled", havingValue = "true")
|
||||
public class StatisticsController {
|
||||
private static final String STANDARD_MODE = "STANDARD";
|
||||
private static final String CROSSTAB_PAGE = "/Report/Crosstab";
|
||||
|
||||
private final StatisticsService statisticsService;
|
||||
private final StatisticsStreamService statisticsStreamService;
|
||||
private final SecurityContextRepository securityContextRepository =
|
||||
new RequestAttributeSecurityContextRepository();
|
||||
|
||||
@PostMapping(value = "/result", produces = "application/x-ndjson")
|
||||
@Operation(
|
||||
summary = "일반 보고서 배열 집계 스트림",
|
||||
description = "공유 데이터를 한 번 조회하고 indexes 순서대로 result/error, 마지막 complete 전송")
|
||||
@ApiResponse(
|
||||
responseCode = "200",
|
||||
content =
|
||||
@Content(
|
||||
mediaType = "application/x-ndjson",
|
||||
schema = @Schema(implementation = StatisticsStreamEventDto.class)))
|
||||
public ResponseEntity<ResponseBodyEmitter> result(
|
||||
@PathVariable ProjectType projectType,
|
||||
@PathVariable String pkey,
|
||||
@Valid @RequestBody StatisticsBatchRequestDto request,
|
||||
@Parameter(hidden = true) RequestUserContext ctx,
|
||||
HttpServletRequest servletRequest,
|
||||
HttpServletResponse servletResponse) {
|
||||
if (isCrosstabPageLink(servletRequest) && !STANDARD_MODE.equals(request.getMode())) {
|
||||
throw BusinessException.forbidden(
|
||||
"EXTERNAL_SCOPE_DENIED", "Cross Tab 공유 링크에서는 Cross Tab 집계만 허용됩니다.");
|
||||
}
|
||||
StatisticsBatchDto statisticsBatch =
|
||||
statisticsService.prepare(
|
||||
new ProjectRefDto(projectType, pkey),
|
||||
request.requests(),
|
||||
ctx);
|
||||
// Common authentication is stateless; retain only this request's identity for ASYNC dispatch.
|
||||
securityContextRepository.saveContext(
|
||||
SecurityContextHolder.getContext(), servletRequest, servletResponse);
|
||||
return ResponseEntity.ok()
|
||||
.header("Cache-Control", "no-store")
|
||||
.header("X-Accel-Buffering", "no")
|
||||
.header("Content-Type", "application/x-ndjson;charset=UTF-8")
|
||||
.body(statisticsStreamService.stream(statisticsBatch));
|
||||
}
|
||||
|
||||
/** A page-only Cross Tab share link may request Cross Tab (STANDARD) results only. */
|
||||
private boolean isCrosstabPageLink(HttpServletRequest servletRequest) {
|
||||
ShareLinkDto link =
|
||||
(ShareLinkDto) servletRequest.getAttribute(ShareLinkService.REQUEST_LINK_ATTRIBUTE);
|
||||
return link != null
|
||||
&& link.isPageOnly()
|
||||
&& URI.create(link.getRealUrl()).getPath().equals(CROSSTAB_PAGE);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user