Update controller
Clean code
This commit is contained in:
parent
a5edc64e0e
commit
3e4c001ae8
@ -1,89 +1,83 @@
|
||||
package com.jasamedika.medifirst2000.controller;
|
||||
|
||||
import java.util.Map;
|
||||
import com.jasamedika.medifirst2000.constants.MessageResource;
|
||||
import com.jasamedika.medifirst2000.controller.base.LocaleController;
|
||||
import com.jasamedika.medifirst2000.exception.ServiceVOException;
|
||||
import com.jasamedika.medifirst2000.service.KontrakService;
|
||||
import com.jasamedika.medifirst2000.vo.RekananSkKontrakDetailVO;
|
||||
import com.jasamedika.medifirst2000.vo.RekananSkKontrakVO;
|
||||
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.HttpServletResponse;
|
||||
import javax.validation.Valid;
|
||||
import java.util.Map;
|
||||
|
||||
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.ResponseBody;
|
||||
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.KontrakService;
|
||||
import com.jasamedika.medifirst2000.util.rest.RestUtil;
|
||||
import com.jasamedika.medifirst2000.vo.RekananSkKontrakDetailVO;
|
||||
import com.jasamedika.medifirst2000.vo.RekananSkKontrakVO;
|
||||
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
|
||||
@RequestMapping("/kontrak")
|
||||
public class KontrakController extends LocaleController{
|
||||
|
||||
private static final Logger LOGGER = LoggerFactory.getLogger(KontrakController.class);
|
||||
|
||||
public class KontrakController extends LocaleController<RekananSkKontrakVO> {
|
||||
|
||||
private static final Logger LOGGER = getLogger(KontrakController.class);
|
||||
|
||||
@Autowired
|
||||
private KontrakService kontrakService;
|
||||
|
||||
@RequestMapping(value = "/save-kontrak/", method = RequestMethod.POST, produces = MediaType.APPLICATION_JSON_VALUE, consumes = MediaType.APPLICATION_JSON_VALUE)
|
||||
public ResponseEntity<Map<String, Object>> saveKontrak(@Valid @RequestBody RekananSkKontrakVO vo,HttpServletRequest request,HttpServletResponse response) {
|
||||
|
||||
|
||||
@RequestMapping(value = "/save-kontrak/", method = POST, produces = APPLICATION_JSON_VALUE, consumes = APPLICATION_JSON_VALUE)
|
||||
public ResponseEntity<Map<String, Object>> saveKontrak(@Valid @RequestBody RekananSkKontrakVO vo,
|
||||
HttpServletRequest request, HttpServletResponse response) {
|
||||
try {
|
||||
Map<String, Object> result = kontrakService.saveKontrak(vo);
|
||||
if (null != result)
|
||||
mapHeaderMessage.put(WebConstants.HttpHeaderInfo.LABEL_SUCCESS,getMessage(MessageResource.LABEL_SUCCESS, request));
|
||||
return RestUtil.getJsonResponse(result, HttpStatus.CREATED, mapHeaderMessage);
|
||||
mapHeaderMessage.put(LABEL_SUCCESS, getMessage(MessageResource.LABEL_SUCCESS, request));
|
||||
return getJsonResponse(result, CREATED, mapHeaderMessage);
|
||||
} catch (ServiceVOException e) {
|
||||
LOGGER.error("Got exception {} when save kontrak", e.getMessage());
|
||||
addHeaderMessage(Constants.MessageInfo.ERROR_MESSAGE, e.getMessage());
|
||||
return RestUtil.getJsonHttpStatus(HttpStatus.INTERNAL_SERVER_ERROR, mapHeaderMessage);
|
||||
LOGGER.error("Got ServiceVOException {} when saveKontrak", e.getMessage());
|
||||
addHeaderMessage(ERROR_MESSAGE, e.getMessage());
|
||||
return getJsonHttpStatus(INTERNAL_SERVER_ERROR, mapHeaderMessage);
|
||||
} catch (JpaSystemException jse) {
|
||||
LOGGER.error("Got exception {} when save kontrak", jse.getMessage());
|
||||
addHeaderMessage(Constants.MessageInfo.ERROR_MESSAGE, jse.getMessage());
|
||||
return RestUtil.getJsonHttpStatus(HttpStatus.CONFLICT, mapHeaderMessage);
|
||||
LOGGER.error("Got JpaSystemException {} when saveKontrak", jse.getMessage());
|
||||
addHeaderMessage(ERROR_MESSAGE, jse.getMessage());
|
||||
return getJsonHttpStatus(CONFLICT, mapHeaderMessage);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
@RequestMapping(value = "/save-kontrak-detail/", method = RequestMethod.POST, produces = MediaType.APPLICATION_JSON_VALUE, consumes = MediaType.APPLICATION_JSON_VALUE)
|
||||
public ResponseEntity<Map<String, Object>> saveKontrakDetail(@Valid @RequestBody RekananSkKontrakDetailVO vo,HttpServletRequest request,HttpServletResponse response) {
|
||||
|
||||
|
||||
@RequestMapping(value = "/save-kontrak-detail/", method = POST, produces = APPLICATION_JSON_VALUE, consumes = APPLICATION_JSON_VALUE)
|
||||
public ResponseEntity<Map<String, Object>> saveKontrakDetail(@Valid @RequestBody RekananSkKontrakDetailVO vo,
|
||||
HttpServletRequest request, HttpServletResponse response) {
|
||||
try {
|
||||
Map<String, Object> result = kontrakService.saveKontrakDetail(vo);
|
||||
if (null != result)
|
||||
mapHeaderMessage.put(WebConstants.HttpHeaderInfo.LABEL_SUCCESS,getMessage(MessageResource.LABEL_SUCCESS, request));
|
||||
return RestUtil.getJsonResponse(result, HttpStatus.CREATED, mapHeaderMessage);
|
||||
mapHeaderMessage.put(LABEL_SUCCESS, getMessage(MessageResource.LABEL_SUCCESS, request));
|
||||
return getJsonResponse(result, CREATED, mapHeaderMessage);
|
||||
} catch (ServiceVOException e) {
|
||||
LOGGER.error("Got exception {} when save kontrak", e.getMessage());
|
||||
addHeaderMessage(Constants.MessageInfo.ERROR_MESSAGE, e.getMessage());
|
||||
return RestUtil.getJsonHttpStatus(HttpStatus.INTERNAL_SERVER_ERROR, mapHeaderMessage);
|
||||
LOGGER.error("Got ServiceVOException {} when saveKontrakDetail", e.getMessage());
|
||||
addHeaderMessage(ERROR_MESSAGE, e.getMessage());
|
||||
return getJsonHttpStatus(INTERNAL_SERVER_ERROR, mapHeaderMessage);
|
||||
} catch (JpaSystemException jse) {
|
||||
LOGGER.error("Got exception {} when save kontrak", jse.getMessage());
|
||||
addHeaderMessage(Constants.MessageInfo.ERROR_MESSAGE, jse.getMessage());
|
||||
return RestUtil.getJsonHttpStatus(HttpStatus.CONFLICT, mapHeaderMessage);
|
||||
LOGGER.error("Got JpaSystemException {} when saveKontrakDetail", jse.getMessage());
|
||||
addHeaderMessage(ERROR_MESSAGE, jse.getMessage());
|
||||
return getJsonHttpStatus(CONFLICT, mapHeaderMessage);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
|
||||
@RequestMapping(value = "/list-kontrak")
|
||||
@ResponseBody
|
||||
public Map<String,Object> listkontrak(
|
||||
public Map<String, Object> listkontrak(
|
||||
@RequestParam(value = "page", required = false, defaultValue = "0") Integer page,
|
||||
@RequestParam(value = "take", required = false, defaultValue = "10") Integer limit,
|
||||
@RequestParam(value = "sort", required = false, defaultValue = "namaKontrak") String sort,
|
||||
@ -91,17 +85,13 @@ public class KontrakController extends LocaleController{
|
||||
@RequestParam(value = "noKontrak", required = false) String noKontrak,
|
||||
@RequestParam(value = "rekananId", required = false) Integer rekananId,
|
||||
@RequestParam(value = "namaKontrak", required = false) String namaKontrak) {
|
||||
|
||||
Map<String, Object> resultPageMap = kontrakService.listKontrak(page, limit, sort, dir, noKontrak, rekananId, namaKontrak);
|
||||
|
||||
return resultPageMap;
|
||||
return kontrakService.listKontrak(page, limit, sort, dir, noKontrak, rekananId,
|
||||
namaKontrak);
|
||||
}
|
||||
|
||||
@RequestMapping(value = "/detail-kontrak", method = RequestMethod.GET, produces = MediaType.APPLICATION_JSON_VALUE)
|
||||
|
||||
@RequestMapping(value = "/detail-kontrak", method = GET, produces = APPLICATION_JSON_VALUE)
|
||||
public Map<String, Object> detilKontrak(@RequestParam(value = "noRec") String noRec) {
|
||||
Map<String, Object> data = kontrakService.detilKontrak(noRec);
|
||||
return data;
|
||||
return kontrakService.detilKontrak(noRec);
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
@ -1,190 +1,81 @@
|
||||
package com.jasamedika.medifirst2000.controller;
|
||||
|
||||
import java.util.Collection;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
import javax.validation.Valid;
|
||||
|
||||
import com.jasamedika.medifirst2000.constants.MessageResource;
|
||||
import com.jasamedika.medifirst2000.controller.base.LocaleController;
|
||||
import com.jasamedika.medifirst2000.entities.KontrakKinerja;
|
||||
import com.jasamedika.medifirst2000.exception.ServiceVOException;
|
||||
import com.jasamedika.medifirst2000.service.KontrakKinerjaService;
|
||||
import com.jasamedika.medifirst2000.vo.KontrakKinerjaVO;
|
||||
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.LoggerFactory;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.data.jpa.domain.Specification;
|
||||
import org.springframework.data.jpa.domain.Specifications;
|
||||
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.constants.Constants;
|
||||
import com.jasamedika.medifirst2000.constants.MessageResource;
|
||||
import com.jasamedika.medifirst2000.controller.base.IBaseRestController;
|
||||
import com.jasamedika.medifirst2000.controller.base.LocaleController;
|
||||
import com.jasamedika.medifirst2000.core.web.WebConstants;
|
||||
import com.jasamedika.medifirst2000.entities.KontrakKinerja;
|
||||
import com.jasamedika.medifirst2000.exception.ServiceVOException;
|
||||
import com.jasamedika.medifirst2000.service.KontrakKinerjaService;
|
||||
import com.jasamedika.medifirst2000.util.rest.RestUtil;
|
||||
import com.jasamedika.medifirst2000.vo.KontrakKinerjaVO;
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
import javax.validation.Valid;
|
||||
import java.util.Collection;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
import net.kaczmarzyk.spring.data.jpa.domain.Equal;
|
||||
import net.kaczmarzyk.spring.data.jpa.web.annotation.Spec;
|
||||
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
|
||||
@RequestMapping("/kontrak-kinerja")
|
||||
public class KontrakKinerjaController extends LocaleController<KontrakKinerjaVO> implements IBaseRestController<KontrakKinerjaVO>{
|
||||
|
||||
public class KontrakKinerjaController extends LocaleController<KontrakKinerjaVO> {
|
||||
|
||||
private static final Logger LOGGER = getLogger(KontrakKinerjaController.class);
|
||||
|
||||
@Autowired
|
||||
private KontrakKinerjaService kontrakKinerjaService;
|
||||
|
||||
private static final Logger LOGGER = LoggerFactory
|
||||
.getLogger(KontrakKinerjaController.class);
|
||||
|
||||
@RequestMapping(value = "/save-kontrak-kinerja/", method = RequestMethod.POST, produces = MediaType.APPLICATION_JSON_VALUE, consumes = MediaType.APPLICATION_JSON_VALUE)
|
||||
public ResponseEntity<Map<String,Object>> addVO(@Valid @RequestBody KontrakKinerjaVO vo, HttpServletRequest request) {
|
||||
|
||||
try {
|
||||
Map<String,Object> result=kontrakKinerjaService.addKontrakKinerja(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 Kontrak Kinerja", 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 Kontrak Kinerja", jse.getMessage());
|
||||
addHeaderMessage(Constants.MessageInfo.ERROR_MESSAGE,
|
||||
jse.getMessage());
|
||||
return RestUtil.getJsonHttpStatus(HttpStatus.CONFLICT,
|
||||
mapHeaderMessage);
|
||||
}
|
||||
}
|
||||
|
||||
@RequestMapping(value = "/update-kontrak-kinerja/", method = RequestMethod.POST, produces = MediaType.APPLICATION_JSON_VALUE, consumes = MediaType.APPLICATION_JSON_VALUE)
|
||||
public ResponseEntity<Map<String,Object>> updateVO(@Valid @RequestBody KontrakKinerjaVO vo, HttpServletRequest request) {
|
||||
|
||||
try {
|
||||
Map<String,Object> result=kontrakKinerjaService.updateKontrakKinerja(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 Kontrak Kinerja", 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 Kontrak Kinerja", jse.getMessage());
|
||||
addHeaderMessage(Constants.MessageInfo.ERROR_MESSAGE,
|
||||
jse.getMessage());
|
||||
return RestUtil.getJsonHttpStatus(HttpStatus.CONFLICT,
|
||||
mapHeaderMessage);
|
||||
}
|
||||
}
|
||||
|
||||
@RequestMapping(value = "/find-all-kontrak-kinerja/", method = RequestMethod.GET, produces = MediaType.APPLICATION_JSON_VALUE)
|
||||
public ResponseEntity<Map<String,Object>> getAllVO(HttpServletRequest request) {
|
||||
|
||||
try {
|
||||
Map<String,Object> result=kontrakKinerjaService.findAllKontrakKinerja();
|
||||
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 Kontrak Kinerja", 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 Kontrak Kinerja", jse.getMessage());
|
||||
addHeaderMessage(Constants.MessageInfo.ERROR_MESSAGE,
|
||||
jse.getMessage());
|
||||
return RestUtil.getJsonHttpStatus(HttpStatus.CONFLICT,
|
||||
mapHeaderMessage);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public ResponseEntity<Collection<KontrakKinerjaVO>> getAllVOWithQueryString(HttpServletRequest request,
|
||||
Integer page, Integer limit, String sort, String dir) {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public ResponseEntity<KontrakKinerjaVO> getVO(Integer id) {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public ResponseEntity<String> addVO(KontrakKinerjaVO vo) {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public ResponseEntity<String> editVO(KontrakKinerjaVO vo) {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public ResponseEntity<String> deleteVO(Integer id) {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public ResponseEntity<List<KontrakKinerjaVO>> getAllVO() {
|
||||
return null;
|
||||
}
|
||||
|
||||
@RequestMapping(value="/find-all/", method= RequestMethod.GET,produces = MediaType.APPLICATION_JSON_VALUE)
|
||||
public ResponseEntity<Collection<KontrakKinerja>> findAll(
|
||||
@RequestMapping(value = "/find-all/", method = GET, produces = APPLICATION_JSON_VALUE)
|
||||
public ResponseEntity<Collection<PasienVO>> 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 = "id") String sort,
|
||||
@RequestParam(value = "dir", required = false, defaultValue = "asc") String dir,
|
||||
@Spec(path = "id", params = "id", spec = Equal.class) Specification<KontrakKinerja> kontrakKinerja,
|
||||
@Spec(path = "unitKerjaId", params = "unitKerjaId", spec = Equal.class) Specification<KontrakKinerja> ruangan,
|
||||
@Spec(path = "tahun", params = "periode", spec = Equal.class) Specification<KontrakKinerja> tahun)
|
||||
{
|
||||
Specification<KontrakKinerja> spec = Specifications.where(kontrakKinerja).and(ruangan).and(tahun);
|
||||
Map<String, Object> result = new HashMap<String, Object>();
|
||||
result = kontrakKinerjaService.findAll(page, take, sort,dir, spec);
|
||||
return constructListPageResult(result);
|
||||
@Spec(path = "tahun", params = "periode", spec = Equal.class) Specification<KontrakKinerja> tahun) {
|
||||
Specification<KontrakKinerja> spec = Specifications.where(kontrakKinerja).and(ruangan).and(tahun);
|
||||
Map<String, Object> result = kontrakKinerjaService.findAll(page, take, sort, dir, spec);
|
||||
return constructListPageResult(result);
|
||||
}
|
||||
|
||||
@RequestMapping(value="/save/", method= RequestMethod.POST,produces = MediaType.APPLICATION_JSON_VALUE)
|
||||
public ResponseEntity<Map<String,Object>> save(@Valid @RequestBody List<KontrakKinerjaVO> vos,HttpServletRequest request){
|
||||
try{
|
||||
@RequestMapping(value = "/save/", method = POST, produces = APPLICATION_JSON_VALUE)
|
||||
public ResponseEntity<Map<String, Object>> save(@Valid @RequestBody List<KontrakKinerjaVO> vos,
|
||||
HttpServletRequest request) {
|
||||
try {
|
||||
Map<String, Object> result = kontrakKinerjaService.save(vos);
|
||||
if(null!= result)
|
||||
mapHeaderMessage.put(WebConstants.HttpHeaderInfo.LABEL_SUCCESS, getMessage(MessageResource.LABEL_SUCCESS,request));
|
||||
return RestUtil.getJsonResponse(result, HttpStatus.CREATED, mapHeaderMessage);
|
||||
|
||||
if (null != result)
|
||||
mapHeaderMessage.put(LABEL_SUCCESS, getMessage(MessageResource.LABEL_SUCCESS, request));
|
||||
return getJsonResponse(result, CREATED, mapHeaderMessage);
|
||||
} catch (ServiceVOException e) {
|
||||
LOGGER.error("Got exception {} when add/update Kontrak Kinerja", e.getMessage());
|
||||
addHeaderMessage(Constants.MessageInfo.ERROR_MESSAGE,
|
||||
e.getMessage());
|
||||
return RestUtil.getJsonHttpStatus(HttpStatus.INTERNAL_SERVER_ERROR,
|
||||
mapHeaderMessage);
|
||||
|
||||
LOGGER.error("Got ServiceVOException {} when save", e.getMessage());
|
||||
addHeaderMessage(ERROR_MESSAGE, e.getMessage());
|
||||
return getJsonHttpStatus(INTERNAL_SERVER_ERROR, mapHeaderMessage);
|
||||
} catch (JpaSystemException jse) {
|
||||
LOGGER.error("Got exception {} when add/update Kontrak Kinerja", jse.getMessage());
|
||||
addHeaderMessage(Constants.MessageInfo.ERROR_MESSAGE,
|
||||
jse.getMessage());
|
||||
return RestUtil.getJsonHttpStatus(HttpStatus.CONFLICT,
|
||||
mapHeaderMessage);
|
||||
LOGGER.error("Got JpaSystemException {} when save", jse.getMessage());
|
||||
addHeaderMessage(ERROR_MESSAGE, jse.getMessage());
|
||||
return getJsonHttpStatus(CONFLICT, mapHeaderMessage);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@ -1,128 +0,0 @@
|
||||
package com.jasamedika.medifirst2000.controller;
|
||||
|
||||
|
||||
import java.net.URISyntaxException;
|
||||
import java.util.Collection;
|
||||
import java.util.Map;
|
||||
|
||||
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.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.RequestParam;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
|
||||
import com.jasamedika.medifirst2000.controller.base.LocaleController;
|
||||
import com.jasamedika.medifirst2000.entities.KonversiSatuan;
|
||||
import com.jasamedika.medifirst2000.service.KonversiSatuanService;
|
||||
import com.jasamedika.medifirst2000.util.rest.RestUtil;
|
||||
import com.jasamedika.medifirst2000.vo.KonversiSatuanVO;
|
||||
|
||||
@RestController
|
||||
public class KonversiSatuanController extends LocaleController<KonversiSatuanVO> {
|
||||
|
||||
private static final Logger log = LoggerFactory.getLogger(KonversiSatuanController.class);
|
||||
|
||||
@Autowired
|
||||
private KonversiSatuanService konversiSatuanService;
|
||||
|
||||
/**
|
||||
* Creates entity.
|
||||
*
|
||||
* @param konversiSatuan
|
||||
* @return
|
||||
* @throws URISyntaxException
|
||||
*/
|
||||
@RequestMapping(value = "/konversi_satuan", method = RequestMethod.POST,
|
||||
produces = MediaType.APPLICATION_JSON_VALUE,
|
||||
consumes = MediaType.APPLICATION_JSON_VALUE)
|
||||
public ResponseEntity<?> create(@Valid @RequestBody KonversiSatuanVO konversiSatuan) throws URISyntaxException {
|
||||
log.debug("REST request to save KonversiSatuan: {}", konversiSatuan);
|
||||
Map<String, Object> result = konversiSatuanService.save(konversiSatuan);
|
||||
return RestUtil.getJsonResponse(result, HttpStatus.CREATED, mapHeaderMessage);
|
||||
}
|
||||
|
||||
/**
|
||||
* Find one entity.
|
||||
*
|
||||
* @param id
|
||||
* @return
|
||||
*/
|
||||
@RequestMapping(value = "/konversi_satuan/{id}", method = RequestMethod.GET,
|
||||
produces = MediaType.APPLICATION_JSON_VALUE)
|
||||
public ResponseEntity<?> get(@PathVariable String id) {
|
||||
log.debug("REST request to get KonversiSatuan: {}", id);
|
||||
Map<String, Object> result = konversiSatuanService.get(id);
|
||||
if (result.get("data") != null) {
|
||||
return RestUtil.getJsonResponse(result, HttpStatus.OK, mapHeaderMessage);
|
||||
} else {
|
||||
return RestUtil.getJsonHttpStatus(HttpStatus.NOT_FOUND);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* List collection of entities by product.
|
||||
*
|
||||
* @param produkId
|
||||
* @return
|
||||
*/
|
||||
@RequestMapping(value = "/konversi_satuan/filter", method = RequestMethod.GET,
|
||||
produces = MediaType.APPLICATION_JSON_VALUE)
|
||||
public ResponseEntity<?> getByProduk(@RequestParam("produkId") Integer produkId) {
|
||||
log.debug("REST request to get KonversiSatuan by produk: ", produkId);
|
||||
Map<String, Object> result = konversiSatuanService.listByProduk(produkId);
|
||||
return RestUtil.getJsonResponse(result, HttpStatus.OK, mapHeaderMessage);
|
||||
}
|
||||
|
||||
/**
|
||||
* List collection of entities.
|
||||
*
|
||||
* @param pageable
|
||||
* @return
|
||||
* @throws URISyntaxException
|
||||
*/
|
||||
@SuppressWarnings("unchecked")
|
||||
@RequestMapping(value = "/konversi_satuan/list", method = RequestMethod.GET, produces = MediaType.APPLICATION_JSON_VALUE)
|
||||
public ResponseEntity<Collection<KonversiSatuan>> list(@RequestParam(value = "page", required = false, defaultValue = "0") Integer page,
|
||||
@RequestParam(value = "take", required = false, defaultValue = "100") Integer limit,
|
||||
@RequestParam(value = "sort", required = false, defaultValue= "produk.namaProduk") String sort,
|
||||
@RequestParam(value = "dir", required = false, defaultValue = "asc") String dir) throws URISyntaxException {
|
||||
log.debug("REST request to get list of KonversiSatuan");
|
||||
Map<String, Object> result = konversiSatuanService.list(page, limit, sort, dir);
|
||||
return constructListPageResult(result);
|
||||
}
|
||||
|
||||
/**
|
||||
* Updates entity.
|
||||
*
|
||||
* @param konversiSatuan
|
||||
* @return
|
||||
* @throws URISyntaxException
|
||||
*/
|
||||
@RequestMapping(value = "/konversi_satuan", method = RequestMethod.PUT,
|
||||
produces = MediaType.APPLICATION_JSON_VALUE,
|
||||
consumes = MediaType.APPLICATION_JSON_VALUE)
|
||||
public ResponseEntity<?> update(@Valid @RequestBody KonversiSatuanVO konversiSatuan)
|
||||
throws URISyntaxException {
|
||||
log.debug("REST request to update KonversiSatuan: {}", konversiSatuan);
|
||||
if (konversiSatuan.getNoRec().isEmpty()) {
|
||||
return create(konversiSatuan);
|
||||
}
|
||||
|
||||
Map<String, Object> result = konversiSatuanService.update(konversiSatuan);
|
||||
if (result.get("noRec") != null) {
|
||||
return ResponseEntity.ok().body(result);
|
||||
} else {
|
||||
return RestUtil.getJsonHttpStatus(HttpStatus.NOT_FOUND);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
@ -1,34 +1,33 @@
|
||||
package com.jasamedika.medifirst2000.controller;
|
||||
|
||||
import java.util.Collection;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
import javax.validation.Valid;
|
||||
|
||||
import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
|
||||
import com.jasamedika.medifirst2000.constants.MessageResource;
|
||||
import com.jasamedika.medifirst2000.controller.base.LocaleController;
|
||||
import com.jasamedika.medifirst2000.entities.Koping;
|
||||
import com.jasamedika.medifirst2000.exception.ServiceVOException;
|
||||
import com.jasamedika.medifirst2000.service.KopingService;
|
||||
import com.jasamedika.medifirst2000.vo.KopingVO;
|
||||
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.fasterxml.jackson.annotation.JsonIgnoreProperties;
|
||||
import com.jasamedika.medifirst2000.constants.Constants;
|
||||
import com.jasamedika.medifirst2000.constants.MessageResource;
|
||||
import com.jasamedika.medifirst2000.controller.base.IBaseRestController;
|
||||
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.KopingService;
|
||||
import com.jasamedika.medifirst2000.util.rest.RestUtil;
|
||||
import com.jasamedika.medifirst2000.vo.KopingVO;
|
||||
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_ERROR;
|
||||
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;
|
||||
|
||||
/**
|
||||
* Controller class for KopingController
|
||||
@ -37,70 +36,35 @@ import com.jasamedika.medifirst2000.vo.KopingVO;
|
||||
*/
|
||||
@RestController
|
||||
@RequestMapping("/koping")
|
||||
@JsonIgnoreProperties(ignoreUnknown = true)
|
||||
public class KopingController extends LocaleController<KopingVO> implements
|
||||
IBaseRestController<KopingVO> {
|
||||
|
||||
private static final Logger LOGGER = LoggerFactory.getLogger(KopingController.class);
|
||||
@JsonIgnoreProperties(ignoreUnknown = true)
|
||||
public class KopingController extends LocaleController<KopingVO> {
|
||||
|
||||
private static final Logger LOGGER = getLogger(KopingController.class);
|
||||
|
||||
@Autowired
|
||||
private KopingService kopingService;
|
||||
private KopingService<Koping> kopingService;
|
||||
|
||||
@RequestMapping(value = "/save-koping", method = RequestMethod.POST, produces = MediaType.APPLICATION_JSON_VALUE, consumes = MediaType.APPLICATION_JSON_VALUE)
|
||||
public ResponseEntity<Map<String,Object>> save(@Valid @RequestBody KopingVO vo,HttpServletRequest request) {
|
||||
@RequestMapping(value = "/save-koping", method = POST, produces = APPLICATION_JSON_VALUE, consumes = APPLICATION_JSON_VALUE)
|
||||
public ResponseEntity<Map<String, Object>> save(@Valid @RequestBody KopingVO vo, HttpServletRequest request) {
|
||||
try {
|
||||
Map<String,Object> result = kopingService.addKoping(vo);
|
||||
Map<String, Object> result = kopingService.addKoping(vo);
|
||||
|
||||
if (null != result){
|
||||
mapHeaderMessage.put(WebConstants.HttpHeaderInfo.LABEL_SUCCESS,getMessage(MessageResource.LABEL_SUCCESS,request ));
|
||||
}else{
|
||||
mapHeaderMessage.put(WebConstants.HttpHeaderInfo.LABEL_ERROR,getMessage(MessageResource.LABEL_ERROR,request ));
|
||||
if (null != result) {
|
||||
mapHeaderMessage.put(LABEL_SUCCESS, getMessage(MessageResource.LABEL_SUCCESS, request));
|
||||
} else {
|
||||
mapHeaderMessage.put(LABEL_ERROR, getMessage(MessageResource.LABEL_ERROR, request));
|
||||
}
|
||||
SaveLog("Koping", "Pemeriksaan",request);
|
||||
return RestUtil.getJsonResponse(result, HttpStatus.CREATED,mapHeaderMessage);
|
||||
|
||||
SaveLog("Koping", "Pemeriksaan", request);
|
||||
return getJsonResponse(result, CREATED, mapHeaderMessage);
|
||||
} catch (ServiceVOException e) {
|
||||
LOGGER.error("Got exception {} when add Pasien", e.getMessage());
|
||||
addHeaderMessage(Constants.MessageInfo.ERROR_MESSAGE, e.getMessage());
|
||||
return RestUtil.getJsonHttpStatus(HttpStatus.INTERNAL_SERVER_ERROR, mapHeaderMessage);
|
||||
LOGGER.error("Got ServiceVOException {} when addKoping", e.getMessage());
|
||||
addHeaderMessage(ERROR_MESSAGE, e.getMessage());
|
||||
return getJsonHttpStatus(INTERNAL_SERVER_ERROR, mapHeaderMessage);
|
||||
} catch (JpaSystemException jse) {
|
||||
LOGGER.error("Got exception {} when add Pasien", jse.getMessage());
|
||||
addHeaderMessage(Constants.MessageInfo.ERROR_MESSAGE, jse.getMessage());
|
||||
return RestUtil.getJsonHttpStatus(HttpStatus.CONFLICT, mapHeaderMessage);
|
||||
LOGGER.error("Got JpaSystemException {} when addKoping", jse.getMessage());
|
||||
addHeaderMessage(ERROR_MESSAGE, jse.getMessage());
|
||||
return getJsonHttpStatus(CONFLICT, mapHeaderMessage);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public ResponseEntity<Collection<KopingVO>> getAllVOWithQueryString(HttpServletRequest request,
|
||||
Integer page, Integer limit, String sort, String dir) {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public ResponseEntity<KopingVO> getVO(Integer id) {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public ResponseEntity<String> addVO(KopingVO vo) {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public ResponseEntity<String> editVO(KopingVO vo) {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public ResponseEntity<String> deleteVO(Integer id) {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public ResponseEntity<List<KopingVO>> getAllVO() {
|
||||
return null;
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
@ -1,222 +1,128 @@
|
||||
package com.jasamedika.medifirst2000.controller;
|
||||
|
||||
import java.util.Map;
|
||||
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
import javax.validation.Valid;
|
||||
|
||||
import com.jasamedika.medifirst2000.constants.MessageResource;
|
||||
import com.jasamedika.medifirst2000.controller.base.LocaleController;
|
||||
import com.jasamedika.medifirst2000.exception.ServiceVOException;
|
||||
import com.jasamedika.medifirst2000.service.LapPembedahanDanInstruksiPascaBedahService;
|
||||
import com.jasamedika.medifirst2000.vo.AsuhanKeperawatanPeriOperasiHeaderVO;
|
||||
import com.jasamedika.medifirst2000.vo.AsuhanKeperawatanPeriOperatifVO;
|
||||
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.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.LapPembedahanDanInstruksiPascaBedahService;
|
||||
import com.jasamedika.medifirst2000.util.rest.RestUtil;
|
||||
import com.jasamedika.medifirst2000.vo.AsuhanKeperawatanPeriOperasiHeaderVO;
|
||||
import com.jasamedika.medifirst2000.vo.AsuhanKeperawatanPeriOperatifVO;
|
||||
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
|
||||
@RequestMapping("/laporan-pembedahan-instruksi-pasca-bedah")
|
||||
public class LapPembedahanDanInstruksiPascaBedahController extends LocaleController<AsuhanKeperawatanPeriOperatifVO>{
|
||||
private static final Logger LOGGER = LoggerFactory.getLogger(LapPembedahanDanInstruksiPascaBedahController.class);
|
||||
|
||||
public class LapPembedahanDanInstruksiPascaBedahController extends LocaleController<AsuhanKeperawatanPeriOperatifVO> {
|
||||
|
||||
private static final Logger LOGGER = getLogger(LapPembedahanDanInstruksiPascaBedahController.class);
|
||||
|
||||
@Autowired
|
||||
private LapPembedahanDanInstruksiPascaBedahService lapPembedahanDanInstruksiPascaBedahService;
|
||||
|
||||
/*
|
||||
@RequestMapping(
|
||||
value = "/get-lap-pemedahan",
|
||||
method = RequestMethod.GET,
|
||||
produces = MediaType.APPLICATION_JSON_VALUE)
|
||||
public ResponseEntity<Map<String, Object>> getLoadLapPembedahan(HttpServletRequest request) {
|
||||
|
||||
try {
|
||||
Map<String, Object> result = this.lapPembedahanDanInstruksiPascaBedahService.getLapPembedahan();
|
||||
|
||||
if (null != result) {
|
||||
mapHeaderMessage.put(WebConstants.HttpHeaderInfo.LABEL_SUCCESS,
|
||||
getMessage(MessageResource.LABEL_SUCCESS, request));
|
||||
return RestUtil.getJsonResponse(result, HttpStatus.OK, mapHeaderMessage);
|
||||
} else {
|
||||
return RestUtil.getJsonResponse(result, HttpStatus.NOT_FOUND, mapHeaderMessage);
|
||||
}
|
||||
|
||||
} catch (ServiceVOException e) {
|
||||
LOGGER.error("Got exception {} when getLoadLapPembedahan", e.getMessage());
|
||||
addHeaderMessage(Constants.MessageInfo.ERROR_MESSAGE, e.getMessage());
|
||||
return RestUtil.getJsonHttptatus(HttpStatus.INTERNAL_SERVER_ERROR, mapHeaderMessage);
|
||||
|
||||
} catch (JpaSystemException jse) {
|
||||
LOGGER.error("Got exception {} when getLoadLapPembedahan", jse.getMessage());
|
||||
addHeaderMessage(Constants.MessageInfo.ERROR_MESSAGE, jse.getMessage());
|
||||
return RestUtil.getJsonHttptatus(HttpStatus.CONFLICT, mapHeaderMessage);
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@RequestMapping(
|
||||
value = "/get-instruksi-pasca-bedah",
|
||||
method = RequestMethod.GET,
|
||||
produces = MediaType.APPLICATION_JSON_VALUE)
|
||||
public ResponseEntity<Map<String, Object>> getLoadLapIntruksiPascaBedah(HttpServletRequest request) {
|
||||
|
||||
try {
|
||||
Map<String, Object> result = this.lapPembedahanDanInstruksiPascaBedahService.getInstruksiPascaBedah();
|
||||
|
||||
if (null != result) {
|
||||
mapHeaderMessage.put(WebConstants.HttpHeaderInfo.LABEL_SUCCESS,
|
||||
getMessage(MessageResource.LABEL_SUCCESS, request));
|
||||
return RestUtil.getJsonResponse(result, HttpStatus.OK, mapHeaderMessage);
|
||||
} else {
|
||||
return RestUtil.getJsonResponse(result, HttpStatus.NOT_FOUND, mapHeaderMessage);
|
||||
}
|
||||
|
||||
} catch (ServiceVOException e) {
|
||||
LOGGER.error("Got exception {} when getLoadLapIntruksiPascaBedah", e.getMessage());
|
||||
addHeaderMessage(Constants.MessageInfo.ERROR_MESSAGE, e.getMessage());
|
||||
return RestUtil.getJsonHttptatus(HttpStatus.INTERNAL_SERVER_ERROR, mapHeaderMessage);
|
||||
|
||||
} catch (JpaSystemException jse) {
|
||||
LOGGER.error("Got exception {} when getLoadLapIntruksiPascaBedah", jse.getMessage());
|
||||
addHeaderMessage(Constants.MessageInfo.ERROR_MESSAGE, jse.getMessage());
|
||||
return RestUtil.getJsonHttptatus(HttpStatus.CONFLICT, mapHeaderMessage);
|
||||
|
||||
}
|
||||
}
|
||||
*/
|
||||
|
||||
@RequestMapping(
|
||||
value = "/save-pasca-bedah",
|
||||
method = RequestMethod.POST,
|
||||
produces = MediaType.APPLICATION_JSON_VALUE,
|
||||
consumes = MediaType.APPLICATION_JSON_VALUE)
|
||||
@RequestMapping(value = "/save-pasca-bedah", method = POST, produces = APPLICATION_JSON_VALUE, consumes = APPLICATION_JSON_VALUE)
|
||||
public ResponseEntity<Map<String, Object>> savePascaBedah(
|
||||
@Valid @RequestBody AsuhanKeperawatanPeriOperasiHeaderVO vo, HttpServletRequest request) {
|
||||
|
||||
try {
|
||||
Map<String, Object> result = this.lapPembedahanDanInstruksiPascaBedahService.saveLapInstruksiPascaBedahHeader(vo);
|
||||
|
||||
Map<String, Object> result = this.lapPembedahanDanInstruksiPascaBedahService
|
||||
.saveLapInstruksiPascaBedahHeader(vo);
|
||||
if (result != null)
|
||||
mapHeaderMessage.put(WebConstants.HttpHeaderInfo.LABEL_SUCCESS,
|
||||
getMessage(MessageResource.LABEL_SUCCESS, request));
|
||||
return RestUtil.getJsonResponse(result, HttpStatus.CREATED, mapHeaderMessage);
|
||||
mapHeaderMessage.put(LABEL_SUCCESS, getMessage(MessageResource.LABEL_SUCCESS, request));
|
||||
return getJsonResponse(result, CREATED, mapHeaderMessage);
|
||||
} catch (ServiceVOException e) {
|
||||
|
||||
LOGGER.error("Got exception {} when savePascaBedah", e.getMessage());
|
||||
addHeaderMessage(Constants.MessageInfo.ERROR_MESSAGE, e.getMessage());
|
||||
return RestUtil.getJsonHttpStatus(HttpStatus.INTERNAL_SERVER_ERROR, mapHeaderMessage);
|
||||
|
||||
LOGGER.error("Got ServiceVOException {} when saveLapInstruksiPascaBedahHeader", e.getMessage());
|
||||
addHeaderMessage(ERROR_MESSAGE, e.getMessage());
|
||||
return getJsonHttpStatus(INTERNAL_SERVER_ERROR, mapHeaderMessage);
|
||||
} catch (JpaSystemException jse) {
|
||||
|
||||
LOGGER.error("Got exception {} when savePascaBedah", jse.getMessage());
|
||||
addHeaderMessage(Constants.MessageInfo.ERROR_MESSAGE, jse.getMessage());
|
||||
return RestUtil.getJsonHttpStatus(HttpStatus.CONFLICT, mapHeaderMessage);
|
||||
}
|
||||
}
|
||||
|
||||
@RequestMapping(
|
||||
value = "/get-list-by-notrans",
|
||||
method = RequestMethod.GET,
|
||||
produces = MediaType.APPLICATION_JSON_VALUE)
|
||||
public ResponseEntity<Map<String, Object>> getLoadDataByNoTrans(
|
||||
@RequestParam(value = "notrans", required = true) String notrans, HttpServletRequest request) {
|
||||
|
||||
try {
|
||||
Map<String, Object> result = this.lapPembedahanDanInstruksiPascaBedahService.getListAsuhanByNoTrans(notrans);
|
||||
|
||||
if (null != result) {
|
||||
mapHeaderMessage.put(WebConstants.HttpHeaderInfo.LABEL_SUCCESS,
|
||||
getMessage(MessageResource.LABEL_SUCCESS, request));
|
||||
return RestUtil.getJsonResponse(result, HttpStatus.OK, mapHeaderMessage);
|
||||
} else {
|
||||
return RestUtil.getJsonResponse(result, HttpStatus.NOT_FOUND, mapHeaderMessage);
|
||||
}
|
||||
|
||||
} catch (ServiceVOException e) {
|
||||
LOGGER.error("Got exception {} when getLoadDataByNoTrans", 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 getLoadDataByNoTrans", jse.getMessage());
|
||||
addHeaderMessage(Constants.MessageInfo.ERROR_MESSAGE, jse.getMessage());
|
||||
return RestUtil.getJsonHttpStatus(HttpStatus.CONFLICT, mapHeaderMessage);
|
||||
|
||||
LOGGER.error("Got JpaSystemException {} when saveLapInstruksiPascaBedahHeader", jse.getMessage());
|
||||
addHeaderMessage(ERROR_MESSAGE, jse.getMessage());
|
||||
return getJsonHttpStatus(CONFLICT, mapHeaderMessage);
|
||||
}
|
||||
}
|
||||
|
||||
@RequestMapping(
|
||||
value = "get-pasien-operasi",
|
||||
method = RequestMethod.GET,
|
||||
produces = MediaType.APPLICATION_JSON_VALUE)
|
||||
public ResponseEntity<Map<String, Object>> getPasienDaftarOperasi(
|
||||
@RequestParam(value = "noRec", required = true) String noRec, HttpServletRequest request) {
|
||||
|
||||
@RequestMapping(value = "/get-list-by-notrans", method = GET, produces = APPLICATION_JSON_VALUE)
|
||||
public ResponseEntity<Map<String, Object>> getLoadDataByNoTrans(@RequestParam(value = "notrans") String notrans,
|
||||
HttpServletRequest request) {
|
||||
try {
|
||||
Map<String, Object> result = this.lapPembedahanDanInstruksiPascaBedahService
|
||||
.getListAsuhanByNoTrans(notrans);
|
||||
if (null != result) {
|
||||
mapHeaderMessage.put(LABEL_SUCCESS, getMessage(MessageResource.LABEL_SUCCESS, request));
|
||||
return getJsonResponse(result, OK, mapHeaderMessage);
|
||||
} else {
|
||||
return getJsonResponse(null, NOT_FOUND, mapHeaderMessage);
|
||||
}
|
||||
} catch (ServiceVOException e) {
|
||||
LOGGER.error("Got ServiceVOException {} when getListAsuhanByNoTrans", e.getMessage());
|
||||
addHeaderMessage(ERROR_MESSAGE, e.getMessage());
|
||||
return getJsonHttpStatus(INTERNAL_SERVER_ERROR, mapHeaderMessage);
|
||||
|
||||
} catch (JpaSystemException jse) {
|
||||
LOGGER.error("Got JpaSystemException {} when getListAsuhanByNoTrans", jse.getMessage());
|
||||
addHeaderMessage(ERROR_MESSAGE, jse.getMessage());
|
||||
return getJsonHttpStatus(CONFLICT, mapHeaderMessage);
|
||||
}
|
||||
}
|
||||
|
||||
@RequestMapping(value = "get-pasien-operasi", method = GET, produces = APPLICATION_JSON_VALUE)
|
||||
public ResponseEntity<Map<String, Object>> getPasienDaftarOperasi(@RequestParam(value = "noRec") String noRec,
|
||||
HttpServletRequest request) {
|
||||
try {
|
||||
Map<String, Object> result = this.lapPembedahanDanInstruksiPascaBedahService.getPasienDaftarOperasi(noRec);
|
||||
|
||||
if (null != result) {
|
||||
mapHeaderMessage.put(WebConstants.HttpHeaderInfo.LABEL_SUCCESS,
|
||||
getMessage(MessageResource.LABEL_SUCCESS, request));
|
||||
return RestUtil.getJsonResponse(result, HttpStatus.OK, mapHeaderMessage);
|
||||
mapHeaderMessage.put(LABEL_SUCCESS, getMessage(MessageResource.LABEL_SUCCESS, request));
|
||||
return getJsonResponse(result, OK, mapHeaderMessage);
|
||||
} else {
|
||||
return RestUtil.getJsonResponse(result, HttpStatus.NOT_FOUND, mapHeaderMessage);
|
||||
return getJsonResponse(null, NOT_FOUND, mapHeaderMessage);
|
||||
}
|
||||
|
||||
} catch (ServiceVOException e) {
|
||||
LOGGER.error("Got exception {} when getPasienDaftarOperasi", e.getMessage());
|
||||
addHeaderMessage(Constants.MessageInfo.ERROR_MESSAGE, e.getMessage());
|
||||
return RestUtil.getJsonHttpStatus(HttpStatus.INTERNAL_SERVER_ERROR, mapHeaderMessage);
|
||||
|
||||
LOGGER.error("Got ServiceVOException {} when getPasienDaftarOperasi", e.getMessage());
|
||||
addHeaderMessage(ERROR_MESSAGE, e.getMessage());
|
||||
return getJsonHttpStatus(INTERNAL_SERVER_ERROR, mapHeaderMessage);
|
||||
} catch (JpaSystemException jse) {
|
||||
LOGGER.error("Got exception {} when getPasienDaftarOperasi", jse.getMessage());
|
||||
addHeaderMessage(Constants.MessageInfo.ERROR_MESSAGE, jse.getMessage());
|
||||
return RestUtil.getJsonHttpStatus(HttpStatus.CONFLICT, mapHeaderMessage);
|
||||
|
||||
LOGGER.error("Got JpaSystemException {} when getPasienDaftarOperasi", jse.getMessage());
|
||||
addHeaderMessage(ERROR_MESSAGE, jse.getMessage());
|
||||
return getJsonHttpStatus(CONFLICT, mapHeaderMessage);
|
||||
}
|
||||
}
|
||||
|
||||
@RequestMapping(
|
||||
value = "get-macam-infus",
|
||||
method = RequestMethod.GET,
|
||||
produces = MediaType.APPLICATION_JSON_VALUE)
|
||||
|
||||
@RequestMapping(value = "get-macam-infus", method = GET, produces = APPLICATION_JSON_VALUE)
|
||||
public ResponseEntity<Map<String, Object>> getMacamInfus(HttpServletRequest request) {
|
||||
try {
|
||||
Map<String, Object> result = this.lapPembedahanDanInstruksiPascaBedahService.getMacamInfus();
|
||||
|
||||
if (null != result) {
|
||||
mapHeaderMessage.put(WebConstants.HttpHeaderInfo.LABEL_SUCCESS,
|
||||
getMessage(MessageResource.LABEL_SUCCESS, request));
|
||||
return RestUtil.getJsonResponse(result, HttpStatus.OK, mapHeaderMessage);
|
||||
mapHeaderMessage.put(LABEL_SUCCESS, getMessage(MessageResource.LABEL_SUCCESS, request));
|
||||
return getJsonResponse(result, OK, mapHeaderMessage);
|
||||
} else {
|
||||
return RestUtil.getJsonResponse(result, HttpStatus.NOT_FOUND, mapHeaderMessage);
|
||||
return getJsonResponse(null, NOT_FOUND, mapHeaderMessage);
|
||||
}
|
||||
|
||||
} catch (ServiceVOException e) {
|
||||
LOGGER.error("Got exception {} when getMacamInfus", e.getMessage());
|
||||
addHeaderMessage(Constants.MessageInfo.ERROR_MESSAGE, e.getMessage());
|
||||
return RestUtil.getJsonHttpStatus(HttpStatus.INTERNAL_SERVER_ERROR, mapHeaderMessage);
|
||||
|
||||
LOGGER.error("Got ServiceVOException {} when getMacamInfus", e.getMessage());
|
||||
addHeaderMessage(ERROR_MESSAGE, e.getMessage());
|
||||
return getJsonHttpStatus(INTERNAL_SERVER_ERROR, mapHeaderMessage);
|
||||
} catch (JpaSystemException jse) {
|
||||
LOGGER.error("Got exception {} when getMacamInfus", jse.getMessage());
|
||||
addHeaderMessage(Constants.MessageInfo.ERROR_MESSAGE, jse.getMessage());
|
||||
return RestUtil.getJsonHttpStatus(HttpStatus.CONFLICT, mapHeaderMessage);
|
||||
|
||||
LOGGER.error("Got JpaSystemException {} when getMacamInfus", jse.getMessage());
|
||||
addHeaderMessage(ERROR_MESSAGE, jse.getMessage());
|
||||
return getJsonHttpStatus(CONFLICT, mapHeaderMessage);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
@ -1,114 +1,93 @@
|
||||
package com.jasamedika.medifirst2000.controller;
|
||||
|
||||
import java.util.Map;
|
||||
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
import javax.validation.Valid;
|
||||
|
||||
import com.jasamedika.medifirst2000.constants.MessageResource;
|
||||
import com.jasamedika.medifirst2000.controller.base.LocaleController;
|
||||
import com.jasamedika.medifirst2000.entities.LaporanUjiHasil;
|
||||
import com.jasamedika.medifirst2000.exception.ServiceVOException;
|
||||
import com.jasamedika.medifirst2000.service.LaporanUjiHasilService;
|
||||
import com.jasamedika.medifirst2000.vo.LaporanUjiHasilVO;
|
||||
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.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.dao.LaporanUjiHasilDao;
|
||||
import com.jasamedika.medifirst2000.exception.ServiceVOException;
|
||||
import com.jasamedika.medifirst2000.service.LaporanUjiHasilService;
|
||||
import com.jasamedika.medifirst2000.util.rest.RestUtil;
|
||||
import com.jasamedika.medifirst2000.vo.LaporanUjiHasilVO;
|
||||
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
|
||||
@RequestMapping("/laporan-uji-hasil")
|
||||
public class LaporanUjiHasilController extends LocaleController<LaporanUjiHasilVO> {
|
||||
|
||||
|
||||
private static final Logger LOGGER = getLogger(LaporanUjiHasilController.class);
|
||||
|
||||
@Autowired
|
||||
private LaporanUjiHasilService laporanUjiHasilService;
|
||||
|
||||
@Autowired
|
||||
private LaporanUjiHasilDao laporanUjiHasilDao;
|
||||
|
||||
private static final Logger LOGGER = LoggerFactory
|
||||
.getLogger(LaporanUjiHasilController.class);
|
||||
|
||||
@RequestMapping(value = "/save-laporan-uji-hasil/", method = RequestMethod.POST, produces = MediaType.APPLICATION_JSON_VALUE, consumes = MediaType.APPLICATION_JSON_VALUE)
|
||||
public ResponseEntity<Map<String,Object>> addVO(@Valid @RequestBody LaporanUjiHasilVO vo,HttpServletRequest request) {
|
||||
|
||||
try{
|
||||
private LaporanUjiHasilService<LaporanUjiHasil> laporanUjiHasilService;
|
||||
|
||||
@RequestMapping(value = "/save-laporan-uji-hasil/", method = POST, produces = APPLICATION_JSON_VALUE, consumes = APPLICATION_JSON_VALUE)
|
||||
public ResponseEntity<Map<String, Object>> addVO(@Valid @RequestBody LaporanUjiHasilVO vo,
|
||||
HttpServletRequest request) {
|
||||
try {
|
||||
Map<String, Object> result = laporanUjiHasilService.addLaporanUjiHasil(vo);
|
||||
if (null != result)
|
||||
mapHeaderMessage.put(WebConstants.HttpHeaderInfo.LABEL_SUCCESS, getMessage(MessageResource.LABEL_SUCCESS,request));
|
||||
return RestUtil.getJsonResponse(result, HttpStatus.CREATED, mapHeaderMessage);
|
||||
mapHeaderMessage.put(LABEL_SUCCESS, getMessage(MessageResource.LABEL_SUCCESS, request));
|
||||
return getJsonResponse(result, CREATED, mapHeaderMessage);
|
||||
} catch (ServiceVOException e) {
|
||||
LOGGER.error("Got exception {} when add laporan uji hasil", e.getMessage());
|
||||
addHeaderMessage(Constants.MessageInfo.ERROR_MESSAGE,
|
||||
e.getMessage());
|
||||
return RestUtil.getJsonHttpStatus(HttpStatus.INTERNAL_SERVER_ERROR,
|
||||
mapHeaderMessage);
|
||||
|
||||
LOGGER.error("Got ServiceVOException {} when addLaporanUjiHasil", e.getMessage());
|
||||
addHeaderMessage(ERROR_MESSAGE, e.getMessage());
|
||||
return getJsonHttpStatus(INTERNAL_SERVER_ERROR, mapHeaderMessage);
|
||||
} catch (JpaSystemException jse) {
|
||||
LOGGER.error("Got exception {} when add laporan uji hasil", jse.getMessage());
|
||||
addHeaderMessage(Constants.MessageInfo.ERROR_MESSAGE,
|
||||
jse.getMessage());
|
||||
return RestUtil.getJsonHttpStatus(HttpStatus.CONFLICT,
|
||||
mapHeaderMessage);
|
||||
LOGGER.error("Got JpaSystemException {} when addLaporanUjiHasil", jse.getMessage());
|
||||
addHeaderMessage(ERROR_MESSAGE, jse.getMessage());
|
||||
return getJsonHttpStatus(CONFLICT, mapHeaderMessage);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
@RequestMapping(value = "/list-laporan-uji-hasil")
|
||||
public Map<String,Object> lisLimbahB3Masuk(
|
||||
public Map<String, Object> lisLimbahB3Masuk(
|
||||
@RequestParam(value = "page", required = false, defaultValue = "0") Integer page,
|
||||
@RequestParam(value = "take", required = false, defaultValue = "100") Integer limit,
|
||||
@RequestParam(value = "sort", required = false, defaultValue = "noRec") String sort,
|
||||
@RequestParam(value = "dir", required = false, defaultValue = "asc") String dir,
|
||||
@RequestParam(value = "dateStart", required = false) String dateStart,
|
||||
@RequestParam(value = "dateEnd", required = false) String dateEnd) {
|
||||
|
||||
Map<String, Object> resultPageMap = laporanUjiHasilService.findLaporanUjiHasilByPeriode(page, limit, sort, dir, dateStart, dateEnd);
|
||||
|
||||
return resultPageMap;
|
||||
return laporanUjiHasilService.findLaporanUjiHasilByPeriode(page, limit, sort, dir, dateStart, dateEnd);
|
||||
}
|
||||
|
||||
|
||||
@RequestMapping(value = "/laporan-uji-hasil-detail")
|
||||
public Map<String,Object> laporanUjiHasilDetail(
|
||||
@RequestParam(value = "noRec", required = true) String noRec) {
|
||||
|
||||
Map<String, Object> resultPageMap = laporanUjiHasilService.laporanUjiHasilDetail(noRec);
|
||||
|
||||
return resultPageMap;
|
||||
public Map<String, Object> laporanUjiHasilDetail(@RequestParam(value = "noRec") String noRec) {
|
||||
return laporanUjiHasilService.laporanUjiHasilDetail(noRec);
|
||||
}
|
||||
|
||||
@RequestMapping(value = "/get-rekanan", method = RequestMethod.GET)
|
||||
public ResponseEntity<Map<String,Object>> getRekanan(HttpServletRequest request) {
|
||||
|
||||
@RequestMapping(value = "/get-rekanan", method = GET)
|
||||
public ResponseEntity<Map<String, Object>> getRekanan(HttpServletRequest request) {
|
||||
try {
|
||||
Map<String,Object> rekanan = laporanUjiHasilService.getRakanan();
|
||||
mapHeaderMessage.put(WebConstants.HttpHeaderInfo.LABEL_SUCCESS,
|
||||
getMessage(MessageResource.LABEL_SUCCESS, request));
|
||||
return RestUtil.getJsonResponse(rekanan, HttpStatus.OK, mapHeaderMessage);
|
||||
Map<String, Object> rekanan = laporanUjiHasilService.getRakanan();
|
||||
mapHeaderMessage.put(LABEL_SUCCESS, getMessage(MessageResource.LABEL_SUCCESS, request));
|
||||
return getJsonResponse(rekanan, OK, mapHeaderMessage);
|
||||
} catch (ServiceVOException e) {
|
||||
LOGGER.error("Got exception {} when get all dokter", e.getMessage());
|
||||
addHeaderMessage(Constants.MessageInfo.ERROR_MESSAGE, e.getMessage());
|
||||
return RestUtil.getJsonHttpStatus(HttpStatus.INTERNAL_SERVER_ERROR, mapHeaderMessage);
|
||||
LOGGER.error("Got ServiceVOException {} when getRakanan", e.getMessage());
|
||||
addHeaderMessage(ERROR_MESSAGE, e.getMessage());
|
||||
return getJsonHttpStatus(INTERNAL_SERVER_ERROR, mapHeaderMessage);
|
||||
} catch (JpaSystemException jse) {
|
||||
LOGGER.error("Got exception {} when get all dokter", jse.getMessage());
|
||||
addHeaderMessage(Constants.MessageInfo.ERROR_MESSAGE, jse.getMessage());
|
||||
return RestUtil.getJsonHttpStatus(HttpStatus.CONFLICT, mapHeaderMessage);
|
||||
LOGGER.error("Got JpaSystemException {} when getRakanan", jse.getMessage());
|
||||
addHeaderMessage(ERROR_MESSAGE, jse.getMessage());
|
||||
return getJsonHttpStatus(CONFLICT, mapHeaderMessage);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
@ -1,143 +0,0 @@
|
||||
package com.jasamedika.medifirst2000.controller;
|
||||
|
||||
import java.util.Collection;
|
||||
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.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.IBaseRestController;
|
||||
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.LembarKonsultasiService;
|
||||
import com.jasamedika.medifirst2000.util.rest.RestUtil;
|
||||
import com.jasamedika.medifirst2000.vo.LembarKonsultasiVO;
|
||||
|
||||
@RestController
|
||||
@RequestMapping("/lembarKonsultasi")
|
||||
public class LembarKonsultasiController extends LocaleController<LembarKonsultasiVO> implements
|
||||
IBaseRestController<LembarKonsultasiVO>{
|
||||
|
||||
@Autowired
|
||||
private LembarKonsultasiService lembarKonsultasiService;
|
||||
|
||||
private static final Logger LOGGER = LoggerFactory
|
||||
.getLogger(LembarKonsultasiController.class);
|
||||
|
||||
@Override
|
||||
public ResponseEntity<LembarKonsultasiVO> getVO(Integer id) {
|
||||
return null;
|
||||
}
|
||||
|
||||
@RequestMapping(value = "/save-lembar-konsultasi", method = RequestMethod.POST, produces = MediaType.APPLICATION_JSON_VALUE, consumes = MediaType.APPLICATION_JSON_VALUE)
|
||||
public ResponseEntity<Map<String,Object>> addVO(@Valid @RequestBody LembarKonsultasiVO vo, HttpServletRequest request) {
|
||||
|
||||
try {
|
||||
Map<String,Object> result=lembarKonsultasiService.saveLembarKonsultasi(vo);
|
||||
|
||||
if (null != result){
|
||||
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.CREATED,mapHeaderMessage);
|
||||
} catch (ServiceVOException e) {
|
||||
LOGGER.error("Got exception {} when add Lembar Konsultasi", 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 Lembar Konsultasi", jse.getMessage());
|
||||
addHeaderMessage(Constants.MessageInfo.ERROR_MESSAGE,
|
||||
jse.getMessage());
|
||||
return RestUtil.getJsonHttpStatus(HttpStatus.CONFLICT,
|
||||
mapHeaderMessage);
|
||||
}
|
||||
}
|
||||
|
||||
@RequestMapping(value = "/update-lembar-konsultasi/", method = RequestMethod.POST, produces = MediaType.APPLICATION_JSON_VALUE, consumes = MediaType.APPLICATION_JSON_VALUE)
|
||||
public ResponseEntity<Map<String,Object>> editVO(@Valid @RequestBody LembarKonsultasiVO vo,HttpServletRequest request) {
|
||||
try {
|
||||
Map<String,Object> result=lembarKonsultasiService.updateLembarKonsultasi(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 Lembar Konsultasi", 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 Lembar Konsultasi", jse.getMessage());
|
||||
addHeaderMessage(Constants.MessageInfo.ERROR_MESSAGE,
|
||||
jse.getMessage());
|
||||
return RestUtil.getJsonHttpStatus(HttpStatus.CONFLICT,
|
||||
mapHeaderMessage);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public ResponseEntity<String> deleteVO(Integer id) {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public ResponseEntity<List<LembarKonsultasiVO>> getAllVO() {
|
||||
return null;
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public ResponseEntity<String> addVO(LembarKonsultasiVO vo) {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public ResponseEntity<Collection<LembarKonsultasiVO>> getAllVOWithQueryString(HttpServletRequest request,
|
||||
Integer page, Integer limit, String sort, String dir) {
|
||||
return null;
|
||||
}
|
||||
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
@RequestMapping(value = "/search-lembar-konsultasi-by-nocm/", method = RequestMethod.GET, produces = MediaType.APPLICATION_JSON_VALUE, consumes = MediaType.APPLICATION_JSON_VALUE)
|
||||
public ResponseEntity<Map<String,Object>> findByNoCm(@RequestParam(value = "noCm", required = false, defaultValue = "000000000000001") String noCm,HttpServletRequest request){
|
||||
Map<String,Object> result = lembarKonsultasiService.findByNocm(noCm);
|
||||
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);
|
||||
}
|
||||
|
||||
|
||||
|
||||
@Override
|
||||
public ResponseEntity<String> editVO(LembarKonsultasiVO vo) {
|
||||
return null;
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
||||
@ -1,81 +1,54 @@
|
||||
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.controller.base.LocaleController;
|
||||
import com.jasamedika.medifirst2000.core.web.WebConstants;
|
||||
import com.jasamedika.medifirst2000.dto.LevelTingkatDto;
|
||||
import com.jasamedika.medifirst2000.service.LevelTingkatService;
|
||||
import com.jasamedika.medifirst2000.util.rest.RestUtil;
|
||||
import com.jasamedika.medifirst2000.vo.PegawaiSKGajiVO;
|
||||
import com.jasamedika.medifirst2000.vo.LevelTingkatVO;
|
||||
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
|
||||
@RequestMapping(value="/level-tingkat")
|
||||
public class LevelTingkatController extends LocaleController<PegawaiSKGajiVO> {
|
||||
|
||||
@RequestMapping(value = "/level-tingkat")
|
||||
public class LevelTingkatController extends LocaleController<LevelTingkatVO> {
|
||||
|
||||
@Autowired
|
||||
private LevelTingkatService levelTingkatService;
|
||||
|
||||
@RequestMapping(value="/save-level-tingkat", method = RequestMethod.POST, produces = MediaType.APPLICATION_JSON_VALUE)
|
||||
public ResponseEntity<Map<String,Object>> save(@RequestBody LevelTingkatDto dto,
|
||||
HttpServletRequest request) {
|
||||
Map<String,Object> result = levelTingkatService.save(dto);
|
||||
@RequestMapping(value = "/save-level-tingkat", method = POST, produces = APPLICATION_JSON_VALUE)
|
||||
public ResponseEntity<Map<String, Object>> save(@RequestBody LevelTingkatDto dto, HttpServletRequest request) {
|
||||
Map<String, Object> result = levelTingkatService.save(dto);
|
||||
if (!result.isEmpty()) {
|
||||
mapHeaderMessage.put(WebConstants.HttpHeaderInfo.LABEL_SUCCESS, getMessage(MessageResource.LABEL_SUCCESS, request));
|
||||
return RestUtil.getJsonResponse(result, HttpStatus.OK, mapHeaderMessage);
|
||||
mapHeaderMessage.put(LABEL_SUCCESS, getMessage(MessageResource.LABEL_SUCCESS, request));
|
||||
return getJsonResponse(result, OK, mapHeaderMessage);
|
||||
}
|
||||
return RestUtil.getJsonHttpStatus(HttpStatus.INTERNAL_SERVER_ERROR, mapHeaderMessage);
|
||||
return getJsonHttpStatus(INTERNAL_SERVER_ERROR, mapHeaderMessage);
|
||||
}
|
||||
|
||||
@RequestMapping(value="/get-level-tingkat", method = RequestMethod.GET, produces = MediaType.APPLICATION_JSON_VALUE)
|
||||
public ResponseEntity<Map<String, Object>> get(
|
||||
@RequestParam(value="idLevelTingkat", required = true) Integer idLevelTingkat,
|
||||
HttpServletRequest request) {
|
||||
Map<String, Object> result = levelTingkatService.get(idLevelTingkat);
|
||||
|
||||
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-level-tingkat", method = RequestMethod.GET, produces = MediaType.APPLICATION_JSON_VALUE)
|
||||
public ResponseEntity<List<Map<String, Object>>> getAll(
|
||||
HttpServletRequest request) {
|
||||
@RequestMapping(value = "/get-all-level-tingkat", method = GET, produces = APPLICATION_JSON_VALUE)
|
||||
public ResponseEntity<List<Map<String, Object>>> getAll(HttpServletRequest request) {
|
||||
List<Map<String, Object>> result = levelTingkatService.getAll();
|
||||
|
||||
if (result!=null) {
|
||||
mapHeaderMessage.put(WebConstants.HttpHeaderInfo.LABEL_SUCCESS, getMessage(MessageResource.LABEL_SUCCESS, request));
|
||||
return RestUtil.getJsonResponse(result, HttpStatus.OK, mapHeaderMessage);
|
||||
if (result != null) {
|
||||
mapHeaderMessage.put(LABEL_SUCCESS, getMessage(MessageResource.LABEL_SUCCESS, request));
|
||||
return getJsonResponse(result, OK, mapHeaderMessage);
|
||||
}
|
||||
return RestUtil.getJsonHttpStatus(HttpStatus.INTERNAL_SERVER_ERROR, mapHeaderMessage);
|
||||
}
|
||||
|
||||
@RequestMapping(value="/get-all-departemen", method = RequestMethod.GET, produces = MediaType.APPLICATION_JSON_VALUE)
|
||||
public ResponseEntity<List<Map<String, Object>>> getAllDetailKategoriPegawai(
|
||||
HttpServletRequest request) {
|
||||
List<Map<String, Object>> result = levelTingkatService.getAllDepartemen();
|
||||
|
||||
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);
|
||||
return getJsonHttpStatus(INTERNAL_SERVER_ERROR, mapHeaderMessage);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@ -1,241 +1,145 @@
|
||||
package com.jasamedika.medifirst2000.controller;
|
||||
|
||||
import java.util.Map;
|
||||
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
import javax.validation.Valid;
|
||||
|
||||
import com.jasamedika.medifirst2000.constants.MessageResource;
|
||||
import com.jasamedika.medifirst2000.controller.base.LocaleController;
|
||||
import com.jasamedika.medifirst2000.entities.LimbahB3Keluar;
|
||||
import com.jasamedika.medifirst2000.entities.LimbahB3Masuk;
|
||||
import com.jasamedika.medifirst2000.exception.ServiceVOException;
|
||||
import com.jasamedika.medifirst2000.service.LimbahB3KeluarService;
|
||||
import com.jasamedika.medifirst2000.service.LimbahB3MasukService;
|
||||
import com.jasamedika.medifirst2000.vo.LimbahB3KeluarVO;
|
||||
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.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.LimbahB3KeluarService;
|
||||
import com.jasamedika.medifirst2000.service.LimbahB3MasukService;
|
||||
import com.jasamedika.medifirst2000.util.rest.RestUtil;
|
||||
import com.jasamedika.medifirst2000.vo.LimbahB3KeluarVO;
|
||||
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
|
||||
@RequestMapping("/limbah-b3-keluar")
|
||||
public class LimbahB3KeluarController extends LocaleController<LimbahB3KeluarVO> {
|
||||
|
||||
|
||||
private static final Logger LOGGER = getLogger(LimbahB3KeluarController.class);
|
||||
|
||||
@Autowired
|
||||
private LimbahB3KeluarService limbahB3KeluarService;
|
||||
|
||||
private LimbahB3KeluarService<LimbahB3Keluar> limbahB3KeluarService;
|
||||
|
||||
@Autowired
|
||||
private LimbahB3MasukService limbahB3MasukService;;
|
||||
|
||||
private static final Logger LOGGER = LoggerFactory
|
||||
.getLogger(LimbahB3KeluarController.class);
|
||||
|
||||
@RequestMapping(value = "/save-limbah-b3-keluar/", method = RequestMethod.POST, produces = MediaType.APPLICATION_JSON_VALUE, consumes = MediaType.APPLICATION_JSON_VALUE)
|
||||
public ResponseEntity<Map<String,Object>> addVO(@Valid @RequestBody LimbahB3KeluarVO vo,HttpServletRequest request) {
|
||||
|
||||
try{
|
||||
Map<String, Object> result = limbahB3KeluarService.addLimbahB3Keluar(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 limbah b3 keluar", 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 limbah b3 keluar", jse.getMessage());
|
||||
addHeaderMessage(Constants.MessageInfo.ERROR_MESSAGE,
|
||||
jse.getMessage());
|
||||
return RestUtil.getJsonHttpStatus(HttpStatus.CONFLICT,
|
||||
mapHeaderMessage);
|
||||
}
|
||||
}
|
||||
|
||||
@RequestMapping(value = "/update-limbah-b3-keluar/", method = RequestMethod.POST, produces = MediaType.APPLICATION_JSON_VALUE, consumes = MediaType.APPLICATION_JSON_VALUE)
|
||||
public ResponseEntity<Map<String,Object>> updatLimbahB3Keluar(@Valid @RequestBody LimbahB3KeluarVO vo,HttpServletRequest request) {
|
||||
|
||||
try{
|
||||
Map<String, Object> result = limbahB3KeluarService.addLimbahB3Keluar(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 limbah b3 keluar", 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 limbah b3 keluar", jse.getMessage());
|
||||
addHeaderMessage(Constants.MessageInfo.ERROR_MESSAGE,
|
||||
jse.getMessage());
|
||||
return RestUtil.getJsonHttpStatus(HttpStatus.CONFLICT,
|
||||
mapHeaderMessage);
|
||||
}
|
||||
}
|
||||
|
||||
@RequestMapping(value = "/find-all-limbah-b3-keluar/", method = RequestMethod.GET, produces = MediaType.APPLICATION_JSON_VALUE)
|
||||
public ResponseEntity<Map<String,Object>> getAllVO(HttpServletRequest request) {
|
||||
|
||||
try {
|
||||
Map<String,Object> result=limbahB3KeluarService.findAllLimbahB3Keluar();
|
||||
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 limbah b3 keluar", 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 limbah b3 keluar", jse.getMessage());
|
||||
addHeaderMessage(Constants.MessageInfo.ERROR_MESSAGE,
|
||||
jse.getMessage());
|
||||
return RestUtil.getJsonHttpStatus(HttpStatus.CONFLICT,
|
||||
mapHeaderMessage);
|
||||
}
|
||||
}
|
||||
|
||||
@RequestMapping(value = "/delete-limbah-b3-keluar", method = RequestMethod.GET)
|
||||
public ResponseEntity<String> deleteNamaBahan(@RequestParam(value = "noRec", required = true) String noRec) {
|
||||
|
||||
private LimbahB3MasukService<LimbahB3Masuk> limbahB3MasukService;
|
||||
|
||||
@RequestMapping(value = "/save-limbah-b3-keluar/", method = POST, produces = APPLICATION_JSON_VALUE, consumes = APPLICATION_JSON_VALUE)
|
||||
public ResponseEntity<Map<String, Object>> addVO(@Valid @RequestBody LimbahB3KeluarVO vo,
|
||||
HttpServletRequest request) {
|
||||
try {
|
||||
if (limbahB3KeluarService.deleteLimbahB3Keluar(noRec) == true)
|
||||
return RestUtil.getJsonResponse(noRec +" Dihapus", HttpStatus.CREATED);
|
||||
|
||||
Map<String, Object> result = limbahB3KeluarService.addLimbahB3Keluar(vo);
|
||||
if (null != result)
|
||||
mapHeaderMessage.put(LABEL_SUCCESS, getMessage(MessageResource.LABEL_SUCCESS, request));
|
||||
return getJsonResponse(result, CREATED, mapHeaderMessage);
|
||||
} catch (ServiceVOException e) {
|
||||
LOGGER.error("Got exception {} when delete Limbah b3 keluar", e.getMessage());
|
||||
addHeaderMessage(Constants.MessageInfo.ERROR_MESSAGE,
|
||||
e.getMessage());
|
||||
return RestUtil.getJsonHttpStatus(HttpStatus.INTERNAL_SERVER_ERROR,
|
||||
mapHeaderMessage);
|
||||
LOGGER.error("Got ServiceVOException {} when addLimbahB3Keluar", e.getMessage());
|
||||
addHeaderMessage(ERROR_MESSAGE, e.getMessage());
|
||||
return getJsonHttpStatus(INTERNAL_SERVER_ERROR, mapHeaderMessage);
|
||||
} catch (JpaSystemException jse) {
|
||||
LOGGER.error("Got exception {} when delete Limbah b3 keluar", jse.getMessage());
|
||||
addHeaderMessage(Constants.MessageInfo.ERROR_MESSAGE,
|
||||
jse.getMessage());
|
||||
return RestUtil.getJsonHttpStatus(HttpStatus.CONFLICT,
|
||||
mapHeaderMessage);
|
||||
LOGGER.error("Got JpaSystemException {} when addLimbahB3Keluar", jse.getMessage());
|
||||
addHeaderMessage(ERROR_MESSAGE, jse.getMessage());
|
||||
return getJsonHttpStatus(CONFLICT, mapHeaderMessage);
|
||||
}
|
||||
|
||||
return RestUtil.getJsonHttpStatus(HttpStatus.NOT_ACCEPTABLE);
|
||||
}
|
||||
|
||||
@RequestMapping(value = "/find-by-periode", method = RequestMethod.GET, produces = MediaType.APPLICATION_JSON_VALUE)
|
||||
public ResponseEntity<Map<String, Object>> getDataByPriode(
|
||||
@RequestParam(value = "periodeAwal", required = true) String periodeAwal,
|
||||
@RequestParam(value = "periodeAkhir", required = true) String periodeAkhir, HttpServletRequest request) {
|
||||
|
||||
Map<String, Object> result = limbahB3KeluarService
|
||||
.findLimbahB3KeluarByPeriode(periodeAwal, periodeAkhir);
|
||||
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));
|
||||
@RequestMapping(value = "/update-limbah-b3-keluar/", method = POST, produces = APPLICATION_JSON_VALUE, consumes = APPLICATION_JSON_VALUE)
|
||||
public ResponseEntity<Map<String, Object>> updatLimbahB3Keluar(@Valid @RequestBody LimbahB3KeluarVO vo,
|
||||
HttpServletRequest request) {
|
||||
return addVO(vo, request);
|
||||
}
|
||||
|
||||
@RequestMapping(value = "/delete-limbah-b3-keluar", method = GET)
|
||||
public ResponseEntity<String> deleteNamaBahan(@RequestParam(value = "noRec") String noRec) {
|
||||
try {
|
||||
if (limbahB3KeluarService.deleteLimbahB3Keluar(noRec))
|
||||
return getJsonResponse(noRec + " Dihapus", CREATED);
|
||||
} catch (ServiceVOException e) {
|
||||
LOGGER.error("Got ServiceVOException {} when deleteLimbahB3Keluar", e.getMessage());
|
||||
addHeaderMessage(ERROR_MESSAGE, e.getMessage());
|
||||
return getJsonHttpStatus(INTERNAL_SERVER_ERROR, mapHeaderMessage);
|
||||
} catch (JpaSystemException jse) {
|
||||
LOGGER.error("Got JpaSystemException {} when deleteLimbahB3Keluar", jse.getMessage());
|
||||
addHeaderMessage(ERROR_MESSAGE, jse.getMessage());
|
||||
return getJsonHttpStatus(CONFLICT, mapHeaderMessage);
|
||||
}
|
||||
return RestUtil.getJsonResponse(result, HttpStatus.OK);
|
||||
return getJsonHttpStatus(NOT_ACCEPTABLE);
|
||||
}
|
||||
|
||||
@RequestMapping(value = "/get-data-by-periode",
|
||||
method = RequestMethod.GET,
|
||||
produces = MediaType.APPLICATION_JSON_VALUE)
|
||||
public Map<String, Object> getDataByPeriode(
|
||||
@RequestParam(value = "periodeAwal") String periodeAwal,
|
||||
@RequestParam(value = "periodeAkhir") String periodeAkhir
|
||||
) {
|
||||
Map<String, Object> result = this.limbahB3KeluarService.getLimbahB3Keluar(periodeAwal, periodeAkhir);
|
||||
return result;
|
||||
}
|
||||
|
||||
@RequestMapping(value = "/get-rekanan",
|
||||
method = RequestMethod.GET,
|
||||
produces = MediaType.APPLICATION_JSON_VALUE)
|
||||
|
||||
@RequestMapping(value = "/get-rekanan", method = GET, produces = APPLICATION_JSON_VALUE)
|
||||
public Map<String, Object> getRekanan() {
|
||||
Map<String, Object> result = this.limbahB3KeluarService.getRekanan();
|
||||
return result;
|
||||
return this.limbahB3KeluarService.getRekanan();
|
||||
}
|
||||
|
||||
@RequestMapping(value = "/get-sisa-limbah-di-tps-by-jenis-limbah",
|
||||
method = RequestMethod.GET,
|
||||
produces = MediaType.APPLICATION_JSON_VALUE)
|
||||
public Map<String, Object> getSisaLimbahDiTpsByJenisLimbah(@RequestParam(value="jenisLimbah")Integer jenisLimbah) {
|
||||
Map<String, Object> result = this.limbahB3KeluarService.getSisaLimbahdiTpsByJenisLimbah(jenisLimbah);
|
||||
return result;
|
||||
|
||||
@RequestMapping(value = "/get-sisa-limbah-di-tps-by-jenis-limbah", method = GET, produces = APPLICATION_JSON_VALUE)
|
||||
public Map<String, Object> getSisaLimbahDiTpsByJenisLimbah(
|
||||
@RequestParam(value = "jenisLimbah") Integer jenisLimbah) {
|
||||
return this.limbahB3KeluarService.getSisaLimbahdiTpsByJenisLimbah(jenisLimbah);
|
||||
}
|
||||
|
||||
@RequestMapping(value = "/get-total-limbah-by-periode/", method = RequestMethod.GET, produces = MediaType.APPLICATION_JSON_VALUE)
|
||||
|
||||
@RequestMapping(value = "/get-total-limbah-by-periode/", method = GET, produces = APPLICATION_JSON_VALUE)
|
||||
public ResponseEntity<Map<String, Double>> getTotalByPeriode(
|
||||
@RequestParam(value = "periodeAwal", required = true) String periodeAwal,
|
||||
@RequestParam(value = "periodeAkhir", required = true) String periodeAkhir,
|
||||
@RequestParam(value = "jenisLibahB3MasukId", required = true) Integer jenisLibahB3MasukId,HttpServletRequest request) {
|
||||
|
||||
try {
|
||||
Map<String,Double> result=limbahB3MasukService.getTotalBeratLimbah(periodeAwal, periodeAkhir, jenisLibahB3MasukId);
|
||||
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 total LimbahB3Masuk", 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 total LimbahB3Masuk", jse.getMessage());
|
||||
addHeaderMessage(Constants.MessageInfo.ERROR_MESSAGE,
|
||||
jse.getMessage());
|
||||
return RestUtil.getJsonHttpStatus(HttpStatus.CONFLICT,
|
||||
mapHeaderMessage);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@RequestMapping(value = "/get-total-limbah-by-periode-list/", method = RequestMethod.GET, produces = MediaType.APPLICATION_JSON_VALUE)
|
||||
@RequestParam(value = "periodeAwal") String periodeAwal,
|
||||
@RequestParam(value = "periodeAkhir") String periodeAkhir,
|
||||
@RequestParam(value = "jenisLibahB3MasukId") Integer jenisLibahB3MasukId, HttpServletRequest request) {
|
||||
try {
|
||||
Map<String, Double> result = limbahB3MasukService.getTotalBeratLimbah(periodeAwal, periodeAkhir,
|
||||
jenisLibahB3MasukId);
|
||||
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 getTotalBeratLimbah", e.getMessage());
|
||||
addHeaderMessage(ERROR_MESSAGE, e.getMessage());
|
||||
return getJsonHttpStatus(INTERNAL_SERVER_ERROR, mapHeaderMessage);
|
||||
} catch (JpaSystemException jse) {
|
||||
LOGGER.error("Got JpaSystemException {} when getTotalBeratLimbah", jse.getMessage());
|
||||
addHeaderMessage(ERROR_MESSAGE, jse.getMessage());
|
||||
return getJsonHttpStatus(CONFLICT, mapHeaderMessage);
|
||||
}
|
||||
}
|
||||
|
||||
@RequestMapping(value = "/get-total-limbah-by-periode-list/", method = GET, produces = APPLICATION_JSON_VALUE)
|
||||
public ResponseEntity<Map<String, Object>> getTotalByPeriodeList(
|
||||
@RequestParam(value = "periodeAwal", required = true) String periodeAwal,
|
||||
@RequestParam(value = "periodeAkhir", required = true) String periodeAkhir,HttpServletRequest request) {
|
||||
|
||||
try {
|
||||
Map<String, Object> result=limbahB3MasukService.getTotalBeratLimbahList(periodeAwal, periodeAkhir);
|
||||
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 total LimbahB3Masuk", 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 total LimbahB3Masuk", jse.getMessage());
|
||||
addHeaderMessage(Constants.MessageInfo.ERROR_MESSAGE,
|
||||
jse.getMessage());
|
||||
return RestUtil.getJsonHttpStatus(HttpStatus.CONFLICT,
|
||||
mapHeaderMessage);
|
||||
}
|
||||
}
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
@RequestParam(value = "periodeAwal") String periodeAwal,
|
||||
@RequestParam(value = "periodeAkhir") String periodeAkhir, HttpServletRequest request) {
|
||||
try {
|
||||
Map<String, Object> result = limbahB3MasukService.getTotalBeratLimbahList(periodeAwal, periodeAkhir);
|
||||
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 getTotalBeratLimbahList", e.getMessage());
|
||||
addHeaderMessage(ERROR_MESSAGE, e.getMessage());
|
||||
return getJsonHttpStatus(INTERNAL_SERVER_ERROR, mapHeaderMessage);
|
||||
} catch (JpaSystemException jse) {
|
||||
LOGGER.error("Got JpaSystemException {} when getTotalBeratLimbahList", jse.getMessage());
|
||||
addHeaderMessage(ERROR_MESSAGE, jse.getMessage());
|
||||
return getJsonHttpStatus(CONFLICT, mapHeaderMessage);
|
||||
}
|
||||
}
|
||||
|
||||
@RequestMapping(value = "/list-limbah-b3-keluar")
|
||||
public Map<String,Object> lisLimbahB3Masuk(
|
||||
public Map<String, Object> lisLimbahB3Masuk(
|
||||
@RequestParam(value = "page", required = false, defaultValue = "0") Integer page,
|
||||
@RequestParam(value = "take", required = false, defaultValue = "100") Integer limit,
|
||||
@RequestParam(value = "sort", required = false, defaultValue = "noRec") String sort,
|
||||
@ -243,10 +147,7 @@ public class LimbahB3KeluarController extends LocaleController<LimbahB3KeluarVO>
|
||||
@RequestParam(value = "dateStart", required = false) String dateStart,
|
||||
@RequestParam(value = "dateEnd", required = false) String dateEnd,
|
||||
@RequestParam(value = "jenisLimbah", required = false) Integer jenisLimbah) {
|
||||
|
||||
Map<String, Object> resultPageMap = limbahB3KeluarService.lisLimbahB3Keluar(page, limit, sort, dir, dateStart, dateEnd, jenisLimbah);
|
||||
|
||||
return resultPageMap;
|
||||
return limbahB3KeluarService.lisLimbahB3Keluar(page, limit, sort, dir, dateStart, dateEnd, jenisLimbah);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@ -1,31 +1,7 @@
|
||||
package com.jasamedika.medifirst2000.controller;
|
||||
|
||||
import java.util.Collection;
|
||||
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.security.core.Authentication;
|
||||
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.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.dto.GantiPasswordDTO;
|
||||
import com.jasamedika.medifirst2000.entities.LoginUser;
|
||||
import com.jasamedika.medifirst2000.exception.ServiceVOException;
|
||||
@ -34,106 +10,95 @@ import com.jasamedika.medifirst2000.security.service.TokenAuthenticationService;
|
||||
import com.jasamedika.medifirst2000.service.LoginUserService;
|
||||
import com.jasamedika.medifirst2000.util.CommonUtil;
|
||||
import com.jasamedika.medifirst2000.util.PasswordUtil;
|
||||
import com.jasamedika.medifirst2000.util.rest.RestUtil;
|
||||
import com.jasamedika.medifirst2000.vo.LoginUserVO;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.http.ResponseEntity;
|
||||
import org.springframework.orm.jpa.JpaSystemException;
|
||||
import org.springframework.security.core.Authentication;
|
||||
import org.springframework.web.bind.annotation.RequestBody;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.bind.annotation.RequestParam;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
import javax.validation.Valid;
|
||||
import java.util.Collection;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
import static com.jasamedika.medifirst2000.constants.Constants.MessageInfo.ERROR_MESSAGE;
|
||||
import static com.jasamedika.medifirst2000.core.web.WebConstants.HttpHeaderInfo.*;
|
||||
import static com.jasamedika.medifirst2000.core.web.WebConstants.PageParameter.*;
|
||||
import static com.jasamedika.medifirst2000.util.rest.RestUtil.getJsonHttpStatus;
|
||||
import static com.jasamedika.medifirst2000.util.rest.RestUtil.getJsonResponse;
|
||||
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
|
||||
@RequestMapping("/user")
|
||||
public class LoginUserController extends LocaleController<LoginUserVO> {
|
||||
|
||||
//Alter by Syamsu
|
||||
|
||||
@Autowired
|
||||
private TokenAuthenticationService tokenAuthenticationService;
|
||||
|
||||
//Alter by Syamsu
|
||||
|
||||
@Autowired
|
||||
private LoginUserService loginUserService;
|
||||
|
||||
private static final Logger LOGGER = LoggerFactory.getLogger(LoginUserController.class);
|
||||
|
||||
/// Alter by Syamsu untuk edit data password user
|
||||
// nanti tambahkan AppPermission, sehingga minta supervisi user name dan password otomatis untuk dirinya sendiri
|
||||
@RequestMapping(value = "/update-password-user/", method = RequestMethod.POST, produces = MediaType.APPLICATION_JSON_VALUE, consumes = MediaType.APPLICATION_JSON_VALUE)
|
||||
|
||||
@RequestMapping(value = "/update-password-user/", method = POST, produces = APPLICATION_JSON_VALUE, consumes = APPLICATION_JSON_VALUE)
|
||||
@AppPermission(AppPermission.SPECIALS)
|
||||
public ResponseEntity<String> updatePassword(@Valid @RequestBody GantiPasswordDTO ubah, HttpServletRequest request){
|
||||
|
||||
public ResponseEntity<String> updatePassword(@Valid @RequestBody GantiPasswordDTO ubah,
|
||||
HttpServletRequest request) {
|
||||
try {
|
||||
Authentication authentication = tokenAuthenticationService.getAuthentication(request);
|
||||
|
||||
String namaUser = authentication.getName();
|
||||
List<LoginUser> loginUser = loginUserService.findByNamaUser(namaUser);
|
||||
|
||||
if (!loginUser.isEmpty()) {
|
||||
|
||||
LoginUser user = loginUser.get(0);
|
||||
|
||||
PasswordUtil passwordUtil = new PasswordUtil();
|
||||
|
||||
Boolean isValidPassword = passwordUtil.isPasswordEqual(ubah.getPassword(), user.getKataSandi());
|
||||
|
||||
boolean isValidPassword = passwordUtil.isPasswordEqual(ubah.getPassword(), user.getKataSandi());
|
||||
if (isValidPassword) {
|
||||
|
||||
LoginUserVO vo = loginUserService.findById(ubah.getId());
|
||||
vo.setId(ubah.getId());
|
||||
vo.setKataSandi(ubah.getKataSandi());
|
||||
LoginUserVO result = loginUserService.update(vo);
|
||||
|
||||
if (null != result){
|
||||
mapHeaderMessage.put(WebConstants.HttpHeaderInfo.LABEL_SUCCESS,getMessage(MessageResource.LABEL_SUCCESS));
|
||||
return RestUtil.getJsonResponse(String.valueOf(vo.getId()), HttpStatus.OK, mapHeaderMessage);
|
||||
if (null != result) {
|
||||
mapHeaderMessage.put(LABEL_SUCCESS, getMessage(MessageResource.LABEL_SUCCESS));
|
||||
return getJsonResponse(String.valueOf(vo.getId()), OK, mapHeaderMessage);
|
||||
} else {
|
||||
LOGGER.error("Got exception {} when update password User failed");
|
||||
addHeaderMessage(Constants.MessageInfo.ERROR_MESSAGE, "update password User failed");
|
||||
return RestUtil.getJsonHttpStatus(HttpStatus.INTERNAL_SERVER_ERROR, mapHeaderMessage);
|
||||
LOGGER.error("Got exception when update password User failed");
|
||||
addHeaderMessage(ERROR_MESSAGE, "update password User failed");
|
||||
return getJsonHttpStatus(INTERNAL_SERVER_ERROR, mapHeaderMessage);
|
||||
}
|
||||
}else{
|
||||
LOGGER.error("Got exception {} when update Pegawai, password invalid");
|
||||
addHeaderMessage(Constants.MessageInfo.ERROR_MESSAGE, "Invalid Password");
|
||||
return RestUtil.getJsonHttpStatus(HttpStatus.INTERNAL_SERVER_ERROR, mapHeaderMessage);
|
||||
} else {
|
||||
LOGGER.error("Got exception when update Pegawai, password invalid");
|
||||
addHeaderMessage(ERROR_MESSAGE, "Invalid Password");
|
||||
return getJsonHttpStatus(INTERNAL_SERVER_ERROR, mapHeaderMessage);
|
||||
}
|
||||
} else {
|
||||
LOGGER.error("Got exception {} when update Pegawai");
|
||||
addHeaderMessage(Constants.MessageInfo.ERROR_MESSAGE, "User is unauthorized");
|
||||
return RestUtil.getJsonHttpStatus(HttpStatus.INTERNAL_SERVER_ERROR, mapHeaderMessage);
|
||||
LOGGER.error("Got exception when update Pegawai");
|
||||
addHeaderMessage(ERROR_MESSAGE, "User is unauthorized");
|
||||
return getJsonHttpStatus(INTERNAL_SERVER_ERROR, mapHeaderMessage);
|
||||
}
|
||||
} catch (ServiceVOException e) {
|
||||
LOGGER.error("Got exception {} when update password User", e.getMessage());
|
||||
addHeaderMessage(Constants.MessageInfo.ERROR_MESSAGE, e.getMessage());
|
||||
return RestUtil.getJsonHttpStatus(HttpStatus.INTERNAL_SERVER_ERROR, mapHeaderMessage);
|
||||
LOGGER.error("Got ServiceVOException {} when update", e.getMessage());
|
||||
addHeaderMessage(ERROR_MESSAGE, e.getMessage());
|
||||
return getJsonHttpStatus(INTERNAL_SERVER_ERROR, mapHeaderMessage);
|
||||
} catch (JpaSystemException jse) {
|
||||
LOGGER.error("Got exception {} when update password User", jse.getMessage());
|
||||
addHeaderMessage(Constants.MessageInfo.ERROR_MESSAGE, jse.getMessage());
|
||||
return RestUtil.getJsonHttpStatus(HttpStatus.CONFLICT, mapHeaderMessage);
|
||||
LOGGER.error("Got JpaSystemException {} when update", jse.getMessage());
|
||||
addHeaderMessage(ERROR_MESSAGE, jse.getMessage());
|
||||
return getJsonHttpStatus(CONFLICT, mapHeaderMessage);
|
||||
} catch (Exception ex) {
|
||||
LOGGER.error("Got exception {} when update password User", ex.getMessage());
|
||||
addHeaderMessage(Constants.MessageInfo.ERROR_MESSAGE, ex.getMessage());
|
||||
return RestUtil.getJsonHttpStatus(HttpStatus.CONFLICT, mapHeaderMessage);
|
||||
LOGGER.error("Got Exception {} when update", ex.getMessage());
|
||||
addHeaderMessage(ERROR_MESSAGE, ex.getMessage());
|
||||
return getJsonHttpStatus(CONFLICT, mapHeaderMessage);
|
||||
}
|
||||
|
||||
// return RestUtil.getJsonHttptatus(HttpStatus.NOT_ACCEPTABLE);
|
||||
}
|
||||
|
||||
|
||||
|
||||
@RequestMapping(value = "/edit-user/", method = RequestMethod.POST, produces = MediaType.APPLICATION_JSON_VALUE, consumes = MediaType.APPLICATION_JSON_VALUE)
|
||||
public ResponseEntity<String> editVO(@Valid @RequestBody LoginUserVO vo, HttpServletRequest request) {
|
||||
try {
|
||||
LoginUserVO result = loginUserService.update(vo);
|
||||
if (null != result)
|
||||
return RestUtil.getJsonResponse(String.valueOf(vo.getId()), HttpStatus.OK);
|
||||
} catch (ServiceVOException e) {
|
||||
LOGGER.error("Got exception {} when update User", 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 User", jse.getMessage());
|
||||
addHeaderMessage(Constants.MessageInfo.ERROR_MESSAGE, jse.getMessage());
|
||||
return RestUtil.getJsonHttpStatus(HttpStatus.CONFLICT, mapHeaderMessage);
|
||||
}
|
||||
|
||||
return RestUtil.getJsonHttpStatus(HttpStatus.NOT_ACCEPTABLE);
|
||||
}
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
@ -144,123 +109,93 @@ public class LoginUserController extends LocaleController<LoginUserVO> {
|
||||
@RequestParam(value = "dir", required = false, defaultValue = "asc") String dir) {
|
||||
Map<String, Object> resultPageMap = loginUserService.findAllWithPageAndLimitAndSortByAndDirectionParameter(page,
|
||||
limit, sort, dir);
|
||||
|
||||
return constructListPageResult(resultPageMap, request);
|
||||
}
|
||||
|
||||
@SuppressWarnings("rawtypes")
|
||||
private ResponseEntity constructListPageResult(Map<String, Object> map, HttpServletRequest request) {
|
||||
|
||||
if (map == null) {
|
||||
Map<String, String> mapHeaderMessage = new HashMap<String, String>();
|
||||
mapHeaderMessage.put(WebConstants.HttpHeaderInfo.TOTAL_PAGE_HEADER, "0");
|
||||
mapHeaderMessage.put(WebConstants.HttpHeaderInfo.TOTAL_COUNT_HEADER, "0");
|
||||
mapHeaderMessage.put(Constants.MessageInfo.ERROR_MESSAGE, "Data not found.");
|
||||
return RestUtil.getJsonResponse(null, HttpStatus.BAD_REQUEST, mapHeaderMessage);
|
||||
Map<String, String> mapHeaderMessage = new HashMap<>();
|
||||
mapHeaderMessage.put(TOTAL_PAGE_HEADER, "0");
|
||||
mapHeaderMessage.put(TOTAL_COUNT_HEADER, "0");
|
||||
mapHeaderMessage.put(ERROR_MESSAGE, "Data not found.");
|
||||
return getJsonResponse(null, BAD_REQUEST, mapHeaderMessage);
|
||||
} else {
|
||||
@SuppressWarnings("unchecked")
|
||||
Collection<LoginUserVO> vos = (Collection<LoginUserVO>) map.get(WebConstants.PageParameter.LIST_DATA);
|
||||
|
||||
Map<String, String> mapHeaderMessage = new HashMap<String, String>();
|
||||
mapHeaderMessage.put(WebConstants.HttpHeaderInfo.TOTAL_PAGE_HEADER,
|
||||
String.valueOf(map.get(WebConstants.PageParameter.TOTAL_PAGES)));
|
||||
mapHeaderMessage.put(WebConstants.HttpHeaderInfo.TOTAL_COUNT_HEADER,
|
||||
String.valueOf(map.get(WebConstants.PageParameter.TOTAL_ELEMENTS)));
|
||||
|
||||
mapHeaderMessage.put(WebConstants.HttpHeaderInfo.LABEL_SUCCESS,
|
||||
getMessage(MessageResource.LABEL_SUCCESS, request));
|
||||
|
||||
return RestUtil.getJsonResponse(vos, HttpStatus.OK, mapHeaderMessage);
|
||||
Collection<LoginUserVO> vos = (Collection<LoginUserVO>) map.get(LIST_DATA);
|
||||
Map<String, String> mapHeaderMessage = new HashMap<>();
|
||||
mapHeaderMessage.put(TOTAL_PAGE_HEADER, String.valueOf(map.get(TOTAL_PAGES)));
|
||||
mapHeaderMessage.put(TOTAL_COUNT_HEADER, String.valueOf(map.get(TOTAL_ELEMENTS)));
|
||||
mapHeaderMessage.put(LABEL_SUCCESS, getMessage(MessageResource.LABEL_SUCCESS, request));
|
||||
return getJsonResponse(vos, OK, mapHeaderMessage);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
@RequestMapping(value = "/list-user", method = RequestMethod.GET)
|
||||
public ResponseEntity<List<LoginUserVO>> listUser() {
|
||||
List<LoginUserVO> loginUserVOs = loginUserService.findAll();
|
||||
return RestUtil.getJsonResponse(loginUserVOs, HttpStatus.OK, mapHeaderMessage);
|
||||
}
|
||||
|
||||
@RequestMapping(value = "/get-user", method = RequestMethod.GET)
|
||||
@RequestMapping(value = "/get-user", method = GET)
|
||||
public ResponseEntity<LoginUser> getUser() {
|
||||
LoginUser loginUser = loginUserService.getLoginUser();
|
||||
return RestUtil.getJsonResponse(loginUser, HttpStatus.OK, mapHeaderMessage);
|
||||
return getJsonResponse(loginUser, OK, mapHeaderMessage);
|
||||
}
|
||||
|
||||
|
||||
@RequestMapping(value = "/get-all-user/", method = RequestMethod.GET, produces = MediaType.APPLICATION_JSON_VALUE)
|
||||
@RequestMapping(value = "/get-all-user/", method = GET, produces = APPLICATION_JSON_VALUE)
|
||||
public ResponseEntity<Map<String, Object>> getAllUser(HttpServletRequest request) {
|
||||
Map<String, Object> result = null;
|
||||
try{
|
||||
result = loginUserService.getAllUser();
|
||||
Boolean dataFound=new Boolean((boolean) result.get("dataFound"));
|
||||
|
||||
if(dataFound){
|
||||
mapHeaderMessage.put(WebConstants.HttpHeaderInfo.LABEL_SUCCESS,getMessage(MessageResource.LABEL_SUCCESS,request ));
|
||||
try {
|
||||
Map<String, Object> result = loginUserService.getAllUser();
|
||||
boolean dataFound = (boolean) result.get("dataFound");
|
||||
if (dataFound) {
|
||||
mapHeaderMessage.put(LABEL_SUCCESS, getMessage(MessageResource.LABEL_SUCCESS, request));
|
||||
} else {
|
||||
mapHeaderMessage.put(LABEL_ERROR, getMessage(MessageResource.LABEL_ERROR, request));
|
||||
}
|
||||
else{
|
||||
mapHeaderMessage.put(WebConstants.HttpHeaderInfo.LABEL_ERROR,getMessage(MessageResource.LABEL_ERROR,request ));
|
||||
}
|
||||
}catch (Exception e){
|
||||
e.printStackTrace();
|
||||
return getJsonResponse(result, OK);
|
||||
} catch (Exception e) {
|
||||
throw new ServiceVOException(e.getMessage());
|
||||
}
|
||||
return RestUtil.getJsonResponse(result, HttpStatus.OK);
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------------------------------------------------------
|
||||
|
||||
@RequestMapping(value = "/get-load-data", method = RequestMethod.GET, produces = MediaType.APPLICATION_JSON_VALUE)
|
||||
|
||||
@RequestMapping(value = "/get-load-data", method = GET, produces = APPLICATION_JSON_VALUE)
|
||||
public ResponseEntity<Map<String, Object>> getLoadData(HttpServletRequest request) {
|
||||
try {
|
||||
Map<String,Object> result = loginUserService.getLoadData();
|
||||
if (null != result){
|
||||
mapHeaderMessage.put(WebConstants.HttpHeaderInfo.LABEL_SUCCESS,getMessage(MessageResource.LABEL_SUCCESS,request));
|
||||
return RestUtil.getJsonResponse(result, HttpStatus.OK,mapHeaderMessage);
|
||||
} else{
|
||||
return RestUtil.getJsonResponse(result, HttpStatus.NOT_FOUND,mapHeaderMessage);
|
||||
Map<String, Object> result = loginUserService.getLoadData();
|
||||
if (null != result) {
|
||||
mapHeaderMessage.put(LABEL_SUCCESS, getMessage(MessageResource.LABEL_SUCCESS, request));
|
||||
return getJsonResponse(result, OK, mapHeaderMessage);
|
||||
} else {
|
||||
return getJsonResponse(null, NOT_FOUND, mapHeaderMessage);
|
||||
}
|
||||
} catch (ServiceVOException e) {
|
||||
LOGGER.error("Got exception {} when getLoadData", e.getMessage());
|
||||
addHeaderMessage(Constants.MessageInfo.ERROR_MESSAGE, e.getMessage());
|
||||
return RestUtil.getJsonHttpStatus(HttpStatus.INTERNAL_SERVER_ERROR, mapHeaderMessage);
|
||||
LOGGER.error("Got ServiceVOException {} when getLoadData", e.getMessage());
|
||||
addHeaderMessage(ERROR_MESSAGE, e.getMessage());
|
||||
return getJsonHttpStatus(INTERNAL_SERVER_ERROR, mapHeaderMessage);
|
||||
} catch (JpaSystemException jse) {
|
||||
LOGGER.error("Got exception {} when getLoadData", jse.getMessage());
|
||||
addHeaderMessage(Constants.MessageInfo.ERROR_MESSAGE, jse.getMessage());
|
||||
return RestUtil.getJsonHttpStatus(HttpStatus.CONFLICT, mapHeaderMessage);
|
||||
LOGGER.error("Got JpaSystemException {} when getLoadData", jse.getMessage());
|
||||
addHeaderMessage(ERROR_MESSAGE, jse.getMessage());
|
||||
return getJsonHttpStatus(CONFLICT, mapHeaderMessage);
|
||||
}
|
||||
}
|
||||
|
||||
@RequestMapping(value = "/save-login-user", method = RequestMethod.POST, produces = MediaType.APPLICATION_JSON_VALUE, consumes = MediaType.APPLICATION_JSON_VALUE)
|
||||
public ResponseEntity<Map<String, Object>> saveLoginUser(@Valid @RequestBody LoginUserVO vo,HttpServletRequest request) {
|
||||
@RequestMapping(value = "/save-login-user", method = POST, produces = APPLICATION_JSON_VALUE, consumes = APPLICATION_JSON_VALUE)
|
||||
public ResponseEntity<Map<String, Object>> saveLoginUser(@Valid @RequestBody LoginUserVO vo,
|
||||
HttpServletRequest request) {
|
||||
try {
|
||||
Map<String,Object> result = loginUserService.saveUpdateLoginUser(vo);
|
||||
Map<String, Object> result = loginUserService.saveUpdateLoginUser(vo);
|
||||
if (CommonUtil.isNullOrEmpty(result.get("statusError"))) {
|
||||
mapHeaderMessage.put(WebConstants.HttpHeaderInfo.LABEL_SUCCESS,getMessage(MessageResource.LABEL_SUCCESS,request));
|
||||
return RestUtil.getJsonResponse(result, HttpStatus.CREATED, mapHeaderMessage);
|
||||
mapHeaderMessage.put(LABEL_SUCCESS, getMessage(MessageResource.LABEL_SUCCESS, request));
|
||||
return getJsonResponse(result, CREATED, mapHeaderMessage);
|
||||
} else {
|
||||
Map<String, String> headerMessageCustom = new HashMap<>();
|
||||
headerMessageCustom.put("label-success", (String) result.get("statusError"));
|
||||
return RestUtil.getJsonResponse(result, HttpStatus.CREATED, headerMessageCustom);
|
||||
headerMessageCustom.put("label-success", result.get("statusError").toString());
|
||||
return getJsonResponse(result, CREATED, headerMessageCustom);
|
||||
}
|
||||
} catch (ServiceVOException e) {
|
||||
LOGGER.error("Got exception {} when saveLoginUser", e.getMessage());
|
||||
addHeaderMessage(Constants.MessageInfo.ERROR_MESSAGE, e.getMessage());
|
||||
return RestUtil.getJsonHttpStatus(HttpStatus.INTERNAL_SERVER_ERROR, mapHeaderMessage);
|
||||
LOGGER.error("Got ServiceVOException {} when saveUpdateLoginUser", e.getMessage());
|
||||
addHeaderMessage(ERROR_MESSAGE, e.getMessage());
|
||||
return getJsonHttpStatus(INTERNAL_SERVER_ERROR, mapHeaderMessage);
|
||||
} catch (JpaSystemException jse) {
|
||||
LOGGER.error("Got exception {} when saveLoginUser", jse.getMessage());
|
||||
addHeaderMessage(Constants.MessageInfo.ERROR_MESSAGE, jse.getMessage());
|
||||
return RestUtil.getJsonHttpStatus(HttpStatus.CONFLICT, mapHeaderMessage);
|
||||
LOGGER.error("Got JpaSystemException {} when saveUpdateLoginUser", jse.getMessage());
|
||||
addHeaderMessage(ERROR_MESSAGE, jse.getMessage());
|
||||
return getJsonHttpStatus(CONFLICT, mapHeaderMessage);
|
||||
}
|
||||
}
|
||||
|
||||
@RequestMapping(value = "/check-nama-user", method = RequestMethod.GET)
|
||||
public boolean namaUserExists(@RequestParam(value = "nama-user", required = true) String namaUser) {
|
||||
List<LoginUser> users = loginUserService.findByNamaUser(namaUser);
|
||||
if (!users.isEmpty()) {
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@ -1,115 +1,87 @@
|
||||
package com.jasamedika.medifirst2000.controller;
|
||||
|
||||
import java.text.ParseException;
|
||||
import java.text.SimpleDateFormat;
|
||||
import java.util.Map;
|
||||
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
import javax.validation.Valid;
|
||||
|
||||
import com.jasamedika.medifirst2000.constants.MessageResource;
|
||||
import com.jasamedika.medifirst2000.controller.base.LocaleController;
|
||||
import com.jasamedika.medifirst2000.exception.ServiceVOException;
|
||||
import com.jasamedika.medifirst2000.service.ManagementDashboardService;
|
||||
import com.jasamedika.medifirst2000.vo.ManagementDashboardVO;
|
||||
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.ManagementDashboardService;
|
||||
import com.jasamedika.medifirst2000.util.DateUtil;
|
||||
import com.jasamedika.medifirst2000.util.rest.RestUtil;
|
||||
import com.jasamedika.medifirst2000.vo.AkunVO;
|
||||
import com.jasamedika.medifirst2000.vo.ManagementDashboardVO;
|
||||
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.DateUtil.toDate;
|
||||
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
|
||||
@RequestMapping("/management")
|
||||
public class ManagementController extends LocaleController<AkunVO> {
|
||||
public class ManagementController extends LocaleController<ManagementDashboardVO> {
|
||||
|
||||
private static final Logger LOGGER = getLogger(ManagementController.class);
|
||||
|
||||
private static final Logger LOGGER = LoggerFactory.getLogger(ManagementController.class);
|
||||
@Autowired
|
||||
private ManagementDashboardService managementDashboardService;
|
||||
@RequestMapping(value = "/save-management-dashboard", method = RequestMethod.POST, produces = MediaType.APPLICATION_JSON_VALUE, consumes = MediaType.APPLICATION_JSON_VALUE)
|
||||
public ResponseEntity<Map<String,Object>> saveManagementDashboard(@Valid @RequestBody ManagementDashboardVO vo,HttpServletRequest request) throws ParseException {
|
||||
try {
|
||||
SimpleDateFormat format = new SimpleDateFormat("dd-MM-yyyy");
|
||||
|
||||
Map<String,Object> result=managementDashboardService.saveManagementDashboard(vo);
|
||||
BroadcastMessage("Dashboard", "");
|
||||
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 Pasien", 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 Pasien", jse.getMessage());
|
||||
addHeaderMessage(Constants.MessageInfo.ERROR_MESSAGE, jse.getMessage());
|
||||
return RestUtil.getJsonHttpStatus(HttpStatus.CONFLICT, mapHeaderMessage);
|
||||
}
|
||||
@RequestMapping(value = "/save-management-dashboard", method = POST, produces = APPLICATION_JSON_VALUE, consumes = APPLICATION_JSON_VALUE)
|
||||
public ResponseEntity<Map<String, Object>> saveManagementDashboard(@Valid @RequestBody ManagementDashboardVO vo,
|
||||
HttpServletRequest request) {
|
||||
try {
|
||||
Map<String, Object> result = managementDashboardService.saveManagementDashboard(vo);
|
||||
BroadcastMessage("Dashboard", "");
|
||||
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 saveManagementDashboard", e.getMessage());
|
||||
addHeaderMessage(ERROR_MESSAGE, e.getMessage());
|
||||
return getJsonHttpStatus(INTERNAL_SERVER_ERROR, mapHeaderMessage);
|
||||
} catch (JpaSystemException jse) {
|
||||
LOGGER.error("Got JpaSystemException {} when saveManagementDashboard", jse.getMessage());
|
||||
addHeaderMessage(ERROR_MESSAGE, jse.getMessage());
|
||||
return getJsonHttpStatus(CONFLICT, mapHeaderMessage);
|
||||
}
|
||||
}
|
||||
|
||||
@RequestMapping(value = "/get-save-management-dashboard/{nama}", method = GET, produces = APPLICATION_JSON_VALUE)
|
||||
public ResponseEntity<Map<String, Object>> getsaveManagementDashboard(@PathVariable("nama") String nama,
|
||||
HttpServletRequest request) {
|
||||
try {
|
||||
if (nama.equals("-"))
|
||||
nama = "";
|
||||
Map<String, Object> result = managementDashboardService.findByName(nama);
|
||||
mapHeaderMessage.put(LABEL_SUCCESS, getMessage(MessageResource.LABEL_SUCCESS, request));
|
||||
return getJsonResponse(result, OK);
|
||||
} catch (Exception e) {
|
||||
throw new ServiceVOException(e.getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
@RequestMapping(value = "/get-save-management-dashboard/{nama}", method = RequestMethod.GET, produces = MediaType.APPLICATION_JSON_VALUE)
|
||||
public ResponseEntity<Map<String, Object>> getsaveManagementDashboard(
|
||||
@PathVariable("nama") String nama,
|
||||
HttpServletRequest request) {
|
||||
Map<String, Object> result = null;
|
||||
try{
|
||||
if(nama.equals("-"))
|
||||
nama="";
|
||||
result = managementDashboardService.findByName(nama);
|
||||
|
||||
mapHeaderMessage.put(WebConstants.HttpHeaderInfo.LABEL_SUCCESS,getMessage(MessageResource.LABEL_SUCCESS,request ));
|
||||
}catch (Exception e){
|
||||
e.printStackTrace();
|
||||
}
|
||||
return RestUtil.getJsonResponse(result, HttpStatus.OK);
|
||||
}
|
||||
|
||||
@RequestMapping(value = "/get-dashboard/{noRec}", method = RequestMethod.GET, produces = MediaType.APPLICATION_JSON_VALUE)
|
||||
public ResponseEntity<Map<String, Object>> getDashboard(
|
||||
@PathVariable("noRec") String noRec,
|
||||
HttpServletRequest request) {
|
||||
Map<String, Object> result = null;
|
||||
try{
|
||||
|
||||
result = managementDashboardService.findByNoRec(noRec);
|
||||
|
||||
mapHeaderMessage.put(WebConstants.HttpHeaderInfo.LABEL_SUCCESS,getMessage(MessageResource.LABEL_SUCCESS,request ));
|
||||
}catch (Exception e){
|
||||
e.printStackTrace();
|
||||
}
|
||||
return RestUtil.getJsonResponse(result, HttpStatus.OK);
|
||||
}
|
||||
|
||||
@RequestMapping(value = "/get-detail-dashboard/{noRec}/{start}/{until}", method = RequestMethod.GET, produces = MediaType.APPLICATION_JSON_VALUE)
|
||||
public ResponseEntity<Map<String, Object>> getDetailDashboard(
|
||||
@PathVariable("noRec") String noRec,
|
||||
@PathVariable("start") String start,
|
||||
@PathVariable("until") String until,
|
||||
HttpServletRequest request) {
|
||||
Map<String, Object> result = null;
|
||||
try{
|
||||
|
||||
result = managementDashboardService.findByNoDetail(noRec,DateUtil.toDate(start),DateUtil.toDate(until));
|
||||
|
||||
mapHeaderMessage.put(WebConstants.HttpHeaderInfo.LABEL_SUCCESS,getMessage(MessageResource.LABEL_SUCCESS,request ));
|
||||
}catch (Exception e){
|
||||
e.printStackTrace();
|
||||
}
|
||||
return RestUtil.getJsonResponse(result, HttpStatus.OK);
|
||||
@RequestMapping(value = "/get-detail-dashboard/{noRec}/{start}/{until}", method = GET, produces = APPLICATION_JSON_VALUE)
|
||||
public ResponseEntity<Map<String, Object>> getDetailDashboard(@PathVariable("noRec") String noRec,
|
||||
@PathVariable("start") String start, @PathVariable("until") String until, HttpServletRequest request) {
|
||||
try {
|
||||
Map<String, Object> result = managementDashboardService.findByNoDetail(noRec, toDate(start), toDate(until));
|
||||
mapHeaderMessage.put(LABEL_SUCCESS, getMessage(MessageResource.LABEL_SUCCESS, request));
|
||||
return getJsonResponse(result, OK);
|
||||
} catch (Exception e) {
|
||||
throw new ServiceVOException(e.getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@ -1,142 +1,58 @@
|
||||
package com.jasamedika.medifirst2000.controller;
|
||||
|
||||
import java.util.Collection;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
import javax.validation.Valid;
|
||||
|
||||
import com.jasamedika.medifirst2000.constants.MessageResource;
|
||||
import com.jasamedika.medifirst2000.controller.base.LocaleController;
|
||||
import com.jasamedika.medifirst2000.exception.ServiceVOException;
|
||||
import com.jasamedika.medifirst2000.service.ManajemenPromosiService;
|
||||
import com.jasamedika.medifirst2000.vo.ManajemenPromosiVO;
|
||||
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.IBaseRestController;
|
||||
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.ManajemenPromosiService;
|
||||
import com.jasamedika.medifirst2000.util.rest.RestUtil;
|
||||
import com.jasamedika.medifirst2000.vo.ManajemenPromosiVO;
|
||||
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
|
||||
@RequestMapping("/manajemen-promosi")
|
||||
public class ManajemenPromosiController extends LocaleController<ManajemenPromosiVO> implements IBaseRestController<ManajemenPromosiVO> {
|
||||
|
||||
public class ManajemenPromosiController extends LocaleController<ManajemenPromosiVO> {
|
||||
|
||||
private static final Logger LOGGER = getLogger(ManajemenPromosiController.class);
|
||||
|
||||
@Autowired
|
||||
private ManajemenPromosiService manajemenPromosiService;
|
||||
|
||||
private static final Logger LOGGER = LoggerFactory
|
||||
.getLogger(ManajemenPromosiController.class);
|
||||
|
||||
@RequestMapping(value = "/save-manajemen-promosi/", method = RequestMethod.POST, produces = MediaType.APPLICATION_JSON_VALUE, consumes = MediaType.APPLICATION_JSON_VALUE)
|
||||
public ResponseEntity<Map<String,Object>> addVO(@Valid @RequestBody ManajemenPromosiVO vo, HttpServletRequest request) {
|
||||
|
||||
|
||||
@RequestMapping(value = "/save-manajemen-promosi/", method = POST, produces = APPLICATION_JSON_VALUE, consumes = APPLICATION_JSON_VALUE)
|
||||
public ResponseEntity<Map<String, Object>> addVO(@Valid @RequestBody ManajemenPromosiVO vo,
|
||||
HttpServletRequest request) {
|
||||
try {
|
||||
Map<String,Object> result=manajemenPromosiService.addManajemenPromosi(vo);
|
||||
Map<String, Object> result = manajemenPromosiService.addManajemenPromosi(vo);
|
||||
if (null != result)
|
||||
mapHeaderMessage.put(WebConstants.HttpHeaderInfo.LABEL_SUCCESS,getMessage(MessageResource.LABEL_SUCCESS,request ));
|
||||
return RestUtil.getJsonResponse(result, HttpStatus.CREATED,mapHeaderMessage);
|
||||
mapHeaderMessage.put(LABEL_SUCCESS,
|
||||
getMessage(MessageResource.LABEL_SUCCESS, request));
|
||||
return getJsonResponse(result, CREATED, mapHeaderMessage);
|
||||
} catch (ServiceVOException e) {
|
||||
LOGGER.error("Got exception {} when add ManajemenPromosi", e.getMessage());
|
||||
addHeaderMessage(Constants.MessageInfo.ERROR_MESSAGE,
|
||||
e.getMessage());
|
||||
return RestUtil.getJsonHttpStatus(HttpStatus.INTERNAL_SERVER_ERROR,
|
||||
mapHeaderMessage);
|
||||
LOGGER.error("Got ServiceVOException {} when addManajemenPromosi", e.getMessage());
|
||||
addHeaderMessage(ERROR_MESSAGE, e.getMessage());
|
||||
return getJsonHttpStatus(INTERNAL_SERVER_ERROR, mapHeaderMessage);
|
||||
} catch (JpaSystemException jse) {
|
||||
LOGGER.error("Got exception {} when add ManajemenPromosi", jse.getMessage());
|
||||
addHeaderMessage(Constants.MessageInfo.ERROR_MESSAGE,
|
||||
jse.getMessage());
|
||||
return RestUtil.getJsonHttpStatus(HttpStatus.CONFLICT,
|
||||
mapHeaderMessage);
|
||||
LOGGER.error("Got JpaSystemException {} when addManajemenPromosi", jse.getMessage());
|
||||
addHeaderMessage(ERROR_MESSAGE, jse.getMessage());
|
||||
return getJsonHttpStatus(CONFLICT, mapHeaderMessage);
|
||||
}
|
||||
}
|
||||
|
||||
@RequestMapping(value = "/update-manajemen-promosi/", method = RequestMethod.POST, produces = MediaType.APPLICATION_JSON_VALUE, consumes = MediaType.APPLICATION_JSON_VALUE)
|
||||
public ResponseEntity<Map<String,Object>> updateVO(@Valid @RequestBody ManajemenPromosiVO vo, HttpServletRequest request) {
|
||||
|
||||
try {
|
||||
Map<String,Object> result=manajemenPromosiService.updateManajemenPromosi(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 ManajemenPromosi", 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 ManajemenPromosi", jse.getMessage());
|
||||
addHeaderMessage(Constants.MessageInfo.ERROR_MESSAGE,
|
||||
jse.getMessage());
|
||||
return RestUtil.getJsonHttpStatus(HttpStatus.CONFLICT,
|
||||
mapHeaderMessage);
|
||||
}
|
||||
}
|
||||
|
||||
@RequestMapping(value = "/find-all-manajemen-promosi/", method = RequestMethod.GET, produces = MediaType.APPLICATION_JSON_VALUE)
|
||||
public ResponseEntity<Map<String,Object>> getAllVO(HttpServletRequest request) {
|
||||
|
||||
try {
|
||||
Map<String,Object> result=manajemenPromosiService.findAllManajemenPromosi();
|
||||
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 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 get all sasaran strategis", jse.getMessage());
|
||||
addHeaderMessage(Constants.MessageInfo.ERROR_MESSAGE,
|
||||
jse.getMessage());
|
||||
return RestUtil.getJsonHttpStatus(HttpStatus.CONFLICT,
|
||||
mapHeaderMessage);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public ResponseEntity<Collection<ManajemenPromosiVO>> getAllVOWithQueryString(HttpServletRequest request,
|
||||
Integer page, Integer limit, String sort, String dir) {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public ResponseEntity<ManajemenPromosiVO> getVO(Integer id) {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public ResponseEntity<String> addVO(ManajemenPromosiVO vo) {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public ResponseEntity<String> editVO(ManajemenPromosiVO vo) {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public ResponseEntity<String> deleteVO(Integer id) {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public ResponseEntity<List<ManajemenPromosiVO>> getAllVO() {
|
||||
return null;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user