add crud jabatan

This commit is contained in:
dirgantarasiahaan
2023-05-26 16:36:02 +07:00
parent fe72608465
commit 00dd061bac
12 changed files with 469 additions and 0 deletions

View File

@@ -0,0 +1,41 @@
package com.iconplus.smartproc.service.jabatan;
import com.iconplus.smartproc.exception.BusinessException;
import com.iconplus.smartproc.helper.service.BaseService;
import com.iconplus.smartproc.model.entity.Jabatan;
import com.iconplus.smartproc.model.request.JabatanRequest;
import com.iconplus.smartproc.model.response.JabatanResponse;
import com.iconplus.smartproc.repository.JabatanRepository;
import org.springframework.stereotype.Service;
@Service
public class PostCreateJabatanService implements BaseService<JabatanRequest, JabatanResponse> {
private JabatanRepository jabatanRepository;
public PostCreateJabatanService(JabatanRepository jabatanRepository) {
this.jabatanRepository = jabatanRepository;
}
@Override
public JabatanResponse execute(JabatanRequest input) {
var jabatan = jabatanRepository.findByJabatanAndIsDeleteFalse(input.getJabatan());
if (jabatan.isPresent()) {
throw new BusinessException("err", "err", "err");
}
Jabatan jabatanEntity = Jabatan.builder()
.jabatan(input.getJabatan())
.keterangan(input.getKeterangan())
.instansiId(input.getInstansiId())
.bidangId(input.getBidangId())
.isActive(input.getIsActive())
.isDelete(false)
.build();
var result = jabatanRepository.save(jabatanEntity);
return JabatanResponse.builder()
.id(result.getId())
.build();
}
}