45 lines
2.0 KiB
Java
45 lines
2.0 KiB
Java
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.ProjectService;
|
|
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;
|
|
private final ProjectService projectService;
|
|
|
|
@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, RequestUserContext ctx) {
|
|
ShareLinkDto link = shareLinkService.lookup(urlKey);
|
|
projectService.requireAccess(new ProjectRefDto(link.projectType(), link.pkey()), ctx);
|
|
return link;
|
|
}
|
|
}
|