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,112 @@
package com.example.questionbank.service;
import com.example.questionbank.domain.Choice;
import com.example.questionbank.repository.ChoiceRepository;
import com.example.questionbank.service.dto.ChoiceDTO;
import com.example.questionbank.service.mapper.ChoiceMapper;
import java.util.LinkedList;
import java.util.List;
import java.util.Optional;
import java.util.stream.Collectors;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
/**
* Service Implementation for managing {@link com.example.questionbank.domain.Choice}.
*/
@Service
@Transactional
public class ChoiceService {
private static final Logger LOG = LoggerFactory.getLogger(ChoiceService.class);
private final ChoiceRepository choiceRepository;
private final ChoiceMapper choiceMapper;
public ChoiceService(ChoiceRepository choiceRepository, ChoiceMapper choiceMapper) {
this.choiceRepository = choiceRepository;
this.choiceMapper = choiceMapper;
}
/**
* Save a choice.
*
* @param choiceDTO the entity to save.
* @return the persisted entity.
*/
public ChoiceDTO save(ChoiceDTO choiceDTO) {
LOG.debug("Request to save Choice : {}", choiceDTO);
Choice choice = choiceMapper.toEntity(choiceDTO);
choice = choiceRepository.save(choice);
return choiceMapper.toDto(choice);
}
/**
* Update a choice.
*
* @param choiceDTO the entity to save.
* @return the persisted entity.
*/
public ChoiceDTO update(ChoiceDTO choiceDTO) {
LOG.debug("Request to update Choice : {}", choiceDTO);
Choice choice = choiceMapper.toEntity(choiceDTO);
choice = choiceRepository.save(choice);
return choiceMapper.toDto(choice);
}
/**
* Partially update a choice.
*
* @param choiceDTO the entity to update partially.
* @return the persisted entity.
*/
public Optional<ChoiceDTO> partialUpdate(ChoiceDTO choiceDTO) {
LOG.debug("Request to partially update Choice : {}", choiceDTO);
return choiceRepository
.findById(choiceDTO.getId())
.map(existingChoice -> {
choiceMapper.partialUpdate(existingChoice, choiceDTO);
return existingChoice;
})
.map(choiceRepository::save)
.map(choiceMapper::toDto);
}
/**
* Get all the choices.
*
* @return the list of entities.
*/
@Transactional(readOnly = true)
public List<ChoiceDTO> findAll() {
LOG.debug("Request to get all Choices");
return choiceRepository.findAll().stream().map(choiceMapper::toDto).collect(Collectors.toCollection(LinkedList::new));
}
/**
* Get one choice by id.
*
* @param id the id of the entity.
* @return the entity.
*/
@Transactional(readOnly = true)
public Optional<ChoiceDTO> findOne(Long id) {
LOG.debug("Request to get Choice : {}", id);
return choiceRepository.findById(id).map(choiceMapper::toDto);
}
/**
* Delete the choice by id.
*
* @param id the id of the entity.
*/
public void delete(Long id) {
LOG.debug("Request to delete Choice : {}", id);
choiceRepository.deleteById(id);
}
}