Merge branch 'main' into yoon
This commit is contained in:
commit
856dd1b618
@ -42,6 +42,9 @@ public class WebMvcConfig implements WebMvcConfigurer {
|
|||||||
@Value("${filePath.boardfile}")
|
@Value("${filePath.boardfile}")
|
||||||
private String boardFilePath;
|
private String boardFilePath;
|
||||||
|
|
||||||
|
@Value("${filePath.profile}")
|
||||||
|
private String uploadPath;
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void addInterceptors(InterceptorRegistry registry) {
|
public void addInterceptors(InterceptorRegistry registry) {
|
||||||
// 여기서 인터셉터를 추가할 수 있음
|
// 여기서 인터셉터를 추가할 수 있음
|
||||||
@ -58,6 +61,9 @@ public class WebMvcConfig implements WebMvcConfigurer {
|
|||||||
//게시판 에디터 안 이미지 업로드 경로
|
//게시판 에디터 안 이미지 업로드 경로
|
||||||
registry.addResourceHandler("/upload/img/board/**")
|
registry.addResourceHandler("/upload/img/board/**")
|
||||||
.addResourceLocations("file:" + boardFilePath);
|
.addResourceLocations("file:" + boardFilePath);
|
||||||
|
//프로필 이미지 업로드 경로
|
||||||
|
registry.addResourceHandler("/upload/img/profile/**")
|
||||||
|
.addResourceLocations("file:" + uploadPath);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Controller의 파라미터를 처리할 Resolver 등록
|
// Controller의 파라미터를 처리할 Resolver 등록
|
||||||
|
|||||||
@ -23,6 +23,7 @@ import lombok.RequiredArgsConstructor;
|
|||||||
@RequiredArgsConstructor
|
@RequiredArgsConstructor
|
||||||
public class localbordService {
|
public class localbordService {
|
||||||
private final localbordMapper boardMapper;
|
private final localbordMapper boardMapper;
|
||||||
|
private static final long MAX_FILE_SIZE = 5 * 1024 * 1024; // 5MB
|
||||||
|
|
||||||
public List<MapDto> getNotices(MapDto map) {
|
public List<MapDto> getNotices(MapDto map) {
|
||||||
List<MapDto> posts = boardMapper.getNotices(map);
|
List<MapDto> posts = boardMapper.getNotices(map);
|
||||||
@ -57,11 +58,26 @@ public class localbordService {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public void addAttachment(MapDto map) {
|
public void addAttachment(MapDto map) {
|
||||||
|
String boardSeqStr = (String) map.get("CMNBRDSEQ");
|
||||||
|
Long boardSeq = Long.parseLong(boardSeqStr);
|
||||||
|
map.put("CMNBRDSEQ", boardSeq);
|
||||||
|
|
||||||
String newFilename = UUID.randomUUID().toString();
|
String newFilename = UUID.randomUUID().toString();
|
||||||
map.put("CMNFLENAM", newFilename);
|
map.put("CMNFLENAM", newFilename);
|
||||||
|
|
||||||
boardMapper.addAttachment(map);
|
boardMapper.addAttachment(map);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void validateAttachmentsSize(List<MapDto> attachments) {
|
||||||
|
long totalSize = attachments.stream()
|
||||||
|
.mapToLong(attachment -> (Long) attachment.get("size"))
|
||||||
|
.sum();
|
||||||
|
|
||||||
|
if (totalSize > MAX_FILE_SIZE) {
|
||||||
|
throw new IllegalArgumentException("첨부파일의 총 용량이 5MB를 초과합니다.");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
public MapDto getBoardDetail(Long boardId) {
|
public MapDto getBoardDetail(Long boardId) {
|
||||||
incrementViewCount(boardId);
|
incrementViewCount(boardId);
|
||||||
MapDto boardDetail = boardMapper.selectBoardDetail(boardId);
|
MapDto boardDetail = boardMapper.selectBoardDetail(boardId);
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user