1616import lombok .RequiredArgsConstructor ;
1717import org .springframework .http .ResponseEntity ;
1818import org .springframework .stereotype .Service ;
19+ import org .springframework .web .multipart .MultipartFile ;
1920
2021import java .util .Collections ;
2122import java .util .List ;
@@ -55,10 +56,21 @@ public void refreshSkillTags() {
5556 }
5657
5758 public ResponseEntity <ApiResponse <SkillTagEntity >> createSkillTag (SkillTagRequest request ) {
58- String ext = getSkillExtension (request .getImg ().getOriginalFilename ());
59+ MultipartFile img = request .getImg ();
60+
61+ if (img == null || img .isEmpty ()) {
62+ throw new CustomException (ErrorException .FILE_EMPTY ); // 적절한 에러 코드 사용
63+ }
64+
65+ String originalFilename = img .getOriginalFilename ();
66+ if (originalFilename == null || originalFilename .trim ().isEmpty ()) {
67+ throw new CustomException (ErrorException .FILE_NOT_SEARCH );
68+ }
69+
70+ String ext = getSkillExtension (originalFilename );
5971 String fileName = request .getName ().trim ().replaceAll ("\\ s+" , "_" ) + "." + ext ;
6072
61- String imgUrl = awsS3Client .upload (request . getImg () , fileName );
73+ String imgUrl = awsS3Client .upload (img , fileName );
6274
6375 SkillTagEntity skillTag = new SkillTagEntity (request .getName (), imgUrl );
6476 SkillTagEntity saved = skillTagRepository .save (skillTag );
@@ -67,6 +79,7 @@ public ResponseEntity<ApiResponse<SkillTagEntity>> createSkillTag(SkillTagReques
6779 return ResponseEntity .ok (new ApiResponse <>(200 , true , "스킬 태그 등록 성공" , saved ));
6880 }
6981
82+
7083 public ResponseEntity <ApiResponse <PositionTagEntity >> createPositionTag (PositionTagRequest request ) {
7184 PositionTagEntity positionTag = new PositionTagEntity (request .getName ());
7285 PositionTagEntity saved = positionTagRepository .save (positionTag );
0 commit comments