Update SdmController.java

Pembuatan Rest API untuk simpan, update, dan delete MapJabatanProfesi, view Daftar Profesi berdasarkan id pegawai login
This commit is contained in:
Salman Manoe 2022-01-03 10:38:37 +07:00
parent 7f69cecc77
commit c924fb8fd5

View File

@ -105,6 +105,7 @@ import com.jasamedika.medifirst2000.service.PermohonanCutiPegawaiService;
import com.jasamedika.medifirst2000.service.PermohonanStatusPegawaiService;
import com.jasamedika.medifirst2000.service.PernelitianEksternalService;
import com.jasamedika.medifirst2000.service.PosisiLamaranService;
import com.jasamedika.medifirst2000.service.ProfesiService;
import com.jasamedika.medifirst2000.service.ProgramPendidikanService;
import com.jasamedika.medifirst2000.service.ProgramPengajaranService;
import com.jasamedika.medifirst2000.service.RangeKmkService;
@ -423,6 +424,9 @@ public class SdmController extends LocaleController<AkunVO> {
@Autowired
private MapJabatanProfesiService mapJabatanProfesiService;
@Autowired
private ProfesiService profesiService;
@RequestMapping(value = "/save-custom-uraian-kerja", method = RequestMethod.POST, produces = MediaType.APPLICATION_JSON_VALUE, consumes = MediaType.APPLICATION_JSON_VALUE)
public ResponseEntity<Map<String, Object>> saveBerkasLamaran(@Valid @RequestBody CustomIndexKerjaVO vo,
HttpServletRequest request) throws ParseException {
@ -5936,6 +5940,55 @@ public class SdmController extends LocaleController<AkunVO> {
}
}
@RequestMapping(value = "/save-map-jabatan-profesi", method = RequestMethod.POST, produces = MediaType.APPLICATION_JSON_VALUE, consumes = MediaType.APPLICATION_JSON_VALUE)
public ResponseEntity<MapJabatanProfesiVO> saveMapJabatanProfesi(HttpServletRequest request,
@Valid @RequestBody MapJabatanProfesiVO vo) {
try {
MapJabatanProfesiVO result = new MapJabatanProfesiVO();
if (CommonUtil.isNotNullOrEmpty(vo.getId())) {
result = mapJabatanProfesiService.update(vo);
} else {
result = mapJabatanProfesiService.add(vo);
}
if (CommonUtil.isNotNullOrEmpty(result)) {
mapHeaderMessage.put(WebConstants.HttpHeaderInfo.LABEL_SUCCESS,
getMessage(MessageResource.LABEL_SUCCESS, request));
return RestUtil.getJsonResponse(result, HttpStatus.CREATED, mapHeaderMessage);
} else {
mapHeaderMessage.put(WebConstants.HttpHeaderInfo.LABEL_ERROR,
getMessage(MessageResource.LABEL_ERROR, request));
return RestUtil.getJsonHttptatus(HttpStatus.BAD_REQUEST, mapHeaderMessage);
}
} catch (ServiceVOException sve) {
LOGGER.error("Got exception {} when add/update mapping jabatan ke profesi", sve.getMessage());
addHeaderMessage(Constants.MessageInfo.ERROR_MESSAGE, sve.getMessage());
return RestUtil.getJsonHttptatus(HttpStatus.INTERNAL_SERVER_ERROR, mapHeaderMessage);
} catch (JpaSystemException jse) {
LOGGER.error("Got exception {} when add/update mapping jabatan ke profesi", jse.getMessage());
addHeaderMessage(Constants.MessageInfo.ERROR_MESSAGE, jse.getMessage());
return RestUtil.getJsonHttptatus(HttpStatus.CONFLICT, mapHeaderMessage);
}
}
@RequestMapping(value = "/delete-map-jabatan-profesi", method = RequestMethod.POST)
public ResponseEntity<Boolean> deleteMapJabatanProfesi(HttpServletRequest request,
@RequestParam(value = "id", required = true) Integer id) {
try {
Boolean result = mapJabatanProfesiService.delete(id);
mapHeaderMessage.put(WebConstants.HttpHeaderInfo.LABEL_SUCCESS,
getMessage(MessageResource.LABEL_SUCCESS, request));
return RestUtil.getJsonResponse(result, HttpStatus.OK, mapHeaderMessage);
} catch (ServiceVOException sve) {
LOGGER.error("Got exception {} when delete mapping jabatan ke profesi", sve.getMessage());
addHeaderMessage(Constants.MessageInfo.ERROR_MESSAGE, sve.getMessage());
return RestUtil.getJsonHttptatus(HttpStatus.INTERNAL_SERVER_ERROR, mapHeaderMessage);
} catch (JpaSystemException jse) {
LOGGER.error("Got exception {} when delete mapping jabatan ke profesi", jse.getMessage());
addHeaderMessage(Constants.MessageInfo.ERROR_MESSAGE, jse.getMessage());
return RestUtil.getJsonHttptatus(HttpStatus.CONFLICT, mapHeaderMessage);
}
}
@RequestMapping(value = "/get-all-mapping-jabatan-profesi", method = RequestMethod.GET, produces = MediaType.APPLICATION_JSON_VALUE)
public ResponseEntity<List<Map<String, Object>>> getAllMappingProfesiJabatan(HttpServletRequest request) {
try {
@ -5955,4 +6008,25 @@ public class SdmController extends LocaleController<AkunVO> {
}
}
@RequestMapping(value = "/get-daftar-profesi", method = RequestMethod.GET, produces = MediaType.APPLICATION_JSON_VALUE)
public ResponseEntity<List<Map<String, Object>>> getDaftarProfesi(HttpServletRequest request,
@RequestParam(value = "pegawaiId", required = true) Integer idPegawai,
@RequestParam(value = "jenisId", required = false) Short idJenis) {
try {
List<Map<String, Object>> result = profesiService.findByStatus(idPegawai, idJenis);
if (null != result)
mapHeaderMessage.put(WebConstants.HttpHeaderInfo.LABEL_SUCCESS,
getMessage(MessageResource.LABEL_SUCCESS, request));
return RestUtil.getJsonResponse(result, HttpStatus.OK, mapHeaderMessage);
} catch (ServiceVOException e) {
LOGGER.error("Got exception {} when get daftar profesi", e.getMessage());
addHeaderMessage(Constants.MessageInfo.ERROR_MESSAGE, e.getMessage());
return RestUtil.getJsonHttptatus(HttpStatus.INTERNAL_SERVER_ERROR, mapHeaderMessage);
} catch (JpaSystemException jse) {
LOGGER.error("Got exception {} when get daftar profesi", jse.getMessage());
addHeaderMessage(Constants.MessageInfo.ERROR_MESSAGE, jse.getMessage());
return RestUtil.getJsonHttptatus(HttpStatus.CONFLICT, mapHeaderMessage);
}
}
}