Update controller

Clean code
This commit is contained in:
Salman Manoe 2024-12-24 14:15:46 +07:00
parent 3e4c001ae8
commit 71a48a7dfe
22 changed files with 863 additions and 2005 deletions

View File

@ -1,59 +1,54 @@
package com.jasamedika.medifirst2000.controller; package com.jasamedika.medifirst2000.controller;
import java.util.List;
import java.util.Map;
import javax.servlet.http.HttpServletRequest;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.HttpStatus;
import org.springframework.http.MediaType;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RestController;
import com.jasamedika.medifirst2000.constants.MessageResource; import com.jasamedika.medifirst2000.constants.MessageResource;
import com.jasamedika.medifirst2000.controller.base.LocaleController; import com.jasamedika.medifirst2000.controller.base.LocaleController;
import com.jasamedika.medifirst2000.core.web.WebConstants;
import com.jasamedika.medifirst2000.dto.MapJenisDietToProdukDto; import com.jasamedika.medifirst2000.dto.MapJenisDietToProdukDto;
import com.jasamedika.medifirst2000.service.MapJenisDietToProdukService; import com.jasamedika.medifirst2000.service.MapJenisDietToProdukService;
import com.jasamedika.medifirst2000.util.rest.RestUtil; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import javax.servlet.http.HttpServletRequest;
import java.util.List;
import java.util.Map;
import static com.jasamedika.medifirst2000.core.web.WebConstants.HttpHeaderInfo.LABEL_SUCCESS;
import static com.jasamedika.medifirst2000.util.rest.RestUtil.getJsonHttpStatus;
import static com.jasamedika.medifirst2000.util.rest.RestUtil.getJsonResponse;
import static org.springframework.http.HttpStatus.INTERNAL_SERVER_ERROR;
import static org.springframework.http.HttpStatus.OK;
import static org.springframework.http.MediaType.APPLICATION_JSON_VALUE;
import static org.springframework.web.bind.annotation.RequestMethod.GET;
import static org.springframework.web.bind.annotation.RequestMethod.POST;
@RestController @RestController
@RequestMapping("/map-jenis-diet-to-produk") @RequestMapping("/map-jenis-diet-to-produk")
public class MapJenisDietToProdukController extends LocaleController{ public class MapJenisDietToProdukController extends LocaleController<MapJenisDietToProdukDto> {
@Autowired @Autowired
private MapJenisDietToProdukService mapJenisDietToProdukService; private MapJenisDietToProdukService mapJenisDietToProdukService;
@RequestMapping(value="/get/", @RequestMapping(value = "/get/", method = GET, produces = APPLICATION_JSON_VALUE)
method=RequestMethod.GET,
produces=MediaType.APPLICATION_JSON_VALUE)
public Map<String, Object> get(HttpServletRequest request) { public Map<String, Object> get(HttpServletRequest request) {
Map<String, Object> result = this.mapJenisDietToProdukService.getMapJenisDietToProduk(); return this.mapJenisDietToProdukService.getMapJenisDietToProduk();
return result;
} }
@RequestMapping(value="/save/", @RequestMapping(value = "/save/", method = POST, produces = APPLICATION_JSON_VALUE)
method = RequestMethod.POST, public ResponseEntity<List<Map<String, Object>>> save(@RequestBody List<MapJenisDietToProdukDto> dtos,
produces = MediaType.APPLICATION_JSON_VALUE) HttpServletRequest request) {
public ResponseEntity<List<Map<String, Object>>> save(
@RequestBody List<MapJenisDietToProdukDto> dtos, HttpServletRequest request){
List<Map<String, Object>> result = this.mapJenisDietToProdukService.saveMapJenisDietToProduk(dtos); List<Map<String, Object>> result = this.mapJenisDietToProdukService.saveMapJenisDietToProduk(dtos);
if (!result.isEmpty()) { if (!result.isEmpty()) {
mapHeaderMessage.put(WebConstants.HttpHeaderInfo.LABEL_SUCCESS, getMessage(MessageResource.LABEL_SUCCESS, request)); mapHeaderMessage.put(LABEL_SUCCESS, getMessage(MessageResource.LABEL_SUCCESS, request));
return RestUtil.getJsonResponse(result, HttpStatus.OK, mapHeaderMessage); return getJsonResponse(result, OK, mapHeaderMessage);
} }
return RestUtil.getJsonHttpStatus(HttpStatus.INTERNAL_SERVER_ERROR, mapHeaderMessage); return getJsonHttpStatus(INTERNAL_SERVER_ERROR, mapHeaderMessage);
} }
@RequestMapping(value="/get-produk-gizi/", @RequestMapping(value = "/get-produk-gizi/", method = GET, produces = APPLICATION_JSON_VALUE)
method=RequestMethod.GET,
produces=MediaType.APPLICATION_JSON_VALUE)
public Map<String, Object> getProdukGizi(HttpServletRequest request) { public Map<String, Object> getProdukGizi(HttpServletRequest request) {
Map<String, Object> result = this.mapJenisDietToProdukService.getProdukGizi(); return this.mapJenisDietToProdukService.getProdukGizi();
return result;
} }
} }

View File

@ -1,77 +1,63 @@
package com.jasamedika.medifirst2000.controller; package com.jasamedika.medifirst2000.controller;
import java.util.Map;
import javax.servlet.http.HttpServletRequest;
import javax.validation.Valid;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.HttpStatus;
import org.springframework.http.MediaType;
import org.springframework.http.ResponseEntity;
import org.springframework.orm.jpa.JpaSystemException;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;
import com.jasamedika.medifirst2000.base.vo.BaseModelVO; import com.jasamedika.medifirst2000.base.vo.BaseModelVO;
import com.jasamedika.medifirst2000.constants.Constants;
import com.jasamedika.medifirst2000.constants.MessageResource; import com.jasamedika.medifirst2000.constants.MessageResource;
import com.jasamedika.medifirst2000.controller.base.LocaleController; import com.jasamedika.medifirst2000.controller.base.LocaleController;
import com.jasamedika.medifirst2000.core.web.WebConstants;
import com.jasamedika.medifirst2000.dto.MapKebutuhanSaranaToKamarDto; import com.jasamedika.medifirst2000.dto.MapKebutuhanSaranaToKamarDto;
import com.jasamedika.medifirst2000.exception.ServiceVOException; import com.jasamedika.medifirst2000.exception.ServiceVOException;
import com.jasamedika.medifirst2000.service.MapKebutuhanSaranaToKamarService; import com.jasamedika.medifirst2000.service.MapKebutuhanSaranaToKamarService;
import com.jasamedika.medifirst2000.util.rest.RestUtil; import org.slf4j.Logger;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.ResponseEntity;
import org.springframework.orm.jpa.JpaSystemException;
import org.springframework.web.bind.annotation.*;
import javax.servlet.http.HttpServletRequest;
import javax.validation.Valid;
import java.util.Map;
import static com.jasamedika.medifirst2000.constants.Constants.MessageInfo.ERROR_MESSAGE;
import static com.jasamedika.medifirst2000.core.web.WebConstants.HttpHeaderInfo.LABEL_SUCCESS;
import static com.jasamedika.medifirst2000.util.rest.RestUtil.getJsonHttpStatus;
import static com.jasamedika.medifirst2000.util.rest.RestUtil.getJsonResponse;
import static org.slf4j.LoggerFactory.getLogger;
import static org.springframework.http.HttpStatus.*;
import static org.springframework.http.MediaType.APPLICATION_JSON_VALUE;
import static org.springframework.web.bind.annotation.RequestMethod.GET;
import static org.springframework.web.bind.annotation.RequestMethod.POST;
@RestController @RestController
@RequestMapping("/map-kebutuhan-sarana-to-kamar") @RequestMapping("/map-kebutuhan-sarana-to-kamar")
public class MapKebutuhanSaranaToKamarController extends LocaleController<BaseModelVO>{ public class MapKebutuhanSaranaToKamarController extends LocaleController<BaseModelVO> {
private static final Logger LOGGER = LoggerFactory.getLogger(MapKebutuhanSaranaToKamarController.class);
private static final Logger LOGGER = getLogger(MapKebutuhanSaranaToKamarController.class);
@Autowired
@Autowired
private MapKebutuhanSaranaToKamarService mapKebutuhanSaranaToKamarService; private MapKebutuhanSaranaToKamarService mapKebutuhanSaranaToKamarService;
@RequestMapping(value = "/save/", method = RequestMethod.POST, produces = MediaType.APPLICATION_JSON_VALUE, consumes = MediaType.APPLICATION_JSON_VALUE) @RequestMapping(value = "/save/", method = POST, produces = APPLICATION_JSON_VALUE, consumes = APPLICATION_JSON_VALUE)
public ResponseEntity<Map<String, Object>> save(@Valid @RequestBody MapKebutuhanSaranaToKamarDto dto, public ResponseEntity<Map<String, Object>> save(@Valid @RequestBody MapKebutuhanSaranaToKamarDto dto,
HttpServletRequest request) { HttpServletRequest request) {
try { try {
Map<String, Object> result = this.mapKebutuhanSaranaToKamarService.save(dto); Map<String, Object> result = this.mapKebutuhanSaranaToKamarService.save(dto);
if (null != result) if (null != result)
mapHeaderMessage.put(WebConstants.HttpHeaderInfo.LABEL_SUCCESS, mapHeaderMessage.put(LABEL_SUCCESS, getMessage(MessageResource.LABEL_SUCCESS, request));
getMessage(MessageResource.LABEL_SUCCESS, request)); return getJsonResponse(result, CREATED, mapHeaderMessage);
return RestUtil.getJsonResponse(result, HttpStatus.CREATED, mapHeaderMessage);
} catch (ServiceVOException e) { } catch (ServiceVOException e) {
LOGGER.error("Got exception {} when save", e.getMessage()); LOGGER.error("Got ServiceVOException {} when save", e.getMessage());
addHeaderMessage(Constants.MessageInfo.ERROR_MESSAGE, e.getMessage()); addHeaderMessage(ERROR_MESSAGE, e.getMessage());
return RestUtil.getJsonHttpStatus(HttpStatus.INTERNAL_SERVER_ERROR, mapHeaderMessage); return getJsonHttpStatus(INTERNAL_SERVER_ERROR, mapHeaderMessage);
} catch (JpaSystemException jse) { } catch (JpaSystemException jse) {
LOGGER.error("Got exception {} when save", jse.getMessage()); LOGGER.error("Got JpaSystemException {} when save", jse.getMessage());
addHeaderMessage(Constants.MessageInfo.ERROR_MESSAGE, jse.getMessage()); addHeaderMessage(ERROR_MESSAGE, jse.getMessage());
return RestUtil.getJsonHttpStatus(HttpStatus.CONFLICT, mapHeaderMessage); return getJsonHttpStatus(CONFLICT, mapHeaderMessage);
} }
}
} @RequestMapping(value = "/get-all-data", method = GET, produces = APPLICATION_JSON_VALUE)
public Map<String, Object> getAllData(@RequestParam("idKamar") Integer idKamar, HttpServletRequest request) {
@RequestMapping(value="/get-all-data", return this.mapKebutuhanSaranaToKamarService.getDataAll(idKamar);
method=RequestMethod.GET,
produces=MediaType.APPLICATION_JSON_VALUE)
public Map<String, Object> getAllData(@RequestParam("idKamar")Integer idKamar, HttpServletRequest request) {
Map<String, Object> result = this.mapKebutuhanSaranaToKamarService.getDataAll(idKamar);
return result;
}
@RequestMapping(value="/get-data-by-id",
method=RequestMethod.GET,
produces=MediaType.APPLICATION_JSON_VALUE)
public Map<String, Object> getDataById(@RequestParam("id")Integer id, HttpServletRequest request) {
Map<String, Object> result = this.mapKebutuhanSaranaToKamarService.getDataById(id);
return result;
} }
} }

View File

@ -1,103 +0,0 @@
package com.jasamedika.medifirst2000.controller;
import java.util.Map;
import javax.servlet.http.HttpServletRequest;
import javax.validation.Valid;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.HttpStatus;
import org.springframework.http.MediaType;
import org.springframework.http.ResponseEntity;
import org.springframework.orm.jpa.JpaSystemException;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RestController;
import com.jasamedika.medifirst2000.constants.Constants;
import com.jasamedika.medifirst2000.constants.MessageResource;
import com.jasamedika.medifirst2000.controller.base.LocaleController;
import com.jasamedika.medifirst2000.core.web.WebConstants;
import com.jasamedika.medifirst2000.exception.ServiceVOException;
import com.jasamedika.medifirst2000.service.MapObjekModulToKelompokUserService;
import com.jasamedika.medifirst2000.util.rest.RestUtil;
import com.jasamedika.medifirst2000.vo.MapObjekModulToKelompokUserVO;
@RestController
@RequestMapping("/map-objek-modul-to-kelompok-user")
public class MapObjekModulToKelompokUserController extends LocaleController<MapObjekModulToKelompokUserVO> {
@Autowired
private MapObjekModulToKelompokUserService mapObjekModulToKelompokUserService;
private static final Logger LOGGER = LoggerFactory
.getLogger(MapObjekModulToKelompokUserController.class);
@RequestMapping(value = "/save-map-objek-modul-to-kelompok-user/", method = RequestMethod.POST, produces = MediaType.APPLICATION_JSON_VALUE, consumes = MediaType.APPLICATION_JSON_VALUE)
public ResponseEntity<Map<String,Object>> addVO(@Valid @RequestBody MapObjekModulToKelompokUserVO vo,HttpServletRequest request) {
try{
Map<String, Object> result = mapObjekModulToKelompokUserService.addMapObjekModulToKelompokUser(vo);
if (null != result)
mapHeaderMessage.put(WebConstants.HttpHeaderInfo.LABEL_SUCCESS, getMessage(MessageResource.LABEL_SUCCESS,request));
return RestUtil.getJsonResponse(result, HttpStatus.CREATED, mapHeaderMessage);
} catch (ServiceVOException e) {
LOGGER.error("Got exception {} when add mapObjekModulToKelompokUser", e.getMessage());
addHeaderMessage(Constants.MessageInfo.ERROR_MESSAGE,
e.getMessage());
return RestUtil.getJsonHttpStatus(HttpStatus.INTERNAL_SERVER_ERROR,
mapHeaderMessage);
} catch (JpaSystemException jse) {
LOGGER.error("Got exception {} when add mapObjekModulToKelompokUser", jse.getMessage());
addHeaderMessage(Constants.MessageInfo.ERROR_MESSAGE,
jse.getMessage());
return RestUtil.getJsonHttpStatus(HttpStatus.CONFLICT,
mapHeaderMessage);
}
}
@RequestMapping(value = "/update-map-objek-modul-to-kelompok-user/", method = RequestMethod.POST, produces = MediaType.APPLICATION_JSON_VALUE, consumes = MediaType.APPLICATION_JSON_VALUE)
public ResponseEntity<Map<String,Object>> updateVO(@Valid @RequestBody MapObjekModulToKelompokUserVO vo,HttpServletRequest request) {
try{
Map<String, Object> result = mapObjekModulToKelompokUserService.updateMapObjekModulToKelompokUser(vo);
if (null != result)
mapHeaderMessage.put(WebConstants.HttpHeaderInfo.LABEL_SUCCESS, getMessage(MessageResource.LABEL_SUCCESS,request));
return RestUtil.getJsonResponse(result, HttpStatus.CREATED, mapHeaderMessage);
} catch (ServiceVOException e) {
LOGGER.error("Got exception {} when update mapObjekModulToKelompokUser", e.getMessage());
addHeaderMessage(Constants.MessageInfo.ERROR_MESSAGE,
e.getMessage());
return RestUtil.getJsonHttpStatus(HttpStatus.INTERNAL_SERVER_ERROR,
mapHeaderMessage);
} catch (JpaSystemException jse) {
LOGGER.error("Got exception {} when update mapObjekModulToKelompokUser", jse.getMessage());
addHeaderMessage(Constants.MessageInfo.ERROR_MESSAGE,
jse.getMessage());
return RestUtil.getJsonHttpStatus(HttpStatus.CONFLICT,
mapHeaderMessage);
}
}
@RequestMapping(value = "/find-modul-by-kelompok-user/{kelompokUser}", method = RequestMethod.GET, produces = MediaType.APPLICATION_JSON_VALUE, consumes = MediaType.APPLICATION_JSON_VALUE)
public ResponseEntity<Map<String,Object>> findModul(@PathVariable("kelompokUser") Integer kelompokUser,HttpServletRequest request) {
Map<String,Object> result = mapObjekModulToKelompokUserService.findByKelompokUser(kelompokUser);
Boolean dataFound=new Boolean((boolean) result.get("dataFound"));
if(dataFound){
mapHeaderMessage.put(WebConstants.HttpHeaderInfo.LABEL_SUCCESS,getMessage(MessageResource.LABEL_SUCCESS,request ));
}else{
mapHeaderMessage.put(WebConstants.HttpHeaderInfo.LABEL_ERROR,getMessage(MessageResource.LABEL_ERROR,request ));
}
return RestUtil.getJsonResponse(result, HttpStatus.OK,mapHeaderMessage);
}
}

View File

@ -1,128 +1,103 @@
package com.jasamedika.medifirst2000.controller; package com.jasamedika.medifirst2000.controller;
import java.util.List; import com.jasamedika.medifirst2000.constants.MessageResource;
import java.util.Map; import com.jasamedika.medifirst2000.controller.base.LocaleController;
import com.jasamedika.medifirst2000.exception.ServiceVOException;
import javax.servlet.http.HttpServletRequest; import com.jasamedika.medifirst2000.service.MapPegawaiIpsrsService;
import javax.validation.Valid; import com.jasamedika.medifirst2000.vo.MapPegawaiIpsrsVO;
import org.slf4j.Logger; import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.HttpStatus;
import org.springframework.http.MediaType;
import org.springframework.http.ResponseEntity; import org.springframework.http.ResponseEntity;
import org.springframework.orm.jpa.JpaSystemException; import org.springframework.orm.jpa.JpaSystemException;
import org.springframework.web.bind.annotation.RequestBody; import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RequestParam; import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController; import org.springframework.web.bind.annotation.RestController;
import com.jasamedika.medifirst2000.constants.Constants; import javax.servlet.http.HttpServletRequest;
import com.jasamedika.medifirst2000.constants.MessageResource; import javax.validation.Valid;
import com.jasamedika.medifirst2000.controller.base.LocaleController; import java.util.List;
import com.jasamedika.medifirst2000.core.web.WebConstants; import java.util.Map;
import com.jasamedika.medifirst2000.exception.ServiceVOException;
import com.jasamedika.medifirst2000.service.MapPegawaiIpsrsService; import static com.jasamedika.medifirst2000.constants.Constants.MessageInfo.ERROR_MESSAGE;
import com.jasamedika.medifirst2000.util.rest.RestUtil; import static com.jasamedika.medifirst2000.core.web.WebConstants.HttpHeaderInfo.LABEL_SUCCESS;
import com.jasamedika.medifirst2000.vo.MapPegawaiIpsrsVO; import static com.jasamedika.medifirst2000.util.rest.RestUtil.getJsonHttpStatus;
import static com.jasamedika.medifirst2000.util.rest.RestUtil.getJsonResponse;
import static org.slf4j.LoggerFactory.getLogger;
import static org.springframework.http.HttpStatus.*;
import static org.springframework.http.MediaType.APPLICATION_JSON_VALUE;
import static org.springframework.web.bind.annotation.RequestMethod.GET;
import static org.springframework.web.bind.annotation.RequestMethod.POST;
@RestController @RestController
@RequestMapping("/map-pegawai-ipsrs") @RequestMapping("/map-pegawai-ipsrs")
public class MapPegawaiIpsrsController extends LocaleController<MapPegawaiIpsrsVO>{ public class MapPegawaiIpsrsController extends LocaleController<MapPegawaiIpsrsVO> {
private static final Logger LOGGER = LoggerFactory.getLogger(MapPegawaiIpsrsController.class);
private static final Logger LOGGER = getLogger(MapPegawaiIpsrsController.class);
@Autowired @Autowired
private MapPegawaiIpsrsService mapPegawaiIpsrsService; private MapPegawaiIpsrsService mapPegawaiIpsrsService;
@RequestMapping( @RequestMapping(value = "/save-map-pegawai-ipsrs", method = POST, produces = APPLICATION_JSON_VALUE, consumes = APPLICATION_JSON_VALUE)
value = "/save-map-pegawai-ipsrs", public ResponseEntity<Map<String, Object>> saveMapPegawaiIpsrs(@Valid @RequestBody List<MapPegawaiIpsrsVO> vos,
method = RequestMethod.POST, HttpServletRequest request) {
produces = MediaType.APPLICATION_JSON_VALUE,
consumes = MediaType.APPLICATION_JSON_VALUE)
public ResponseEntity<Map<String, Object>> saveMapPegawaiIpsrs(
@Valid @RequestBody List<MapPegawaiIpsrsVO> vos, HttpServletRequest request) {
try { try {
Map<String, Object> result = this.mapPegawaiIpsrsService.saveMapPegawaiIpsrs(vos); Map<String, Object> result = this.mapPegawaiIpsrsService.saveMapPegawaiIpsrs(vos);
if (result != null) if (result != null)
mapHeaderMessage.put(WebConstants.HttpHeaderInfo.LABEL_SUCCESS, mapHeaderMessage.put(LABEL_SUCCESS, getMessage(MessageResource.LABEL_SUCCESS, request));
getMessage(MessageResource.LABEL_SUCCESS, request)); return getJsonResponse(result, CREATED, mapHeaderMessage);
return RestUtil.getJsonResponse(result, HttpStatus.CREATED, mapHeaderMessage);
} catch (ServiceVOException e) { } catch (ServiceVOException e) {
LOGGER.error("Got ServiceVOException {} when saveMapPegawaiIpsrs", e.getMessage());
LOGGER.error("Got exception {} when saveMapPegawaiIpsrs", e.getMessage()); addHeaderMessage(ERROR_MESSAGE, e.getMessage());
addHeaderMessage(Constants.MessageInfo.ERROR_MESSAGE, e.getMessage()); return getJsonHttpStatus(INTERNAL_SERVER_ERROR, mapHeaderMessage);
return RestUtil.getJsonHttpStatus(HttpStatus.INTERNAL_SERVER_ERROR, mapHeaderMessage);
} catch (JpaSystemException jse) { } catch (JpaSystemException jse) {
LOGGER.error("Got JpaSystemException {} when saveMapPegawaiIpsrs", jse.getMessage());
LOGGER.error("Got exception {} when saveMapPegawaiIpsrs", jse.getMessage()); addHeaderMessage(ERROR_MESSAGE, jse.getMessage());
addHeaderMessage(Constants.MessageInfo.ERROR_MESSAGE, jse.getMessage()); return getJsonHttpStatus(CONFLICT, mapHeaderMessage);
return RestUtil.getJsonHttpStatus(HttpStatus.CONFLICT, mapHeaderMessage); }
}
} }
@RequestMapping(
value = "/get-list-pegawai-by-kategori",
method = RequestMethod.GET,
produces = MediaType.APPLICATION_JSON_VALUE)
public ResponseEntity<Map<String, Object>> getLoadDataByNoTrans(
@RequestParam(value = "idJenis", required = true) Integer idJenis, HttpServletRequest request) {
@RequestMapping(value = "/get-list-pegawai-by-kategori", method = GET, produces = APPLICATION_JSON_VALUE)
public ResponseEntity<Map<String, Object>> getLoadDataByNoTrans(@RequestParam(value = "idJenis") Integer idJenis,
HttpServletRequest request) {
try { try {
Map<String, Object> result = this.mapPegawaiIpsrsService.getListMapPegawaiIpsrsByJenis(idJenis); Map<String, Object> result = this.mapPegawaiIpsrsService.getListMapPegawaiIpsrsByJenis(idJenis);
if (null != result) { if (null != result) {
mapHeaderMessage.put(WebConstants.HttpHeaderInfo.LABEL_SUCCESS, mapHeaderMessage.put(LABEL_SUCCESS, getMessage(MessageResource.LABEL_SUCCESS, request));
getMessage(MessageResource.LABEL_SUCCESS, request)); return getJsonResponse(result, OK, mapHeaderMessage);
return RestUtil.getJsonResponse(result, HttpStatus.OK, mapHeaderMessage);
} else { } else {
return RestUtil.getJsonResponse(result, HttpStatus.NOT_FOUND, mapHeaderMessage); return getJsonResponse(null, NOT_FOUND, mapHeaderMessage);
} }
} catch (ServiceVOException e) { } catch (ServiceVOException e) {
LOGGER.error("Got exception {} when getLoadDataByNoTrans", e.getMessage()); LOGGER.error("Got ServiceVOException {} when getListMapPegawaiIpsrsByJenis", e.getMessage());
addHeaderMessage(Constants.MessageInfo.ERROR_MESSAGE, e.getMessage()); addHeaderMessage(ERROR_MESSAGE, e.getMessage());
return RestUtil.getJsonHttpStatus(HttpStatus.INTERNAL_SERVER_ERROR, mapHeaderMessage); return getJsonHttpStatus(INTERNAL_SERVER_ERROR, mapHeaderMessage);
} catch (JpaSystemException jse) { } catch (JpaSystemException jse) {
LOGGER.error("Got exception {} when getLoadDataByNoTrans", jse.getMessage()); LOGGER.error("Got JpaSystemException {} when getListMapPegawaiIpsrsByJenis", jse.getMessage());
addHeaderMessage(Constants.MessageInfo.ERROR_MESSAGE, jse.getMessage()); addHeaderMessage(ERROR_MESSAGE, jse.getMessage());
return RestUtil.getJsonHttpStatus(HttpStatus.CONFLICT, mapHeaderMessage); return getJsonHttpStatus(CONFLICT, mapHeaderMessage);
} }
} }
@RequestMapping(
value = "/get-group-pegawai-ipsrs",
method = RequestMethod.GET,
produces = MediaType.APPLICATION_JSON_VALUE)
public ResponseEntity<Map<String, Object>> getGroupPegawaiIpsrs(HttpServletRequest request) {
@RequestMapping(value = "/get-group-pegawai-ipsrs", method = GET, produces = APPLICATION_JSON_VALUE)
public ResponseEntity<Map<String, Object>> getGroupPegawaiIpsrs(HttpServletRequest request) {
try { try {
Map<String, Object> result = this.mapPegawaiIpsrsService.getGroupPegawaiIpsrs(); Map<String, Object> result = this.mapPegawaiIpsrsService.getGroupPegawaiIpsrs();
if (null != result) { if (null != result) {
mapHeaderMessage.put(WebConstants.HttpHeaderInfo.LABEL_SUCCESS, mapHeaderMessage.put(LABEL_SUCCESS, getMessage(MessageResource.LABEL_SUCCESS, request));
getMessage(MessageResource.LABEL_SUCCESS, request)); return getJsonResponse(result, OK, mapHeaderMessage);
return RestUtil.getJsonResponse(result, HttpStatus.OK, mapHeaderMessage);
} else { } else {
return RestUtil.getJsonResponse(result, HttpStatus.NOT_FOUND, mapHeaderMessage); return getJsonResponse(null, NOT_FOUND, mapHeaderMessage);
} }
} catch (ServiceVOException e) { } catch (ServiceVOException e) {
LOGGER.error("Got exception {} when getGroupPegawaiIpsrs", e.getMessage()); LOGGER.error("Got ServiceVOException {} when getGroupPegawaiIpsrs", e.getMessage());
addHeaderMessage(Constants.MessageInfo.ERROR_MESSAGE, e.getMessage()); addHeaderMessage(ERROR_MESSAGE, e.getMessage());
return RestUtil.getJsonHttpStatus(HttpStatus.INTERNAL_SERVER_ERROR, mapHeaderMessage); return getJsonHttpStatus(INTERNAL_SERVER_ERROR, mapHeaderMessage);
} catch (JpaSystemException jse) { } catch (JpaSystemException jse) {
LOGGER.error("Got exception {} when getGroupPegawaiIpsrs", jse.getMessage()); LOGGER.error("Got JpaSystemException {} when getGroupPegawaiIpsrs", jse.getMessage());
addHeaderMessage(Constants.MessageInfo.ERROR_MESSAGE, jse.getMessage()); addHeaderMessage(ERROR_MESSAGE, jse.getMessage());
return RestUtil.getJsonHttpStatus(HttpStatus.CONFLICT, mapHeaderMessage); return getJsonHttpStatus(CONFLICT, mapHeaderMessage);
} }
} }
} }

View File

@ -1,93 +1,83 @@
package com.jasamedika.medifirst2000.controller; package com.jasamedika.medifirst2000.controller;
import java.text.ParseException; import com.jasamedika.medifirst2000.constants.MessageResource;
import java.util.HashMap; import com.jasamedika.medifirst2000.controller.base.LocaleController;
import java.util.List; import com.jasamedika.medifirst2000.exception.ServiceVOException;
import java.util.Map; import com.jasamedika.medifirst2000.service.MapPegawaiJabatanToUnitKerjaService;
import com.jasamedika.medifirst2000.vo.MapPegawaiJabatanToUnitKerjaVO;
import javax.servlet.http.HttpServletRequest;
import javax.validation.Valid;
import org.slf4j.Logger; import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.HttpStatus;
import org.springframework.http.MediaType;
import org.springframework.http.ResponseEntity; import org.springframework.http.ResponseEntity;
import org.springframework.orm.jpa.JpaSystemException; import org.springframework.orm.jpa.JpaSystemException;
import org.springframework.web.bind.annotation.PathVariable; import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody; import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RestController; import org.springframework.web.bind.annotation.RestController;
import com.jasamedika.medifirst2000.constants.Constants; import javax.servlet.http.HttpServletRequest;
import com.jasamedika.medifirst2000.constants.MessageResource; import javax.validation.Valid;
import com.jasamedika.medifirst2000.controller.base.LocaleController; import java.text.ParseException;
import com.jasamedika.medifirst2000.core.web.WebConstants; import java.util.HashMap;
import com.jasamedika.medifirst2000.exception.ServiceVOException; import java.util.List;
import com.jasamedika.medifirst2000.service.MapPegawaiJabatanToUnitKerjaService; import java.util.Map;
import com.jasamedika.medifirst2000.util.rest.RestUtil;
import com.jasamedika.medifirst2000.vo.MapPegawaiJabatanToUnitKerjaVO; import static com.jasamedika.medifirst2000.constants.Constants.MessageInfo.ERROR_MESSAGE;
import static com.jasamedika.medifirst2000.core.web.WebConstants.HttpHeaderInfo.LABEL_SUCCESS;
import static com.jasamedika.medifirst2000.util.rest.RestUtil.getJsonHttpStatus;
import static com.jasamedika.medifirst2000.util.rest.RestUtil.getJsonResponse;
import static org.slf4j.LoggerFactory.getLogger;
import static org.springframework.http.HttpStatus.*;
import static org.springframework.http.MediaType.APPLICATION_JSON_VALUE;
import static org.springframework.web.bind.annotation.RequestMethod.GET;
import static org.springframework.web.bind.annotation.RequestMethod.POST;
@RestController @RestController
@RequestMapping("/map-pegawai-jabatan-unitkerja") @RequestMapping("/map-pegawai-jabatan-unitkerja")
public class MapPegawaiJabatanToUnitKerjaController extends LocaleController<MapPegawaiJabatanToUnitKerjaVO> { public class MapPegawaiJabatanToUnitKerjaController extends LocaleController<MapPegawaiJabatanToUnitKerjaVO> {
private static final Logger LOGGER = getLogger(MapPegawaiJabatanToUnitKerjaController.class);
@Autowired @Autowired
private MapPegawaiJabatanToUnitKerjaService mapPegawaiJabatanToUnitKerjaService; private MapPegawaiJabatanToUnitKerjaService mapPegawaiJabatanToUnitKerjaService;
private static final Logger LOGGER = LoggerFactory.getLogger(MapPegawaiJabatanToUnitKerjaController.class); @RequestMapping(value = "/save-map", method = POST, produces = APPLICATION_JSON_VALUE, consumes = APPLICATION_JSON_VALUE)
@RequestMapping(value = "/save-map", method = RequestMethod.POST, produces = MediaType.APPLICATION_JSON_VALUE, consumes = MediaType.APPLICATION_JSON_VALUE)
public ResponseEntity<Map<String, Object>> save(@Valid @RequestBody List<MapPegawaiJabatanToUnitKerjaVO> vo, public ResponseEntity<Map<String, Object>> save(@Valid @RequestBody List<MapPegawaiJabatanToUnitKerjaVO> vo,
HttpServletRequest request) throws ParseException { HttpServletRequest request) throws ParseException {
try { try {
Map<String, String> mapHeaderMessage = new HashMap<String, String>(); Map<String, String> mapHeaderMessage = new HashMap<>();
Map<String, Object> result = mapPegawaiJabatanToUnitKerjaService.save(vo); Map<String, Object> result = mapPegawaiJabatanToUnitKerjaService.save(vo);
if (null != result) if (null != result)
mapHeaderMessage.put(WebConstants.HttpHeaderInfo.LABEL_SUCCESS, mapHeaderMessage.put(LABEL_SUCCESS, getMessage(MessageResource.LABEL_SUCCESS, request));
getMessage(MessageResource.LABEL_SUCCESS, request)); return getJsonResponse(result, CREATED, mapHeaderMessage);
return RestUtil.getJsonResponse(result, HttpStatus.CREATED, mapHeaderMessage);
} catch (ServiceVOException e) { } catch (ServiceVOException e) {
LOGGER.error("Got exception {} when add Map", e.getMessage()); LOGGER.error("Got ServiceVOException {} when save", e.getMessage());
addHeaderMessage(Constants.MessageInfo.ERROR_MESSAGE, e.getMessage()); addHeaderMessage(ERROR_MESSAGE, e.getMessage());
return RestUtil.getJsonHttpStatus(HttpStatus.INTERNAL_SERVER_ERROR, mapHeaderMessage); return getJsonHttpStatus(INTERNAL_SERVER_ERROR, mapHeaderMessage);
} catch (JpaSystemException jse) { } catch (JpaSystemException jse) {
LOGGER.error("Got exception {} when add Map", jse.getMessage()); LOGGER.error("Got JpaSystemException {} when save", jse.getMessage());
addHeaderMessage(Constants.MessageInfo.ERROR_MESSAGE, jse.getMessage()); addHeaderMessage(ERROR_MESSAGE, jse.getMessage());
return RestUtil.getJsonHttpStatus(HttpStatus.CONFLICT, mapHeaderMessage); return getJsonHttpStatus(CONFLICT, mapHeaderMessage);
} }
} }
@RequestMapping(value = "/get-map-by-pegawai/{id}", method = RequestMethod.GET) @RequestMapping(value = "/get-map-by-pegawai/{id}", method = GET)
public ResponseEntity<Map<String, Object>> getMapByPegawai(@PathVariable("id") Integer id) { public ResponseEntity<Map<String, Object>> getMapByPegawai(@PathVariable("id") Integer id) {
return RestUtil.getJsonResponse(mapPegawaiJabatanToUnitKerjaService.findAllByPegawai(id), HttpStatus.OK); return getJsonResponse(mapPegawaiJabatanToUnitKerjaService.findAllByPegawai(id), OK);
} }
@RequestMapping(value = "/get-sub-unit-by-unit/{id}/{idUnit}", method = RequestMethod.GET) @RequestMapping(value = "/get-unit-by-pegawai/{id}", method = GET)
public ResponseEntity<Map<String, Object>> getSubUnitByUnit(@PathVariable("id") Integer id,
@PathVariable("idUnit") Integer idUnit) {
return RestUtil.getJsonResponse(mapPegawaiJabatanToUnitKerjaService.findSubUnitByUnit(id, idUnit),
HttpStatus.OK);
}
@RequestMapping(value = "/get-unit-by-pegawai/{id}", method = RequestMethod.GET)
public ResponseEntity<Map<String, Object>> getSubUnitByUnit(@PathVariable("id") Integer id) { public ResponseEntity<Map<String, Object>> getSubUnitByUnit(@PathVariable("id") Integer id) {
return RestUtil.getJsonResponse(mapPegawaiJabatanToUnitKerjaService.findUnitByPgw(id), HttpStatus.OK); return getJsonResponse(mapPegawaiJabatanToUnitKerjaService.findUnitByPgw(id), OK);
} }
@RequestMapping(value = "/get-unit-by-pegawai-jadwal/{id}", method = RequestMethod.GET) @RequestMapping(value = "/get-unit-by-pegawai-jadwal/{id}", method = GET)
public ResponseEntity<List<Map<String, Object>>> getSubUnitByUnitJadwal(@PathVariable("id") Integer id) { public ResponseEntity<List<Map<String, Object>>> getSubUnitByUnitJadwal(@PathVariable("id") Integer id) {
return RestUtil.getJsonResponse(mapPegawaiJabatanToUnitKerjaService.findUnitByPgwJadwal(id), HttpStatus.OK); return getJsonResponse(mapPegawaiJabatanToUnitKerjaService.findUnitByPgwJadwal(id), OK);
} }
@RequestMapping(value = "/get-sub-unit-by-unit-jadwal/{id}/{idUnit}", method = RequestMethod.GET) @RequestMapping(value = "/get-sub-unit-by-unit-jadwal/{id}/{idUnit}", method = GET)
public ResponseEntity<List<Map<String, Object>>> getSubUnitByUnitJadwal(@PathVariable("id") Integer id, public ResponseEntity<List<Map<String, Object>>> getSubUnitByUnitJadwal(@PathVariable("id") Integer id,
@PathVariable("idUnit") Integer idUnit) { @PathVariable("idUnit") Integer idUnit) {
return RestUtil.getJsonResponse(mapPegawaiJabatanToUnitKerjaService.findSubUnitByUnitJadwal(id, idUnit), return getJsonResponse(mapPegawaiJabatanToUnitKerjaService.findSubUnitByUnitJadwal(id, idUnit), OK);
HttpStatus.OK);
} }
} }

View File

@ -1,68 +0,0 @@
package com.jasamedika.medifirst2000.controller;
import java.text.ParseException;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import javax.servlet.http.HttpServletRequest;
import javax.validation.Valid;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.HttpStatus;
import org.springframework.http.MediaType;
import org.springframework.http.ResponseEntity;
import org.springframework.orm.jpa.JpaSystemException;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RestController;
import com.jasamedika.medifirst2000.constants.Constants;
import com.jasamedika.medifirst2000.constants.MessageResource;
import com.jasamedika.medifirst2000.controller.base.LocaleController;
import com.jasamedika.medifirst2000.core.web.WebConstants;
import com.jasamedika.medifirst2000.exception.ServiceVOException;
import com.jasamedika.medifirst2000.service.MapPegawailaboratRadiologiService;
import com.jasamedika.medifirst2000.util.rest.RestUtil;
import com.jasamedika.medifirst2000.vo.MapPegawaiLaboratRadiologiVO;
@RestController
@RequestMapping("/mappegawailaboratradiologi")
public class MapPegawaiLaboratRadiologiController extends LocaleController<MapPegawaiLaboratRadiologiVO> {
@Autowired
private MapPegawailaboratRadiologiService mapPegawailaboratRadiologiService;
private static final Logger LOGGER = LoggerFactory.getLogger(MapPegawaiLaboratRadiologiController.class);
@RequestMapping(value = "/save-map", method = RequestMethod.POST, produces = MediaType.APPLICATION_JSON_VALUE, consumes = MediaType.APPLICATION_JSON_VALUE)
public ResponseEntity<Map<String, Object>> save(@Valid @RequestBody List<MapPegawaiLaboratRadiologiVO> vo,
HttpServletRequest request) throws ParseException {
try {
Map<String, String> mapHeaderMessage = new HashMap<String, String>();
Map<String, Object> result = mapPegawailaboratRadiologiService.save(vo);
if (null != result)
mapHeaderMessage.put(WebConstants.HttpHeaderInfo.LABEL_SUCCESS,
getMessage(MessageResource.LABEL_SUCCESS, request));
return RestUtil.getJsonResponse(result, HttpStatus.CREATED, mapHeaderMessage);
} catch (ServiceVOException e) {
LOGGER.error("Got exception {} when add Map", e.getMessage());
addHeaderMessage(Constants.MessageInfo.ERROR_MESSAGE, e.getMessage());
return RestUtil.getJsonHttpStatus(HttpStatus.INTERNAL_SERVER_ERROR, mapHeaderMessage);
} catch (JpaSystemException jse) {
LOGGER.error("Got exception {} when add Map", jse.getMessage());
addHeaderMessage(Constants.MessageInfo.ERROR_MESSAGE, jse.getMessage());
return RestUtil.getJsonHttpStatus(HttpStatus.CONFLICT, mapHeaderMessage);
}
}
@RequestMapping(value = "/get-map", method = RequestMethod.GET)
public ResponseEntity<Map<String, Object>> getMapByPegawai() {
return RestUtil.getJsonResponse(mapPegawailaboratRadiologiService.findAll(), HttpStatus.OK);
}
}

View File

@ -1,140 +1,50 @@
package com.jasamedika.medifirst2000.controller; package com.jasamedika.medifirst2000.controller;
import java.util.Collection; import com.jasamedika.medifirst2000.constants.MessageResource;
import java.util.HashMap; import com.jasamedika.medifirst2000.controller.base.LocaleController;
import java.util.List; import com.jasamedika.medifirst2000.service.MapProdukMenuToBahanService;
import java.util.Map; import com.jasamedika.medifirst2000.vo.MapProdukMenuToBahanVO;
import com.jasamedika.medifirst2000.vo.PasienVO;
import javax.servlet.http.HttpServletRequest;
import javax.validation.Valid;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.HttpStatus;
import org.springframework.http.MediaType;
import org.springframework.http.ResponseEntity; import org.springframework.http.ResponseEntity;
import org.springframework.orm.jpa.JpaSystemException;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RequestParam; import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController; import org.springframework.web.bind.annotation.RestController;
import com.jasamedika.medifirst2000.constants.Constants; import javax.servlet.http.HttpServletRequest;
import com.jasamedika.medifirst2000.constants.MessageResource; import java.util.Collection;
import com.jasamedika.medifirst2000.controller.base.IBaseRestController; import java.util.Map;
import com.jasamedika.medifirst2000.controller.base.LocaleController;
import com.jasamedika.medifirst2000.core.web.WebConstants; import static com.jasamedika.medifirst2000.core.web.WebConstants.HttpHeaderInfo.LABEL_SUCCESS;
import com.jasamedika.medifirst2000.entities.MapProdukMenuToBahan; import static com.jasamedika.medifirst2000.util.rest.RestUtil.getJsonResponse;
import com.jasamedika.medifirst2000.exception.ServiceVOException; import static org.springframework.http.HttpStatus.CREATED;
import com.jasamedika.medifirst2000.service.MapProdukMenuToBahanService; import static org.springframework.http.MediaType.APPLICATION_JSON_VALUE;
import com.jasamedika.medifirst2000.util.rest.RestUtil; import static org.springframework.web.bind.annotation.RequestMethod.GET;
import com.jasamedika.medifirst2000.vo.MapProdukMenuToBahanVO;
@RestController @RestController
@RequestMapping(value="/menu-to-bahan") @RequestMapping(value = "/menu-to-bahan")
public class MapProdukMenuToBahanController extends LocaleController<MapProdukMenuToBahanVO> public class MapProdukMenuToBahanController extends LocaleController<MapProdukMenuToBahanVO> {
implements IBaseRestController<MapProdukMenuToBahanVO>{
@Autowired @Autowired
private MapProdukMenuToBahanService mapService; private MapProdukMenuToBahanService mapService;
private static final Logger LOGGER = LoggerFactory @RequestMapping(value = "/find-all/", method = GET, produces = APPLICATION_JSON_VALUE)
.getLogger(IndikatorRensarController.class); public ResponseEntity<Collection<PasienVO>> findAll(
@RequestMapping(value="/find-all/", method= RequestMethod.GET,produces = MediaType.APPLICATION_JSON_VALUE)
public ResponseEntity<Collection<MapProdukMenuToBahan>> findAll(
@RequestParam(value = "page", required = false, defaultValue = "0") Integer page, @RequestParam(value = "page", required = false, defaultValue = "0") Integer page,
@RequestParam(value = "take", required = false, defaultValue = "100") Integer take, @RequestParam(value = "take", required = false, defaultValue = "100") Integer take,
@RequestParam(value = "sort", required = false, defaultValue = "id") String sort, @RequestParam(value = "sort", required = false, defaultValue = "id") String sort,
@RequestParam(value = "dir", required = false, defaultValue = "asc") String dir, @RequestParam(value = "dir", required = false, defaultValue = "asc") String dir,
@RequestParam(value = "menuId", required = true) Integer menuId) @RequestParam(value = "menuId") Integer menuId) {
{ Map<String, Object> result = mapService.findAll(page, take, sort, dir, menuId);
Map<String, Object> result = new HashMap<String, Object>(); return constructListPageResult(result);
// result = mapService.findAll(page, take, sort,dir, spec);
result = mapService.findAll(page, take, sort, dir, menuId);
return constructListPageResult(result);
} }
@RequestMapping(value="/get-menu-gizi/", method= RequestMethod.GET,produces = MediaType.APPLICATION_JSON_VALUE) @RequestMapping(value = "/get-menu-gizi/", method = GET, produces = APPLICATION_JSON_VALUE)
public ResponseEntity<Map<String,Object>> findMenuGizi( public ResponseEntity<Map<String, Object>> findMenuGizi(HttpServletRequest request) {
HttpServletRequest request) Map<String, Object> result = mapService.findMenuGizi();
{ if (null != result)
Map<String, Object> result = new HashMap<String, Object>(); mapHeaderMessage.put(LABEL_SUCCESS, getMessage(MessageResource.LABEL_SUCCESS, request));
result = mapService.findMenuGizi(); return getJsonResponse(result, CREATED, mapHeaderMessage);
if (null != result)
mapHeaderMessage.put(WebConstants.HttpHeaderInfo.LABEL_SUCCESS,getMessage(MessageResource.LABEL_SUCCESS,request ));
return RestUtil.getJsonResponse(result, HttpStatus.CREATED, mapHeaderMessage);
}
@RequestMapping(value="/get-bahan-gizi/", method= RequestMethod.GET,produces = MediaType.APPLICATION_JSON_VALUE)
public ResponseEntity<Map<String,Object>> findBahanGizi(
HttpServletRequest request)
{
Map<String, Object> result = new HashMap<String, Object>();
result = mapService.findBahanGizi();
if (null != result)
mapHeaderMessage.put(WebConstants.HttpHeaderInfo.LABEL_SUCCESS,getMessage(MessageResource.LABEL_SUCCESS,request ));
return RestUtil.getJsonResponse(result, HttpStatus.CREATED, mapHeaderMessage);
}
@RequestMapping(value="/save/", method= RequestMethod.POST,produces = MediaType.APPLICATION_JSON_VALUE)
public ResponseEntity<Map<String,Object>> save(@Valid @RequestBody List<MapProdukMenuToBahanVO> vo,HttpServletRequest request){
try{
Map<String, Object> result = mapService.save(vo);
if(null!= result)
mapHeaderMessage.put(WebConstants.HttpHeaderInfo.LABEL_SUCCESS, getMessage(MessageResource.LABEL_SUCCESS,request));
return RestUtil.getJsonResponse(result, HttpStatus.CREATED, mapHeaderMessage);
} catch (ServiceVOException e) {
LOGGER.error("Got exception {} when add/update Menu To Bahan", e.getMessage());
addHeaderMessage(Constants.MessageInfo.ERROR_MESSAGE,
e.getMessage());
return RestUtil.getJsonHttpStatus(HttpStatus.INTERNAL_SERVER_ERROR,
mapHeaderMessage);
} catch (JpaSystemException jse) {
LOGGER.error("Got exception {} when add/update Menu To Bahan", jse.getMessage());
addHeaderMessage(Constants.MessageInfo.ERROR_MESSAGE,
jse.getMessage());
return RestUtil.getJsonHttpStatus(HttpStatus.CONFLICT,
mapHeaderMessage);
}
}
@Override
public ResponseEntity<Collection<MapProdukMenuToBahanVO>> getAllVOWithQueryString(HttpServletRequest request,
Integer page, Integer limit, String sort, String dir) {
return null;
} }
@Override
public ResponseEntity<MapProdukMenuToBahanVO> getVO(Integer id) {
return null;
}
@Override
public ResponseEntity<String> addVO(MapProdukMenuToBahanVO vo) {
return null;
}
@Override
public ResponseEntity<String> editVO(MapProdukMenuToBahanVO vo) {
return null;
}
@Override
public ResponseEntity<String> deleteVO(Integer id) {
return null;
}
@Override
public ResponseEntity<List<MapProdukMenuToBahanVO>> getAllVO() {
return null;
}
} }

View File

@ -1,211 +1,146 @@
package com.jasamedika.medifirst2000.controller; package com.jasamedika.medifirst2000.controller;
import java.util.Collection; import com.jasamedika.medifirst2000.constants.MessageResource;
import java.util.List; import com.jasamedika.medifirst2000.controller.base.LocaleController;
import java.util.Map; import com.jasamedika.medifirst2000.entities.MapRuanganToKelas;
import com.jasamedika.medifirst2000.exception.ServiceVOException;
import javax.servlet.http.HttpServletRequest; import com.jasamedika.medifirst2000.service.MapRuanganToKelasService;
import javax.validation.Valid; import com.jasamedika.medifirst2000.vo.MapRuanganToKelasVO;
import com.jasamedika.medifirst2000.vo.MapRuanganToKelasVO_;
import org.slf4j.Logger; import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.HttpStatus;
import org.springframework.http.MediaType;
import org.springframework.http.ResponseEntity; import org.springframework.http.ResponseEntity;
import org.springframework.orm.jpa.JpaSystemException; import org.springframework.orm.jpa.JpaSystemException;
import org.springframework.web.bind.annotation.RequestBody; import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RequestParam; import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController; import org.springframework.web.bind.annotation.RestController;
import com.jasamedika.medifirst2000.constants.Constants; import javax.servlet.http.HttpServletRequest;
import com.jasamedika.medifirst2000.constants.MessageResource; import javax.validation.Valid;
import com.jasamedika.medifirst2000.controller.base.IBaseRestController; import java.util.List;
import com.jasamedika.medifirst2000.controller.base.LocaleController; import java.util.Map;
import com.jasamedika.medifirst2000.core.web.WebConstants;
import com.jasamedika.medifirst2000.exception.ServiceVOException;
import com.jasamedika.medifirst2000.util.rest.RestUtil;
import com.jasamedika.medifirst2000.service.MapRuanganToKelasService; import static com.jasamedika.medifirst2000.constants.Constants.MessageInfo.ERROR_MESSAGE;
import com.jasamedika.medifirst2000.vo.MapRuanganToKelasVO_; import static com.jasamedika.medifirst2000.core.web.WebConstants.HttpHeaderInfo.LABEL_SUCCESS;
import static com.jasamedika.medifirst2000.util.rest.RestUtil.getJsonHttpStatus;
import static com.jasamedika.medifirst2000.util.rest.RestUtil.getJsonResponse;
import static org.slf4j.LoggerFactory.getLogger;
import static org.springframework.http.HttpStatus.*;
import static org.springframework.http.MediaType.APPLICATION_JSON_VALUE;
import static org.springframework.web.bind.annotation.RequestMethod.GET;
import static org.springframework.web.bind.annotation.RequestMethod.POST;
@RestController @RestController
@RequestMapping("/mapRuanganToKelas") @RequestMapping("/mapRuanganToKelas")
public class MapRuanganToKelasController extends LocaleController<MapRuanganToKelasVO_> implements public class MapRuanganToKelasController extends LocaleController<MapRuanganToKelasVO_> {
IBaseRestController<MapRuanganToKelasVO_> {
private static final Logger LOGGER = getLogger(MapRuanganToKelasController.class);
@Autowired @Autowired
private MapRuanganToKelasService mapRuanganToKelasService; private MapRuanganToKelasService<MapRuanganToKelas> mapRuanganToKelasService;
private static final Logger LOGGER = LoggerFactory
.getLogger(MapRuanganToKelasController.class);
public ResponseEntity<Collection<MapRuanganToKelasVO_>> getAllVOWithQueryString(HttpServletRequest request, @RequestMapping(value = "/save-map-ruangan-to-kelas", method = POST, produces = APPLICATION_JSON_VALUE, consumes = APPLICATION_JSON_VALUE)
Integer page, Integer limit, String sort, String dir) {
return null;
}
@Override
public ResponseEntity<MapRuanganToKelasVO_> getVO(Integer id) {
return null;
}
@RequestMapping(value = "/save-map-ruangan-to-kelas", method = RequestMethod.POST, produces = MediaType.APPLICATION_JSON_VALUE, consumes = MediaType.APPLICATION_JSON_VALUE)
public ResponseEntity<String> addVO(@Valid @RequestBody MapRuanganToKelasVO_ vo, HttpServletRequest request) { public ResponseEntity<String> addVO(@Valid @RequestBody MapRuanganToKelasVO_ vo, HttpServletRequest request) {
try { try {
List<MapRuanganToKelasVO_> result = mapRuanganToKelasService.addVo(vo); List<MapRuanganToKelasVO> result = mapRuanganToKelasService.addVo(vo);
if (null != result) if (null != result)
mapHeaderMessage.put(WebConstants.HttpHeaderInfo.LABEL_SUCCESS,getMessage(MessageResource.LABEL_SUCCESS,request )); mapHeaderMessage.put(LABEL_SUCCESS, getMessage(MessageResource.LABEL_SUCCESS, request));
return RestUtil.getJsonResponse("", HttpStatus.CREATED,mapHeaderMessage); return getJsonResponse("", CREATED, mapHeaderMessage);
} catch (ServiceVOException e) { } catch (ServiceVOException e) {
LOGGER.error("Got exception {} when add Map Ruangan to Kelas", e.getMessage()); LOGGER.error("Got ServiceVOException {} when addVo", e.getMessage());
addHeaderMessage(Constants.MessageInfo.ERROR_MESSAGE, e.getMessage()); addHeaderMessage(ERROR_MESSAGE, e.getMessage());
return RestUtil.getJsonHttpStatus(HttpStatus.INTERNAL_SERVER_ERROR, mapHeaderMessage); return getJsonHttpStatus(INTERNAL_SERVER_ERROR, mapHeaderMessage);
} catch (JpaSystemException jse) { } catch (JpaSystemException jse) {
LOGGER.error("Got exception {} when add Map Ruangan to Kelas", jse.getMessage()); LOGGER.error("Got JpaSystemException {} when addVo", jse.getMessage());
addHeaderMessage(Constants.MessageInfo.ERROR_MESSAGE, jse.getMessage()); addHeaderMessage(ERROR_MESSAGE, jse.getMessage());
return RestUtil.getJsonHttpStatus(HttpStatus.CONFLICT, mapHeaderMessage); return getJsonHttpStatus(CONFLICT, mapHeaderMessage);
} }
} }
@RequestMapping(value = "/update-map-ruangan-to-kelas", method = RequestMethod.POST, produces = MediaType.APPLICATION_JSON_VALUE, consumes = MediaType.APPLICATION_JSON_VALUE) @RequestMapping(value = "/update-map-ruangan-to-kelas", method = POST, produces = APPLICATION_JSON_VALUE, consumes = APPLICATION_JSON_VALUE)
public ResponseEntity<String> editVO(@Valid @RequestBody MapRuanganToKelasVO_ vo) { public ResponseEntity<String> editVO(@Valid @RequestBody MapRuanganToKelasVO_ vo) {
try { try {
List<MapRuanganToKelasVO_> result = mapRuanganToKelasService.updateVo(vo); List<MapRuanganToKelasVO> result = mapRuanganToKelasService.updateVo(vo);
if (null != result) if (null != result)
addHeaderMessage(Constants.MessageInfo.ERROR_MESSAGE, ""); addHeaderMessage(ERROR_MESSAGE, "");
RestUtil.getJsonHttpStatus(HttpStatus.CREATED); getJsonHttpStatus(CREATED);
return RestUtil.getJsonResponse("", HttpStatus.CREATED); return getJsonResponse("", CREATED);
} catch (ServiceVOException e) { } catch (ServiceVOException e) {
LOGGER.error("Got exception {} when update Map Ruangan to Kelas", e.getMessage()); LOGGER.error("Got ServiceVOException {} when updateVo", e.getMessage());
addHeaderMessage(Constants.MessageInfo.ERROR_MESSAGE, e.getMessage()); addHeaderMessage(ERROR_MESSAGE, e.getMessage());
return RestUtil.getJsonHttpStatus(HttpStatus.INTERNAL_SERVER_ERROR, mapHeaderMessage); return getJsonHttpStatus(INTERNAL_SERVER_ERROR, mapHeaderMessage);
} catch (JpaSystemException jse) { } catch (JpaSystemException jse) {
LOGGER.error("Got exception {} when update Map Ruangan to Kelas", jse.getMessage()); LOGGER.error("Got JpaSystemException {} when updateVo", jse.getMessage());
addHeaderMessage(Constants.MessageInfo.ERROR_MESSAGE, jse.getMessage()); addHeaderMessage(ERROR_MESSAGE, jse.getMessage());
return RestUtil.getJsonHttpStatus(HttpStatus.CONFLICT, mapHeaderMessage); return getJsonHttpStatus(CONFLICT, mapHeaderMessage);
} }
} }
@SuppressWarnings("unchecked")
@RequestMapping(value = "/search-map-ruangan-to-kelas", method = RequestMethod.GET, produces = MediaType.APPLICATION_JSON_VALUE, consumes = MediaType.APPLICATION_JSON_VALUE)
public ResponseEntity<Collection<MapRuanganToKelasVO_>> getAllVOWithQueryString(
@RequestParam(value = "page", required = false ,defaultValue = "1") Integer page,
@RequestParam(value = "limit", required = false ,defaultValue = "10") Integer limit,
@RequestParam(value = "sort", required = false, defaultValue = "id") String sort,
@RequestParam(value = "dir", required = false, defaultValue = "asc") String dir){
Map<String, Object> resultPageMap = mapRuanganToKelasService.findAllWithPageAndLimitAndSortByAndDirectionParameter(page,
limit, sort, dir);
return constructListPageResult(resultPageMap); @RequestMapping(value = "/get-ruangan-by-kelas", method = GET, produces = APPLICATION_JSON_VALUE)
}
@RequestMapping(value = "/delete-mapRuanganToKelas/", method = RequestMethod.GET, produces = MediaType.APPLICATION_JSON_VALUE, consumes = MediaType.APPLICATION_JSON_VALUE)
public ResponseEntity<String> deleteVO(Integer id) {
try {
if (mapRuanganToKelasService.delete(id) == true)
return RestUtil.getJsonResponse("", HttpStatus.CREATED);
} catch (ServiceVOException e) {
LOGGER.error("Got exception {} when delete MapRuanganToKelas", e.getMessage());
addHeaderMessage(Constants.MessageInfo.ERROR_MESSAGE,
e.getMessage());
return RestUtil.getJsonHttpStatus(HttpStatus.INTERNAL_SERVER_ERROR,
mapHeaderMessage);
} catch (JpaSystemException jse) {
LOGGER.error("Got exception {} when delete MapRuanganToKelas", jse.getMessage());
addHeaderMessage(Constants.MessageInfo.ERROR_MESSAGE,
jse.getMessage());
return RestUtil.getJsonHttpStatus(HttpStatus.CONFLICT,
mapHeaderMessage);
}
return RestUtil.getJsonHttpStatus(HttpStatus.NOT_ACCEPTABLE);
}
@Override
public ResponseEntity<List<MapRuanganToKelasVO_>> getAllVO() {
return null;
}
@Override
public ResponseEntity<String> addVO(MapRuanganToKelasVO_ vo) {
return null;
}
@RequestMapping(value = "/get-ruangan-by-kelas", method = RequestMethod.GET, produces = MediaType.APPLICATION_JSON_VALUE)
public ResponseEntity<Map<String, Object>> getRuanganByRuangan( public ResponseEntity<Map<String, Object>> getRuanganByRuangan(
@RequestParam(value="kelasId",required = false) Integer kelasId, HttpServletRequest request) { @RequestParam(value = "kelasId", required = false) Integer kelasId, HttpServletRequest request) {
try { try {
Map<String,Object> result = mapRuanganToKelasService.getRuanganByKelas(kelasId); Map<String, Object> result = mapRuanganToKelasService.getRuanganByKelas(kelasId);
if (null != result){ if (null != result) {
mapHeaderMessage.put(WebConstants.HttpHeaderInfo.LABEL_SUCCESS,getMessage(MessageResource.LABEL_SUCCESS,request)); mapHeaderMessage.put(LABEL_SUCCESS, getMessage(MessageResource.LABEL_SUCCESS, request));
return RestUtil.getJsonResponse(result, HttpStatus.OK,mapHeaderMessage); return getJsonResponse(result, OK, mapHeaderMessage);
} else{ } else {
return RestUtil.getJsonResponse(result, HttpStatus.NOT_FOUND,mapHeaderMessage); return getJsonResponse(null, NOT_FOUND, mapHeaderMessage);
} }
} catch (ServiceVOException e) { } catch (ServiceVOException e) {
LOGGER.error("Got exception {} when getRuanganByRuangan", e.getMessage()); LOGGER.error("Got ServiceVOException {} when getRuanganByKelas", e.getMessage());
addHeaderMessage(Constants.MessageInfo.ERROR_MESSAGE, e.getMessage()); addHeaderMessage(ERROR_MESSAGE, e.getMessage());
return RestUtil.getJsonHttpStatus(HttpStatus.INTERNAL_SERVER_ERROR, mapHeaderMessage); return getJsonHttpStatus(INTERNAL_SERVER_ERROR, mapHeaderMessage);
} catch (JpaSystemException jse) { } catch (JpaSystemException jse) {
LOGGER.error("Got exception {} when getRuanganByRuangan", jse.getMessage()); LOGGER.error("Got JpaSystemException {} when getRuanganByKelas", jse.getMessage());
addHeaderMessage(Constants.MessageInfo.ERROR_MESSAGE, jse.getMessage()); addHeaderMessage(ERROR_MESSAGE, jse.getMessage());
return RestUtil.getJsonHttpStatus(HttpStatus.CONFLICT, mapHeaderMessage); return getJsonHttpStatus(CONFLICT, mapHeaderMessage);
} }
} }
@RequestMapping(value = "/get-kelas-by-ruangan", method = RequestMethod.GET, produces = MediaType.APPLICATION_JSON_VALUE) @RequestMapping(value = "/get-kelas-by-ruangan", method = GET, produces = APPLICATION_JSON_VALUE)
public ResponseEntity<Map<String, Object>> getKelasByRuangan( public ResponseEntity<Map<String, Object>> getKelasByRuangan(
@RequestParam(value="ruanganId",required = false) Integer ruanganId, HttpServletRequest request) { @RequestParam(value = "ruanganId", required = false) Integer ruanganId, HttpServletRequest request) {
try { try {
Map<String,Object> result = mapRuanganToKelasService.getKelasByRuangan(ruanganId); Map<String, Object> result = mapRuanganToKelasService.getKelasByRuangan(ruanganId);
if (null != result){ if (null != result) {
mapHeaderMessage.put(WebConstants.HttpHeaderInfo.LABEL_SUCCESS,getMessage(MessageResource.LABEL_SUCCESS,request)); mapHeaderMessage.put(LABEL_SUCCESS, getMessage(MessageResource.LABEL_SUCCESS, request));
return RestUtil.getJsonResponse(result, HttpStatus.OK,mapHeaderMessage); return getJsonResponse(result, OK, mapHeaderMessage);
} else{ } else {
return RestUtil.getJsonResponse(result, HttpStatus.NOT_FOUND,mapHeaderMessage); return getJsonResponse(null, NOT_FOUND, mapHeaderMessage);
} }
} catch (ServiceVOException e) { } catch (ServiceVOException e) {
LOGGER.error("Got exception {} when getKelasByRuangan", e.getMessage()); LOGGER.error("Got ServiceVOException {} when getKelasByRuangan", e.getMessage());
addHeaderMessage(Constants.MessageInfo.ERROR_MESSAGE, e.getMessage()); addHeaderMessage(ERROR_MESSAGE, e.getMessage());
return RestUtil.getJsonHttpStatus(HttpStatus.INTERNAL_SERVER_ERROR, mapHeaderMessage); return getJsonHttpStatus(INTERNAL_SERVER_ERROR, mapHeaderMessage);
} catch (JpaSystemException jse) { } catch (JpaSystemException jse) {
LOGGER.error("Got exception {} when getKelasByRuangan", jse.getMessage()); LOGGER.error("Got JpaSystemException {} when getKelasByRuangan", jse.getMessage());
addHeaderMessage(Constants.MessageInfo.ERROR_MESSAGE, jse.getMessage()); addHeaderMessage(ERROR_MESSAGE, jse.getMessage());
return RestUtil.getJsonHttpStatus(HttpStatus.CONFLICT, mapHeaderMessage); return getJsonHttpStatus(CONFLICT, mapHeaderMessage);
} }
} }
@RequestMapping(value = "/get-kamar-by-kelas", method = RequestMethod.GET, produces = MediaType.APPLICATION_JSON_VALUE) @RequestMapping(value = "/get-kamar-by-kelas", method = GET, produces = APPLICATION_JSON_VALUE)
public ResponseEntity<Map<String, Object>> getKamarByKelas( public ResponseEntity<Map<String, Object>> getKamarByKelas(
@RequestParam(value="kelasId",required = false) Integer kelasId, @RequestParam(value = "kelasId", required = false) Integer kelasId,
@RequestParam(value="ruanganId",required = false) Integer ruanganId, HttpServletRequest request) { @RequestParam(value = "ruanganId", required = false) Integer ruanganId, HttpServletRequest request) {
try { try {
Map<String,Object> result = mapRuanganToKelasService.getKamarByKelas(kelasId, ruanganId); Map<String, Object> result = mapRuanganToKelasService.getKamarByKelas(kelasId, ruanganId);
if (null != result){ if (null != result) {
mapHeaderMessage.put(WebConstants.HttpHeaderInfo.LABEL_SUCCESS,getMessage(MessageResource.LABEL_SUCCESS,request)); mapHeaderMessage.put(LABEL_SUCCESS, getMessage(MessageResource.LABEL_SUCCESS, request));
return RestUtil.getJsonResponse(result, HttpStatus.OK,mapHeaderMessage); return getJsonResponse(result, OK, mapHeaderMessage);
} else{ } else {
return RestUtil.getJsonResponse(result, HttpStatus.NOT_FOUND,mapHeaderMessage); return getJsonResponse(null, NOT_FOUND, mapHeaderMessage);
} }
} catch (ServiceVOException e) { } catch (ServiceVOException e) {
LOGGER.error("Got exception {} when getKamarByKelas", e.getMessage()); LOGGER.error("Got ServiceVOException {} when getKamarByKelas", e.getMessage());
addHeaderMessage(Constants.MessageInfo.ERROR_MESSAGE, e.getMessage()); addHeaderMessage(ERROR_MESSAGE, e.getMessage());
return RestUtil.getJsonHttpStatus(HttpStatus.INTERNAL_SERVER_ERROR, mapHeaderMessage); return getJsonHttpStatus(INTERNAL_SERVER_ERROR, mapHeaderMessage);
} catch (JpaSystemException jse) { } catch (JpaSystemException jse) {
LOGGER.error("Got exception {} when getKamarByKelas", jse.getMessage()); LOGGER.error("Got JpaSystemException {} when getKamarByKelas", jse.getMessage());
addHeaderMessage(Constants.MessageInfo.ERROR_MESSAGE, jse.getMessage()); addHeaderMessage(ERROR_MESSAGE, jse.getMessage());
return RestUtil.getJsonHttpStatus(HttpStatus.CONFLICT, mapHeaderMessage); return getJsonHttpStatus(CONFLICT, mapHeaderMessage);
} }
} }

View File

@ -1,185 +1,64 @@
package com.jasamedika.medifirst2000.controller; package com.jasamedika.medifirst2000.controller;
import java.util.Collection; import com.jasamedika.medifirst2000.constants.MessageResource;
import java.util.List; import com.jasamedika.medifirst2000.controller.base.LocaleController;
import java.util.Map; import com.jasamedika.medifirst2000.exception.ServiceVOException;
import com.jasamedika.medifirst2000.service.MappingAlatToBundleService;
import javax.servlet.http.HttpServletRequest; import com.jasamedika.medifirst2000.vo.MappingAlatToBundleVO;
import javax.validation.Valid;
import org.slf4j.Logger; import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.HttpStatus;
import org.springframework.http.MediaType;
import org.springframework.http.ResponseEntity; import org.springframework.http.ResponseEntity;
import org.springframework.orm.jpa.JpaSystemException; import org.springframework.orm.jpa.JpaSystemException;
import org.springframework.web.bind.annotation.RequestBody; import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController; import org.springframework.web.bind.annotation.RestController;
import com.jasamedika.medifirst2000.constants.Constants; import javax.servlet.http.HttpServletRequest;
import com.jasamedika.medifirst2000.constants.MessageResource; import javax.validation.Valid;
import com.jasamedika.medifirst2000.controller.base.IBaseRestController; import java.util.List;
import com.jasamedika.medifirst2000.controller.base.LocaleController; import java.util.Map;
import com.jasamedika.medifirst2000.core.web.WebConstants;
import com.jasamedika.medifirst2000.exception.ServiceVOException; import static com.jasamedika.medifirst2000.constants.Constants.MessageInfo.ERROR_MESSAGE;
import com.jasamedika.medifirst2000.service.MappingAlatToBundleService; import static com.jasamedika.medifirst2000.core.web.WebConstants.HttpHeaderInfo.LABEL_SUCCESS;
import com.jasamedika.medifirst2000.util.rest.RestUtil; import static com.jasamedika.medifirst2000.util.rest.RestUtil.getJsonHttpStatus;
import com.jasamedika.medifirst2000.vo.MappingAlatToBundleVO; import static com.jasamedika.medifirst2000.util.rest.RestUtil.getJsonResponse;
import static org.slf4j.LoggerFactory.getLogger;
import static org.springframework.http.HttpStatus.*;
import static org.springframework.http.MediaType.APPLICATION_JSON_VALUE;
import static org.springframework.web.bind.annotation.RequestMethod.GET;
import static org.springframework.web.bind.annotation.RequestMethod.POST;
@RestController @RestController
@RequestMapping("/mapping-alat-to-bundle") @RequestMapping("/mapping-alat-to-bundle")
public class MappingAlatToBundleController extends LocaleController<MappingAlatToBundleVO> implements IBaseRestController<MappingAlatToBundleVO>{ public class MappingAlatToBundleController extends LocaleController<MappingAlatToBundleVO> {
private static final Logger LOGGER = getLogger(MappingAlatToBundleController.class);
@Autowired @Autowired
private MappingAlatToBundleService mappingAlatToBundleService; private MappingAlatToBundleService mappingAlatToBundleService;
private static final Logger LOGGER = LoggerFactory @RequestMapping(value = "/save-all-mapping-alat-to-bundle/", method = POST, produces = APPLICATION_JSON_VALUE, consumes = APPLICATION_JSON_VALUE)
.getLogger(MappingAlatToBundleController.class); public ResponseEntity<Map<String, Object>> saveAllVO(@Valid @RequestBody List<MappingAlatToBundleVO> vos,
@RequestMapping(value = "/save-mapping-alat-to-bundle/", method = RequestMethod.POST, produces = MediaType.APPLICATION_JSON_VALUE, consumes = MediaType.APPLICATION_JSON_VALUE)
public ResponseEntity<Map<String,Object>> addVO(@Valid @RequestBody MappingAlatToBundleVO vo, HttpServletRequest request) {
try {
Map<String,Object> result=mappingAlatToBundleService.addMappingAlatToBundle(vo);
if (null != result)
mapHeaderMessage.put(WebConstants.HttpHeaderInfo.LABEL_SUCCESS,getMessage(MessageResource.LABEL_SUCCESS,request ));
return RestUtil.getJsonResponse(result, HttpStatus.CREATED,mapHeaderMessage);
} catch (ServiceVOException e) {
LOGGER.error("Got exception {} when add Mapping Alat To Bundle", e.getMessage());
addHeaderMessage(Constants.MessageInfo.ERROR_MESSAGE,
e.getMessage());
return RestUtil.getJsonHttpStatus(HttpStatus.INTERNAL_SERVER_ERROR,
mapHeaderMessage);
} catch (JpaSystemException jse) {
LOGGER.error("Got exception {} when add Mapping Alat To Bundle", jse.getMessage());
addHeaderMessage(Constants.MessageInfo.ERROR_MESSAGE,
jse.getMessage());
return RestUtil.getJsonHttpStatus(HttpStatus.CONFLICT,
mapHeaderMessage);
}
}
@RequestMapping(value = "/update-mapping-alat-to-bundle/", method = RequestMethod.POST, produces = MediaType.APPLICATION_JSON_VALUE, consumes = MediaType.APPLICATION_JSON_VALUE)
public ResponseEntity<Map<String,Object>> updateVO(@Valid @RequestBody MappingAlatToBundleVO vo, HttpServletRequest request) {
try {
Map<String,Object> result=mappingAlatToBundleService.updateMappingAlatToBundle(vo);
if (null != result)
mapHeaderMessage.put(WebConstants.HttpHeaderInfo.LABEL_SUCCESS,getMessage(MessageResource.LABEL_SUCCESS,request ));
return RestUtil.getJsonResponse(result, HttpStatus.CREATED,mapHeaderMessage);
} catch (ServiceVOException e) {
LOGGER.error("Got exception {} when add Mapping Alat To Bundle", e.getMessage());
addHeaderMessage(Constants.MessageInfo.ERROR_MESSAGE,
e.getMessage());
return RestUtil.getJsonHttpStatus(HttpStatus.INTERNAL_SERVER_ERROR,
mapHeaderMessage);
} catch (JpaSystemException jse) {
LOGGER.error("Got exception {} when add Mapping Alat To Bundle", jse.getMessage());
addHeaderMessage(Constants.MessageInfo.ERROR_MESSAGE,
jse.getMessage());
return RestUtil.getJsonHttpStatus(HttpStatus.CONFLICT,
mapHeaderMessage);
}
}
@RequestMapping(value = "/find-all-mapping-alat-to-bundle/", method = RequestMethod.GET, produces = MediaType.APPLICATION_JSON_VALUE)
public ResponseEntity<Map<String,Object>> getAllVO(HttpServletRequest request) {
try {
Map<String,Object> result=mappingAlatToBundleService.findAllMappingAlatToBundle();
if (null != result)
mapHeaderMessage.put(WebConstants.HttpHeaderInfo.LABEL_SUCCESS,getMessage(MessageResource.LABEL_SUCCESS,request ));
return RestUtil.getJsonResponse(result, HttpStatus.CREATED,mapHeaderMessage);
} catch (ServiceVOException e) {
LOGGER.error("Got exception {} when get all Mapping Alat To Bundle", e.getMessage());
addHeaderMessage(Constants.MessageInfo.ERROR_MESSAGE,
e.getMessage());
return RestUtil.getJsonHttpStatus(HttpStatus.INTERNAL_SERVER_ERROR,
mapHeaderMessage);
} catch (JpaSystemException jse) {
LOGGER.error("Got exception {} when get all Mapping Alat To Bundle", jse.getMessage());
addHeaderMessage(Constants.MessageInfo.ERROR_MESSAGE,
jse.getMessage());
return RestUtil.getJsonHttpStatus(HttpStatus.CONFLICT,
mapHeaderMessage);
}
}
@RequestMapping(value = "/save-all-mapping-alat-to-bundle/", method = RequestMethod.POST, produces = MediaType.APPLICATION_JSON_VALUE, consumes = MediaType.APPLICATION_JSON_VALUE)
public ResponseEntity<Map<String,Object>> saveAllVO(@Valid @RequestBody List<MappingAlatToBundleVO> vos, HttpServletRequest request) {
try {
Map<String,Object> result=mappingAlatToBundleService.saveAllMappingAlatToBundle(vos);
if (null != result)
mapHeaderMessage.put(WebConstants.HttpHeaderInfo.LABEL_SUCCESS,getMessage(MessageResource.LABEL_SUCCESS,request ));
return RestUtil.getJsonResponse(result, HttpStatus.CREATED,mapHeaderMessage);
} catch (ServiceVOException e) {
LOGGER.error("Got exception {} when add all Jadwal Supir Ambulance", e.getMessage());
addHeaderMessage(Constants.MessageInfo.ERROR_MESSAGE,
e.getMessage());
return RestUtil.getJsonHttpStatus(HttpStatus.INTERNAL_SERVER_ERROR,
mapHeaderMessage);
} catch (JpaSystemException jse) {
LOGGER.error("Got exception {} when add all Jadwal Supir Ambulance", jse.getMessage());
addHeaderMessage(Constants.MessageInfo.ERROR_MESSAGE,
jse.getMessage());
return RestUtil.getJsonHttpStatus(HttpStatus.CONFLICT,
mapHeaderMessage);
}
}
@RequestMapping(value="/get-mesin-all",
method=RequestMethod.GET,
produces=MediaType.APPLICATION_JSON_VALUE)
public Map<String, Object> getMesinAll(HttpServletRequest request) {
Map<String, Object> result = this.mappingAlatToBundleService.getMesinAll();
return result;
}
@RequestMapping(value="/get-bundle-set-alat-by-id",
method=RequestMethod.GET,
produces=MediaType.APPLICATION_JSON_VALUE)
public Map<String, Object> getBundleSetAlatbyId(
@RequestParam("idBundle")Integer idBundle,
HttpServletRequest request) { HttpServletRequest request) {
Map<String, Object> result = this.mappingAlatToBundleService.getMappingAlatToBundleById(idBundle); try {
return result; Map<String, Object> result = mappingAlatToBundleService.saveAllMappingAlatToBundle(vos);
if (null != result)
mapHeaderMessage.put(LABEL_SUCCESS, getMessage(MessageResource.LABEL_SUCCESS, request));
return getJsonResponse(result, CREATED, mapHeaderMessage);
} catch (ServiceVOException e) {
LOGGER.error("Got ServiceVOException {} when saveAllMappingAlatToBundle", e.getMessage());
addHeaderMessage(ERROR_MESSAGE, e.getMessage());
return getJsonHttpStatus(INTERNAL_SERVER_ERROR, mapHeaderMessage);
} catch (JpaSystemException jse) {
LOGGER.error("Got JpaSystemException {} when saveAllMappingAlatToBundle", jse.getMessage());
addHeaderMessage(ERROR_MESSAGE, jse.getMessage());
return getJsonHttpStatus(CONFLICT, mapHeaderMessage);
}
} }
@RequestMapping(value = "/get-mesin-all", method = GET, produces = APPLICATION_JSON_VALUE)
@Override public Map<String, Object> getMesinAll(HttpServletRequest request) {
public ResponseEntity<Collection<MappingAlatToBundleVO>> getAllVOWithQueryString(HttpServletRequest request, return this.mappingAlatToBundleService.getMesinAll();
Integer page, Integer limit, String sort, String dir) {
return null;
}
@Override
public ResponseEntity<MappingAlatToBundleVO> getVO(Integer id) {
return null;
}
@Override
public ResponseEntity<String> addVO(MappingAlatToBundleVO vo) {
return null;
}
@Override
public ResponseEntity<String> editVO(MappingAlatToBundleVO vo) {
return null;
}
@Override
public ResponseEntity<String> deleteVO(Integer id) {
return null;
}
@Override
public ResponseEntity<List<MappingAlatToBundleVO>> getAllVO() {
return null;
} }
} }

View File

@ -1,165 +1,85 @@
package com.jasamedika.medifirst2000.controller; package com.jasamedika.medifirst2000.controller;
import java.util.List;
import java.util.Map;
import javax.servlet.http.HttpServletRequest;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.HttpStatus;
import org.springframework.http.MediaType;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;
import com.jasamedika.medifirst2000.constants.MessageResource; import com.jasamedika.medifirst2000.constants.MessageResource;
import com.jasamedika.medifirst2000.controller.base.LocaleController; import com.jasamedika.medifirst2000.controller.base.LocaleController;
import com.jasamedika.medifirst2000.core.web.WebConstants;
import com.jasamedika.medifirst2000.dto.MapAlatToProdukToBhpDto; import com.jasamedika.medifirst2000.dto.MapAlatToProdukToBhpDto;
import com.jasamedika.medifirst2000.service.MappingBahanToMesinService; import com.jasamedika.medifirst2000.service.MappingBahanToMesinService;
import com.jasamedika.medifirst2000.util.rest.RestUtil;
import com.jasamedika.medifirst2000.vo.MapAlatToProdukToBhpVO; import com.jasamedika.medifirst2000.vo.MapAlatToProdukToBhpVO;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import javax.servlet.http.HttpServletRequest;
import java.util.List;
import java.util.Map;
import static com.jasamedika.medifirst2000.core.web.WebConstants.HttpHeaderInfo.LABEL_SUCCESS;
import static com.jasamedika.medifirst2000.util.rest.RestUtil.getJsonHttpStatus;
import static com.jasamedika.medifirst2000.util.rest.RestUtil.getJsonResponse;
import static org.springframework.http.HttpStatus.INTERNAL_SERVER_ERROR;
import static org.springframework.http.HttpStatus.OK;
import static org.springframework.http.MediaType.APPLICATION_JSON_VALUE;
import static org.springframework.web.bind.annotation.RequestMethod.GET;
import static org.springframework.web.bind.annotation.RequestMethod.POST;
@RestController @RestController
@RequestMapping(value="/map-bahan-to-mesin") @RequestMapping(value = "/map-bahan-to-mesin")
public class MappingBahanToMesinController extends LocaleController<MapAlatToProdukToBhpVO>{ public class MappingBahanToMesinController extends LocaleController<MapAlatToProdukToBhpVO> {
@Autowired @Autowired
private MappingBahanToMesinService mappingBahanToMesinService; private MappingBahanToMesinService mappingBahanToMesinService;
@RequestMapping(value="/save", method = RequestMethod.POST, produces = MediaType.APPLICATION_JSON_VALUE) @RequestMapping(value = "/save", method = POST, produces = APPLICATION_JSON_VALUE)
public ResponseEntity<List<Map<String,Object>>> save(@RequestBody List<MapAlatToProdukToBhpDto> dtos, public ResponseEntity<List<Map<String, Object>>> save(@RequestBody List<MapAlatToProdukToBhpDto> dtos,
HttpServletRequest request) { HttpServletRequest request) {
List<Map<String,Object>> result = mappingBahanToMesinService.saveMappingBahanToMesin(dtos); List<Map<String, Object>> result = mappingBahanToMesinService.saveMappingBahanToMesin(dtos);
if (!result.isEmpty()) { if (!result.isEmpty()) {
mapHeaderMessage.put(WebConstants.HttpHeaderInfo.LABEL_SUCCESS, getMessage(MessageResource.LABEL_SUCCESS, request)); mapHeaderMessage.put(LABEL_SUCCESS, getMessage(MessageResource.LABEL_SUCCESS, request));
return RestUtil.getJsonResponse(result, HttpStatus.OK, mapHeaderMessage); return getJsonResponse(result, OK, mapHeaderMessage);
} }
return RestUtil.getJsonHttpStatus(HttpStatus.INTERNAL_SERVER_ERROR, mapHeaderMessage); return getJsonHttpStatus(INTERNAL_SERVER_ERROR, mapHeaderMessage);
} }
@RequestMapping(value="/get", method = RequestMethod.GET, produces = MediaType.APPLICATION_JSON_VALUE) @RequestMapping(value = "/get-all", method = GET, produces = APPLICATION_JSON_VALUE)
public ResponseEntity<Map<String, Object>> get( public ResponseEntity<List<Map<String, Object>>> getAll(HttpServletRequest request) {
@RequestParam(value="idMappingBahanToMesin", required = true) Integer idMappingBahanToMesin,
HttpServletRequest request) {
Map<String, Object> result = mappingBahanToMesinService.getById(idMappingBahanToMesin);
if (result!=null) {
mapHeaderMessage.put(WebConstants.HttpHeaderInfo.LABEL_SUCCESS, getMessage(MessageResource.LABEL_SUCCESS, request));
return RestUtil.getJsonResponse(result, HttpStatus.OK, mapHeaderMessage);
}
return RestUtil.getJsonHttpStatus(HttpStatus.INTERNAL_SERVER_ERROR, mapHeaderMessage);
}
@RequestMapping(value="/get-all", method = RequestMethod.GET, produces = MediaType.APPLICATION_JSON_VALUE)
public ResponseEntity<List<Map<String, Object>>> getAll(
HttpServletRequest request) {
List<Map<String, Object>> result = mappingBahanToMesinService.getAll(); List<Map<String, Object>> result = mappingBahanToMesinService.getAll();
if (result != null) {
if (result!=null) { mapHeaderMessage.put(LABEL_SUCCESS, getMessage(MessageResource.LABEL_SUCCESS, request));
mapHeaderMessage.put(WebConstants.HttpHeaderInfo.LABEL_SUCCESS, getMessage(MessageResource.LABEL_SUCCESS, request)); return getJsonResponse(result, OK, mapHeaderMessage);
return RestUtil.getJsonResponse(result, HttpStatus.OK, mapHeaderMessage);
} }
return RestUtil.getJsonHttpStatus(HttpStatus.INTERNAL_SERVER_ERROR, mapHeaderMessage); return getJsonHttpStatus(INTERNAL_SERVER_ERROR, mapHeaderMessage);
} }
@RequestMapping(value="/get-all-mesin-cuci", method = RequestMethod.GET, produces = MediaType.APPLICATION_JSON_VALUE) @RequestMapping(value = "/get-all-mesin-cuci", method = GET, produces = APPLICATION_JSON_VALUE)
public ResponseEntity<List<Map<String, Object>>> getAllMesinCuci( public ResponseEntity<List<Map<String, Object>>> getAllMesinCuci(HttpServletRequest request) {
HttpServletRequest request) {
List<Map<String, Object>> result = mappingBahanToMesinService.findMesinCuci(); List<Map<String, Object>> result = mappingBahanToMesinService.findMesinCuci();
if (result != null) {
if (result!=null) { mapHeaderMessage.put(LABEL_SUCCESS, getMessage(MessageResource.LABEL_SUCCESS, request));
mapHeaderMessage.put(WebConstants.HttpHeaderInfo.LABEL_SUCCESS, getMessage(MessageResource.LABEL_SUCCESS, request)); return getJsonResponse(result, OK, mapHeaderMessage);
return RestUtil.getJsonResponse(result, HttpStatus.OK, mapHeaderMessage);
} }
return RestUtil.getJsonHttpStatus(HttpStatus.INTERNAL_SERVER_ERROR, mapHeaderMessage); return getJsonHttpStatus(INTERNAL_SERVER_ERROR, mapHeaderMessage);
} }
@RequestMapping(value="/get-all-proses-cuci", method = RequestMethod.GET, produces = MediaType.APPLICATION_JSON_VALUE) @RequestMapping(value = "/get-all-bahan", method = GET, produces = APPLICATION_JSON_VALUE)
public ResponseEntity<List<Map<String, Object>>> getAllProcessCuci( public ResponseEntity<List<Map<String, Object>>> getKomponenHargaByJenis(HttpServletRequest request) {
HttpServletRequest request) {
List<Map<String, Object>> result = mappingBahanToMesinService.findProsesCuci();
if (result!=null) {
mapHeaderMessage.put(WebConstants.HttpHeaderInfo.LABEL_SUCCESS, getMessage(MessageResource.LABEL_SUCCESS, request));
return RestUtil.getJsonResponse(result, HttpStatus.OK, mapHeaderMessage);
}
return RestUtil.getJsonHttpStatus(HttpStatus.INTERNAL_SERVER_ERROR, mapHeaderMessage);
}
@RequestMapping(value="/get-kapasitas-mesin-cuci", method = RequestMethod.GET, produces = MediaType.APPLICATION_JSON_VALUE)
public ResponseEntity<Map<String, Object>> getKapasitasMesinCuci(
@RequestParam(value="alatId", required = true) Integer alatId,
HttpServletRequest request) {
Map<String, Object> result = mappingBahanToMesinService.findKapasitasMesinCuci(alatId);
if (result!=null) {
mapHeaderMessage.put(WebConstants.HttpHeaderInfo.LABEL_SUCCESS, getMessage(MessageResource.LABEL_SUCCESS, request));
return RestUtil.getJsonResponse(result, HttpStatus.OK, mapHeaderMessage);
}
return RestUtil.getJsonHttpStatus(HttpStatus.INTERNAL_SERVER_ERROR, mapHeaderMessage);
}
@RequestMapping(value="/get-all-bahan", method = RequestMethod.GET, produces = MediaType.APPLICATION_JSON_VALUE)
public ResponseEntity<List<Map<String, Object>>> getKomponenHargaByJenis(
HttpServletRequest request) {
List<Map<String, Object>> result = mappingBahanToMesinService.findBahanCuci(); List<Map<String, Object>> result = mappingBahanToMesinService.findBahanCuci();
if (result != null) {
if (result!=null) { mapHeaderMessage.put(LABEL_SUCCESS, getMessage(MessageResource.LABEL_SUCCESS, request));
mapHeaderMessage.put(WebConstants.HttpHeaderInfo.LABEL_SUCCESS, getMessage(MessageResource.LABEL_SUCCESS, request)); return getJsonResponse(result, OK, mapHeaderMessage);
return RestUtil.getJsonResponse(result, HttpStatus.OK, mapHeaderMessage);
} }
return RestUtil.getJsonHttpStatus(HttpStatus.INTERNAL_SERVER_ERROR, mapHeaderMessage); return getJsonHttpStatus(INTERNAL_SERVER_ERROR, mapHeaderMessage);
} }
@RequestMapping(value="/get-satuan-bahan", method = RequestMethod.GET, produces = MediaType.APPLICATION_JSON_VALUE) @RequestMapping(value = "/get-satuan-bahan", method = GET, produces = APPLICATION_JSON_VALUE)
public ResponseEntity<List<Map<String, Object>>> getSatuanBahan( public ResponseEntity<List<Map<String, Object>>> getSatuanBahan(HttpServletRequest request) {
HttpServletRequest request) {
List<Map<String, Object>> result = mappingBahanToMesinService.findSatuanBahan(); List<Map<String, Object>> result = mappingBahanToMesinService.findSatuanBahan();
if (result != null) {
if (result!=null) { mapHeaderMessage.put(LABEL_SUCCESS, getMessage(MessageResource.LABEL_SUCCESS, request));
mapHeaderMessage.put(WebConstants.HttpHeaderInfo.LABEL_SUCCESS, getMessage(MessageResource.LABEL_SUCCESS, request)); return getJsonResponse(result, OK, mapHeaderMessage);
return RestUtil.getJsonResponse(result, HttpStatus.OK, mapHeaderMessage);
} }
return RestUtil.getJsonHttpStatus(HttpStatus.INTERNAL_SERVER_ERROR, mapHeaderMessage); return getJsonHttpStatus(INTERNAL_SERVER_ERROR, mapHeaderMessage);
}
@RequestMapping(value="/get-all-proses-cuci-cuci", method = RequestMethod.GET, produces = MediaType.APPLICATION_JSON_VALUE)
public ResponseEntity<List<Map<String, Object>>> getAllProcessCuciCuci(
HttpServletRequest request) {
List<Map<String, Object>> result = mappingBahanToMesinService.findProsesCuciCuci();
if (result!=null) {
mapHeaderMessage.put(WebConstants.HttpHeaderInfo.LABEL_SUCCESS, getMessage(MessageResource.LABEL_SUCCESS, request));
return RestUtil.getJsonResponse(result, HttpStatus.OK, mapHeaderMessage);
}
return RestUtil.getJsonHttpStatus(HttpStatus.INTERNAL_SERVER_ERROR, mapHeaderMessage);
}
@RequestMapping(value="/get-all-proses-cuci-bilas", method = RequestMethod.GET, produces = MediaType.APPLICATION_JSON_VALUE)
public ResponseEntity<List<Map<String, Object>>> getAllProcessCuciBilas(
HttpServletRequest request) {
List<Map<String, Object>> result = mappingBahanToMesinService.findProsesCuciBilas();
if (result!=null) {
mapHeaderMessage.put(WebConstants.HttpHeaderInfo.LABEL_SUCCESS, getMessage(MessageResource.LABEL_SUCCESS, request));
return RestUtil.getJsonResponse(result, HttpStatus.OK, mapHeaderMessage);
}
return RestUtil.getJsonHttpStatus(HttpStatus.INTERNAL_SERVER_ERROR, mapHeaderMessage);
}
@RequestMapping(value="/get-all-proses-cuci-kering", method = RequestMethod.GET, produces = MediaType.APPLICATION_JSON_VALUE)
public ResponseEntity<List<Map<String, Object>>> getAllProcessCuciKering(
HttpServletRequest request) {
List<Map<String, Object>> result = mappingBahanToMesinService.findProsesCuciKering();
if (result!=null) {
mapHeaderMessage.put(WebConstants.HttpHeaderInfo.LABEL_SUCCESS, getMessage(MessageResource.LABEL_SUCCESS, request));
return RestUtil.getJsonResponse(result, HttpStatus.OK, mapHeaderMessage);
}
return RestUtil.getJsonHttpStatus(HttpStatus.INTERNAL_SERVER_ERROR, mapHeaderMessage);
} }
} }

View File

@ -1,170 +1,64 @@
package com.jasamedika.medifirst2000.controller; package com.jasamedika.medifirst2000.controller;
import java.util.List; import com.jasamedika.medifirst2000.constants.MessageResource;
import java.util.Map; import com.jasamedika.medifirst2000.controller.base.LocaleController;
import com.jasamedika.medifirst2000.entities.MappingBmhpToSetAlat;
import com.jasamedika.medifirst2000.exception.ServiceVOException;
import com.jasamedika.medifirst2000.service.MappingBmhpToSetAlatService;
import com.jasamedika.medifirst2000.vo.MappingBmhpToSetAlatVO;
import org.slf4j.Logger;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.ResponseEntity;
import org.springframework.orm.jpa.JpaSystemException;
import org.springframework.web.bind.annotation.*;
import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletRequest;
import javax.validation.Valid; import javax.validation.Valid;
import java.util.List;
import java.util.Map;
import org.slf4j.Logger; import static com.jasamedika.medifirst2000.constants.Constants.MessageInfo.ERROR_MESSAGE;
import org.slf4j.LoggerFactory; import static com.jasamedika.medifirst2000.core.web.WebConstants.HttpHeaderInfo.LABEL_SUCCESS;
import org.springframework.beans.factory.annotation.Autowired; import static com.jasamedika.medifirst2000.util.rest.RestUtil.getJsonHttpStatus;
import org.springframework.http.HttpStatus; import static com.jasamedika.medifirst2000.util.rest.RestUtil.getJsonResponse;
import org.springframework.http.MediaType; import static org.slf4j.LoggerFactory.getLogger;
import org.springframework.http.ResponseEntity; import static org.springframework.http.HttpStatus.*;
import org.springframework.orm.jpa.JpaSystemException; import static org.springframework.http.MediaType.APPLICATION_JSON_VALUE;
import org.springframework.web.bind.annotation.RequestBody; import static org.springframework.web.bind.annotation.RequestMethod.GET;
import org.springframework.web.bind.annotation.RequestMapping; import static org.springframework.web.bind.annotation.RequestMethod.POST;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;
import com.jasamedika.medifirst2000.constants.Constants;
import com.jasamedika.medifirst2000.constants.MessageResource;
import com.jasamedika.medifirst2000.controller.base.LocaleController;
import com.jasamedika.medifirst2000.core.web.WebConstants;
import com.jasamedika.medifirst2000.exception.ServiceVOException;
import com.jasamedika.medifirst2000.service.MappingBmhpToSetAlatService;
import com.jasamedika.medifirst2000.util.rest.RestUtil;
import com.jasamedika.medifirst2000.vo.MappingBmhpToSetAlatVO;
@RestController @RestController
@RequestMapping("/mapping-bmhp-to-set-alat") @RequestMapping("/mapping-bmhp-to-set-alat")
public class MappingBmhpToSetAlatController extends LocaleController<MappingBmhpToSetAlatVO> { public class MappingBmhpToSetAlatController extends LocaleController<MappingBmhpToSetAlatVO> {
private static final Logger LOGGER = getLogger(MappingBmhpToSetAlatController.class);
@Autowired @Autowired
private MappingBmhpToSetAlatService mappingBmhpToSetAlatService; private MappingBmhpToSetAlatService<MappingBmhpToSetAlat> mappingBmhpToSetAlatService;
private static final Logger LOGGER = LoggerFactory @RequestMapping(value = "/save-all-mapping-bmhp-to-set-alat/", method = POST, produces = APPLICATION_JSON_VALUE, consumes = APPLICATION_JSON_VALUE)
.getLogger(MappingBmhpToSetAlatController.class); public ResponseEntity<Map<String, Object>> addVOS(@Valid @RequestBody List<MappingBmhpToSetAlatVO> vos,
@RequestMapping(value = "/save-all-mapping-bmhp-to-set-alat/", method = RequestMethod.POST, produces = MediaType.APPLICATION_JSON_VALUE, consumes = MediaType.APPLICATION_JSON_VALUE)
public ResponseEntity<Map<String,Object>> addVOS(@Valid @RequestBody List<MappingBmhpToSetAlatVO> vos,HttpServletRequest request) {
try{
Map<String, Object> result = mappingBmhpToSetAlatService.addMappingBmhpToSetAlats(vos);
if (null != result)
mapHeaderMessage.put(WebConstants.HttpHeaderInfo.LABEL_SUCCESS, getMessage(MessageResource.LABEL_SUCCESS,request));
return RestUtil.getJsonResponse(result, HttpStatus.CREATED, mapHeaderMessage);
} catch (ServiceVOException e) {
LOGGER.error("Got exception {} when add MappingBmhpToSetAlat", e.getMessage());
addHeaderMessage(Constants.MessageInfo.ERROR_MESSAGE,
e.getMessage());
return RestUtil.getJsonHttpStatus(HttpStatus.INTERNAL_SERVER_ERROR,
mapHeaderMessage);
} catch (JpaSystemException jse) {
LOGGER.error("Got exception {} when add MappingBmhpToSetAlat", jse.getMessage());
addHeaderMessage(Constants.MessageInfo.ERROR_MESSAGE,
jse.getMessage());
return RestUtil.getJsonHttpStatus(HttpStatus.CONFLICT,
mapHeaderMessage);
}
}
@RequestMapping(value = "/save-mapping-bmhp-to-set-alat/", method = RequestMethod.POST, produces = MediaType.APPLICATION_JSON_VALUE, consumes = MediaType.APPLICATION_JSON_VALUE)
public ResponseEntity<Map<String,Object>> addVO(@Valid @RequestBody MappingBmhpToSetAlatVO vo,HttpServletRequest request) {
try{
Map<String, Object> result = mappingBmhpToSetAlatService.addMappingBmhpToSetAlat(vo);
if (null != result)
mapHeaderMessage.put(WebConstants.HttpHeaderInfo.LABEL_SUCCESS, getMessage(MessageResource.LABEL_SUCCESS,request));
return RestUtil.getJsonResponse(result, HttpStatus.CREATED, mapHeaderMessage);
} catch (ServiceVOException e) {
LOGGER.error("Got exception {} when add MappingBmhpToSetAlat", e.getMessage());
addHeaderMessage(Constants.MessageInfo.ERROR_MESSAGE,
e.getMessage());
return RestUtil.getJsonHttpStatus(HttpStatus.INTERNAL_SERVER_ERROR,
mapHeaderMessage);
} catch (JpaSystemException jse) {
LOGGER.error("Got exception {} when add MappingBmhpToSetAlat", jse.getMessage());
addHeaderMessage(Constants.MessageInfo.ERROR_MESSAGE,
jse.getMessage());
return RestUtil.getJsonHttpStatus(HttpStatus.CONFLICT,
mapHeaderMessage);
}
}
@RequestMapping(value = "/update-all-mapping-bmhp-to-set-alat/", method = RequestMethod.POST, produces = MediaType.APPLICATION_JSON_VALUE, consumes = MediaType.APPLICATION_JSON_VALUE)
public ResponseEntity<Map<String,Object>> updateVOS(@Valid @RequestBody List<MappingBmhpToSetAlatVO> vos,HttpServletRequest request) {
try{
Map<String, Object> result = mappingBmhpToSetAlatService.addMappingBmhpToSetAlats(vos);
if (null != result)
mapHeaderMessage.put(WebConstants.HttpHeaderInfo.LABEL_SUCCESS, getMessage(MessageResource.LABEL_SUCCESS,request));
return RestUtil.getJsonResponse(result, HttpStatus.CREATED, mapHeaderMessage);
} catch (ServiceVOException e) {
LOGGER.error("Got exception {} when update MappingBmhpToSetAlat", e.getMessage());
addHeaderMessage(Constants.MessageInfo.ERROR_MESSAGE,
e.getMessage());
return RestUtil.getJsonHttpStatus(HttpStatus.INTERNAL_SERVER_ERROR,
mapHeaderMessage);
} catch (JpaSystemException jse) {
LOGGER.error("Got exception {} when update MappingBmhpToSetAlat", jse.getMessage());
addHeaderMessage(Constants.MessageInfo.ERROR_MESSAGE,
jse.getMessage());
return RestUtil.getJsonHttpStatus(HttpStatus.CONFLICT,
mapHeaderMessage);
}
}
@RequestMapping(value = "/update-mapping-bmhp-to-set-alat/", method = RequestMethod.POST, produces = MediaType.APPLICATION_JSON_VALUE, consumes = MediaType.APPLICATION_JSON_VALUE)
public ResponseEntity<Map<String,Object>> updateVO(@Valid @RequestBody MappingBmhpToSetAlatVO vo,HttpServletRequest request) {
try{
Map<String, Object> result = mappingBmhpToSetAlatService.updateMappingBmhpToSetAlat(vo);
if (null != result)
mapHeaderMessage.put(WebConstants.HttpHeaderInfo.LABEL_SUCCESS, getMessage(MessageResource.LABEL_SUCCESS,request));
return RestUtil.getJsonResponse(result, HttpStatus.CREATED, mapHeaderMessage);
} catch (ServiceVOException e) {
LOGGER.error("Got exception {} when update MappingBmhpToSetAlat", e.getMessage());
addHeaderMessage(Constants.MessageInfo.ERROR_MESSAGE,
e.getMessage());
return RestUtil.getJsonHttpStatus(HttpStatus.INTERNAL_SERVER_ERROR,
mapHeaderMessage);
} catch (JpaSystemException jse) {
LOGGER.error("Got exception {} when update MappingBmhpToSetAlat", jse.getMessage());
addHeaderMessage(Constants.MessageInfo.ERROR_MESSAGE,
jse.getMessage());
return RestUtil.getJsonHttpStatus(HttpStatus.CONFLICT,
mapHeaderMessage);
}
}
@RequestMapping(value = "/find-all-mapping-bmhp-to-set-alat/", method = RequestMethod.GET, produces = MediaType.APPLICATION_JSON_VALUE)
public ResponseEntity<Map<String,Object>> getAllVO(HttpServletRequest request) {
try {
Map<String,Object> result=mappingBmhpToSetAlatService.findAllMappingBmhpToSetAlat();
if (null != result)
mapHeaderMessage.put(WebConstants.HttpHeaderInfo.LABEL_SUCCESS,getMessage(MessageResource.LABEL_SUCCESS,request ));
return RestUtil.getJsonResponse(result, HttpStatus.CREATED,mapHeaderMessage);
} catch (ServiceVOException e) {
LOGGER.error("Got exception {} when get all mapping bmhp to set alat", e.getMessage());
addHeaderMessage(Constants.MessageInfo.ERROR_MESSAGE,
e.getMessage());
return RestUtil.getJsonHttpStatus(HttpStatus.INTERNAL_SERVER_ERROR,
mapHeaderMessage);
} catch (JpaSystemException jse) {
LOGGER.error("Got exception {} when get mapping bmhp to set alat", jse.getMessage());
addHeaderMessage(Constants.MessageInfo.ERROR_MESSAGE,
jse.getMessage());
return RestUtil.getJsonHttpStatus(HttpStatus.CONFLICT,
mapHeaderMessage);
}
}
@RequestMapping(value="/get-bundle-set-bmhp-by-id",
method=RequestMethod.GET,
produces=MediaType.APPLICATION_JSON_VALUE)
public Map<String, Object> getBundleSetAlatbyId(
@RequestParam("idBundle")Integer idBundle,
HttpServletRequest request) { HttpServletRequest request) {
Map<String, Object> result = this.mappingBmhpToSetAlatService.getMappingBmhhpToSetAlatByBundle(idBundle); try {
return result; Map<String, Object> result = mappingBmhpToSetAlatService.addMappingBmhpToSetAlats(vos);
if (null != result)
mapHeaderMessage.put(LABEL_SUCCESS, getMessage(MessageResource.LABEL_SUCCESS, request));
return getJsonResponse(result, CREATED, mapHeaderMessage);
} catch (ServiceVOException e) {
LOGGER.error("Got ServiceVOException {} when addMappingBmhpToSetAlats", e.getMessage());
addHeaderMessage(ERROR_MESSAGE, e.getMessage());
return getJsonHttpStatus(INTERNAL_SERVER_ERROR, mapHeaderMessage);
} catch (JpaSystemException jse) {
LOGGER.error("Got JpaSystemException {} when addMappingBmhpToSetAlats", jse.getMessage());
addHeaderMessage(ERROR_MESSAGE, jse.getMessage());
return getJsonHttpStatus(CONFLICT, mapHeaderMessage);
}
}
@RequestMapping(value = "/get-bundle-set-bmhp-by-id", method = GET, produces = APPLICATION_JSON_VALUE)
public Map<String, Object> getBundleSetAlatbyId(@RequestParam("idBundle") Integer idBundle,
HttpServletRequest request) {
return this.mappingBmhpToSetAlatService.getMappingBmhhpToSetAlatByBundle(idBundle);
} }
} }

View File

@ -1,161 +1,131 @@
package com.jasamedika.medifirst2000.controller; package com.jasamedika.medifirst2000.controller;
import java.util.List; import com.jasamedika.medifirst2000.constants.MessageResource;
import java.util.Map; import com.jasamedika.medifirst2000.controller.base.LocaleController;
import com.jasamedika.medifirst2000.dto.MappingCycleDto;
import javax.servlet.http.HttpServletRequest; import com.jasamedika.medifirst2000.dto.MesinDto;
import javax.validation.Valid; import com.jasamedika.medifirst2000.exception.ServiceVOException;
import com.jasamedika.medifirst2000.service.MappingCycleService;
import com.jasamedika.medifirst2000.vo.MappingCycleVO;
import org.slf4j.Logger; import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.jpa.domain.Specification;
import org.springframework.http.HttpStatus;
import org.springframework.http.MediaType;
import org.springframework.http.ResponseEntity; import org.springframework.http.ResponseEntity;
import org.springframework.orm.jpa.JpaSystemException; import org.springframework.orm.jpa.JpaSystemException;
import org.springframework.web.bind.annotation.RequestBody; import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RequestParam; import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.web.bind.annotation.RestController; import org.springframework.web.bind.annotation.RestController;
import com.jasamedika.medifirst2000.constants.Constants; import javax.servlet.http.HttpServletRequest;
import com.jasamedika.medifirst2000.constants.MessageResource; import javax.validation.Valid;
import com.jasamedika.medifirst2000.controller.base.LocaleController; import java.util.List;
import com.jasamedika.medifirst2000.core.web.WebConstants; import java.util.Map;
import com.jasamedika.medifirst2000.dto.MappingCycleDto;
import com.jasamedika.medifirst2000.dto.MesinDto;
import com.jasamedika.medifirst2000.entities.MappingCycle;
import com.jasamedika.medifirst2000.exception.ServiceVOException;
import com.jasamedika.medifirst2000.service.MappingCycleService;
import com.jasamedika.medifirst2000.util.rest.RestUtil;
import com.jasamedika.medifirst2000.vo.MappingCycleVO;
import net.kaczmarzyk.spring.data.jpa.domain.Equal; import static com.jasamedika.medifirst2000.constants.Constants.MessageInfo.ERROR_MESSAGE;
import net.kaczmarzyk.spring.data.jpa.web.annotation.Spec; import static com.jasamedika.medifirst2000.core.web.WebConstants.HttpHeaderInfo.LABEL_SUCCESS;
import static com.jasamedika.medifirst2000.util.rest.RestUtil.getJsonHttpStatus;
import static com.jasamedika.medifirst2000.util.rest.RestUtil.getJsonResponse;
import static org.slf4j.LoggerFactory.getLogger;
import static org.springframework.http.HttpStatus.*;
import static org.springframework.http.MediaType.APPLICATION_JSON_VALUE;
import static org.springframework.web.bind.annotation.RequestMethod.GET;
import static org.springframework.web.bind.annotation.RequestMethod.POST;
@RestController @RestController
@RequestMapping("/mapping-cycle") @RequestMapping("/mapping-cycle")
public class MappingCycleController extends LocaleController<MappingCycleVO> { public class MappingCycleController extends LocaleController<MappingCycleVO> {
private static final Logger LOGGER = getLogger(MappingCycleController.class);
@Autowired @Autowired
private MappingCycleService mappingCycleService; private MappingCycleService mappingCycleService;
private static final Logger LOGGER = LoggerFactory.getLogger(MappingCycleController.class); @RequestMapping(value = "/save-mapping-cycle/", method = POST, produces = APPLICATION_JSON_VALUE, consumes = APPLICATION_JSON_VALUE)
@RequestMapping(value = "/save-mapping-cycle/", method = RequestMethod.POST, produces = MediaType.APPLICATION_JSON_VALUE, consumes = MediaType.APPLICATION_JSON_VALUE)
public ResponseEntity<Map<String, Object>> saveMappingCycle(@Valid @RequestBody MappingCycleVO vo, public ResponseEntity<Map<String, Object>> saveMappingCycle(@Valid @RequestBody MappingCycleVO vo,
HttpServletRequest request) { HttpServletRequest request) {
try { try {
Map<String, Object> result = mappingCycleService.saveMappingCycle(vo); Map<String, Object> result = mappingCycleService.saveMappingCycle(vo);
if (null != result) if (null != result)
mapHeaderMessage.put(WebConstants.HttpHeaderInfo.LABEL_SUCCESS, mapHeaderMessage.put(LABEL_SUCCESS, getMessage(MessageResource.LABEL_SUCCESS, request));
getMessage(MessageResource.LABEL_SUCCESS, request)); return getJsonResponse(result, CREATED, mapHeaderMessage);
return RestUtil.getJsonResponse(result, HttpStatus.CREATED, mapHeaderMessage);
} catch (ServiceVOException e) { } catch (ServiceVOException e) {
LOGGER.error("Got exception {} when save Mapping Cycle", e.getMessage()); LOGGER.error("Got ServiceVOException {} when saveMappingCycle", e.getMessage());
addHeaderMessage(Constants.MessageInfo.ERROR_MESSAGE, e.getMessage()); addHeaderMessage(ERROR_MESSAGE, e.getMessage());
return RestUtil.getJsonHttpStatus(HttpStatus.INTERNAL_SERVER_ERROR, mapHeaderMessage); return getJsonHttpStatus(INTERNAL_SERVER_ERROR, mapHeaderMessage);
} catch (JpaSystemException jse) { } catch (JpaSystemException jse) {
LOGGER.error("Got exception {} when save Mapping Cycle", jse.getMessage()); LOGGER.error("Got JpaSystemException {} when saveMappingCycle", jse.getMessage());
addHeaderMessage(Constants.MessageInfo.ERROR_MESSAGE, jse.getMessage()); addHeaderMessage(ERROR_MESSAGE, jse.getMessage());
return RestUtil.getJsonHttpStatus(HttpStatus.CONFLICT, mapHeaderMessage); return getJsonHttpStatus(CONFLICT, mapHeaderMessage);
} }
} }
@RequestMapping(value = "/find-nama-bahan/", method = RequestMethod.GET) @RequestMapping(value = "/find-nama-bahan/", method = GET)
public ResponseEntity<List<MappingCycleDto>> findProdukByKelompokProduk(HttpServletRequest request) { public ResponseEntity<List<MappingCycleDto>> findProdukByKelompokProduk(HttpServletRequest request) {
try { try {
List<MappingCycleDto> listNamaBahanVO = mappingCycleService.findNamaBahan(); List<MappingCycleDto> listNamaBahanVO = mappingCycleService.findNamaBahan();
mapHeaderMessage.put(WebConstants.HttpHeaderInfo.LABEL_SUCCESS, mapHeaderMessage.put(LABEL_SUCCESS, getMessage(MessageResource.LABEL_SUCCESS, request));
getMessage(MessageResource.LABEL_SUCCESS, request)); return getJsonResponse(listNamaBahanVO, OK, mapHeaderMessage);
return RestUtil.getJsonResponse(listNamaBahanVO, HttpStatus.OK, mapHeaderMessage);
} catch (ServiceVOException e) { } catch (ServiceVOException e) {
LOGGER.error("Got exception {} when Find Nama Bahan", e.getMessage()); LOGGER.error("Got ServiceVOException {} when findNamaBahan", e.getMessage());
addHeaderMessage(Constants.MessageInfo.ERROR_MESSAGE, e.getMessage()); addHeaderMessage(ERROR_MESSAGE, e.getMessage());
return RestUtil.getJsonHttpStatus(HttpStatus.INTERNAL_SERVER_ERROR, mapHeaderMessage); return getJsonHttpStatus(INTERNAL_SERVER_ERROR, mapHeaderMessage);
} catch (JpaSystemException jse) { } catch (JpaSystemException jse) {
LOGGER.error("Got exception {} when Find Nama Bahan", jse.getMessage()); LOGGER.error("Got JpaSystemException {} when findNamaBahan", jse.getMessage());
addHeaderMessage(Constants.MessageInfo.ERROR_MESSAGE, jse.getMessage()); addHeaderMessage(ERROR_MESSAGE, jse.getMessage());
return RestUtil.getJsonHttpStatus(HttpStatus.CONFLICT, mapHeaderMessage); return getJsonHttpStatus(CONFLICT, mapHeaderMessage);
} }
} }
@RequestMapping(value = "/find-mesin-dengan-kapasitas/", method = RequestMethod.GET) @RequestMapping(value = "/find-mesin-dengan-kapasitas/", method = GET)
public ResponseEntity<List<MesinDto>> findMesinDenganKapasitas(HttpServletRequest request) { public ResponseEntity<List<MesinDto>> findMesinDenganKapasitas(HttpServletRequest request) {
try { try {
List<MesinDto> listMesinVO = mappingCycleService.findMesinDenganKapasitas(); List<MesinDto> listMesinVO = mappingCycleService.findMesinDenganKapasitas();
mapHeaderMessage.put(WebConstants.HttpHeaderInfo.LABEL_SUCCESS, mapHeaderMessage.put(LABEL_SUCCESS, getMessage(MessageResource.LABEL_SUCCESS, request));
getMessage(MessageResource.LABEL_SUCCESS, request)); return getJsonResponse(listMesinVO, OK, mapHeaderMessage);
return RestUtil.getJsonResponse(listMesinVO, HttpStatus.OK, mapHeaderMessage);
} catch (ServiceVOException e) { } catch (ServiceVOException e) {
LOGGER.error("Got exception {} when Find Mesin", e.getMessage()); LOGGER.error("Got ServiceVOException {} when findMesinDenganKapasitas", e.getMessage());
addHeaderMessage(Constants.MessageInfo.ERROR_MESSAGE, e.getMessage()); addHeaderMessage(ERROR_MESSAGE, e.getMessage());
return RestUtil.getJsonHttpStatus(HttpStatus.INTERNAL_SERVER_ERROR, mapHeaderMessage); return getJsonHttpStatus(INTERNAL_SERVER_ERROR, mapHeaderMessage);
} catch (JpaSystemException jse) { } catch (JpaSystemException jse) {
LOGGER.error("Got exception {} when Find Mesin", jse.getMessage()); LOGGER.error("Got JpaSystemException {} when findMesinDenganKapasitas", jse.getMessage());
addHeaderMessage(Constants.MessageInfo.ERROR_MESSAGE, jse.getMessage()); addHeaderMessage(ERROR_MESSAGE, jse.getMessage());
return RestUtil.getJsonHttpStatus(HttpStatus.CONFLICT, mapHeaderMessage); return getJsonHttpStatus(CONFLICT, mapHeaderMessage);
} }
} }
@RequestMapping(value="/find-all/", method= RequestMethod.GET,produces = MediaType.APPLICATION_JSON_VALUE) @RequestMapping(value = "/get-all/", method = GET)
@ResponseBody
public Map<String,Object> findAll(
@RequestParam(value = "page", required = false, defaultValue = "0") Integer page,
@RequestParam(value = "take", required = false, defaultValue = "100") Integer take,
@RequestParam(value = "sort", required = false, defaultValue = "noRec") String sort,
@RequestParam(value = "dir", required = false, defaultValue = "asc") String dir,
@Spec(path = "noRec", params = "noRec", spec = Equal.class) Specification<MappingCycle> spec,
HttpServletRequest request)
{
Map<String, Object> resultPageMap = mappingCycleService.findAll(page, take, sort, dir);
return resultPageMap;
}
@RequestMapping(value = "/get-all/", method = RequestMethod.GET)
public ResponseEntity<Map<String, Object>> getAll(HttpServletRequest request) { public ResponseEntity<Map<String, Object>> getAll(HttpServletRequest request) {
try { try {
Map<String, Object> result = this.mappingCycleService.getMappingCycle(); Map<String, Object> result = this.mappingCycleService.getMappingCycle();
mapHeaderMessage.put(WebConstants.HttpHeaderInfo.LABEL_SUCCESS, mapHeaderMessage.put(LABEL_SUCCESS, getMessage(MessageResource.LABEL_SUCCESS, request));
getMessage(MessageResource.LABEL_SUCCESS, request)); return getJsonResponse(result, OK, mapHeaderMessage);
return RestUtil.getJsonResponse(result, HttpStatus.OK, mapHeaderMessage);
} catch (ServiceVOException e) { } catch (ServiceVOException e) {
LOGGER.error("Got exception {} when Find Mesin", e.getMessage()); LOGGER.error("Got ServiceVOException {} when getMappingCycle", e.getMessage());
addHeaderMessage(Constants.MessageInfo.ERROR_MESSAGE, e.getMessage()); addHeaderMessage(ERROR_MESSAGE, e.getMessage());
return RestUtil.getJsonHttpStatus(HttpStatus.INTERNAL_SERVER_ERROR, mapHeaderMessage); return getJsonHttpStatus(INTERNAL_SERVER_ERROR, mapHeaderMessage);
} catch (JpaSystemException jse) { } catch (JpaSystemException jse) {
LOGGER.error("Got exception {} when Find Mesin", jse.getMessage()); LOGGER.error("Got JpaSystemException {} when getMappingCycle", jse.getMessage());
addHeaderMessage(Constants.MessageInfo.ERROR_MESSAGE, jse.getMessage()); addHeaderMessage(ERROR_MESSAGE, jse.getMessage());
return RestUtil.getJsonHttpStatus(HttpStatus.CONFLICT, mapHeaderMessage); return getJsonHttpStatus(CONFLICT, mapHeaderMessage);
} }
} }
@RequestMapping(value = "/get-mapping-cycle-by-norec/", method = RequestMethod.GET) @RequestMapping(value = "/get-mapping-cycle-by-norec/", method = GET)
public ResponseEntity<Map<String, Object>> getAll(@RequestParam(value="noRec", required = true) String noRec, HttpServletRequest request) { public ResponseEntity<Map<String, Object>> getAll(@RequestParam(value = "noRec") String noRec,
HttpServletRequest request) {
try { try {
Map<String, Object> result = this.mappingCycleService.getMappingCycleByNoRec(noRec); Map<String, Object> result = this.mappingCycleService.getMappingCycleByNoRec(noRec);
mapHeaderMessage.put(WebConstants.HttpHeaderInfo.LABEL_SUCCESS, mapHeaderMessage.put(LABEL_SUCCESS, getMessage(MessageResource.LABEL_SUCCESS, request));
getMessage(MessageResource.LABEL_SUCCESS, request)); return getJsonResponse(result, OK, mapHeaderMessage);
return RestUtil.getJsonResponse(result, HttpStatus.OK, mapHeaderMessage);
} catch (ServiceVOException e) { } catch (ServiceVOException e) {
LOGGER.error("Got exception {} when Find Mesin", e.getMessage()); LOGGER.error("Got ServiceVOException {} when getMappingCycleByNoRec", e.getMessage());
addHeaderMessage(Constants.MessageInfo.ERROR_MESSAGE, e.getMessage()); addHeaderMessage(ERROR_MESSAGE, e.getMessage());
return RestUtil.getJsonHttpStatus(HttpStatus.INTERNAL_SERVER_ERROR, mapHeaderMessage); return getJsonHttpStatus(INTERNAL_SERVER_ERROR, mapHeaderMessage);
} catch (JpaSystemException jse) { } catch (JpaSystemException jse) {
LOGGER.error("Got exception {} when Find Mesin", jse.getMessage()); LOGGER.error("Got JpaSystemException {} when getMappingCycleByNoRec", jse.getMessage());
addHeaderMessage(Constants.MessageInfo.ERROR_MESSAGE, jse.getMessage()); addHeaderMessage(ERROR_MESSAGE, jse.getMessage());
return RestUtil.getJsonHttpStatus(HttpStatus.CONFLICT, mapHeaderMessage); return getJsonHttpStatus(CONFLICT, mapHeaderMessage);
} }
} }
} }

View File

@ -1,58 +0,0 @@
package com.jasamedika.medifirst2000.controller;
import java.util.Map;
import javax.servlet.http.HttpServletRequest;
import javax.validation.Valid;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.HttpStatus;
import org.springframework.http.MediaType;
import org.springframework.http.ResponseEntity;
import org.springframework.orm.jpa.JpaSystemException;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RestController;
import com.jasamedika.medifirst2000.constants.Constants;
import com.jasamedika.medifirst2000.constants.MessageResource;
import com.jasamedika.medifirst2000.controller.base.LocaleController;
import com.jasamedika.medifirst2000.core.web.WebConstants;
import com.jasamedika.medifirst2000.exception.ServiceVOException;
import com.jasamedika.medifirst2000.service.MappingDiagnosaKeperawatanService;
import com.jasamedika.medifirst2000.util.rest.RestUtil;
import com.jasamedika.medifirst2000.vo.MappingDiagnosaKeperawatanVO;
import com.jasamedika.medifirst2000.vo.RencanaCustomVO;
@RestController
@RequestMapping("/mapping-diagnosa-keperawatan")
public class MappingDiagnosaKeperawatanController extends LocaleController<RencanaCustomVO> {
@Autowired
private MappingDiagnosaKeperawatanService service;
private static final Logger LOGGER = LoggerFactory.getLogger(MappingDiagnosaKeperawatanController.class);
@RequestMapping(value = "/save-mapping-diagnosa-keperawatan", method = RequestMethod.POST, produces = MediaType.APPLICATION_JSON_VALUE, consumes = MediaType.APPLICATION_JSON_VALUE)
public ResponseEntity<Map<String,Object>> saveMappingDiagnosaKeperawatan(@Valid @RequestBody MappingDiagnosaKeperawatanVO vo,HttpServletRequest request) {
try {
Map<String,Object> result = service.saveMappingDiagnosaKeperawatan(vo);
if (null != result)
mapHeaderMessage.put(WebConstants.HttpHeaderInfo.LABEL_SUCCESS,getMessage(MessageResource.LABEL_SUCCESS,request));
return RestUtil.getJsonResponse(result, HttpStatus.CREATED,mapHeaderMessage);
} catch (ServiceVOException e) {
LOGGER.error("Got exception {} when saveRencana", e.getMessage());
addHeaderMessage(Constants.MessageInfo.ERROR_MESSAGE, e.getMessage());
return RestUtil.getJsonHttpStatus(HttpStatus.INTERNAL_SERVER_ERROR, mapHeaderMessage);
} catch (JpaSystemException jse) {
LOGGER.error("Got exception {} when saveRencana", jse.getMessage());
addHeaderMessage(Constants.MessageInfo.ERROR_MESSAGE, jse.getMessage());
return RestUtil.getJsonHttpStatus(HttpStatus.CONFLICT, mapHeaderMessage);
}
}
}

View File

@ -1,95 +1,54 @@
package com.jasamedika.medifirst2000.controller; package com.jasamedika.medifirst2000.controller;
import java.util.Collection; import com.jasamedika.medifirst2000.constants.MessageResource;
import java.util.List; import com.jasamedika.medifirst2000.controller.base.LocaleController;
import java.util.Map; import com.jasamedika.medifirst2000.dto.MappingJenisLinenToProdukDto;
import com.jasamedika.medifirst2000.service.MappingJenisLinenToProdukService;
import javax.servlet.http.HttpServletRequest; import com.jasamedika.medifirst2000.vo.RegistrasiPelayananVO;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.HttpStatus;
import org.springframework.http.MediaType;
import org.springframework.http.ResponseEntity; import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.RequestBody; import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RequestParam; import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController; import org.springframework.web.bind.annotation.RestController;
import com.jasamedika.medifirst2000.constants.MessageResource; import javax.servlet.http.HttpServletRequest;
import com.jasamedika.medifirst2000.controller.base.IBaseRestController; import java.util.List;
import com.jasamedika.medifirst2000.controller.base.LocaleController; import java.util.Map;
import com.jasamedika.medifirst2000.core.web.WebConstants;
import com.jasamedika.medifirst2000.dto.MappingJenisLinenToProdukDto; import static com.jasamedika.medifirst2000.core.web.WebConstants.HttpHeaderInfo.LABEL_SUCCESS;
import com.jasamedika.medifirst2000.service.MappingJenisLinenToProdukService; import static com.jasamedika.medifirst2000.util.rest.RestUtil.getJsonHttpStatus;
import com.jasamedika.medifirst2000.util.rest.RestUtil; import static com.jasamedika.medifirst2000.util.rest.RestUtil.getJsonResponse;
import com.jasamedika.medifirst2000.vo.RegistrasiPelayananVO; import static org.springframework.http.HttpStatus.INTERNAL_SERVER_ERROR;
import static org.springframework.http.HttpStatus.OK;
import static org.springframework.http.MediaType.APPLICATION_JSON_VALUE;
import static org.springframework.web.bind.annotation.RequestMethod.POST;
@RestController @RestController
@RequestMapping("/mapping-jenis-linen-to-produk") @RequestMapping("/mapping-jenis-linen-to-produk")
public class MappingJenisLinenToProdukController extends LocaleController<RegistrasiPelayananVO> public class MappingJenisLinenToProdukController extends LocaleController<RegistrasiPelayananVO> {
implements IBaseRestController<RegistrasiPelayananVO> {
@Autowired @Autowired
private MappingJenisLinenToProdukService mappingJenisLinenToProdukService; private MappingJenisLinenToProdukService mappingJenisLinenToProdukService;
@RequestMapping(value="/save-bahan-baku-by-jenislinen/",
method = RequestMethod.POST, produces = MediaType.APPLICATION_JSON_VALUE)
public ResponseEntity<List<Map<String, Object>>> saveMasterBahanBaku(
@RequestBody List<MappingJenisLinenToProdukDto> dto,
HttpServletRequest request) {
List<Map<String,Object>> result = mappingJenisLinenToProdukService.saveBahanBaku(dto);
if (!result.isEmpty()) {
mapHeaderMessage.put(WebConstants.HttpHeaderInfo.LABEL_SUCCESS, getMessage(MessageResource.LABEL_SUCCESS, request));
return RestUtil.getJsonResponse(result, HttpStatus.OK, mapHeaderMessage);
}
return RestUtil.getJsonHttpStatus(HttpStatus.INTERNAL_SERVER_ERROR, mapHeaderMessage);
@RequestMapping(value = "/save-bahan-baku-by-jenislinen/", method = POST, produces = APPLICATION_JSON_VALUE)
public ResponseEntity<List<Map<String, Object>>> saveMasterBahanBaku(
@RequestBody List<MappingJenisLinenToProdukDto> dto, HttpServletRequest request) {
List<Map<String, Object>> result = mappingJenisLinenToProdukService.saveBahanBaku(dto);
if (!result.isEmpty()) {
mapHeaderMessage.put(LABEL_SUCCESS, getMessage(MessageResource.LABEL_SUCCESS, request));
return getJsonResponse(result, OK, mapHeaderMessage);
}
return getJsonHttpStatus(INTERNAL_SERVER_ERROR, mapHeaderMessage);
} }
@SuppressWarnings("unchecked")
@RequestMapping(value = "/get-all-master-bahanbaku-by-linen") @RequestMapping(value = "/get-all-master-bahanbaku-by-linen")
public Map<String,Object> getAllDaftarMasterBahanBakuByLinen( public Map<String, Object> getAllDaftarMasterBahanBakuByLinen(
@RequestParam(value = "page", required = false, defaultValue = "0") Integer page, @RequestParam(value = "page", required = false, defaultValue = "0") Integer page,
@RequestParam(value = "take", required = false, defaultValue = "100") Integer limit, @RequestParam(value = "take", required = false, defaultValue = "100") Integer limit,
@RequestParam(value = "sort", required = false, defaultValue = "a.id") String sort, @RequestParam(value = "sort", required = false, defaultValue = "a.id") String sort,
@RequestParam(value = "dir", required = false, defaultValue = "asc") String dir) { @RequestParam(value = "dir", required = false, defaultValue = "asc") String dir) {
return mappingJenisLinenToProdukService.getAllDaftarMasterBahanBakuByLinen(page, limit, sort, dir);
Map<String, Object> resultPageMap = mappingJenisLinenToProdukService.getAllDaftarMasterBahanBakuByLinen(page, limit, sort, dir);
return resultPageMap;
}
@Override
public ResponseEntity<Collection<RegistrasiPelayananVO>> getAllVOWithQueryString(HttpServletRequest request,
Integer page, Integer limit, String sort, String dir) {
return null;
}
@Override
public ResponseEntity<RegistrasiPelayananVO> getVO(Integer id) {
return null;
}
@Override
public ResponseEntity<String> addVO(RegistrasiPelayananVO vo) {
return null;
}
@Override
public ResponseEntity<String> editVO(RegistrasiPelayananVO vo) {
return null;
}
@Override
public ResponseEntity<String> deleteVO(Integer id) {
return null;
}
@Override
public ResponseEntity<List<RegistrasiPelayananVO>> getAllVO() {
return null;
} }
} }

View File

@ -1,118 +1,78 @@
package com.jasamedika.medifirst2000.controller; package com.jasamedika.medifirst2000.controller;
import java.util.Collection; import com.jasamedika.medifirst2000.constants.MessageResource;
import java.util.HashMap; import com.jasamedika.medifirst2000.controller.base.LocaleController;
import java.util.List; import com.jasamedika.medifirst2000.entities.MappingJenisRisikoSasaranStrategis;
import java.util.Map; import com.jasamedika.medifirst2000.exception.ServiceVOException;
import com.jasamedika.medifirst2000.service.MappingJenisRisikoSasaranStrategisService;
import javax.servlet.http.HttpServletRequest; import com.jasamedika.medifirst2000.vo.MappingJenisRisikoSasaranStrategisVO;
import javax.validation.Valid; import com.jasamedika.medifirst2000.vo.PasienVO;
import net.kaczmarzyk.spring.data.jpa.domain.Equal;
import net.kaczmarzyk.spring.data.jpa.web.annotation.Spec;
import org.slf4j.Logger; import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.jpa.domain.Specification; import org.springframework.data.jpa.domain.Specification;
import org.springframework.http.HttpStatus;
import org.springframework.http.MediaType;
import org.springframework.http.ResponseEntity; import org.springframework.http.ResponseEntity;
import org.springframework.orm.jpa.JpaSystemException; import org.springframework.orm.jpa.JpaSystemException;
import org.springframework.web.bind.annotation.RequestBody; import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RequestParam; import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController; import org.springframework.web.bind.annotation.RestController;
import com.jasamedika.medifirst2000.constants.Constants; import javax.servlet.http.HttpServletRequest;
import com.jasamedika.medifirst2000.constants.MessageResource; import javax.validation.Valid;
import com.jasamedika.medifirst2000.controller.base.IBaseRestController; import java.util.Collection;
import com.jasamedika.medifirst2000.controller.base.LocaleController; import java.util.List;
import com.jasamedika.medifirst2000.core.web.WebConstants; import java.util.Map;
import com.jasamedika.medifirst2000.entities.MappingJenisRisikoSasaranStrategis;
import com.jasamedika.medifirst2000.exception.ServiceVOException;
import com.jasamedika.medifirst2000.service.MappingJenisRisikoSasaranStrategisService;
import com.jasamedika.medifirst2000.util.rest.RestUtil;
import com.jasamedika.medifirst2000.vo.MappingJenisRisikoSasaranStrategisVO;
import net.kaczmarzyk.spring.data.jpa.domain.Equal; import static com.jasamedika.medifirst2000.constants.Constants.MessageInfo.ERROR_MESSAGE;
import net.kaczmarzyk.spring.data.jpa.web.annotation.Spec; import static com.jasamedika.medifirst2000.core.web.WebConstants.HttpHeaderInfo.LABEL_SUCCESS;
import static com.jasamedika.medifirst2000.util.rest.RestUtil.getJsonHttpStatus;
import static com.jasamedika.medifirst2000.util.rest.RestUtil.getJsonResponse;
import static org.slf4j.LoggerFactory.getLogger;
import static org.springframework.http.HttpStatus.*;
import static org.springframework.http.MediaType.APPLICATION_JSON_VALUE;
import static org.springframework.web.bind.annotation.RequestMethod.GET;
import static org.springframework.web.bind.annotation.RequestMethod.POST;
@RestController @RestController
@RequestMapping("/jenis-risiko-sasaran-strategis") @RequestMapping("/jenis-risiko-sasaran-strategis")
public class MappingJenisRisikoSasaranStrategisController extends LocaleController<MappingJenisRisikoSasaranStrategisVO> public class MappingJenisRisikoSasaranStrategisController
implements IBaseRestController<MappingJenisRisikoSasaranStrategisVO>{ extends LocaleController<MappingJenisRisikoSasaranStrategisVO> {
private static final Logger LOGGER = getLogger(MappingJenisRisikoSasaranStrategisController.class);
@Autowired @Autowired
private MappingJenisRisikoSasaranStrategisService mappingService; private MappingJenisRisikoSasaranStrategisService mappingService;
private static final Logger LOGGER = LoggerFactory
.getLogger(IndikatorRensarController.class);
@Override
public ResponseEntity<Collection<MappingJenisRisikoSasaranStrategisVO>> getAllVOWithQueryString(
HttpServletRequest request, Integer page, Integer limit, String sort, String dir) {
return null;
}
@Override @RequestMapping(value = "/find-all/", method = GET, produces = APPLICATION_JSON_VALUE)
public ResponseEntity<MappingJenisRisikoSasaranStrategisVO> getVO(Integer id) { public ResponseEntity<Collection<PasienVO>> findAll(
return null;
}
@Override
public ResponseEntity<String> addVO(MappingJenisRisikoSasaranStrategisVO vo) {
return null;
}
@Override
public ResponseEntity<String> editVO(MappingJenisRisikoSasaranStrategisVO vo) {
return null;
}
@Override
public ResponseEntity<String> deleteVO(Integer id) {
return null;
}
@Override
public ResponseEntity<List<MappingJenisRisikoSasaranStrategisVO>> getAllVO() {
return null;
}
@RequestMapping(value="/find-all/", method= RequestMethod.GET,produces = MediaType.APPLICATION_JSON_VALUE)
public ResponseEntity<Collection<MappingJenisRisikoSasaranStrategis>> findAll(
@RequestParam(value = "page", required = false, defaultValue = "0") Integer page, @RequestParam(value = "page", required = false, defaultValue = "0") Integer page,
@RequestParam(value = "take", required = false, defaultValue = "100") Integer take, @RequestParam(value = "take", required = false, defaultValue = "100") Integer take,
@RequestParam(value = "sort", required = false, defaultValue = "id") String sort, @RequestParam(value = "sort", required = false, defaultValue = "id") String sort,
@RequestParam(value = "dir", required = false, defaultValue = "asc") String dir, @RequestParam(value = "dir", required = false, defaultValue = "asc") String dir,
@Spec(path = "id", params = "id", spec = Equal.class) Specification<MappingJenisRisikoSasaranStrategis> spec) @Spec(path = "id", params = "id", spec = Equal.class) Specification<MappingJenisRisikoSasaranStrategis> spec) {
{ Map<String, Object> result = mappingService.findAll(page, take, sort, dir, spec);
Map<String, Object> result = new HashMap<String, Object>(); return constructListPageResult(result);
result = mappingService.findAll(page, take, sort,dir, spec);
return constructListPageResult(result);
} }
@RequestMapping(value="/save/", method= RequestMethod.POST,produces = MediaType.APPLICATION_JSON_VALUE) @RequestMapping(value = "/save/", method = POST, produces = APPLICATION_JSON_VALUE)
public ResponseEntity<Map<String,Object>> save(@Valid @RequestBody List<MappingJenisRisikoSasaranStrategisVO> vos,HttpServletRequest request){ public ResponseEntity<Map<String, Object>> save(@Valid @RequestBody List<MappingJenisRisikoSasaranStrategisVO> vos,
try{ HttpServletRequest request) {
try {
Map<String, Object> result = mappingService.save(vos); Map<String, Object> result = mappingService.save(vos);
if(null!= result) if (null != result)
mapHeaderMessage.put(WebConstants.HttpHeaderInfo.LABEL_SUCCESS, getMessage(MessageResource.LABEL_SUCCESS,request)); mapHeaderMessage.put(LABEL_SUCCESS, getMessage(MessageResource.LABEL_SUCCESS, request));
return RestUtil.getJsonResponse(result, HttpStatus.CREATED, mapHeaderMessage); return getJsonResponse(result, CREATED, mapHeaderMessage);
} catch (ServiceVOException e) { } catch (ServiceVOException e) {
LOGGER.error("Got exception {} when add/update Risiko", e.getMessage()); LOGGER.error("Got ServiceVOException {} when save", e.getMessage());
addHeaderMessage(Constants.MessageInfo.ERROR_MESSAGE, addHeaderMessage(ERROR_MESSAGE, e.getMessage());
e.getMessage()); return getJsonHttpStatus(INTERNAL_SERVER_ERROR, mapHeaderMessage);
return RestUtil.getJsonHttpStatus(HttpStatus.INTERNAL_SERVER_ERROR,
mapHeaderMessage);
} catch (JpaSystemException jse) { } catch (JpaSystemException jse) {
LOGGER.error("Got exception {} when add/update Risiko", jse.getMessage()); LOGGER.error("Got JpaSystemException {} when save", jse.getMessage());
addHeaderMessage(Constants.MessageInfo.ERROR_MESSAGE, addHeaderMessage(ERROR_MESSAGE, jse.getMessage());
jse.getMessage()); return getJsonHttpStatus(CONFLICT, mapHeaderMessage);
return RestUtil.getJsonHttpStatus(HttpStatus.CONFLICT,
mapHeaderMessage);
} }
} }
} }

View File

@ -1,162 +1,58 @@
package com.jasamedika.medifirst2000.controller; package com.jasamedika.medifirst2000.controller;
import java.util.Collection; import com.jasamedika.medifirst2000.constants.MessageResource;
import java.util.List; import com.jasamedika.medifirst2000.controller.base.LocaleController;
import java.util.Map; import com.jasamedika.medifirst2000.exception.ServiceVOException;
import com.jasamedika.medifirst2000.service.MappingPertanyaanToKeteranganService;
import javax.servlet.http.HttpServletRequest; import com.jasamedika.medifirst2000.vo.MappingPertanyaanToKeteranganVO;
import javax.validation.Valid;
import org.slf4j.Logger; import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.HttpStatus;
import org.springframework.http.MediaType;
import org.springframework.http.ResponseEntity; import org.springframework.http.ResponseEntity;
import org.springframework.orm.jpa.JpaSystemException; import org.springframework.orm.jpa.JpaSystemException;
import org.springframework.web.bind.annotation.RequestBody; import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RestController; import org.springframework.web.bind.annotation.RestController;
import com.jasamedika.medifirst2000.constants.Constants; import javax.servlet.http.HttpServletRequest;
import com.jasamedika.medifirst2000.constants.MessageResource; import javax.validation.Valid;
import com.jasamedika.medifirst2000.controller.base.IBaseRestController; import java.util.List;
import com.jasamedika.medifirst2000.controller.base.LocaleController; import java.util.Map;
import com.jasamedika.medifirst2000.core.web.WebConstants;
import com.jasamedika.medifirst2000.exception.ServiceVOException; import static com.jasamedika.medifirst2000.constants.Constants.MessageInfo.ERROR_MESSAGE;
import com.jasamedika.medifirst2000.service.MappingPertanyaanToKeteranganService; import static com.jasamedika.medifirst2000.core.web.WebConstants.HttpHeaderInfo.LABEL_SUCCESS;
import com.jasamedika.medifirst2000.util.rest.RestUtil; import static com.jasamedika.medifirst2000.util.rest.RestUtil.getJsonHttpStatus;
import com.jasamedika.medifirst2000.vo.MappingPertanyaanToKeteranganVO; import static com.jasamedika.medifirst2000.util.rest.RestUtil.getJsonResponse;
import static org.slf4j.LoggerFactory.getLogger;
import static org.springframework.http.HttpStatus.*;
import static org.springframework.http.MediaType.APPLICATION_JSON_VALUE;
import static org.springframework.web.bind.annotation.RequestMethod.POST;
@RestController @RestController
@RequestMapping("/mapping-pertanyaan") @RequestMapping("/mapping-pertanyaan")
public class MappingPertanyaanToKeteranganController extends LocaleController<MappingPertanyaanToKeteranganVO> implements IBaseRestController<MappingPertanyaanToKeteranganVO> { public class MappingPertanyaanToKeteranganController extends LocaleController<MappingPertanyaanToKeteranganVO> {
private static final Logger LOGGER = getLogger(MappingPertanyaanToKeteranganController.class);
@Autowired @Autowired
private MappingPertanyaanToKeteranganService service; private MappingPertanyaanToKeteranganService service;
private static final Logger LOGGER = LoggerFactory
.getLogger(MappingPertanyaanToKeteranganController.class);
@RequestMapping(value = "/save-mapping-pertanyaan/", method = RequestMethod.POST, produces = MediaType.APPLICATION_JSON_VALUE, consumes = MediaType.APPLICATION_JSON_VALUE) @RequestMapping(value = "/save-all-mapping-pertanyaan/", method = POST, produces = APPLICATION_JSON_VALUE, consumes = APPLICATION_JSON_VALUE)
public ResponseEntity<Map<String,Object>> addVO(@Valid @RequestBody MappingPertanyaanToKeteranganVO vo, HttpServletRequest request) { public ResponseEntity<Map<String, Object>> addAllVO(@Valid @RequestBody List<MappingPertanyaanToKeteranganVO> vos,
HttpServletRequest request) {
try { try {
Map<String,Object> result=service.addMappingPertanyaan(vo); Map<String, Object> result = service.addAllMappingPertanyaan(vos);
if (null != result) if (null != result)
mapHeaderMessage.put(WebConstants.HttpHeaderInfo.LABEL_SUCCESS,getMessage(MessageResource.LABEL_SUCCESS,request )); mapHeaderMessage.put(LABEL_SUCCESS, getMessage(MessageResource.LABEL_SUCCESS, request));
return RestUtil.getJsonResponse(result, HttpStatus.CREATED,mapHeaderMessage); return getJsonResponse(result, CREATED, mapHeaderMessage);
} catch (ServiceVOException e) { } catch (ServiceVOException e) {
LOGGER.error("Got exception {} when add Sasaran Strategis", e.getMessage()); LOGGER.error("Got ServiceVOException {} when addAllMappingPertanyaan", e.getMessage());
addHeaderMessage(Constants.MessageInfo.ERROR_MESSAGE, addHeaderMessage(ERROR_MESSAGE, e.getMessage());
e.getMessage()); return getJsonHttpStatus(INTERNAL_SERVER_ERROR, mapHeaderMessage);
return RestUtil.getJsonHttpStatus(HttpStatus.INTERNAL_SERVER_ERROR,
mapHeaderMessage);
} catch (JpaSystemException jse) { } catch (JpaSystemException jse) {
LOGGER.error("Got exception {} when add Sasaran Strategis", jse.getMessage()); LOGGER.error("Got JpaSystemException {} when addAllMappingPertanyaan", jse.getMessage());
addHeaderMessage(Constants.MessageInfo.ERROR_MESSAGE, addHeaderMessage(ERROR_MESSAGE, jse.getMessage());
jse.getMessage()); return getJsonHttpStatus(CONFLICT, mapHeaderMessage);
return RestUtil.getJsonHttpStatus(HttpStatus.CONFLICT,
mapHeaderMessage);
} }
} }
@RequestMapping(value = "/save-all-mapping-pertanyaan/", method = RequestMethod.POST, produces = MediaType.APPLICATION_JSON_VALUE, consumes = MediaType.APPLICATION_JSON_VALUE)
public ResponseEntity<Map<String,Object>> addAllVO(@Valid @RequestBody List<MappingPertanyaanToKeteranganVO> vos, HttpServletRequest request) {
try {
Map<String,Object> result=service.addAllMappingPertanyaan(vos);
if (null != result)
mapHeaderMessage.put(WebConstants.HttpHeaderInfo.LABEL_SUCCESS,getMessage(MessageResource.LABEL_SUCCESS,request ));
return RestUtil.getJsonResponse(result, HttpStatus.CREATED,mapHeaderMessage);
} catch (ServiceVOException e) {
LOGGER.error("Got exception {} when add Sasaran Strategis", e.getMessage());
addHeaderMessage(Constants.MessageInfo.ERROR_MESSAGE,
e.getMessage());
return RestUtil.getJsonHttpStatus(HttpStatus.INTERNAL_SERVER_ERROR,
mapHeaderMessage);
} catch (JpaSystemException jse) {
LOGGER.error("Got exception {} when add Sasaran Strategis", jse.getMessage());
addHeaderMessage(Constants.MessageInfo.ERROR_MESSAGE,
jse.getMessage());
return RestUtil.getJsonHttpStatus(HttpStatus.CONFLICT,
mapHeaderMessage);
}
}
@RequestMapping(value = "/update-jumlah/", method = RequestMethod.POST, produces = MediaType.APPLICATION_JSON_VALUE, consumes = MediaType.APPLICATION_JSON_VALUE)
public ResponseEntity<Map<String,Object>> updateJumlah(@Valid @RequestBody List<MappingPertanyaanToKeteranganVO> vos, HttpServletRequest request) {
try {
Map<String,Object> result=service.updateJumlahSurvey(vos);
if (null != result)
mapHeaderMessage.put(WebConstants.HttpHeaderInfo.LABEL_SUCCESS,getMessage(MessageResource.LABEL_SUCCESS,request ));
return RestUtil.getJsonResponse(result, HttpStatus.CREATED,mapHeaderMessage);
} catch (ServiceVOException e) {
LOGGER.error("Got exception {} when add Sasaran Strategis", e.getMessage());
addHeaderMessage(Constants.MessageInfo.ERROR_MESSAGE,
e.getMessage());
return RestUtil.getJsonHttpStatus(HttpStatus.INTERNAL_SERVER_ERROR,
mapHeaderMessage);
} catch (JpaSystemException jse) {
LOGGER.error("Got exception {} when add Sasaran Strategis", jse.getMessage());
addHeaderMessage(Constants.MessageInfo.ERROR_MESSAGE,
jse.getMessage());
return RestUtil.getJsonHttpStatus(HttpStatus.CONFLICT,
mapHeaderMessage);
}
}
@RequestMapping(value = "/get-all/", method = RequestMethod.GET, produces = MediaType.APPLICATION_JSON_VALUE)
public ResponseEntity<Map<String, Object>> getAll(HttpServletRequest request) {
Map<String, Object> result = null;
try{
result = service.findAllMappingPertanyaan();
Boolean dataFound=new Boolean((boolean) result.get("dataFound"));
if(dataFound){
mapHeaderMessage.put(WebConstants.HttpHeaderInfo.LABEL_SUCCESS,getMessage(MessageResource.LABEL_SUCCESS,request ));
}
else{
mapHeaderMessage.put(WebConstants.HttpHeaderInfo.LABEL_ERROR,getMessage(MessageResource.LABEL_ERROR,request ));
}
}catch (Exception e){
e.printStackTrace();
}
return RestUtil.getJsonResponse(result, HttpStatus.OK);
}
@Override
public ResponseEntity<Collection<MappingPertanyaanToKeteranganVO>> getAllVOWithQueryString(
HttpServletRequest request, Integer page, Integer limit, String sort, String dir) {
return null;
}
@Override
public ResponseEntity<MappingPertanyaanToKeteranganVO> getVO(Integer id) {
return null;
}
@Override
public ResponseEntity<String> addVO(MappingPertanyaanToKeteranganVO vo) {
return null;
}
@Override
public ResponseEntity<String> editVO(MappingPertanyaanToKeteranganVO vo) {
return null;
}
@Override
public ResponseEntity<String> deleteVO(Integer id) {
return null;
}
@Override
public ResponseEntity<List<MappingPertanyaanToKeteranganVO>> getAllVO() {
return null;
}
} }

View File

@ -1,67 +1,65 @@
package com.jasamedika.medifirst2000.controller; package com.jasamedika.medifirst2000.controller;
import java.util.Map; import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
import com.jasamedika.medifirst2000.constants.MessageResource;
import javax.servlet.http.HttpServletRequest; import com.jasamedika.medifirst2000.controller.base.LocaleController;
import javax.validation.Valid; import com.jasamedika.medifirst2000.exception.ServiceVOException;
import com.jasamedika.medifirst2000.service.MasalahKeperawatanService;
import com.jasamedika.medifirst2000.vo.MasalahKeperawatanVO;
import com.jasamedika.medifirst2000.vo.TriaseVO;
import org.slf4j.Logger; import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.HttpStatus;
import org.springframework.http.MediaType;
import org.springframework.http.ResponseEntity; import org.springframework.http.ResponseEntity;
import org.springframework.orm.jpa.JpaSystemException; import org.springframework.orm.jpa.JpaSystemException;
import org.springframework.web.bind.annotation.RequestBody; import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RestController; import org.springframework.web.bind.annotation.RestController;
import com.fasterxml.jackson.annotation.JsonIgnoreProperties; import javax.servlet.http.HttpServletRequest;
import com.jasamedika.medifirst2000.constants.Constants; import javax.validation.Valid;
import com.jasamedika.medifirst2000.constants.MessageResource; import java.util.Map;
import com.jasamedika.medifirst2000.controller.base.LocaleController;
import com.jasamedika.medifirst2000.core.web.WebConstants;
import com.jasamedika.medifirst2000.exception.ServiceVOException;
import com.jasamedika.medifirst2000.service.MasalahKeperawatanService;
import com.jasamedika.medifirst2000.util.rest.RestUtil;
import com.jasamedika.medifirst2000.vo.MasalahKeperawatanVO;
import com.jasamedika.medifirst2000.vo.TriaseVO;
import static com.jasamedika.medifirst2000.constants.Constants.MessageInfo.ERROR_MESSAGE;
import static com.jasamedika.medifirst2000.core.web.WebConstants.HttpHeaderInfo.LABEL_SUCCESS;
import static com.jasamedika.medifirst2000.util.rest.RestUtil.getJsonHttpStatus;
import static com.jasamedika.medifirst2000.util.rest.RestUtil.getJsonResponse;
import static org.slf4j.LoggerFactory.getLogger;
import static org.springframework.http.HttpStatus.*;
import static org.springframework.http.MediaType.APPLICATION_JSON_VALUE;
import static org.springframework.web.bind.annotation.RequestMethod.POST;
/****************** /******************
* @author Shakato * @author Shakato
******************/ ******************/
@RestController @RestController
@RequestMapping("/masalah-keperawatan") @RequestMapping("/masalah-keperawatan")
@JsonIgnoreProperties(ignoreUnknown = true) @JsonIgnoreProperties(ignoreUnknown = true)
public class MasalahKeperawatanController extends LocaleController<TriaseVO>{ public class MasalahKeperawatanController extends LocaleController<TriaseVO> {
private static final Logger LOGGER = getLogger(MasalahKeperawatanController.class);
@Autowired @Autowired
private MasalahKeperawatanService masalahKeperawatanService; private MasalahKeperawatanService masalahKeperawatanService;
private static final Logger LOGGER = LoggerFactory.getLogger(MasalahKeperawatanController.class); @RequestMapping(value = "/save-masalah-keperawatan", method = POST, produces = APPLICATION_JSON_VALUE, consumes = APPLICATION_JSON_VALUE)
public ResponseEntity<String> saveMasalahKeperawatan(@Valid @RequestBody MasalahKeperawatanVO vo,
@RequestMapping(value = "/save-masalah-keperawatan", method = RequestMethod.POST, produces = MediaType.APPLICATION_JSON_VALUE, consumes = MediaType.APPLICATION_JSON_VALUE) HttpServletRequest request) {
public ResponseEntity<String> saveMasalahKeperawatan(@Valid @RequestBody MasalahKeperawatanVO vo, HttpServletRequest request) {
try { try {
Map<String,Object> result = masalahKeperawatanService.saveMasalahKeperawatanService(vo); Map<String, Object> result = masalahKeperawatanService.saveMasalahKeperawatanService(vo);
if (null != result) if (null != result)
mapHeaderMessage.put(WebConstants.HttpHeaderInfo.LABEL_SUCCESS,getMessage(MessageResource.LABEL_SUCCESS,request )); mapHeaderMessage.put(LABEL_SUCCESS, getMessage(MessageResource.LABEL_SUCCESS, request));
RestUtil.getJsonHttpStatus(HttpStatus.CREATED); getJsonHttpStatus(CREATED);
SaveLog("Masalah Keperawatan", "Pemeriksaan",request); SaveLog("Masalah Keperawatan", "Pemeriksaan", request);
return RestUtil.getJsonResponse("Status Sukses", HttpStatus.CREATED,mapHeaderMessage); return getJsonResponse("Status Sukses", CREATED, mapHeaderMessage);
} catch (ServiceVOException e) { } catch (ServiceVOException e) {
LOGGER.error("Got exception {} when save masalah keperawatan", e.getMessage()); LOGGER.error("Got ServiceVOException {} when saveMasalahKeperawatanService", e.getMessage());
addHeaderMessage(Constants.MessageInfo.ERROR_MESSAGE, e.getMessage()); addHeaderMessage(ERROR_MESSAGE, e.getMessage());
return RestUtil.getJsonHttpStatus(HttpStatus.INTERNAL_SERVER_ERROR, mapHeaderMessage); return getJsonHttpStatus(INTERNAL_SERVER_ERROR, mapHeaderMessage);
} catch (JpaSystemException jse) { } catch (JpaSystemException jse) {
LOGGER.error("Got exception {} when update masalah keperawatan", jse.getMessage()); LOGGER.error("Got JpaSystemException {} when saveMasalahKeperawatanService", jse.getMessage());
addHeaderMessage(Constants.MessageInfo.ERROR_MESSAGE, jse.getMessage()); addHeaderMessage(ERROR_MESSAGE, jse.getMessage());
return RestUtil.getJsonHttpStatus(HttpStatus.CONFLICT, mapHeaderMessage); return getJsonHttpStatus(CONFLICT, mapHeaderMessage);
} }
} }
} }

View File

@ -1,118 +1,76 @@
package com.jasamedika.medifirst2000.controller; package com.jasamedika.medifirst2000.controller;
import java.util.Collection; import com.jasamedika.medifirst2000.constants.MessageResource;
import java.util.HashMap; import com.jasamedika.medifirst2000.controller.base.LocaleController;
import java.util.List; import com.jasamedika.medifirst2000.entities.MasterProgramKerjaStrategis;
import java.util.Map; import com.jasamedika.medifirst2000.exception.ServiceVOException;
import com.jasamedika.medifirst2000.service.MasterProgramKerjaStrategisService;
import javax.servlet.http.HttpServletRequest; import com.jasamedika.medifirst2000.vo.MasterProgramKerjaStrategisVO;
import javax.validation.Valid; import com.jasamedika.medifirst2000.vo.PasienVO;
import net.kaczmarzyk.spring.data.jpa.domain.Equal;
import net.kaczmarzyk.spring.data.jpa.web.annotation.Spec;
import org.slf4j.Logger; import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.jpa.domain.Specification; import org.springframework.data.jpa.domain.Specification;
import org.springframework.http.HttpStatus;
import org.springframework.http.MediaType;
import org.springframework.http.ResponseEntity; import org.springframework.http.ResponseEntity;
import org.springframework.orm.jpa.JpaSystemException; import org.springframework.orm.jpa.JpaSystemException;
import org.springframework.web.bind.annotation.RequestBody; import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RequestParam; import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController; import org.springframework.web.bind.annotation.RestController;
import com.jasamedika.medifirst2000.constants.Constants; import javax.servlet.http.HttpServletRequest;
import com.jasamedika.medifirst2000.constants.MessageResource; import javax.validation.Valid;
import com.jasamedika.medifirst2000.controller.base.IBaseRestController; import java.util.Collection;
import com.jasamedika.medifirst2000.controller.base.LocaleController; import java.util.Map;
import com.jasamedika.medifirst2000.core.web.WebConstants;
import com.jasamedika.medifirst2000.entities.MasterProgramKerjaStrategis;
import com.jasamedika.medifirst2000.exception.ServiceVOException;
import com.jasamedika.medifirst2000.service.MasterProgramKerjaStrategisService;
import com.jasamedika.medifirst2000.util.rest.RestUtil;
import com.jasamedika.medifirst2000.vo.MasterProgramKerjaStrategisVO;
import net.kaczmarzyk.spring.data.jpa.domain.Equal; import static com.jasamedika.medifirst2000.constants.Constants.MessageInfo.ERROR_MESSAGE;
import net.kaczmarzyk.spring.data.jpa.web.annotation.Spec; import static com.jasamedika.medifirst2000.core.web.WebConstants.HttpHeaderInfo.LABEL_SUCCESS;
import static com.jasamedika.medifirst2000.util.rest.RestUtil.getJsonHttpStatus;
import static com.jasamedika.medifirst2000.util.rest.RestUtil.getJsonResponse;
import static org.slf4j.LoggerFactory.getLogger;
import static org.springframework.http.HttpStatus.*;
import static org.springframework.http.MediaType.APPLICATION_JSON_VALUE;
import static org.springframework.web.bind.annotation.RequestMethod.GET;
import static org.springframework.web.bind.annotation.RequestMethod.POST;
@RestController @RestController
@RequestMapping("/master-program-kerja-strategis") @RequestMapping("/master-program-kerja-strategis")
public class MasterProgramKerjaStrategisController extends LocaleController<MasterProgramKerjaStrategisVO> public class MasterProgramKerjaStrategisController extends LocaleController<MasterProgramKerjaStrategisVO> {
implements IBaseRestController<MasterProgramKerjaStrategisVO>{
private static final Logger LOGGER = getLogger(MasterProgramKerjaStrategisController.class);
@Autowired @Autowired
private MasterProgramKerjaStrategisService programService; private MasterProgramKerjaStrategisService programService;
private static final Logger LOGGER = LoggerFactory
.getLogger(PegawaiController.class);
@Override
public ResponseEntity<Collection<MasterProgramKerjaStrategisVO>> getAllVOWithQueryString(HttpServletRequest request,
Integer page, Integer limit, String sort, String dir) {
return null;
}
@Override @RequestMapping(value = "/find-all/", method = GET, produces = APPLICATION_JSON_VALUE)
public ResponseEntity<MasterProgramKerjaStrategisVO> getVO(Integer id) { public ResponseEntity<Collection<PasienVO>> findAll(
return null;
}
@Override
public ResponseEntity<String> addVO(MasterProgramKerjaStrategisVO vo) {
return null;
}
@Override
public ResponseEntity<String> editVO(MasterProgramKerjaStrategisVO vo) {
return null;
}
@Override
public ResponseEntity<String> deleteVO(Integer id) {
return null;
}
@Override
public ResponseEntity<List<MasterProgramKerjaStrategisVO>> getAllVO() {
return null;
}
@RequestMapping(value="/find-all/", method= RequestMethod.GET,produces = MediaType.APPLICATION_JSON_VALUE)
public ResponseEntity<Collection<MasterProgramKerjaStrategis>> findAll(
@RequestParam(value = "page", required = false, defaultValue = "0") Integer page, @RequestParam(value = "page", required = false, defaultValue = "0") Integer page,
@RequestParam(value = "take", required = false, defaultValue = "100") Integer take, @RequestParam(value = "take", required = false, defaultValue = "100") Integer take,
@RequestParam(value = "sort", required = false, defaultValue = "id") String sort, @RequestParam(value = "sort", required = false, defaultValue = "id") String sort,
@RequestParam(value = "dir", required = false, defaultValue = "asc") String dir, @RequestParam(value = "dir", required = false, defaultValue = "asc") String dir,
@Spec(path = "id", params = "id", spec = Equal.class) Specification<MasterProgramKerjaStrategis> spec) @Spec(path = "id", params = "id", spec = Equal.class) Specification<MasterProgramKerjaStrategis> spec) {
{ Map<String, Object> result = programService.findAll(page, take, sort, dir, spec);
Map<String, Object> result = new HashMap<String, Object>(); return constructListPageResult(result);
result = programService.findAll(page, take, sort,dir, spec);
return constructListPageResult(result);
} }
@RequestMapping(value="/save/", method= RequestMethod.POST,produces = MediaType.APPLICATION_JSON_VALUE) @RequestMapping(value = "/save/", method = POST, produces = APPLICATION_JSON_VALUE)
public ResponseEntity<Map<String,Object>> save(@Valid @RequestBody MasterProgramKerjaStrategisVO vo,HttpServletRequest request){ public ResponseEntity<Map<String, Object>> save(@Valid @RequestBody MasterProgramKerjaStrategisVO vo,
try{ HttpServletRequest request) {
try {
Map<String, Object> result = programService.save(vo); Map<String, Object> result = programService.save(vo);
if(null!= result) if (null != result)
mapHeaderMessage.put(WebConstants.HttpHeaderInfo.LABEL_SUCCESS, getMessage(MessageResource.LABEL_SUCCESS,request)); mapHeaderMessage.put(LABEL_SUCCESS, getMessage(MessageResource.LABEL_SUCCESS, request));
return RestUtil.getJsonResponse(result, HttpStatus.CREATED, mapHeaderMessage); return getJsonResponse(result, CREATED, mapHeaderMessage);
} catch (ServiceVOException e) { } catch (ServiceVOException e) {
LOGGER.error("Got exception {} when add/update programKerjaStrategis", e.getMessage()); LOGGER.error("Got ServiceVOException {} when save", e.getMessage());
addHeaderMessage(Constants.MessageInfo.ERROR_MESSAGE, addHeaderMessage(ERROR_MESSAGE, e.getMessage());
e.getMessage()); return getJsonHttpStatus(INTERNAL_SERVER_ERROR, mapHeaderMessage);
return RestUtil.getJsonHttpStatus(HttpStatus.INTERNAL_SERVER_ERROR,
mapHeaderMessage);
} catch (JpaSystemException jse) { } catch (JpaSystemException jse) {
LOGGER.error("Got exception {} when add/update programKerjaStrategis", jse.getMessage()); LOGGER.error("Got JpaSystemException {} when save", jse.getMessage());
addHeaderMessage(Constants.MessageInfo.ERROR_MESSAGE, addHeaderMessage(ERROR_MESSAGE, jse.getMessage());
jse.getMessage()); return getJsonHttpStatus(CONFLICT, mapHeaderMessage);
return RestUtil.getJsonHttpStatus(HttpStatus.CONFLICT,
mapHeaderMessage);
} }
} }
} }

View File

@ -1,74 +1,59 @@
package com.jasamedika.medifirst2000.controller; package com.jasamedika.medifirst2000.controller;
import java.util.List; import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
import java.util.Map; import com.jasamedika.medifirst2000.constants.MessageResource;
import javax.servlet.http.HttpServletRequest; import com.jasamedika.medifirst2000.controller.base.LocaleController;
import javax.validation.Valid; import com.jasamedika.medifirst2000.exception.ServiceVOException;
import com.jasamedika.medifirst2000.service.MasukKamarService;
import com.jasamedika.medifirst2000.vo.MasukKamarVO;
import org.slf4j.Logger; import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.HttpStatus;
import org.springframework.http.MediaType;
import org.springframework.http.ResponseEntity; import org.springframework.http.ResponseEntity;
import org.springframework.orm.jpa.JpaSystemException; import org.springframework.orm.jpa.JpaSystemException;
import org.springframework.web.bind.annotation.RequestBody; import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.web.bind.annotation.RestController; import org.springframework.web.bind.annotation.RestController;
import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
import com.jasamedika.medifirst2000.constants.Constants;
import com.jasamedika.medifirst2000.constants.MessageResource;
import com.jasamedika.medifirst2000.controller.base.LocaleController;
import com.jasamedika.medifirst2000.core.web.WebConstants;
import com.jasamedika.medifirst2000.exception.ServiceVOException;
import com.jasamedika.medifirst2000.service.JadwalDpjpRawatInapService;
import com.jasamedika.medifirst2000.service.MasukKamarService;
import com.jasamedika.medifirst2000.util.rest.RestUtil;
import com.jasamedika.medifirst2000.vo.MasukKamarVO;
import javax.servlet.http.HttpServletRequest;
import javax.validation.Valid;
import java.util.Map;
import static com.jasamedika.medifirst2000.constants.Constants.MessageInfo.ERROR_MESSAGE;
import static com.jasamedika.medifirst2000.core.web.WebConstants.HttpHeaderInfo.LABEL_SUCCESS;
import static com.jasamedika.medifirst2000.util.rest.RestUtil.getJsonHttpStatus;
import static com.jasamedika.medifirst2000.util.rest.RestUtil.getJsonResponse;
import static org.slf4j.LoggerFactory.getLogger;
import static org.springframework.http.HttpStatus.*;
import static org.springframework.http.MediaType.APPLICATION_JSON_VALUE;
import static org.springframework.web.bind.annotation.RequestMethod.POST;
@RestController @RestController
@RequestMapping("/masuk-kamar") @RequestMapping("/masuk-kamar")
@JsonIgnoreProperties(ignoreUnknown = true) @JsonIgnoreProperties(ignoreUnknown = true)
public class MasukKamarController extends LocaleController<MasukKamarVO> { public class MasukKamarController extends LocaleController<MasukKamarVO> {
private static final Logger LOGGER = getLogger(MasukKamarController.class);
@Autowired @Autowired
private MasukKamarService masukKamarService; private MasukKamarService masukKamarService;
@Autowired
private JadwalDpjpRawatInapService service;
private static final Logger LOGGER = LoggerFactory
.getLogger(MasukKamarController.class);
@RequestMapping(value = "/save-masuk-kamar", method = RequestMethod.POST, produces = MediaType.APPLICATION_JSON_VALUE, consumes = MediaType.APPLICATION_JSON_VALUE) @RequestMapping(value = "/save-masuk-kamar", method = POST, produces = APPLICATION_JSON_VALUE, consumes = APPLICATION_JSON_VALUE)
public ResponseEntity<Map<String, Object>> savePasienFromRegistrasiPasienGawatDarurat(@Valid @RequestBody MasukKamarVO vo,HttpServletRequest request) { public ResponseEntity<Map<String, Object>> savePasienFromRegistrasiPasienGawatDarurat(
@Valid @RequestBody MasukKamarVO vo, HttpServletRequest request) {
try { try {
Map<String,Object> result=masukKamarService.saveMasukKamar(vo); Map<String, Object> result = masukKamarService.saveMasukKamar(vo);
if (null != result) if (null != result)
mapHeaderMessage.put(WebConstants.HttpHeaderInfo.LABEL_SUCCESS,getMessage(MessageResource.LABEL_SUCCESS,request )); mapHeaderMessage.put(LABEL_SUCCESS, getMessage(MessageResource.LABEL_SUCCESS, request));
return RestUtil.getJsonResponse(result, HttpStatus.CREATED,mapHeaderMessage); return getJsonResponse(result, CREATED, mapHeaderMessage);
} catch (ServiceVOException e) { } catch (ServiceVOException e) {
LOGGER.error("Got exception {} when add Masuk Kamar", e.getMessage()); LOGGER.error("Got ServiceVOException {} when saveMasukKamar", e.getMessage());
addHeaderMessage(Constants.MessageInfo.ERROR_MESSAGE, e.getMessage()); addHeaderMessage(ERROR_MESSAGE, e.getMessage());
return RestUtil.getJsonHttpStatus(HttpStatus.INTERNAL_SERVER_ERROR, mapHeaderMessage); return getJsonHttpStatus(INTERNAL_SERVER_ERROR, mapHeaderMessage);
} catch (JpaSystemException jse) { } catch (JpaSystemException jse) {
LOGGER.error("Got exception {} when add Masuk kamar", jse.getMessage()); LOGGER.error("Got JpaSystemException {} when saveMasukKamar", jse.getMessage());
addHeaderMessage(Constants.MessageInfo.ERROR_MESSAGE, jse.getMessage()); addHeaderMessage(ERROR_MESSAGE, jse.getMessage());
return RestUtil.getJsonHttpStatus(HttpStatus.CONFLICT, mapHeaderMessage); return getJsonHttpStatus(CONFLICT, mapHeaderMessage);
} }
} }
@RequestMapping(value = "/get-jadwal-dpjp")
@ResponseBody
public List<Map<String, Object>> getLoadDataDpjp(
@RequestParam(value = "id", required = false) Integer id) {
return service.getJadwalDpjpByRuangan(id);
}
} }

View File

@ -9,16 +9,17 @@ import net.kaczmarzyk.spring.data.jpa.domain.Equal;
import net.kaczmarzyk.spring.data.jpa.web.annotation.Spec; import net.kaczmarzyk.spring.data.jpa.web.annotation.Spec;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.jpa.domain.Specification; import org.springframework.data.jpa.domain.Specification;
import org.springframework.http.MediaType;
import org.springframework.http.ResponseEntity; import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RequestParam; import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController; import org.springframework.web.bind.annotation.RestController;
import java.util.Collection; import java.util.Collection;
import java.util.Map; import java.util.Map;
import static org.springframework.http.MediaType.APPLICATION_JSON_VALUE;
import static org.springframework.web.bind.annotation.RequestMethod.GET;
@RestController @RestController
@RequestMapping("/matriks-indikator") @RequestMapping("/matriks-indikator")
public class MatriksIndikatorController extends LocaleController<KontrakKinerjaVO> { public class MatriksIndikatorController extends LocaleController<KontrakKinerjaVO> {
@ -26,7 +27,7 @@ public class MatriksIndikatorController extends LocaleController<KontrakKinerjaV
@Autowired @Autowired
private MatriksIndikatorService matriksService; private MatriksIndikatorService matriksService;
@RequestMapping(value = "/find-all/", method = RequestMethod.GET, produces = MediaType.APPLICATION_JSON_VALUE) @RequestMapping(value = "/find-all/", method = GET, produces = APPLICATION_JSON_VALUE)
public ResponseEntity<Collection<PasienVO>> findAll( public ResponseEntity<Collection<PasienVO>> findAll(
@RequestParam(value = "page", required = false, defaultValue = "0") Integer page, @RequestParam(value = "page", required = false, defaultValue = "0") Integer page,
@RequestParam(value = "take", required = false, defaultValue = "100") Integer take, @RequestParam(value = "take", required = false, defaultValue = "100") Integer take,

View File

@ -1,112 +1,66 @@
package com.jasamedika.medifirst2000.controller; package com.jasamedika.medifirst2000.controller;
import java.util.Collection; import com.jasamedika.medifirst2000.constants.MessageResource;
import java.util.HashMap; import com.jasamedika.medifirst2000.controller.base.LocaleController;
import java.util.List; import com.jasamedika.medifirst2000.exception.ServiceVOException;
import java.util.Map; import com.jasamedika.medifirst2000.service.MenuService;
import com.jasamedika.medifirst2000.vo.ProdukVO;
import javax.servlet.http.HttpServletRequest;
import javax.validation.Valid;
import org.slf4j.Logger; import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.HttpStatus;
import org.springframework.http.MediaType;
import org.springframework.http.ResponseEntity; import org.springframework.http.ResponseEntity;
import org.springframework.orm.jpa.JpaSystemException; import org.springframework.orm.jpa.JpaSystemException;
import org.springframework.web.bind.annotation.RequestBody; import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RestController; import org.springframework.web.bind.annotation.RestController;
import com.jasamedika.medifirst2000.constants.Constants; import javax.servlet.http.HttpServletRequest;
import com.jasamedika.medifirst2000.constants.MessageResource; import javax.validation.Valid;
import com.jasamedika.medifirst2000.controller.base.IBaseRestController; import java.util.Map;
import com.jasamedika.medifirst2000.controller.base.LocaleController;
import com.jasamedika.medifirst2000.core.web.WebConstants; import static com.jasamedika.medifirst2000.constants.Constants.MessageInfo.ERROR_MESSAGE;
import com.jasamedika.medifirst2000.exception.ServiceVOException; import static com.jasamedika.medifirst2000.core.web.WebConstants.HttpHeaderInfo.LABEL_SUCCESS;
import com.jasamedika.medifirst2000.service.MenuService; import static com.jasamedika.medifirst2000.util.rest.RestUtil.getJsonHttpStatus;
import com.jasamedika.medifirst2000.util.rest.RestUtil; import static com.jasamedika.medifirst2000.util.rest.RestUtil.getJsonResponse;
import com.jasamedika.medifirst2000.vo.ProdukVO; import static org.slf4j.LoggerFactory.getLogger;
import static org.springframework.http.HttpStatus.*;
import static org.springframework.http.MediaType.APPLICATION_JSON_VALUE;
import static org.springframework.web.bind.annotation.RequestMethod.GET;
import static org.springframework.web.bind.annotation.RequestMethod.POST;
@RestController @RestController
@RequestMapping(value="/menu") @RequestMapping(value = "/menu")
public class MenuController extends LocaleController<ProdukVO> public class MenuController extends LocaleController<ProdukVO> {
implements IBaseRestController<ProdukVO>{
private static final Logger LOGGER = getLogger(MenuController.class);
@Autowired @Autowired
private MenuService menuService; private MenuService menuService;
private static final Logger LOGGER = LoggerFactory @RequestMapping(value = "/find-all/", method = GET, produces = APPLICATION_JSON_VALUE)
.getLogger(MenuController.class); public ResponseEntity<Map<String, Object>> getOrderGizi(HttpServletRequest request) {
Map<String, Object> result = menuService.findAllMenu();
@Override if (null != result)
public ResponseEntity<Collection<ProdukVO>> getAllVOWithQueryString(HttpServletRequest request, Integer page, mapHeaderMessage.put(LABEL_SUCCESS, getMessage(MessageResource.LABEL_SUCCESS, request));
Integer limit, String sort, String dir) { return getJsonResponse(result, CREATED, mapHeaderMessage);
return null;
} }
@Override @RequestMapping(value = "/save/", method = POST, produces = APPLICATION_JSON_VALUE)
public ResponseEntity<ProdukVO> getVO(Integer id) { public ResponseEntity<Map<String, Object>> getOrderGizi(@Valid @RequestBody ProdukVO vo,
return null; HttpServletRequest request) {
} try {
@Override
public ResponseEntity<String> addVO(ProdukVO vo) {
return null;
}
@Override
public ResponseEntity<String> editVO(ProdukVO vo) {
return null;
}
@Override
public ResponseEntity<String> deleteVO(Integer id) {
return null;
}
@Override
public ResponseEntity<List<ProdukVO>> getAllVO() {
return null;
}
@RequestMapping(value="/find-all/", method= RequestMethod.GET,produces = MediaType.APPLICATION_JSON_VALUE)
public ResponseEntity<Map<String,Object>> getOrderGizi(
HttpServletRequest request)
{
Map<String, Object> result = new HashMap<String, Object>();
result = menuService.findAllMenu();
if (null != result)
mapHeaderMessage.put(WebConstants.HttpHeaderInfo.LABEL_SUCCESS,getMessage(MessageResource.LABEL_SUCCESS,request ));
return RestUtil.getJsonResponse(result, HttpStatus.CREATED, mapHeaderMessage);
}
@RequestMapping(value="/save/", method= RequestMethod.POST,produces = MediaType.APPLICATION_JSON_VALUE)
public ResponseEntity<Map<String,Object>> getOrderGizi(
@Valid @RequestBody ProdukVO vo,
HttpServletRequest request)
{
try{
Map<String, Object> result = menuService.saveMenu(vo); Map<String, Object> result = menuService.saveMenu(vo);
if(null!= result) if (null != result)
mapHeaderMessage.put(WebConstants.HttpHeaderInfo.LABEL_SUCCESS, getMessage(MessageResource.LABEL_SUCCESS,request)); mapHeaderMessage.put(LABEL_SUCCESS, getMessage(MessageResource.LABEL_SUCCESS, request));
return RestUtil.getJsonResponse(result, HttpStatus.CREATED, mapHeaderMessage); return getJsonResponse(result, CREATED, mapHeaderMessage);
} catch (ServiceVOException e) { } catch (ServiceVOException e) {
LOGGER.error("Got exception {} when save Menu", e.getMessage()); LOGGER.error("Got ServiceVOException {} when saveMenu", e.getMessage());
addHeaderMessage(Constants.MessageInfo.ERROR_MESSAGE, addHeaderMessage(ERROR_MESSAGE, e.getMessage());
e.getMessage()); return getJsonHttpStatus(INTERNAL_SERVER_ERROR, mapHeaderMessage);
return RestUtil.getJsonHttpStatus(HttpStatus.INTERNAL_SERVER_ERROR,
mapHeaderMessage);
} catch (JpaSystemException jse) { } catch (JpaSystemException jse) {
LOGGER.error("Got exception {} when save Menu", jse.getMessage()); LOGGER.error("Got JpaSystemException {} when saveMenu", jse.getMessage());
addHeaderMessage(Constants.MessageInfo.ERROR_MESSAGE, addHeaderMessage(ERROR_MESSAGE, jse.getMessage());
jse.getMessage()); return getJsonHttpStatus(CONFLICT, mapHeaderMessage);
return RestUtil.getJsonHttpStatus(HttpStatus.CONFLICT,
mapHeaderMessage);
} }
} }
} }

View File

@ -1,211 +1,133 @@
package com.jasamedika.medifirst2000.controller; package com.jasamedika.medifirst2000.controller;
import java.util.Collection;
import java.util.List;
import java.util.Map;
import javax.servlet.http.HttpServletRequest;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.HttpStatus;
import org.springframework.http.MediaType;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RestController;
import com.jasamedika.medifirst2000.constants.Constants;
import com.jasamedika.medifirst2000.controller.base.IBaseRestController;
import com.jasamedika.medifirst2000.controller.base.LocaleController; import com.jasamedika.medifirst2000.controller.base.LocaleController;
import com.jasamedika.medifirst2000.dao.LoginUserDao;
import com.jasamedika.medifirst2000.dao.RuanganDao;
import com.jasamedika.medifirst2000.entities.LoginUser; import com.jasamedika.medifirst2000.entities.LoginUser;
import com.jasamedika.medifirst2000.entities.Pegawai; import com.jasamedika.medifirst2000.entities.Pegawai;
import com.jasamedika.medifirst2000.logging.hibernate.async.LoggingSystemAsynchronous; import com.jasamedika.medifirst2000.logging.hibernate.async.LoggingSystemAsynchronous;
import com.jasamedika.medifirst2000.service.LoginUserService; import com.jasamedika.medifirst2000.service.LoginUserService;
import com.jasamedika.medifirst2000.service.MapLoginUserToRuanganService; import com.jasamedika.medifirst2000.service.MapLoginUserToRuanganService;
import com.jasamedika.medifirst2000.service.MapPegawaiToModulAplikasiService;
import com.jasamedika.medifirst2000.service.ModulAplikasiService; import com.jasamedika.medifirst2000.service.ModulAplikasiService;
import com.jasamedika.medifirst2000.service.ObjekModulAplikasiService; import com.jasamedika.medifirst2000.service.ObjekModulAplikasiService;
import com.jasamedika.medifirst2000.service.PegawaiService;
import com.jasamedika.medifirst2000.util.CommonUtil;
import com.jasamedika.medifirst2000.util.rest.RestUtil;
import com.jasamedika.medifirst2000.vo.MapLoginUserToRuanganVO; import com.jasamedika.medifirst2000.vo.MapLoginUserToRuanganVO;
import com.jasamedika.medifirst2000.vo.MapPegawaiToModulAplikasiVO;
import com.jasamedika.medifirst2000.vo.ModulAplikasiSVO; import com.jasamedika.medifirst2000.vo.ModulAplikasiSVO;
import com.jasamedika.medifirst2000.vo.ModulAplikasiVO; import com.jasamedika.medifirst2000.vo.ModulAplikasiVO;
import com.jasamedika.medifirst2000.vo.ObjekModulAplikasiVO; import com.jasamedika.medifirst2000.vo.ObjekModulAplikasiVO;
import org.slf4j.Logger;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import javax.servlet.http.HttpServletRequest;
import java.util.List;
import java.util.Map;
import static com.jasamedika.medifirst2000.constants.Constants.MessageInfo.ERROR_MESSAGE;
import static com.jasamedika.medifirst2000.util.CommonUtil.isNotNullOrEmpty;
import static com.jasamedika.medifirst2000.util.CommonUtil.isNullOrEmpty;
import static com.jasamedika.medifirst2000.util.rest.RestUtil.defaultJsonResponse;
import static com.jasamedika.medifirst2000.util.rest.RestUtil.getJsonHttpStatus;
import static org.slf4j.LoggerFactory.getLogger;
import static org.springframework.http.HttpStatus.UNAUTHORIZED;
import static org.springframework.http.MediaType.APPLICATION_JSON_VALUE;
import static org.springframework.web.bind.annotation.RequestMethod.GET;
/** /**
* Controller class for menu modul * Controller class for menu modul
* *
* @author Syamsu * @author Syamsu
*/ */
@RestController @RestController
@RequestMapping({"/test-tanpa-auth/modul-aplikasi", "/modul-aplikasi"}) @RequestMapping("/modul-aplikasi")
public class MenuDinamicController extends LocaleController<ModulAplikasiSVO> implements IBaseRestController<ModulAplikasiSVO> { public class MenuDinamicController extends LocaleController<ModulAplikasiSVO> {
private static final Logger LOGGER = LoggerFactory.getLogger(MenuDinamicController.class); private static final Logger LOGGER = getLogger(MenuDinamicController.class);
@Autowired @Autowired
ModulAplikasiService<ModulAplikasiVO> modulAplikasiService; ModulAplikasiService<ModulAplikasiVO> modulAplikasiService;
@Autowired @Autowired
ObjekModulAplikasiService<ObjekModulAplikasiVO> objekModulAplikasiService; ObjekModulAplikasiService<ObjekModulAplikasiVO> objekModulAplikasiService;
@Autowired @Autowired
MapLoginUserToRuanganService<MapLoginUserToRuanganVO> mapLoginUserToRuanganService; MapLoginUserToRuanganService<MapLoginUserToRuanganVO> mapLoginUserToRuanganService;
@Autowired @Autowired
LoggingSystemAsynchronous loggingSystemAsynchronous; LoggingSystemAsynchronous loggingSystemAsynchronous;
@Autowired
MapPegawaiToModulAplikasiService<MapPegawaiToModulAplikasiVO> mapPegawaiToModulAplikasiService;
@Autowired @Autowired
LoginUserService loginUserService; LoginUserService loginUserService;
@Autowired @RequestMapping(value = "/keluar-ruangan/{modulaplikasiId:[0-9]+}", method = GET, produces = APPLICATION_JSON_VALUE)
PegawaiService pegawaiService; public ResponseEntity<String> keluarRuangan(@PathVariable("modulaplikasiId") int modulaplikasiId,
HttpServletRequest request) {
@Autowired try {
private LoginUserDao loginUserDao;
@Autowired
RuanganDao ruanganDao;
@RequestMapping(value="/keluar-ruangan/{modulaplikasiId:[0-9]+}", method = RequestMethod.GET, produces = MediaType.APPLICATION_JSON_VALUE)
public ResponseEntity<String> keluarRuangan(@PathVariable("modulaplikasiId") int modulaplikasiId, HttpServletRequest request){
try{
LoginUser loginUser = loginUserService.getLoginUser(); LoginUser loginUser = loginUserService.getLoginUser();
Integer idPegawai = 0; Integer idPegawai = 0;
if (CommonUtil.isNotNullOrEmpty(loginUser.getPegawai())){ if (isNotNullOrEmpty(loginUser.getPegawai()))
idPegawai = loginUser.getPegawai().getId(); idPegawai = loginUser.getPegawai().getId();
}
loggingSystemAsynchronous.saveSignInLog(modulaplikasiId, 0, loginUser.getNamaUser(), idPegawai); loggingSystemAsynchronous.saveSignInLog(modulaplikasiId, 0, loginUser.getNamaUser(), idPegawai);
Pegawai pegawai = loginUser.getPegawai(); Pegawai pegawai = loginUser.getPegawai();
return RestUtil.defaultJsonResponse(pegawai); return defaultJsonResponse(pegawai);
}catch(Exception e){ } catch (Exception e) {
LOGGER.info("Got exception {} in get objek modul aplikasi", e); LOGGER.info("Got exception {} in getLoginUser(keluarRuangan)", e.getMessage());
addHeaderMessage(Constants.MessageInfo.ERROR_MESSAGE, "Gagal pilih ruangan."); addHeaderMessage(ERROR_MESSAGE, "Gagal pilih ruangan.");
return RestUtil.getJsonHttpStatus(HttpStatus.UNAUTHORIZED, mapHeaderMessage); return getJsonHttpStatus(UNAUTHORIZED, mapHeaderMessage);
} }
} }
@RequestMapping(value = "/pilih-ruangan/{modulaplikasiId:[0-9]+}/{ruanganId:[0-9]+}", method = RequestMethod.GET, produces = MediaType.APPLICATION_JSON_VALUE) @RequestMapping(value = "/pilih-ruangan/{modulaplikasiId:[0-9]+}/{ruanganId:[0-9]+}", method = GET, produces = APPLICATION_JSON_VALUE)
public ResponseEntity<String> pilihRuangan(@PathVariable("modulaplikasiId") int modulaplikasiId, @PathVariable("ruanganId") int ruanganId, HttpServletRequest request){ public ResponseEntity<String> pilihRuangan(@PathVariable("modulaplikasiId") int modulaplikasiId,
try{ @PathVariable("ruanganId") int ruanganId, HttpServletRequest request) {
try {
LoginUser loginUser = loginUserService.getLoginUser(); LoginUser loginUser = loginUserService.getLoginUser();
Integer idPegawai = 0; Integer idPegawai = 0;
if (CommonUtil.isNotNullOrEmpty(loginUser.getPegawai())){ if (isNotNullOrEmpty(loginUser.getPegawai()))
idPegawai = loginUser.getPegawai().getId(); idPegawai = loginUser.getPegawai().getId();
}
Pegawai pegawai = loginUser.getPegawai(); //loginUserService.updateRuanganPegawaiPerLoginPerpindahRuangan(ruanganId);
loggingSystemAsynchronous.saveSignInLog(modulaplikasiId, ruanganId, loginUser.getNamaUser(), idPegawai);
return RestUtil.defaultJsonResponse(pegawai);
}catch(Exception e){
LOGGER.info("Got exception {} in get objek modul aplikasi", e);
addHeaderMessage(Constants.MessageInfo.ERROR_MESSAGE, "Gagal pilih ruangan.");
return RestUtil.getJsonHttpStatus(HttpStatus.UNAUTHORIZED, mapHeaderMessage);
}
}
@RequestMapping(value = "/get-all-sub-system", method = RequestMethod.GET, produces = MediaType.APPLICATION_JSON_VALUE)
public ResponseEntity<List<ModulAplikasiVO>> getAllSubSystem(){
return RestUtil.defaultJsonResponse(modulAplikasiService.findAllSubSytemOrderByModulNoUrutAsc(), mapHeaderMessage) ;
}
@RequestMapping(value = "/get-all-sub-modul/{kdModulAplikasi:[0-9]+}/show", method = RequestMethod.GET, produces = MediaType.APPLICATION_JSON_VALUE)
public ResponseEntity<List<ModulAplikasiVO>> getAllSubModul(@PathVariable("kdModulAplikasi") int kdModulAplikasi, HttpServletRequest request){
//loggingSystemAsynchronous.saveSignInLog(kdModulAplikasi, request, null);
return RestUtil.defaultJsonResponse(modulAplikasiService.findAllSubModulOrderByModulNoUrutAsc(kdModulAplikasi));
}
/// OBJEK MODUL = FORM INPUT
@RequestMapping(value = "/get-all-objek-modul/{idUserLogin:[0-9]+}/{kdModulAplikasi:[0-9]+}/show", method = RequestMethod.GET, produces = MediaType.APPLICATION_JSON_VALUE)
public ResponseEntity<List<ObjekModulAplikasiVO>> getAllObjekModul(@PathVariable("idUserLogin") int idUserLogin, @PathVariable("kdModulAplikasi") int kdModulAplikasi){
try{
//LoginUserVO loginUserVo = loginUserService.findById(idUserLogin);
LoginUser loginUser = loginUserDao.findOne(idUserLogin);
Pegawai pegawai = loginUser.getPegawai(); Pegawai pegawai = loginUser.getPegawai();
Integer pegawaiId = pegawai.getId(); loggingSystemAsynchronous.saveSignInLog(modulaplikasiId, ruanganId, loginUser.getNamaUser(), idPegawai);
return defaultJsonResponse(pegawai);
List<MapPegawaiToModulAplikasiVO> lVO = mapPegawaiToModulAplikasiService.findByPegawaiIdAndModulAplikasiId(pegawaiId, kdModulAplikasi); } catch (Exception e) {
LOGGER.info("Got exception {} in getLoginUser(pilihRuangan)", e.getMessage());
if (CommonUtil.isNullOrEmpty(lVO)) { addHeaderMessage(ERROR_MESSAGE, "Gagal pilih ruangan.");
addHeaderMessage(Constants.MessageInfo.ERROR_MESSAGE, "Anda tidak punya izin akses"); return getJsonHttpStatus(UNAUTHORIZED, mapHeaderMessage);
return RestUtil.getJsonHttpStatus(HttpStatus.UNAUTHORIZED, mapHeaderMessage);
}
return RestUtil.defaultJsonResponse(objekModulAplikasiService.findAllModulAplikasi(kdModulAplikasi));
}catch(Exception e){
LOGGER.info("Got exception {} in get objek modul aplikasi", e);
addHeaderMessage(Constants.MessageInfo.ERROR_MESSAGE, "Anda tidak punya izin akses");
return RestUtil.getJsonHttpStatus(HttpStatus.UNAUTHORIZED, mapHeaderMessage);
} }
} }
@RequestMapping(value = "/get-all-default-objek-modul", method = RequestMethod.GET, produces = MediaType.APPLICATION_JSON_VALUE) @RequestMapping(value = "/get-all-sub-system", method = GET, produces = APPLICATION_JSON_VALUE)
public ResponseEntity<List<ObjekModulAplikasiVO>> getAllDefaultObjekModulAplikasi(){ public ResponseEntity<List<ModulAplikasiVO>> getAllSubSystem() {
return RestUtil.defaultJsonResponse(objekModulAplikasiService.findByKdObjekModulAplikasiHeadIsNullOrderByNoUrutAsc()); return defaultJsonResponse(modulAplikasiService.findAllSubSytemOrderByModulNoUrutAsc(), mapHeaderMessage);
} }
@RequestMapping(value = "/get-all-unit-kerja/{idUserLogin:[0-9]+}/{kdModulAplikasi:[0-9]+}/show", method = RequestMethod.GET, produces = MediaType.APPLICATION_JSON_VALUE) @RequestMapping(value = "/get-all-sub-modul/{kdModulAplikasi:[0-9]+}/show", method = GET, produces = APPLICATION_JSON_VALUE)
public ResponseEntity<List<Map<String, Object>>> getAllUnitKerjaByUserLogin(@PathVariable("idUserLogin") int idUserLogin, @PathVariable("kdModulAplikasi") int kdModulAplikasi){ public ResponseEntity<List<ModulAplikasiVO>> getAllSubModul(@PathVariable("kdModulAplikasi") int kdModulAplikasi,
try{ HttpServletRequest request) {
List<Map<String, Object>> ruangannya = mapLoginUserToRuanganService.findCurrentRoomByUserLoginAndModulAplikasi(idUserLogin, kdModulAplikasi); return defaultJsonResponse(modulAplikasiService.findAllSubModulOrderByModulNoUrutAsc(kdModulAplikasi));
}
if (CommonUtil.isNullOrEmpty(ruangannya)){
addHeaderMessage(Constants.MessageInfo.ERROR_MESSAGE, "Anda tidak punya izin akses"); @RequestMapping(value = "/get-all-default-objek-modul", method = GET, produces = APPLICATION_JSON_VALUE)
return RestUtil.getJsonHttpStatus(HttpStatus.UNAUTHORIZED, mapHeaderMessage); public ResponseEntity<List<ObjekModulAplikasiVO>> getAllDefaultObjekModulAplikasi() {
return defaultJsonResponse(objekModulAplikasiService.findByKdObjekModulAplikasiHeadIsNullOrderByNoUrutAsc());
}
@RequestMapping(value = "/get-all-unit-kerja/{idUserLogin:[0-9]+}/{kdModulAplikasi:[0-9]+}/show", method = GET, produces = APPLICATION_JSON_VALUE)
public ResponseEntity<List<Map<String, Object>>> getAllUnitKerjaByUserLogin(
@PathVariable("idUserLogin") int idUserLogin, @PathVariable("kdModulAplikasi") int kdModulAplikasi) {
try {
List<Map<String, Object>> ruangannya = mapLoginUserToRuanganService
.findCurrentRoomByUserLoginAndModulAplikasi(idUserLogin, kdModulAplikasi);
if (isNullOrEmpty(ruangannya)) {
addHeaderMessage(ERROR_MESSAGE, "Anda tidak punya izin akses");
return getJsonHttpStatus(UNAUTHORIZED, mapHeaderMessage);
} }
return defaultJsonResponse(ruangannya);
return RestUtil.defaultJsonResponse(ruangannya); } catch (Exception e) {
}catch(Exception e){ LOGGER.info("Got exception {} in findCurrentRoomByUserLoginAndModulAplikasi", e.getMessage());
LOGGER.info("Got exception {} in get objek modul aplikasi", e); addHeaderMessage(ERROR_MESSAGE, "Anda tidak punya izin akses");
addHeaderMessage(Constants.MessageInfo.ERROR_MESSAGE, "Anda tidak punya izin akses"); return getJsonHttpStatus(UNAUTHORIZED, mapHeaderMessage);
return RestUtil.getJsonHttpStatus(HttpStatus.UNAUTHORIZED, mapHeaderMessage);
} }
} }
@Override
public ResponseEntity<Collection<ModulAplikasiSVO>> getAllVOWithQueryString(HttpServletRequest request, Integer page, Integer limit, String sort, String dir) {
return null;
}
@Override
public ResponseEntity<ModulAplikasiSVO> getVO(Integer id) {
return null;
}
@Override
public ResponseEntity<String> addVO(ModulAplikasiSVO vo) {
return null;
}
@Override
public ResponseEntity<String> editVO(ModulAplikasiSVO vo) {
return null;
}
@Override
public ResponseEntity<String> deleteVO(Integer id) {
return null;
}
@Override
public ResponseEntity<List<ModulAplikasiSVO>> getAllVO() {
return null;
}
} }