Skip to content

Commit

Permalink
Merge pull request #68 from Team-KeepGoing/feature/student
Browse files Browse the repository at this point in the history
Fix :: Student service
  • Loading branch information
priverg authored Jul 10, 2024
2 parents a29d2dc + ad1fdba commit fab7ab4
Show file tree
Hide file tree
Showing 4 changed files with 10 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -29,4 +29,7 @@ public class Student {

@Column(nullable = false)
private String mail;

@Column
private String imgUrl;
}
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
public class StudentResponseDto {
long id;
String studentName;
String imgUrl;
String studentId;
String phoneNum;
String mail;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,13 +9,9 @@
import java.io.IOException;

public interface StudentService {
@Transactional(readOnly = true)
BaseResponse findByStudentName(StudentFindDto studentFindDto);
@Transactional(readOnly = true)
BaseResponse findByStudentNum(StudentFindDto studentFindDto);
@Transactional(rollbackFor = Exception.class)
BaseResponse editStudent(StudentRequestDto studentRequestDto,Long id);
BaseResponse createManyUserByExcel(MultipartFile multipartFile) throws IOException;
@Transactional(readOnly = true)
BaseResponse findAll();
}
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@
import com.keepgoing.keepserver.domain.student.repository.StudentRepository;
import com.keepgoing.keepserver.domain.student.repository.dto.*;
import com.keepgoing.keepserver.global.common.BaseResponse;
import jakarta.transaction.Transactional;
import lombok.AllArgsConstructor;
import org.apache.commons.io.FilenameUtils;
import org.apache.poi.hssf.usermodel.HSSFWorkbook;
Expand All @@ -14,6 +13,7 @@
import org.apache.poi.xssf.usermodel.XSSFWorkbook;
import org.springframework.http.HttpStatus;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import org.springframework.web.multipart.MultipartFile;

import java.io.IOException;
Expand Down Expand Up @@ -75,6 +75,7 @@ public BaseResponse createManyUserByExcel(MultipartFile file) {
}
}

@Transactional(readOnly = true)
@Override
public BaseResponse findAll() {
ArrayList<StudentResponseDto> lst = new ArrayList<>();
Expand All @@ -96,6 +97,7 @@ private List<StudentResponseDto> convertToResponseDto(List<Student> students) {
return responseDto;
}

@Transactional(readOnly = true)
public BaseResponse findByStudentName(StudentFindDto studentDto) {
try {
List<Student> students = findStudentsByStudentName(studentDto.getStudentName());
Expand All @@ -118,6 +120,7 @@ private StudentResponseDto convertToResponseDto(Student student) {
return studentFormat(student);
}

@Transactional(readOnly = true)
public BaseResponse findByStudentNum(StudentFindDto studentDto) {
try {
Student student = findStudentByStudentId(studentDto.getStudentId());
Expand All @@ -132,6 +135,7 @@ public BaseResponse findByStudentNum(StudentFindDto studentDto) {
}
}

@Transactional(rollbackFor = Exception.class)
public BaseResponse editStudent(StudentRequestDto studentDto, Long id) {
Student studentEntity = studentRepository.findStudentById(id);
if (studentDto.getStudentName() != null) studentEntity.setStudentName(studentDto.getStudentName());
Expand All @@ -153,6 +157,7 @@ public StudentResponseDto studentFormat(Student student) {
.mail(student.getMail())
.phoneNum(student.getPhoneNum())
.studentName(student.getStudentName())
.imgUrl(student.getImgUrl())
.build();
}
}

0 comments on commit fab7ab4

Please sign in to comment.