enhance crud jenis pengadaan

This commit is contained in:
dirgantarasiahaan
2023-05-25 00:46:50 +07:00
parent 28f17d5b54
commit f96c8d2f17
12 changed files with 340 additions and 53 deletions

View File

@@ -0,0 +1,30 @@
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 org.springframework.stereotype.Service;
@Service
public class PutUpdateJenisPengadaanService implements BaseService<JenisPengadaanRequest, JenisPengadaanResponse> {
private JenisPengadaanRepository jenisPengadaanRepository;
public PutUpdateJenisPengadaanService(JenisPengadaanRepository jenisPengadaanRepository) {
this.jenisPengadaanRepository = jenisPengadaanRepository;
}
@Override
public JenisPengadaanResponse execute(JenisPengadaanRequest input) {
var jenisPengadaan = jenisPengadaanRepository.findByIdAndIsDeleteFalse(input.getId())
.orElseThrow(() -> new BusinessException("err", "err", "err"));
jenisPengadaan.setJenisPengadaan(input.getJenisPengadaan());
jenisPengadaan.setKeterangan(input.getKeterangan());
jenisPengadaan.setIsActive(input.getIsActive());
jenisPengadaanRepository.save(jenisPengadaan);
return JenisPengadaanResponse.builder()
.id(jenisPengadaan.getId())
.build();
}
}