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
Original file line number Diff line number Diff line change
Expand Up @@ -37,8 +37,6 @@ public class QChildProblem extends EntityPathBase<ChildProblem> {

public final StringPath imageUrl = createString("imageUrl");

public final NumberPath<Integer> sequence = createNumber("sequence", Integer.class);

//inherited
public final DateTimePath<java.time.LocalDateTime> updatedDate = _super.updatedDate;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ public class QProblem extends EntityPathBase<Problem> {

public final ListPath<String, StringPath> prescriptionImageUrls = this.<String, StringPath>createList("prescriptionImageUrls", String.class, StringPath.class, PathInits.DIRECT2);

public final QProblemAdminId problemAdminId;
public final QProblemCustomId problemCustomId;

public final EnumPath<ProblemType> problemType = createEnum("problemType", ProblemType.class);

Expand Down Expand Up @@ -88,7 +88,7 @@ public QProblem(Class<? extends Problem> type, PathMetadata metadata, PathInits
super(type, metadata, inits);
this.answer = inits.isInitialized("answer") ? new com.moplus.moplus_server.domain.problem.domain.QAnswer(forProperty("answer")) : null;
this.difficulty = inits.isInitialized("difficulty") ? new QDifficulty(forProperty("difficulty")) : null;
this.problemAdminId = inits.isInitialized("problemAdminId") ? new QProblemAdminId(forProperty("problemAdminId")) : null;
this.problemCustomId = inits.isInitialized("problemCustomId") ? new QProblemCustomId(forProperty("problemCustomId")) : null;
this.title = inits.isInitialized("title") ? new QTitle(forProperty("title")) : null;
}

Expand Down

This file was deleted.

Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
package com.moplus.moplus_server.domain.problem.domain.problem;

import static com.querydsl.core.types.PathMetadataFactory.*;

import com.querydsl.core.types.dsl.*;

import com.querydsl.core.types.PathMetadata;
import javax.annotation.processing.Generated;
import com.querydsl.core.types.Path;


/**
* QProblemCustomId is a Querydsl query type for ProblemCustomId
*/
@Generated("com.querydsl.codegen.DefaultEmbeddableSerializer")
public class QProblemCustomId extends BeanPath<ProblemCustomId> {

private static final long serialVersionUID = -517009730L;

public static final QProblemCustomId problemCustomId = new QProblemCustomId("problemCustomId");

public final StringPath id = createString("id");

public QProblemCustomId(String variable) {
super(ProblemCustomId.class, forVariable(variable));
}

public QProblemCustomId(Path<? extends ProblemCustomId> path) {
super(path.getType(), path.getMetadata());
}

public QProblemCustomId(PathMetadata metadata) {
super(ProblemCustomId.class, metadata);
}

}

Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@

@Generated(
value = "org.mapstruct.ap.MappingProcessor",
date = "2025-02-12T02:55:03+0900",
date = "2025-02-18T17:01:34+0900",
comments = "version: 1.6.3, compiler: javac, environment: Java 17.0.10 (JetBrains s.r.o.)"
)
@Component
Expand All @@ -31,7 +31,6 @@ public ChildProblem from(ChildProblemPostRequest request) {
if ( set != null ) {
childProblem.conceptTagIds( new LinkedHashSet<Long>( set ) );
}
childProblem.sequence( request.sequence() );

return childProblem.build();
}
Expand All @@ -44,14 +43,14 @@ public ChildProblem from(ChildProblemUpdateRequest request) {

ChildProblem.ChildProblemBuilder childProblem = ChildProblem.builder();

childProblem.id( request.id() );
childProblem.imageUrl( request.imageUrl() );
childProblem.answerType( request.answerType() );
childProblem.answer( request.answer() );
Set<Long> set = request.conceptTagIds();
if ( set != null ) {
childProblem.conceptTagIds( new LinkedHashSet<Long>( set ) );
}
childProblem.sequence( request.sequence() );

return childProblem.build();
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

import com.moplus.moplus_server.domain.problem.domain.practiceTest.PracticeTestTag;
import com.moplus.moplus_server.domain.problem.domain.problem.Problem;
import com.moplus.moplus_server.domain.problem.domain.problem.ProblemAdminId;
import com.moplus.moplus_server.domain.problem.domain.problem.ProblemCustomId;
import com.moplus.moplus_server.domain.problem.dto.request.ProblemPostRequest;
import com.moplus.moplus_server.domain.problem.dto.request.ProblemUpdateRequest;
import java.util.ArrayList;
Expand All @@ -14,15 +14,15 @@

@Generated(
value = "org.mapstruct.ap.MappingProcessor",
date = "2025-02-13T19:05:39+0900",
date = "2025-02-18T15:29:27+0900",
comments = "version: 1.6.3, compiler: javac, environment: Java 17.0.10 (JetBrains s.r.o.)"
)
@Component
public class ProblemMapperImpl implements ProblemMapper {

@Override
public Problem from(ProblemPostRequest request, ProblemAdminId problemAdminId, PracticeTestTag practiceTestTag) {
if ( request == null && problemAdminId == null && practiceTestTag == null ) {
public Problem from(ProblemPostRequest request, ProblemCustomId problemCustomId, PracticeTestTag practiceTestTag) {
if ( request == null && problemCustomId == null && practiceTestTag == null ) {
return null;
}

Expand All @@ -32,15 +32,15 @@ public Problem from(ProblemPostRequest request, ProblemAdminId problemAdminId, P
problem.problemType( request.problemType() );
problem.number( request.number() );
}
problem.problemAdminId( problemAdminId );
problem.problemCustomId( problemCustomId );
problem.practiceTestTag( practiceTestTag );

return problem.build();
}

@Override
public Problem from(ProblemUpdateRequest request, ProblemAdminId problemAdminId, PracticeTestTag practiceTestTag) {
if ( request == null && problemAdminId == null && practiceTestTag == null ) {
public Problem from(ProblemUpdateRequest request, ProblemCustomId problemCustomId, PracticeTestTag practiceTestTag) {
if ( request == null && problemCustomId == null && practiceTestTag == null ) {
return null;
}

Expand Down Expand Up @@ -68,7 +68,7 @@ public Problem from(ProblemUpdateRequest request, ProblemAdminId problemAdminId,
problem.problemType( request.problemType() );
problem.number( request.number() );
}
problem.problemAdminId( problemAdminId );
problem.problemCustomId( problemCustomId );
problem.practiceTestTag( practiceTestTag );

return problem.build();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ public class QIncorrectProblem extends EntityPathBase<IncorrectProblem> {

public final NumberPath<Long> practiceTestId = createNumber("practiceTestId", Long.class);

public final NumberPath<Long> problemId = createNumber("problemId", Long.class);
public final NumberPath<Long> problemId = createNumber("problemCustomId", Long.class);

public final StringPath problemNumber = createString("problemNumber");

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ public class QProblemImageForTest extends EntityPathBase<ProblemImageForTest> {

public final StringPath imageUrl = createString("imageUrl");

public final NumberPath<Long> problemId = createNumber("problemId", Long.class);
public final NumberPath<Long> problemId = createNumber("problemCustomId", Long.class);

public QProblemImageForTest(String variable) {
super(ProblemImageForTest.class, forVariable(variable));
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
package com.moplus.moplus_server.domain.auth.dto.response;

import jakarta.validation.constraints.NotNull;

public record AccessTokenResponse(
String accessToken
) {}
@NotNull(message = "accessToken을 입력해주세요.")
String accessToken
) {
}
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
@RequiredArgsConstructor
public class ConceptTagController {

ConceptTagRepository conceptTagRepository;
private final ConceptTagRepository conceptTagRepository;

@GetMapping("")
@Operation(summary = "모든 개념 태그 리스트 조회")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,12 @@
import com.moplus.moplus_server.domain.problem.dto.request.ProblemPostRequest;
import com.moplus.moplus_server.domain.problem.dto.request.ProblemUpdateRequest;
import com.moplus.moplus_server.domain.problem.dto.response.ProblemGetResponse;
import com.moplus.moplus_server.domain.problem.service.ChildProblemService;
import com.moplus.moplus_server.domain.problem.service.ProblemDeleteService;
import com.moplus.moplus_server.domain.problem.service.ProblemGetService;
import com.moplus.moplus_server.domain.problem.service.ProblemSaveService;
import com.moplus.moplus_server.domain.problem.service.ProblemUpdateService;
import com.moplus.moplus_server.global.response.IdResponse;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.tags.Tag;
import jakarta.validation.Valid;
Expand All @@ -16,6 +18,7 @@
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
Expand All @@ -30,6 +33,7 @@ public class ProblemController {
private final ProblemUpdateService problemUpdateService;
private final ProblemGetService problemGetService;
private final ProblemDeleteService problemDeleteService;
private final ChildProblemService childProblemService;

@GetMapping("/{id}")
@Operation(summary = "문항 조회", description = "문항를 조회합니다.")
Expand All @@ -40,15 +44,15 @@ public ResponseEntity<ProblemGetResponse> getProblem(
}

@PostMapping("")
@Operation(summary = "문항 생성", description = "문제를 생성합니다. 새끼 문항은 list 순서대로 sequence를 저장합니다.")
public ResponseEntity<Long> createProblem(
@Operation(summary = "문항 생성", description = "문제를 생성합니다. 기출/변형 문제는 모든 값이 필수이며 창작 문제는 문항 타입만 필수 입니다.")
public ResponseEntity<IdResponse> createProblem(
@Valid @RequestBody ProblemPostRequest request
) {
return ResponseEntity.ok(problemSaveService.createProblem(request));
return ResponseEntity.ok(new IdResponse(problemSaveService.createProblem(request)));
}

@PostMapping("/{id}")
@Operation(summary = "문항 업데이트", description = "문제를 업데이트합니다. 문항 번호, 모의고사는 수정할 수 없습니다. 새로 추가되는 새끼문항 id는 빈 값입니다.")
@PutMapping("/{id}")
@Operation(summary = "문항 업데이트", description = "문제를 업데이트합니다. 새끼문항은 들어온 list의 순서로 저장됩니다.")
public ResponseEntity<ProblemGetResponse> updateProblem(
@PathVariable("id") Long id,
@RequestBody ProblemUpdateRequest request
Expand All @@ -64,4 +68,22 @@ public ResponseEntity<Void> updateProblem(
problemDeleteService.deleteProblem(id);
return ResponseEntity.ok().body(null);
}

@PostMapping("/{problemId}/child-problems")
@Operation(summary = "새끼문항 추가", description = "추가되는 새끼 문항의 id를 반환합니다. 컨펌 이후에는 새끼 문항 추가가 불가능합니다.")
public ResponseEntity<IdResponse> createChildProblem(
@PathVariable("problemId") Long problemId
) {
return ResponseEntity.ok(new IdResponse(childProblemService.createChildProblem(problemId)));
}

@DeleteMapping("/{problemId}/child-problems/{childProblemId}")
@Operation(summary = "새끼 문항 삭제", description = "컨펌 이후에는 새끼 문항 삭제가 불가능합니다.")
public ResponseEntity<Void> deleteChildProblem(
@PathVariable("problemId") Long problemId,
@PathVariable("childProblemId") Long childProblemId
) {
childProblemService.deleteChildProblem(problemId, childProblemId);
return ResponseEntity.ok().body(null);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -26,11 +26,12 @@ public class ProblemSearchController {
description = "문항 ID, 문제명, 개념 태그리스트로 문제를 검색합니다. 개념 태그리스트는 OR 조건으로 검색하며 값이 없으면 쿼리파라미터에서 빼주세요"
)
public ResponseEntity<List<ProblemSearchGetResponse>> search(
@RequestParam(value = "problemId", required = false) String problemId,
@RequestParam(value = "problemCustomId", required = false) String problemCustomId,
@RequestParam(value = "comment", required = false) String comment,
@RequestParam(value = "conceptTagIds", required = false) List<Long> conceptTagIds
) {
List<ProblemSearchGetResponse> problems = problemSearchRepository.search(problemId, comment, conceptTagIds);
List<ProblemSearchGetResponse> problems = problemSearchRepository.search(problemCustomId, comment,
conceptTagIds);
return ResponseEntity.ok(problems);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -40,17 +40,24 @@ public class ChildProblem extends BaseEntity {
private Answer answer;
@Enumerated(EnumType.STRING)
private AnswerType answerType;
private int sequence;

@Builder
public ChildProblem(String imageUrl, AnswerType answerType, String answer, Set<Long> conceptTagIds,
int sequence) {
public ChildProblem(Long id, String imageUrl, AnswerType answerType, String answer, Set<Long> conceptTagIds) {
this.id = id;
validateAnswerByType(answer, answerType);
this.imageUrl = imageUrl;
this.answerType = answerType;
this.answer = new Answer(answer, answerType);
this.conceptTagIds = conceptTagIds;
this.sequence = sequence;
}

public static ChildProblem createEmptyChildProblem() {
return ChildProblem.builder()
.imageUrl("")
.answerType(AnswerType.SHORT_STRING_ANSWER)
.answer("")
.conceptTagIds(Set.of())
.build();
}

public void validateAnswerByType(String answer, AnswerType answerType) {
Expand All @@ -62,11 +69,13 @@ public void validateAnswerByType(String answer, AnswerType answerType) {
}

public void update(ChildProblem input) {
if (this.id != input.id) {
throw new InvalidValueException(ErrorCode.INVALID_CHILD_PROBLEM_SEQUENCE);
}
this.imageUrl = input.imageUrl;
this.answerType = input.answerType;
this.answer = input.answer;
this.conceptTagIds = input.conceptTagIds;
this.sequence = input.sequence;
}

public String getAnswer() {
Expand Down
Loading