Skip to content
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

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -20,9 +20,6 @@ public class FieldBookmark extends BaseEntity {
@Column(name = "fbId", nullable = false)
private Integer id;

@Column(name = "fieldRecommend")
private Boolean isRecommend = false;

@ManyToOne(fetch = FetchType.LAZY)
@JoinColumn(name = "fId", nullable = false)
@OnDelete(action = OnDeleteAction.CASCADE)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,9 +21,6 @@ public class MajorBookmark extends BaseEntity {
@Column(name = "mbId", nullable = false)
private Integer id;

@Column(name = "majorRecommend")
private Boolean isRecommend = false;

@ManyToOne(fetch = FetchType.LAZY)
@JoinColumn(name = "mId", nullable = false)
@OnDelete(action = OnDeleteAction.CASCADE)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,6 @@ public class Mock extends BaseEntity {

/** 과목별 점수 리스트 */
@OneToMany(mappedBy = "mock", cascade = CascadeType.ALL, orphanRemoval = true)
@Column(name = "mock_score", nullable = true)
@Builder.Default
private List<MockScore> scoreLists = new ArrayList<>();
public void addMockScore(MockScore mockScore) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,10 @@
import org.hibernate.annotations.OnDelete;
import org.hibernate.annotations.OnDeleteAction;


import java.math.BigDecimal;

import static jakarta.persistence.FetchType.LAZY;
import static jakarta.persistence.FetchType.EAGER;

@Entity
@Table(name = "mockScore")
Expand All @@ -32,7 +33,7 @@ public class MockScore extends BaseEntity {
private Integer percentile;

/** 등급 */
@Column(name = "grade", nullable = false)
@Column(name = "grade")
private Integer grade;

/** 누적 백분위(%) */
Expand All @@ -47,7 +48,7 @@ public class MockScore extends BaseEntity {
@Column(name = "name")
private String name;

@ManyToOne(fetch = LAZY, optional = false)
@ManyToOne(fetch = EAGER, optional = false)
@JoinColumn(name = "mockId", nullable = false)
@OnDelete(action = OnDeleteAction.CASCADE)
private Mock mock;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,6 @@

import hackerthon.likelion13th.canfly.domain.entity.BaseEntity;
import hackerthon.likelion13th.canfly.domain.user.User;
import hackerthon.likelion13th.canfly.domain.entity.CategoryName;
import hackerthon.likelion13th.canfly.grades.dto.ReportResponseDto;
import jakarta.persistence.*;
import lombok.*;
import org.hibernate.annotations.OnDelete;
Expand Down Expand Up @@ -34,8 +32,7 @@ public class Report extends BaseEntity {

/** 과목 카테고리명 (국어/수학) */
@Column(name = "category_name", nullable = false)
@Enumerated(EnumType.STRING)
private CategoryName categoryName;
private Integer categoryName;

/** 카테고리 평균 성적(예: 3.75) */
@Column(name = "category_grade", precision = 5, scale = 2)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
import lombok.*;
import org.hibernate.annotations.OnDelete;
import org.hibernate.annotations.OnDeleteAction;

import java.math.BigDecimal;

@Entity
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,9 +35,6 @@ public class User extends BaseEntity {
@Column(name = "email", length = 50)
private String email;

@Column(name = "phoneNumber", length = 20)
private String phoneNumber;

@Enumerated(EnumType.STRING)
@Column(name = "sex")
private Sex sex;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ public enum SuccessCode implements BaseCode { // 성공
USER_REISSUE_SUCCESS(HttpStatus.OK, "USER_2002", "토큰 재발급이 완료되었습니다."),
USER_DELETE_SUCCESS(HttpStatus.OK, "USER_2003", "회원탈퇴가 완료되었습니다."),
USER_PROFILE_UPDATE_SUCCESS(HttpStatus.OK, "USER_2006", "프로필 저장이 완료되었습니다."),
USER_INFO_GET_SUCCESS(HttpStatus.OK, "USER_2007", "유저 정보 조회가 완료되었습니다."),

MOCK_CREATE_SUCCESS(HttpStatus.CREATED, "MOCK_2011", "모의고사 등록이 완료되었습니다."),
MOCKSCORE_CREATE_SUCCESS(HttpStatus.CREATED, "MOCKSCORE_2011", "모의고사 성적 등록이 완료되었습니다."),
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
package hackerthon.likelion13th.canfly.grades.controller;

import hackerthon.likelion13th.canfly.domain.mock.Mock;
import hackerthon.likelion13th.canfly.domain.mock.MockScore;
import hackerthon.likelion13th.canfly.domain.user.User;
import hackerthon.likelion13th.canfly.global.api.ApiResponse;
import hackerthon.likelion13th.canfly.global.api.SuccessCode;
Expand All @@ -9,8 +11,6 @@
import hackerthon.likelion13th.canfly.grades.dto.MockResponseDto;
import hackerthon.likelion13th.canfly.grades.service.MockService;
import hackerthon.likelion13th.canfly.login.auth.mapper.CustomUserDetails;
import hackerthon.likelion13th.canfly.login.dto.CoinRequestDto;
import hackerthon.likelion13th.canfly.login.dto.CoinResponseDto;
import hackerthon.likelion13th.canfly.login.service.UserService;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.responses.ApiResponses;
Expand Down Expand Up @@ -84,31 +84,33 @@ public ApiResponse<MockResponseDto.MockScoreResponseDto> getMockScore(@PathVaria
return ApiResponse.onSuccess(SuccessCode.MOCKSCORE_GET_SUCCESS, mockScore);
}

@PatchMapping("/{mockId}")
@Operation(summary = "모의고사 정보 수정", description = "특정 모의고사의 정보를 수정하는 메서드입니다.")
@ApiResponses({
@io.swagger.v3.oas.annotations.responses.ApiResponse(responseCode = "Mock_2013", description = "특정 모의고사 정보 수정이 완료되었습니다."),
})
public ApiResponse<MockResponseDto> updateMock(@PathVariable Long mockId, @RequestBody MockRequestDto mockRequestDto) {

MockResponseDto responseDto = mockService.updateMock(mockId, mockRequestDto);
return ApiResponse.onSuccess(SuccessCode.MOCK_PUT_SUCCESS, responseDto);
}

// @Operation(summary = "토큰 사용 및 충전", description = "amount가 0이면 토큰 1개 사용, 0보다 크면 해당 양만큼 충전합니다.")
// @PatchMapping("/token")
// public ApiResponse<CoinResponseDto> updateUserCoins(
// @AuthenticationPrincipal CustomUserDetails userDetails, // 또는 Authentication auth 객체
// @RequestBody CoinRequestDto coinRequestDto) {
// int amount = coinRequestDto.getAmount(); //내가 볼 때 그냥 token을 다른 테이블에 추가시키는 게 나음 ㅅ;ㅂ 이거 너무 많아 정보가
// String username = userDetails.getUsername();
// User updatedUser = userService.processCoins(username, amount);
// CoinResponseDto responseDTO = CoinResponseDto.fromEntity(updatedUser);
//
// // 3. 최종적으로 변환된 DTO를 클라이언트에게 전달합니다.
// return ApiResponse.onSuccess(SuccessCode.TOKEN_PROCESS_SUCCESS, responseDTO);
// 뭔가 만들면서 이상해져서 수정할 건데, 일단 이걸로 POST+DELETE를 해야 함
// @Operation(summary = "모의고사 성적 수정", description = "특정 모의고사의 성적을 수정하는 메서드입니다.")
// @ApiResponses({
// @io.swagger.v3.oas.annotations.responses.ApiResponse(responseCode = "Mock_2013", description = "특정 모의고사 정보 수정이 완료되었습니다."),
// })
// public ApiResponse<MockResponseDto> updateMockScore(@AuthenticationPrincipal CustomUserDetails userDetails, @PathVariable Long mockId, @RequestBody MockRequestDto mockRequestDto) {
// User user = userService.findUserByProviderId(userDetails.getUsername());
// Mock updatedMock = new Mock();
// if (mockRequestDto.getScoreLists() != null && !mockRequestDto.getScoreLists().isEmpty()) {
// List<MockRequestDto.MockScoreRequestDto> newScores = mockRequestDto.getScoreLists();
// for (MockRequestDto.MockScoreRequestDto scoreDto : newScores) {
// MockScore mockScore = MockScore.builder()
// .standardScore(scoreDto.getStandardScore())
// .percentile(scoreDto.getPercentile())
// .grade(scoreDto.getGrade())
// .cumulative(scoreDto.getCumulative())
// .category(scoreDto.getCategory())
// .name(scoreDto.getName())
// .build();
// updatedMock.addMockScore(mockScore);
// }
// }
// MockResponseDto responseDto = new MockResponseDto(updatedMock);
// return ApiResponse.onSuccess(SuccessCode.MOCKSCORE_PUT_SUCCESS, responseDto);
// }


@DeleteMapping("/{mockId}")
@Operation(summary = "모의고사 삭제", description = "특정 모의고사를 삭제하는 메서드입니다.")
@ApiResponses({
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -44,19 +44,19 @@ public ApiResponse<ReportResponseDto> createReport(
return ApiResponse.onSuccess(SuccessCode.REPORT_CREATE_SUCCESS, responseDto);
}

@PostMapping("/{reportId}")
@Operation(summary = "내신 점수 등록", description = "어떤 내신의 특정 과목 성적을 입력하는 메서드입니다..")
@ApiResponses({
@io.swagger.v3.oas.annotations.responses.ApiResponse(responseCode = "Report_2012", description = "내신 성적 등록이 완료되었습니다."),
})
public ApiResponse<ReportResponseDto> createReportScoreLists(
@PathVariable Long reportId,
@RequestBody ReportRequestDto.ReportScoreRequestDto reportScoreRequestDto
) {

ReportResponseDto responseDto = reportService.addReportScoreToReport(reportId, reportScoreRequestDto);
return ApiResponse.onSuccess(SuccessCode.REPORTSCORE_CREATE_SUCCESS, responseDto);
}
// @PostMapping("/{reportId}")
// @Operation(summary = "내신 점수 등록", description = "어떤 내신의 특정 과목 성적을 입력하는 메서드입니다..")
// @ApiResponses({
// @io.swagger.v3.oas.annotations.responses.ApiResponse(responseCode = "Report_2012", description = "내신 성적 등록이 완료되었습니다."),
// })
// public ApiResponse<ReportResponseDto> createReportScoreLists(
// @PathVariable Long reportId,
// @RequestBody ReportRequestDto.ReportScoreRequestDto reportScoreRequestDto
// ) {
//
// ReportResponseDto responseDto = reportService.addReportScoreToReport(reportId, reportScoreRequestDto);
// return ApiResponse.onSuccess(SuccessCode.REPORTSCORE_CREATE_SUCCESS, responseDto);
// }

@GetMapping
@Operation(summary = "전체 내신 조회", description = "사용자가 진행했던 모든 내신를 조회하는 메서드입니다.")
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
package hackerthon.likelion13th.canfly.grades.dto;

import io.swagger.v3.oas.annotations.media.Schema;
import lombok.*;

import java.math.BigDecimal;
import java.util.List;

Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
package hackerthon.likelion13th.canfly.grades.dto;

import hackerthon.likelion13th.canfly.domain.entity.CategoryName;
import lombok.*;

import java.math.BigDecimal;
Expand All @@ -14,7 +13,7 @@
public class ReportRequestDto {
private Integer userGrade;
private Integer term;
private CategoryName categoryName;
private Integer categoryName;
private BigDecimal categoryGrade;
private List<ReportScoreRequestDto> scoreLists;

Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
package hackerthon.likelion13th.canfly.grades.dto;

import hackerthon.likelion13th.canfly.domain.entity.CategoryName;
import hackerthon.likelion13th.canfly.domain.report.Report;
import hackerthon.likelion13th.canfly.domain.report.ReportScore;
import lombok.*;
Expand All @@ -19,7 +18,7 @@ public class ReportResponseDto {
private Long id;
private Integer userGrade;
private Integer term;
private CategoryName categoryName;
private Integer categoryName;
private BigDecimal categoryGrade;
private List<ReportScoreResponseDto> scoreList = new ArrayList<>();

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -71,25 +71,25 @@ public MockResponseDto createMock(String userId, MockRequestDto mockRequestDto)

return new MockResponseDto(newMock);
}

@Transactional
public MockResponseDto addMockScoreToMock(Long mockId, MockRequestDto.MockScoreRequestDto scoreRequestDto) {
Mock mock = mockRepository.findById(mockId)
.orElseThrow(() -> new IllegalArgumentException("Mock not found with id: " + mockId));

// DTO 필드에서 MockScore 엔티티 직접 생성
MockScore newMockScore = MockScore.builder()
.standardScore(scoreRequestDto.getStandardScore())
.percentile(scoreRequestDto.getPercentile())
.grade(scoreRequestDto.getGrade())
.cumulative(scoreRequestDto.getCumulative())
.category(scoreRequestDto.getCategory())
.name(scoreRequestDto.getName())
.build();
mock.addMockScore(newMockScore); // Mock 엔티티에 MockScore 추가 (양방향 관계 설정)
mockScoreRepository.save(newMockScore);
return new MockResponseDto(mock);
}
// 사용하지 않는 관계로 주석 처리
// @Transactional
// public MockResponseDto addMockScoreToMock(Long mockId, MockRequestDto.MockScoreRequestDto scoreRequestDto) {
// Mock mock = mockRepository.findById(mockId)
// .orElseThrow(() -> new IllegalArgumentException("Mock not found with id: " + mockId));
//
// // DTO 필드에서 MockScore 엔티티 직접 생성
// MockScore newMockScore = MockScore.builder()
// .standardScore(scoreRequestDto.getStandardScore())
// .percentile(scoreRequestDto.getPercentile())
// .grade(scoreRequestDto.getGrade())
// .cumulative(scoreRequestDto.getCumulative())
// .category(scoreRequestDto.getCategory())
// .name(scoreRequestDto.getName())
// .build();
// mock.addMockScore(newMockScore); // Mock 엔티티에 MockScore 추가 (양방향 관계 설정)
// mockScoreRepository.save(newMockScore);
// return new MockResponseDto(mock);
// }

@Transactional(readOnly = true)
public MockResponseDto getMockById(Long mockId) {
Expand Down Expand Up @@ -124,17 +124,6 @@ public MockResponseDto.MockScoreResponseDto getMockScoreById(Long mockId, Long s
return new MockResponseDto.MockScoreResponseDto(mockScore);
}

@Transactional
public MockResponseDto updateMock(Long mockId, MockRequestDto mockRequestDto) {
Mock existingMock = mockRepository.findById(mockId)
.orElseThrow(() -> new IllegalArgumentException("Mock not found with id: " + mockId));
existingMock.setExamYear(mockRequestDto.getExamYear());
existingMock.setExamMonth(mockRequestDto.getExamMonth());
existingMock.setExamGrade(mockRequestDto.getExamGrade());
Mock updatedMock = mockRepository.save(existingMock);
return convertToDto(updatedMock);
}

@Transactional
public MockResponseDto.MockScoreResponseDto updateMockScore(Long mockScoreId, MockRequestDto.MockScoreRequestDto scoreRequestDto) {
MockScore existingMockScore = mockScoreRepository.findById(mockScoreId)
Expand All @@ -149,6 +138,22 @@ public MockResponseDto.MockScoreResponseDto updateMockScore(Long mockScoreId, Mo
return convertToDto(updatedMockScore);
}

// if (mockRequestDto.getScoreLists() != null && !mockRequestDto.getScoreLists().isEmpty()) {
// for (MockRequestDto.MockScoreRequestDto scoreDto : mockRequestDto.getScoreLists()) {
// MockScore mockScore = MockScore.builder()
// .standardScore(scoreDto.getStandardScore())
// .percentile(scoreDto.getPercentile())
// .grade(scoreDto.getGrade())
// .cumulative(scoreDto.getCumulative())
// .category(scoreDto.getCategory())
// .name(scoreDto.getName())
// .build();
// newMock.addMockScore(mockScore);
// }
// }
// user.addMock(newMock);
// mockRepository.save(newMock);

@Transactional
public void deleteMock(Long mockId) {
mockRepository.deleteById(mockId);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -147,8 +147,6 @@ public ReportResponseDto updateReport(Long reportId, ReportRequestDto reportRequ
Report existingReport = reportRepository.findById(reportId)
.orElseThrow(() -> new IllegalArgumentException("Report not found with id: " + reportId));
existingReport.setCategoryName(reportRequestDto.getCategoryName());
existingReport.setTerm(reportRequestDto.getTerm());
existingReport.setUserGrade(reportRequestDto.getUserGrade());
Report updatedReport = reportRepository.save(existingReport);
return convertToDto(updatedReport);
}
Expand Down
Loading