first commit
This commit is contained in:
@@ -0,0 +1,81 @@
|
||||
package com.kri.notihub.server.controller;
|
||||
|
||||
import com.kri.common.webmvc.RequestUserContext;
|
||||
import com.kri.notihub.server.dto.template.TemplateBasicDto;
|
||||
import com.kri.notihub.server.dto.template.TemplateDto;
|
||||
import com.kri.notihub.server.dto.template.TemplateSummaryDto;
|
||||
import com.kri.notihub.server.service.FileService;
|
||||
import com.kri.notihub.server.service.TemplateService;
|
||||
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.util.List;
|
||||
|
||||
@RestController
|
||||
@RequestMapping("/api/v1/template")
|
||||
@RequiredArgsConstructor
|
||||
@Tag(name = "Template", description = "템플릿 API")
|
||||
public class TemplateController {
|
||||
|
||||
private final TemplateService templateService;
|
||||
private final FileService fileService;
|
||||
|
||||
@Operation(summary = "템플릿 목록 조회")
|
||||
@GetMapping("/list/{itrntPrjctCd}")
|
||||
public List<TemplateSummaryDto> getTemplateList(@PathVariable String itrntPrjctCd) {
|
||||
return templateService.getTemplateList(itrntPrjctCd);
|
||||
}
|
||||
|
||||
@Operation(summary = "템플릿 단건 조회")
|
||||
@GetMapping("/{tmplatIdx}")
|
||||
public TemplateDto getTemplate(@PathVariable long tmplatIdx) {
|
||||
return templateService.getTemplate(tmplatIdx);
|
||||
}
|
||||
|
||||
@Operation(summary = "템플릿 생성")
|
||||
@PutMapping("/{itrntPrjctCd}")
|
||||
public long createTemplate(
|
||||
@PathVariable String itrntPrjctCd,
|
||||
@Valid @RequestBody TemplateBasicDto template,
|
||||
RequestUserContext ctx
|
||||
) {
|
||||
String newHtml = fileService.syncOnSave(
|
||||
itrntPrjctCd,
|
||||
template.getTmplatBody()
|
||||
);
|
||||
template.setTmplatBody(newHtml);
|
||||
|
||||
return templateService.createTemplate(itrntPrjctCd, template, ctx.getUserId());
|
||||
}
|
||||
|
||||
@Operation(summary = "시나리오 이미지 업로드")
|
||||
@PutMapping("/body-image/{itrntPrjctCd}")
|
||||
public String uploadContactSenarioImage(@PathVariable String itrntPrjctCd, @RequestParam("file") MultipartFile file) {
|
||||
return fileService.storeTempFile(itrntPrjctCd, file);
|
||||
}
|
||||
|
||||
@Operation(summary = "템플릿 수정")
|
||||
@PatchMapping()
|
||||
public TemplateDto updateTemplate(
|
||||
@Valid @RequestBody TemplateDto template,
|
||||
RequestUserContext ctx
|
||||
) {
|
||||
String newHtml = fileService.syncOnSave(
|
||||
template.getItrntPrjctCd(),
|
||||
template.getTmplatBody()
|
||||
);
|
||||
template.setTmplatBody(newHtml);
|
||||
|
||||
return templateService.updateTemplate(template, ctx.getUserId());
|
||||
}
|
||||
|
||||
@Operation(summary = "템플릿 삭제(소프트 삭제)")
|
||||
@DeleteMapping("/{tmplatIdx}")
|
||||
public void deleteTemplate(@PathVariable long tmplatIdx, RequestUserContext ctx) {
|
||||
templateService.deleteTemplate(tmplatIdx, ctx.getUserId());
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user