Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feat/teacher profile form 선생님 구글폼 프로필 등록 #4

Merged
merged 3 commits into from
Jan 31, 2025

Conversation

ywj9811
Copy link
Contributor

@ywj9811 ywj9811 commented Jan 31, 2025

🐈 PR 요약

PR 내용 한 줄로 요약

✨ PR 상세

PR 상세 내용 개조식으로 작성

  • S3 설정 추가 및 build.gradle 추가
  • 선생님 구글폼 등록시 프로필 업데이트
  • 선생님 핸드폰 번호를 통해 선생님 구분 후 해당 선생님 프로필 업데이트
  • 영상 등록 API 는 제외되어 있음

🚨 참고사항

리뷰어들이 알아야 하거나 알면 좋은 참고사항 작성

✅ 체크리스트

  • Label 지정했나요?
  • 관련 테크스펙 링크 연결했나요?

Summary by CodeRabbit

  • New Features

    • Added teacher profile management functionality
    • Implemented file upload capabilities for teacher profiles using AWS S3
  • Dependencies

    • Added Spring Cloud AWS starter for AWS service integration
  • Improvements

    • Enhanced teacher data retrieval and update processes
    • Added support for profile image upload and management

@ywj9811 ywj9811 added the ✨ Feature New feature or request label Jan 31, 2025
@ywj9811 ywj9811 self-assigned this Jan 31, 2025
Copy link

coderabbitai bot commented Jan 31, 2025

Walkthrough

This pull request introduces functionality for teacher profile management with AWS S3 integration. The changes enable teachers to upload profile images by adding new classes and methods across multiple layers of the application. The implementation includes a new endpoint in the TeacherController, services for retrieving and updating teacher information, and configuration for AWS S3 file uploads. The changes facilitate storing and managing teacher profile images using Amazon S3.

Changes

File Change Summary
build.gradle Added Spring Cloud AWS starter dependency
...domain/teacher/application/dto/req/TeacherProfileFormRequest.java New record for teacher profile form request with phoneNumber field
...domain/teacher/application/usecase/TeacherManageUseCase.java Added saveTeacherProfile method with S3 upload and teacher profile update logic
...domain/teacher/domain/entity/Teacher.java Added updateProfile method to update teacher profile
...domain/teacher/domain/entity/TeacherClassInfo.java Added updateProfile method to update profile field
...domain/teacher/domain/repository/TeacherRepository.java Added method to find teacher by phone number
...domain/teacher/domain/service/TeacherGetService.java New service to retrieve teacher by phone number
...domain/teacher/domain/service/TeacherUpdateService.java New service to update teacher profile
...domain/teacher/presentation/TeacherController.java Added endpoint /form/profile for profile submission
...global/config/s3/S3Config.java New configuration for AWS S3 client
...global/config/s3/S3UploadService.java New service for S3 file upload and deletion

Sequence Diagram

sequenceDiagram
    participant Controller as TeacherController
    participant UseCase as TeacherManageUseCase
    participant GetService as TeacherGetService
    participant S3Service as S3UploadService
    participant UpdateService as TeacherUpdateService

    Controller->>UseCase: saveTeacherProfile(profile, request)
    UseCase->>GetService: byPhoneNumber(phoneNumber)
    GetService-->>UseCase: Teacher
    UseCase->>S3Service: saveProfileFile(profile)
    S3Service-->>UseCase: profileUrl
    UseCase->>UpdateService: updateProfile(teacher, profileUrl)
    UpdateService->>UseCase: profile updated
Loading

Possibly Related PRs

Poem

🐰 A Rabbit's Ode to Teacher Profiles 🖼️

In clouds of AWS, a profile takes flight,
With S3 magic, images shine bright
Teachers upload, their stories unfurl
A digital canvas, their talents uncurl
Code hops, data dances, innovation's delight! 🚀

✨ Finishing Touches
  • 📝 Generate Docstrings (Beta)

🪧 Tips

Chat

There are 3 ways to chat with CodeRabbit:

  • Review comments: Directly reply to a review comment made by CodeRabbit. Example:
    • I pushed a fix in commit <commit_id>, please review it.
    • Generate unit testing code for this file.
    • Open a follow-up GitHub issue for this discussion.
  • Files and specific lines of code (under the "Files changed" tab): Tag @coderabbitai in a new review comment at the desired location with your query. Examples:
    • @coderabbitai generate unit testing code for this file.
    • @coderabbitai modularize this function.
  • PR comments: Tag @coderabbitai in a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples:
    • @coderabbitai gather interesting stats about this repository and render them as a table. Additionally, render a pie chart showing the language distribution in the codebase.
    • @coderabbitai read src/utils.ts and generate unit testing code.
    • @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.
    • @coderabbitai help me debug CodeRabbit configuration file.

Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments.

CodeRabbit Commands (Invoked using PR comments)

  • @coderabbitai pause to pause the reviews on a PR.
  • @coderabbitai resume to resume the paused reviews.
  • @coderabbitai review to trigger an incremental review. This is useful when automatic reviews are disabled for the repository.
  • @coderabbitai full review to do a full review from scratch and review all the files again.
  • @coderabbitai summary to regenerate the summary of the PR.
  • @coderabbitai generate docstrings to generate docstrings for this PR. (Beta)
  • @coderabbitai resolve resolve all the CodeRabbit review comments.
  • @coderabbitai configuration to show the current CodeRabbit configuration for the repository.
  • @coderabbitai help to get help.

Other keywords and placeholders

  • Add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.
  • Add @coderabbitai summary to generate the high-level summary at a specific location in the PR description.
  • Add @coderabbitai anywhere in the PR title to generate the title automatically.

CodeRabbit Configuration File (.coderabbit.yaml)

  • You can programmatically configure CodeRabbit by adding a .coderabbit.yaml file to the root of your repository.
  • Please see the configuration documentation for more information.
  • If your editor has YAML language server enabled, you can add the path at the top of this file to enable auto-completion and validation: # yaml-language-server: $schema=https://coderabbit.ai/integrations/schema.v2.json

Documentation and Community

  • Visit our Documentation for detailed information on how to use CodeRabbit.
  • Join our Discord Community to get help, request features, and share feedback.
  • Follow us on X/Twitter for updates and announcements.

Copy link

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 9

🧹 Nitpick comments (2)
src/main/java/com/yedu/backend/global/config/s3/S3Config.java (1)

22-30: Consider using builder pattern consistently.

The type casting to AmazonS3Client is unnecessary since the builder already returns the correct type.

Apply this diff to improve the code:

     @Bean
-    public AmazonS3Client amazonS3Client() {
+    public AmazonS3 amazonS3Client() {
         AWSCredentials credentials = new BasicAWSCredentials(accessKey, secretKey);
-        return (AmazonS3Client)
-                AmazonS3ClientBuilder.standard()
+        return AmazonS3ClientBuilder.standard()
                         .withCredentials(new AWSStaticCredentialsProvider(credentials))
                         .withRegion(region)
                         .build();
     }
src/main/java/com/yedu/backend/domain/teacher/domain/entity/TeacherClassInfo.java (1)

43-46: Track TODO comment in issue tracker.

The TODO comment about adding video functionality should be tracked in your issue management system.

Would you like me to create an issue to track this TODO item for implementing the video update functionality? I can help generate a detailed issue description with acceptance criteria.

📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 7a7f3f8 and 39cca50.

📒 Files selected for processing (11)
  • build.gradle (1 hunks)
  • src/main/java/com/yedu/backend/domain/teacher/application/dto/req/TeacherProfileFormRequest.java (1 hunks)
  • src/main/java/com/yedu/backend/domain/teacher/application/usecase/TeacherManageUseCase.java (3 hunks)
  • src/main/java/com/yedu/backend/domain/teacher/domain/entity/Teacher.java (1 hunks)
  • src/main/java/com/yedu/backend/domain/teacher/domain/entity/TeacherClassInfo.java (1 hunks)
  • src/main/java/com/yedu/backend/domain/teacher/domain/repository/TeacherRepository.java (1 hunks)
  • src/main/java/com/yedu/backend/domain/teacher/domain/service/TeacherGetService.java (1 hunks)
  • src/main/java/com/yedu/backend/domain/teacher/domain/service/TeacherUpdateService.java (1 hunks)
  • src/main/java/com/yedu/backend/domain/teacher/presentation/TeacherController.java (2 hunks)
  • src/main/java/com/yedu/backend/global/config/s3/S3Config.java (1 hunks)
  • src/main/java/com/yedu/backend/global/config/s3/S3UploadService.java (1 hunks)
✅ Files skipped from review due to trivial changes (1)
  • src/main/java/com/yedu/backend/domain/teacher/application/dto/req/TeacherProfileFormRequest.java
🔇 Additional comments (3)
src/main/java/com/yedu/backend/domain/teacher/presentation/TeacherController.java (1)

22-22: Add CORS configuration if needed.

Consider adding CORS configuration if the form is hosted on a different domain.

Run this script to check if CORS is configured:

✅ Verification successful

CORS is already configured but needs review for production

The application has a global CORS configuration in SecurityConfig.java that allows requests from all origins (*). While this works for development, consider restricting allowed origins to specific domains in production for better security.

🏁 Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Description: Check for CORS configuration in the codebase

# Look for CORS configuration
echo "Checking for CORS configuration..."
rg -l "CrossOrigin|addCorsMappings|CorsConfiguration" 

# Look for security configuration
echo "Checking for security configuration..."
rg -l "WebSecurityConfigurerAdapter|SecurityFilterChain|WebSecurityCustomizer"

Length of output: 450


Script:

#!/bin/bash
# Examine the CORS configuration implementation
echo "Content of SecurityConfig.java:"
cat src/main/java/com/yedu/backend/global/config/security/SecurityConfig.java

Length of output: 3019

src/main/java/com/yedu/backend/domain/teacher/domain/entity/Teacher.java (1)

54-56: LGTM!

The updateProfile method correctly delegates to teacherClassInfo.

src/main/java/com/yedu/backend/domain/teacher/application/usecase/TeacherManageUseCase.java (1)

25-27: LGTM! Dependencies are properly injected.

The new services are correctly injected using constructor injection via @RequiredArgsConstructor.

Comment on lines +6 to +11
@Service
public class TeacherUpdateService {
public void updateProfile(Teacher teacher, String profile) {
teacher.updateProfile(profile);
}
}
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🛠️ Refactor suggestion

Add transaction management and error handling.

The service implementation should include:

  1. @Transactional annotation for database operations
  2. Error handling for failed profile updates

Apply this diff:

 @Service
+@Transactional
 public class TeacherUpdateService {
     public void updateProfile(Teacher teacher, String profile) {
+        if (teacher == null) {
+            throw new IllegalArgumentException("Teacher cannot be null");
+        }
+        if (profile == null || profile.isBlank()) {
+            throw new IllegalArgumentException("Profile cannot be null or blank");
+        }
         teacher.updateProfile(profile);
     }
 }
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
@Service
public class TeacherUpdateService {
public void updateProfile(Teacher teacher, String profile) {
teacher.updateProfile(profile);
}
}
@Service
@Transactional
public class TeacherUpdateService {
public void updateProfile(Teacher teacher, String profile) {
if (teacher == null) {
throw new IllegalArgumentException("Teacher cannot be null");
}
if (profile == null || profile.isBlank()) {
throw new IllegalArgumentException("Profile cannot be null or blank");
}
teacher.updateProfile(profile);
}
}


public interface TeacherRepository extends JpaRepository<Teacher, Long> {
Optional<Teacher> findByTeacherInfo_PhoneNumber(String PhoneNumber);
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🛠️ Refactor suggestion

Fix parameter naming convention and consider adding an index.

  1. Parameter name should be camelCase
  2. Consider adding an index on the phone_number column for better query performance

Apply this diff:

-    Optional<Teacher> findByTeacherInfo_PhoneNumber(String PhoneNumber);
+    Optional<Teacher> findByTeacherInfo_PhoneNumber(String phoneNumber);

Add the following annotation to the phoneNumber field in TeacherInfo class:

@Column(name = "phone_number", index = true)
private String phoneNumber;

Comment on lines +13 to +16
public Teacher byPhoneNumber(String phoneNumber) {
return teacherRepository.findByTeacherInfo_PhoneNumber(phoneNumber)
.orElseThrow();
}
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🛠️ Refactor suggestion

Improve error handling and add phone number validation.

  1. Use custom exception with meaningful message
  2. Validate phone number format before query
  3. Add logging for debugging purposes

Apply this diff:

+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
 @Service
 @RequiredArgsConstructor
 public class TeacherGetService {
+    private static final Logger log = LoggerFactory.getLogger(TeacherGetService.class);
     private final TeacherRepository teacherRepository;
 
     public Teacher byPhoneNumber(String phoneNumber) {
+        if (phoneNumber == null || !phoneNumber.matches("^\\d{10,11}$")) {
+            throw new IllegalArgumentException("Invalid phone number format");
+        }
+        log.debug("Searching for teacher with phone number: {}", phoneNumber);
         return teacherRepository.findByTeacherInfo_PhoneNumber(phoneNumber)
-                .orElseThrow();
+                .orElseThrow(() -> 
+                    new TeacherNotFoundException("Teacher not found with phone number: " + phoneNumber));
     }
 }

Committable suggestion skipped: line range outside the PR's diff.

Comment on lines +23 to +27
@PostMapping("/form/profile")
public ResponseEntity saveProfileByForm(@RequestPart TeacherProfileFormRequest request, @RequestPart MultipartFile profile) {
manageUseCase.saveTeacherProfile(profile, request);
return ResponseEntity.ok().build();
}
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🛠️ Refactor suggestion

Add validation, documentation and proper response type.

  1. Add file size and type validation
  2. Add Swagger/OpenAPI documentation
  3. Specify response type and error responses

Apply this diff:

+    @Operation(summary = "Save teacher profile from form submission")
+    @ApiResponses(value = {
+        @ApiResponse(responseCode = "200", description = "Profile saved successfully"),
+        @ApiResponse(responseCode = "400", description = "Invalid request"),
+        @ApiResponse(responseCode = "404", description = "Teacher not found"),
+        @ApiResponse(responseCode = "500", description = "Internal server error")
+    })
     @PostMapping("/form/profile")
-    public ResponseEntity saveProfileByForm(@RequestPart TeacherProfileFormRequest request, @RequestPart MultipartFile profile) {
+    public ResponseEntity<Void> saveProfileByForm(
+            @RequestPart @Valid TeacherProfileFormRequest request,
+            @RequestPart @ValidFile(maxSize = 5 * 1024 * 1024, types = {"image/jpeg", "image/png"}) MultipartFile profile) {
         manageUseCase.saveTeacherProfile(profile, request);
         return ResponseEntity.ok().build();
     }

Create a custom validator annotation:

@Target({ElementType.PARAMETER})
@Retention(RetentionPolicy.RUNTIME)
@Constraint(validatedBy = FileValidator.class)
public @interface ValidFile {
    String message() default "Invalid file";
    Class<?>[] groups() default {};
    Class<? extends Payload>[] payload() default {};
    long maxSize() default 1024 * 1024;
    String[] types() default {};
}

Comment on lines +15 to +20
@Value("${cloud.aws.credentials.access-key}")
public String accessKey;
@Value("${cloud.aws.credentials.secret-key}")
public String secretKey;
@Value("${cloud.aws.region.static}")
public String region;
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue

Enhance security by making fields private and using AWS credential provider chain.

The configuration fields should not be public. Additionally, consider using AWS SDK's default credential provider chain instead of explicitly storing credentials.

Apply this diff to improve security:

-    public String accessKey;
-    public String secretKey;
-    public String region;
+    private String accessKey;
+    private String secretKey;
+    private String region;

Consider using AWS SDK's default credential provider chain by:

  1. Setting up AWS credentials in ~/.aws/credentials
  2. Using environment variables (AWS_ACCESS_KEY_ID, AWS_SECRET_ACCESS_KEY)
  3. Using IAM roles for EC2 instances
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
@Value("${cloud.aws.credentials.access-key}")
public String accessKey;
@Value("${cloud.aws.credentials.secret-key}")
public String secretKey;
@Value("${cloud.aws.region.static}")
public String region;
@Value("${cloud.aws.credentials.access-key}")
private String accessKey;
@Value("${cloud.aws.credentials.secret-key}")
private String secretKey;
@Value("${cloud.aws.region.static}")
private String region;

Comment on lines +46 to +54
public void deleteProfileImage(String url) {
try {
String decodedUrl = URLDecoder.decode(url, "UTF-8");
String fileName = decodedUrl.substring(decodedUrl.lastIndexOf('/') + 1);
amazonS3.deleteObject(bucket + "/" + profile, fileName);
} catch (UnsupportedEncodingException e) {
throw new IllegalArgumentException(); //todo : 적절한 예외 처리
}
}
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue

Fix path construction in deleteProfileImage method.

The bucket path construction is incorrect and the error handling needs improvement.

Apply this diff:

     public void deleteProfileImage(String url)  {
         try {
             String decodedUrl = URLDecoder.decode(url, "UTF-8");
             String fileName = decodedUrl.substring(decodedUrl.lastIndexOf('/') + 1);
-            amazonS3.deleteObject(bucket + "/" + profile, fileName);
+            amazonS3.deleteObject(bucket, profile + "/" + fileName);
         } catch (UnsupportedEncodingException e) {
-            throw new IllegalArgumentException(); //todo : 적절한 예외 처리
+            throw new FileDeleteException("Failed to decode file URL", e);
+        } catch (AmazonS3Exception e) {
+            throw new FileDeleteException("Failed to delete file from S3", e);
         }
     }
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
public void deleteProfileImage(String url) {
try {
String decodedUrl = URLDecoder.decode(url, "UTF-8");
String fileName = decodedUrl.substring(decodedUrl.lastIndexOf('/') + 1);
amazonS3.deleteObject(bucket + "/" + profile, fileName);
} catch (UnsupportedEncodingException e) {
throw new IllegalArgumentException(); //todo : 적절한 예외 처리
}
}
public void deleteProfileImage(String url) {
try {
String decodedUrl = URLDecoder.decode(url, "UTF-8");
String fileName = decodedUrl.substring(decodedUrl.lastIndexOf('/') + 1);
amazonS3.deleteObject(bucket, profile + "/" + fileName);
} catch (UnsupportedEncodingException e) {
throw new FileDeleteException("Failed to decode file URL", e);
} catch (AmazonS3Exception e) {
throw new FileDeleteException("Failed to delete file from S3", e);
}
}

Comment on lines +30 to +44
private String getString(MultipartFile multipartFile, String dir) {
try {
String originalFilename = multipartFile.getOriginalFilename();
String fileName = dir +"/" + originalFilename + UUID.randomUUID();

ObjectMetadata metadata = new ObjectMetadata();
metadata.setContentLength(multipartFile.getSize());
metadata.setContentType(multipartFile.getContentType());

amazonS3.putObject(bucket, fileName, multipartFile.getInputStream(), metadata);
return amazonS3.getUrl(bucket, fileName).toString();
} catch (IOException ex) {
throw new IllegalArgumentException(); //todo : 적절한 예외 처리
}
}
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue

Improve file upload security and error handling.

Several improvements needed in the file upload logic:

  1. File name collision possible with UUID appended after original name
  2. Missing file size limits
  3. Generic exception handling
  4. Missing content type validation

Apply these improvements:

     private String getString(MultipartFile multipartFile, String dir) {
+        if (multipartFile.getSize() > 5_000_000) { // 5MB limit
+            throw new FileSizeLimitExceededException("File size exceeds limit", multipartFile.getSize(), 5_000_000);
+        }
+        String contentType = multipartFile.getContentType();
+        if (contentType == null || !contentType.startsWith("image/")) {
+            throw new InvalidFileTypeException("Only image files are allowed");
+        }
         try {
             String originalFilename = multipartFile.getOriginalFilename();
-            String fileName = dir +"/" + originalFilename + UUID.randomUUID();
+            String extension = originalFilename.substring(originalFilename.lastIndexOf("."));
+            String fileName = dir + "/" + UUID.randomUUID() + extension;
 
             ObjectMetadata metadata = new ObjectMetadata();
             metadata.setContentLength(multipartFile.getSize());
             metadata.setContentType(multipartFile.getContentType());
 
             amazonS3.putObject(bucket, fileName, multipartFile.getInputStream(), metadata);
             return amazonS3.getUrl(bucket, fileName).toString();
         } catch (IOException ex) {
-            throw new IllegalArgumentException(); //todo : 적절한 예외 처리
+            throw new FileUploadException("Failed to upload file to S3", ex);
         }
     }

Committable suggestion skipped: line range outside the PR's diff.

Comment on lines +77 to +81
public void saveTeacherProfile(MultipartFile profile, TeacherProfileFormRequest request) {
String profileUrl = s3UploadService.saveProfileFile(profile);
Teacher teacher = teacherGetService.byPhoneNumber(request.phoneNumber());
teacherUpdateService.updateProfile(teacher, profileUrl);
}
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue

Add error handling for file upload and teacher lookup.

The method needs to handle potential failure scenarios:

  1. Invalid or empty profile file
  2. S3 upload failures
  3. Teacher not found by phone number

Consider adding proper error handling:

 public void saveTeacherProfile(MultipartFile profile, TeacherProfileFormRequest request) {
+    if (profile == null || profile.isEmpty()) {
+        throw new IllegalArgumentException("Profile image is required");
+    }
+    
     String profileUrl = s3UploadService.saveProfileFile(profile);
     Teacher teacher = teacherGetService.byPhoneNumber(request.phoneNumber());
+    
+    if (teacher == null) {
+        throw new EntityNotFoundException("Teacher not found with phone number: " + request.phoneNumber());
+    }
+    
     teacherUpdateService.updateProfile(teacher, profileUrl);
 }
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
public void saveTeacherProfile(MultipartFile profile, TeacherProfileFormRequest request) {
String profileUrl = s3UploadService.saveProfileFile(profile);
Teacher teacher = teacherGetService.byPhoneNumber(request.phoneNumber());
teacherUpdateService.updateProfile(teacher, profileUrl);
}
public void saveTeacherProfile(MultipartFile profile, TeacherProfileFormRequest request) {
if (profile == null || profile.isEmpty()) {
throw new IllegalArgumentException("Profile image is required");
}
String profileUrl = s3UploadService.saveProfileFile(profile);
Teacher teacher = teacherGetService.byPhoneNumber(request.phoneNumber());
if (teacher == null) {
throw new EntityNotFoundException("Teacher not found with phone number: " + request.phoneNumber());
}
teacherUpdateService.updateProfile(teacher, profileUrl);
}

Comment on lines +52 to +54

// aws s3
implementation 'org.springframework.cloud:spring-cloud-starter-aws:2.2.6.RELEASE'
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue

Fix Spring Cloud AWS version compatibility with Spring Boot 3.x.

The current Spring Cloud AWS starter version (2.2.6.RELEASE) is not compatible with Spring Boot 3.x. This will cause runtime issues.

Replace with the compatible AWS SDK dependency:

-    implementation 'org.springframework.cloud:spring-cloud-starter-aws:2.2.6.RELEASE'
+    implementation 'io.awspring.cloud:spring-cloud-aws-starter-s3:3.0.2'

This version is specifically designed for Spring Boot 3.x and provides better integration with AWS S3.

📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
// aws s3
implementation 'org.springframework.cloud:spring-cloud-starter-aws:2.2.6.RELEASE'
// aws s3
implementation 'io.awspring.cloud:spring-cloud-aws-starter-s3:3.0.2'

@ywj9811 ywj9811 merged commit 6ae4649 into develop Jan 31, 2025
2 checks passed
@coderabbitai coderabbitai bot mentioned this pull request Feb 21, 2025
2 tasks
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
✨ Feature New feature or request
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant