feat: add profile image to employee
This commit is contained in:
@@ -30,6 +30,7 @@ import org.springframework.web.bind.annotation.*;
|
||||
import jakarta.validation.Valid;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
@Tag(name = "Employee", description = "직원 관리 API")
|
||||
@RestController
|
||||
@@ -186,6 +187,16 @@ public class EmployeeController {
|
||||
return ResponseEntity.ok(ApiResponse.ok("비상연락망이 삭제되었습니다", null));
|
||||
}
|
||||
|
||||
@Operation(summary = "프로필 이미지 설정", description = "직원의 프로필 이미지 URL을 저장합니다")
|
||||
@PreAuthorize("hasAnyRole('EMPLOYEE', 'MANAGER', 'ADMIN')")
|
||||
@PutMapping("/{empId}/profile-image")
|
||||
public ResponseEntity<ApiResponse<Employee>> updateProfileImage(
|
||||
@PathVariable Long empId, @RequestBody Map<String, String> body) {
|
||||
Employee emp = employeeService.findById(empId);
|
||||
emp.setProfileImage(body.get("profileImage"));
|
||||
return ResponseEntity.ok(ApiResponse.ok("프로필 이미지가 저장되었습니다", employeeService.update(empId, emp)));
|
||||
}
|
||||
|
||||
@Operation(summary = "비밀번호 변경", description = "현재 사용자의 비밀번호를 변경합니다")
|
||||
@PreAuthorize("hasAnyRole('EMPLOYEE', 'MANAGER', 'ADMIN')")
|
||||
@PutMapping("/me/password")
|
||||
|
||||
@@ -20,5 +20,6 @@ public record EmployeeSummary(
|
||||
String education,
|
||||
String major,
|
||||
LocalDate graduationDate,
|
||||
String residence
|
||||
String residence,
|
||||
String profileImage
|
||||
) {}
|
||||
|
||||
@@ -77,6 +77,9 @@ public class Employee extends BaseEntity {
|
||||
@Column(name = "residence", length = 255)
|
||||
private String residence;
|
||||
|
||||
@Column(name = "profile_image", length = 500)
|
||||
private String profileImage;
|
||||
|
||||
@OneToMany(mappedBy = "employee", cascade = CascadeType.ALL, orphanRemoval = true)
|
||||
@OrderBy("sortOrder ASC")
|
||||
private List<EmployeeEmergencyContact> emergencyContacts;
|
||||
|
||||
@@ -109,6 +109,7 @@ public class EmployeeService {
|
||||
employee.setMajor(updateRequest.getMajor());
|
||||
employee.setGraduationDate(updateRequest.getGraduationDate());
|
||||
employee.setResidence(updateRequest.getResidence());
|
||||
employee.setProfileImage(updateRequest.getProfileImage());
|
||||
|
||||
if (updateRequest.getPassword() != null && !updateRequest.getPassword().isBlank()) {
|
||||
employee.setPassword(passwordEncoder.encode(updateRequest.getPassword()));
|
||||
@@ -143,7 +144,8 @@ public class EmployeeService {
|
||||
employee.getEducation(),
|
||||
employee.getMajor(),
|
||||
employee.getGraduationDate(),
|
||||
employee.getResidence()
|
||||
employee.getResidence(),
|
||||
employee.getProfileImage()
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user