refactor base smartproc
This commit is contained in:
@@ -0,0 +1,39 @@
|
||||
package com.iconplus.smartproc.service.jenisanggaran;
|
||||
|
||||
import com.iconplus.smartproc.exception.BusinessException;
|
||||
import com.iconplus.smartproc.helper.model.EmptyResponse;
|
||||
import com.iconplus.smartproc.helper.service.BaseService;
|
||||
import com.iconplus.smartproc.model.entity.JenisAnggaran;
|
||||
import com.iconplus.smartproc.model.request.JenisAnggaranRequest;
|
||||
import com.iconplus.smartproc.repository.JenisAnggaranRepository;
|
||||
import com.iconplus.smartproc.util.Constants;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.http.HttpStatus;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
@Service
|
||||
@Slf4j
|
||||
public class DeleteJenisAnggaranService implements BaseService<JenisAnggaranRequest, EmptyResponse> {
|
||||
|
||||
private JenisAnggaranRepository jenisAnggaranRepository;
|
||||
|
||||
public DeleteJenisAnggaranService(JenisAnggaranRepository jenisAnggaranRepository) {
|
||||
this.jenisAnggaranRepository = jenisAnggaranRepository;
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public EmptyResponse execute(JenisAnggaranRequest input) {
|
||||
|
||||
var jenisAnggaran = jenisAnggaranRepository.findByIdAndDeletedFalse(input.getId())
|
||||
.orElseThrow(() -> new BusinessException(HttpStatus.CONFLICT,
|
||||
Constants.ERR_CODE_10001,
|
||||
Constants.ERR_TTL_10001,
|
||||
String.format(Constants.ERR_MSG_10001, input.getId())));
|
||||
|
||||
jenisAnggaran.setDeleted(true);
|
||||
jenisAnggaranRepository.save(jenisAnggaran);
|
||||
log.info("success delete jenis anggaran id {}", jenisAnggaran.getDeleted());
|
||||
return new EmptyResponse();
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user