add master data api

This commit is contained in:
dirgantarasiahaan
2023-05-26 10:39:31 +07:00
parent c573eb2fb3
commit fe72608465
67 changed files with 2376 additions and 307 deletions

View File

@@ -0,0 +1,40 @@
package com.iconplus.smartproc.service.metodepengadaan;
import com.iconplus.smartproc.exception.BusinessException;
import com.iconplus.smartproc.helper.service.BaseService;
import com.iconplus.smartproc.model.request.MetodePengadaanRequest;
import com.iconplus.smartproc.model.response.MetodePengadaanResponse;
import com.iconplus.smartproc.repository.MetodePengadaanRepository;
import com.iconplus.smartproc.util.Constants;
import org.springframework.http.HttpStatus;
import org.springframework.stereotype.Service;
@Service
public class GetMetodePengadaanByIdService implements BaseService<MetodePengadaanRequest, MetodePengadaanResponse> {
private final MetodePengadaanRepository metodePengadaanRepository;
public GetMetodePengadaanByIdService(MetodePengadaanRepository metodePengadaanRepository) {
this.metodePengadaanRepository = metodePengadaanRepository;
}
@Override
public MetodePengadaanResponse execute(MetodePengadaanRequest input) {
var metodePengadaanView = metodePengadaanRepository.findByIdAndIsDeleteFalse(input.getId());
if (metodePengadaanView.isEmpty()) {
throw new BusinessException(HttpStatus.CONFLICT,
Constants.ERR_CODE_10001,
Constants.ERR_TTL_10001,
String.format(Constants.ERR_MSG_10001, input.getId()));
}
return MetodePengadaanResponse.builder()
.id(metodePengadaanView.get().getId())
.metodePengadaan(metodePengadaanView.get().getMetodePengadaan())
.keterangan(metodePengadaanView.get().getKeterangan())
.isActive(metodePengadaanView.get().getIsActive())
.isDelete(metodePengadaanView.get().getIsDelete())
.build();
}
}