260615_02_ENH: excel upload용 양식 다운로드 추가
This commit is contained in:
@@ -66,6 +66,14 @@ public class ShortUrlController {
|
||||
return shortUrlService.createShortUrl(req, ctx.getUserId(), now);
|
||||
}
|
||||
|
||||
@Operation(summary = "단축 URL 일괄 생성 양식 다운로드")
|
||||
@PostMapping("/excel/template")
|
||||
public ResponseEntity<byte[]> exportShortUrlsTemplate() {
|
||||
byte[] bytes = shortUrlService.exportShortUrlsTemplate();
|
||||
|
||||
return buildExcelResponse("short_url_upload_template.xlsx", bytes);
|
||||
}
|
||||
|
||||
@Operation(summary = "단축 URL 일괄 생성(엑셀 업로드)")
|
||||
@PostMapping(value = "/excel/upload/{useParam}", consumes = MediaType.MULTIPART_FORM_DATA_VALUE)
|
||||
public ResponseEntity<byte[]> createShortUrlsFromExcel(
|
||||
|
||||
@@ -12,6 +12,7 @@ import com.kri.shorturl.persistence.repository.ShortUrlRepository;
|
||||
import java.io.ByteArrayOutputStream;
|
||||
import java.net.URI;
|
||||
import java.time.LocalDateTime;
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import org.apache.poi.ss.usermodel.Workbook;
|
||||
@@ -41,6 +42,18 @@ public class ShortUrlService {
|
||||
.orElseGet(() -> createNewShortUrl(req, regUser, regDt));
|
||||
}
|
||||
|
||||
public byte[] exportShortUrlsTemplate() {
|
||||
try (Workbook workbook =
|
||||
ExcelMapper.writeToWorkbook(Collections.emptyList(), UrlUploadDto.class);
|
||||
ByteArrayOutputStream out = new ByteArrayOutputStream()) {
|
||||
|
||||
workbook.write(out);
|
||||
return out.toByteArray();
|
||||
} catch (Exception e) {
|
||||
throw BusinessException.internalError("공연 업로드 템플릿 엑셀 생성 중 오류");
|
||||
}
|
||||
}
|
||||
|
||||
@Transactional(transactionManager = "transactionManager")
|
||||
public byte[] createShortUrlsFromExcel(
|
||||
boolean useParam,
|
||||
|
||||
Reference in New Issue
Block a user