38 lines
1.6 KiB
Java
38 lines
1.6 KiB
Java
package com.iconplus.smartproc.service.jenispengadaan;
|
|
|
|
import com.iconplus.smartproc.exception.BusinessException;
|
|
import com.iconplus.smartproc.helper.service.BaseService;
|
|
import com.iconplus.smartproc.model.request.JenisPengadaanRequest;
|
|
import com.iconplus.smartproc.model.response.JenisPengadaanResponse;
|
|
import com.iconplus.smartproc.repository.JenisPengadaanRepository;
|
|
import com.iconplus.smartproc.util.Constants;
|
|
import org.springframework.http.HttpStatus;
|
|
import org.springframework.stereotype.Service;
|
|
|
|
@Service
|
|
public class GetJenisPengadaanService implements BaseService<JenisPengadaanRequest, JenisPengadaanResponse> {
|
|
|
|
private JenisPengadaanRepository jenisPengadaanRepository;
|
|
public GetJenisPengadaanService(JenisPengadaanRepository jenisPengadaanRepository) {
|
|
this.jenisPengadaanRepository = jenisPengadaanRepository;
|
|
}
|
|
|
|
@Override
|
|
public JenisPengadaanResponse execute(JenisPengadaanRequest input) {
|
|
|
|
var jenisPengadaan = jenisPengadaanRepository.findByIdAndIsDeleteFalse(input.getId())
|
|
.orElseThrow(() -> new BusinessException(HttpStatus.CONFLICT,
|
|
Constants.ERR_CODE_10001,
|
|
Constants.ERR_TTL_10001,
|
|
String.format(Constants.ERR_MSG_10001, "Jenis Pengadaan", input.getId())));
|
|
|
|
return JenisPengadaanResponse.builder()
|
|
.id(jenisPengadaan.getId())
|
|
.jenisPengadaan(jenisPengadaan.getJenisPengadaan())
|
|
.keterangan(jenisPengadaan.getKeterangan())
|
|
.isActive(jenisPengadaan.getIsActive())
|
|
.isDelete(jenisPengadaan.getIsDelete())
|
|
.build();
|
|
}
|
|
}
|