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

Fix :: Student service #68

Merged
merged 1 commit into from
Jul 10, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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();
}
}