Update SlipGajiService
Pembuatan service delete komponen slip gaji sebelum unggah excel
This commit is contained in:
parent
3c46431352
commit
30ac291c02
@ -20,4 +20,7 @@ public interface SlipGajiKomponenDao extends JpaRepository<SlipGajiKomponen, Str
|
||||
+ "where sgk.slipGaji.pegawai.id = :pegawaiId " + "and sgk.slipGaji.bulan between :start and :end")
|
||||
List<Map<String, Object>> findAll(@Param("pegawaiId") Integer pegawaiId, @Param("start") Date start,
|
||||
@Param("end") Date end);
|
||||
|
||||
@Query("select sgk from SlipGajiKomponen sgk where sgk.slipGaji.id in (:listId)")
|
||||
List<SlipGajiKomponen> findBySlipId(@Param("listId") List<String> listId);
|
||||
}
|
||||
|
||||
@ -15,6 +15,8 @@ public interface SlipGajiService {
|
||||
void save(SlipGajiDto dto);
|
||||
|
||||
void save(List<SlipGajiDto> dtoList);
|
||||
|
||||
void delete(List<SlipGajiDto> dtoList);
|
||||
|
||||
void updateDetail(SlipGajiDto dto);
|
||||
|
||||
|
||||
@ -191,6 +191,13 @@ public class SlipGajiServiceImpl implements SlipGajiService {
|
||||
});
|
||||
}
|
||||
|
||||
@Override
|
||||
public void delete(List<SlipGajiDto> dtoList) {
|
||||
List<String> listIdSlip = dtoList.stream().map(m -> m.getId()).collect(Collectors.toList());
|
||||
List<SlipGajiKomponen> slipGajiKomponen = slipGajiKomponenDao.findBySlipId(listIdSlip);
|
||||
slipGajiKomponenDao.delete(slipGajiKomponen);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void updateDetail(SlipGajiDto dto) {
|
||||
{
|
||||
|
||||
@ -59,6 +59,7 @@ public class SlipGajiController {
|
||||
@RequestMapping(value = "/unggah", method = RequestMethod.POST, produces = MediaType.APPLICATION_JSON_VALUE, consumes = MediaType.APPLICATION_JSON_VALUE)
|
||||
public ResponseEntity<Object> save(@RequestBody @Valid List<SlipGajiDto> dtoList) {
|
||||
try {
|
||||
slipGajiService.delete(dtoList);
|
||||
slipGajiService.save(dtoList);
|
||||
return new ResponseEntity<>(true, HttpStatus.CREATED);
|
||||
} catch (Exception e) {
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user