Generate question bank domain model from JDL

This commit is contained in:
jieun committed 2026-10-20 18:46:29 +09:00
1 parent 1d97cc4e31
commit 1d74d8f04b
160 files changed
+26900 -2

No files matched your search

@@ -0,0 +1,21 @@
package com.example.questionbank.service.mapper;
import com.example.questionbank.domain.Choice;
import com.example.questionbank.domain.Question;
import com.example.questionbank.service.dto.ChoiceDTO;
import com.example.questionbank.service.dto.QuestionDTO;
import org.mapstruct.*;
/**
* Mapper for the entity {@link Choice} and its DTO {@link ChoiceDTO}.
*/
@Mapper(componentModel = "spring")
public interface ChoiceMapper extends EntityMapper<ChoiceDTO, Choice> {
@Mapping(target = "question", source = "question", qualifiedByName = "questionId")
ChoiceDTO toDto(Choice s);
@Named("questionId")
@BeanMapping(ignoreByDefault = true)
@Mapping(target = "id", source = "id")
QuestionDTO toDtoQuestionId(Question question);
}
@@ -0,0 +1,28 @@
package com.example.questionbank.service.mapper;
import java.util.List;
import org.mapstruct.BeanMapping;
import org.mapstruct.MappingTarget;
import org.mapstruct.Named;
import org.mapstruct.NullValuePropertyMappingStrategy;
/**
* Contract for a generic dto to entity mapper.
*
* @param <D> - DTO type parameter.
* @param <E> - Entity type parameter.
*/
public interface EntityMapper<D, E> {
E toEntity(D dto);
D toDto(E entity);
List<E> toEntity(List<D> dtoList);
List<D> toDto(List<E> entityList);
@Named("partialUpdate")
@BeanMapping(nullValuePropertyMappingStrategy = NullValuePropertyMappingStrategy.IGNORE)
void partialUpdate(@MappingTarget E entity, D dto);
}
@@ -0,0 +1,29 @@
package com.example.questionbank.service.mapper;
import com.example.questionbank.domain.ExamAnswer;
import com.example.questionbank.domain.ExamAttempt;
import com.example.questionbank.domain.Question;
import com.example.questionbank.service.dto.ExamAnswerDTO;
import com.example.questionbank.service.dto.ExamAttemptDTO;
import com.example.questionbank.service.dto.QuestionDTO;
import org.mapstruct.*;
/**
* Mapper for the entity {@link ExamAnswer} and its DTO {@link ExamAnswerDTO}.
*/
@Mapper(componentModel = "spring")
public interface ExamAnswerMapper extends EntityMapper<ExamAnswerDTO, ExamAnswer> {
@Mapping(target = "question", source = "question", qualifiedByName = "questionId")
@Mapping(target = "attempt", source = "attempt", qualifiedByName = "examAttemptId")
ExamAnswerDTO toDto(ExamAnswer s);
@Named("questionId")
@BeanMapping(ignoreByDefault = true)
@Mapping(target = "id", source = "id")
QuestionDTO toDtoQuestionId(Question question);
@Named("examAttemptId")
@BeanMapping(ignoreByDefault = true)
@Mapping(target = "id", source = "id")
ExamAttemptDTO toDtoExamAttemptId(ExamAttempt examAttempt);
}
@@ -0,0 +1,31 @@
package com.example.questionbank.service.mapper;
import com.example.questionbank.domain.ExamAttempt;
import com.example.questionbank.domain.Subject;
import com.example.questionbank.domain.User;
import com.example.questionbank.service.dto.ExamAttemptDTO;
import com.example.questionbank.service.dto.SubjectDTO;
import com.example.questionbank.service.dto.UserDTO;
import org.mapstruct.*;
/**
* Mapper for the entity {@link ExamAttempt} and its DTO {@link ExamAttemptDTO}.
*/
@Mapper(componentModel = "spring")
public interface ExamAttemptMapper extends EntityMapper<ExamAttemptDTO, ExamAttempt> {
@Mapping(target = "subject", source = "subject", qualifiedByName = "subjectName")
@Mapping(target = "user", source = "user", qualifiedByName = "userLogin")
ExamAttemptDTO toDto(ExamAttempt s);
@Named("subjectName")
@BeanMapping(ignoreByDefault = true)
@Mapping(target = "id", source = "id")
@Mapping(target = "name", source = "name")
SubjectDTO toDtoSubjectName(Subject subject);
@Named("userLogin")
@BeanMapping(ignoreByDefault = true)
@Mapping(target = "id", source = "id")
@Mapping(target = "login", source = "login")
UserDTO toDtoUserLogin(User user);
}
@@ -0,0 +1,22 @@
package com.example.questionbank.service.mapper;
import com.example.questionbank.domain.Question;
import com.example.questionbank.domain.Subject;
import com.example.questionbank.service.dto.QuestionDTO;
import com.example.questionbank.service.dto.SubjectDTO;
import org.mapstruct.*;
/**
* Mapper for the entity {@link Question} and its DTO {@link QuestionDTO}.
*/
@Mapper(componentModel = "spring")
public interface QuestionMapper extends EntityMapper<QuestionDTO, Question> {
@Mapping(target = "subject", source = "subject", qualifiedByName = "subjectName")
QuestionDTO toDto(Question s);
@Named("subjectName")
@BeanMapping(ignoreByDefault = true)
@Mapping(target = "id", source = "id")
@Mapping(target = "name", source = "name")
SubjectDTO toDtoSubjectName(Subject subject);
}
@@ -0,0 +1,11 @@
package com.example.questionbank.service.mapper;
import com.example.questionbank.domain.Subject;
import com.example.questionbank.service.dto.SubjectDTO;
import org.mapstruct.*;
/**
* Mapper for the entity {@link Subject} and its DTO {@link SubjectDTO}.
*/
@Mapper(componentModel = "spring")
public interface SubjectMapper extends EntityMapper<SubjectDTO, Subject> {}