Skip to content

Commit

Permalink
Merge pull request #56 from Team-KeepGoing/feature/student
Browse files Browse the repository at this point in the history
Fix :: edit student service
  • Loading branch information
priverg authored Jun 17, 2024
2 parents b1c8e02 + dfd2a3d commit dc13176
Show file tree
Hide file tree
Showing 4 changed files with 7 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -37,8 +37,8 @@ public BaseResponse findAll() {

@Operation(summary = "학생 정보 수정하기", description = "id를 통해 학생 정보를 수정합니다. 파라미터는 전체 코드가 아닌, 수정할 내용만 넘기셔도 됩니다.")
@PatchMapping("/edit/{id}")
public BaseResponse editStudent(@RequestBody StudentRequestDto studentRequestDto, @PathVariable String id) {
return studentService.editStudent(studentRequestDto);
public BaseResponse editStudent(@RequestBody StudentRequestDto studentRequestDto, @PathVariable Long id) {
return studentService.editStudent(studentRequestDto, id);
}

@Operation(summary = "학생 등록하기", description = "형식에 맞는 엑셀 파일 업로드 시 업로딩됩니다")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
import java.util.List;

public interface StudentRepository extends JpaRepository<Student, Long> {
Student findStudentById(Long id);
Student findStudentByStudentId(String studentId);
List<Student> findStudentsByStudentName(String name);
}
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ public interface StudentService {
@Transactional(readOnly = true)
BaseResponse findByStudentNum(StudentFindDto studentFindDto);
@Transactional(rollbackFor = Exception.class)
BaseResponse editStudent(StudentRequestDto studentRequestDto);
BaseResponse editStudent(StudentRequestDto studentRequestDto,Long id);
BaseResponse createManyUserByExcel(MultipartFile multipartFile) throws IOException;
@Transactional(readOnly = true)
BaseResponse findAll();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -132,11 +132,11 @@ public BaseResponse findByStudentNum(StudentFindDto studentDto) {
}
}

public BaseResponse editStudent(StudentRequestDto studentDto) {
Student studentEntity = studentRepository.findStudentByStudentId(studentDto.getStudentId());
public BaseResponse editStudent(StudentRequestDto studentDto,Long id) {
Student studentEntity = studentRepository.findStudentById(id);
if (studentDto.getStudentName() != null) studentEntity.setStudentName(studentDto.getStudentName());
if (studentDto.getStudentId() != null) studentEntity.setStudentId(studentDto.getStudentId());
if (studentDto.getPhoneNum() != null) studentEntity.setPhoneNum(studentDto.getPhoneNum());
if (studentDto.getStudentId() != null) studentEntity.setStudentId(studentDto.getStudentId());
if (studentDto.getMail() != null) studentEntity.setMail(studentDto.getMail());
if (studentDto.getAddress() != null) studentEntity.setAddress(studentDto.getAddress());

Expand Down

0 comments on commit dc13176

Please sign in to comment.