Update sdm controllers
Clean code
This commit is contained in:
parent
c7c751e61f
commit
0801da3173
@ -265,6 +265,14 @@
|
||||
<version>${commons-collections.version}</version>
|
||||
</dependency>
|
||||
|
||||
<!-- https://mvnrepository.com/artifact/org.projectlombok/lombok -->
|
||||
<dependency>
|
||||
<groupId>org.projectlombok</groupId>
|
||||
<artifactId>lombok</artifactId>
|
||||
<version>${project.lombok.version}</version>
|
||||
<scope>provided</scope>
|
||||
</dependency>
|
||||
|
||||
</dependencies>
|
||||
|
||||
<build>
|
||||
|
||||
@ -6,73 +6,51 @@ import java.text.SimpleDateFormat;
|
||||
/**
|
||||
* Constants value
|
||||
*
|
||||
* @author Roberto
|
||||
* @author Roberto, Syamsu
|
||||
*/
|
||||
public class Constants {
|
||||
|
||||
public static final String JASAMEDIKA = "SkFTQU1FRElLQQ==";
|
||||
public static final String APP_VERSION = "APP_VERSION";
|
||||
|
||||
public static final String AUTH_HEADER_NAME = "X-AUTH-TOKEN";
|
||||
|
||||
//for example
|
||||
public static final String IDR = "IDR";
|
||||
public static final String RP = "RP";
|
||||
|
||||
public static final String COMMA = ",";
|
||||
|
||||
public static final DecimalFormat ONE_COMA_FORMAT = new DecimalFormat("#.#");
|
||||
public static final DecimalFormat TWO_COMA_FORMAT = new DecimalFormat(
|
||||
"#.##");
|
||||
|
||||
public static final DecimalFormat MONEY_FORMAT_WITHOUT_COMMA = new DecimalFormat(
|
||||
"###,###");
|
||||
public static final DecimalFormat TWO_COMA_FORMAT = new DecimalFormat("#.##");
|
||||
public static final DecimalFormat MONEY_FORMAT_WITHOUT_COMMA = new DecimalFormat("###,###");
|
||||
|
||||
public static final class DateFormat {
|
||||
public static final SimpleDateFormat yyyyMMdd = new SimpleDateFormat(
|
||||
"yyyyMMdd");
|
||||
public static final SimpleDateFormat dd_MMM_yyyy = new SimpleDateFormat(
|
||||
"dd MMM yyyy");
|
||||
public static final SimpleDateFormat yyyy_MM_dd_HH_mm_ss = new SimpleDateFormat(
|
||||
"yyyy-MM-dd HH:mm:ss");
|
||||
public static final SimpleDateFormat yyyy_MM_dd_T_HH_mm_ss = new SimpleDateFormat(
|
||||
"yyyy-MM-dd'T'HH:mm:ss");
|
||||
public static final SimpleDateFormat yyyyMMdd_HH_mm_ss = new SimpleDateFormat(
|
||||
"yyyyMMdd HH:mm:ss");
|
||||
public static final SimpleDateFormat yyyyMMdd = new SimpleDateFormat("yyyyMMdd");
|
||||
public static final SimpleDateFormat dd_MMM_yyyy = new SimpleDateFormat("dd MMM yyyy");
|
||||
public static final SimpleDateFormat yyyy_MM_dd_HH_mm_ss = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
|
||||
public static final SimpleDateFormat yyyy_MM_dd_T_HH_mm_ss = new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ss");
|
||||
public static final SimpleDateFormat yyyyMMdd_HH_mm_ss = new SimpleDateFormat("yyyyMMdd HH:mm:ss");
|
||||
}
|
||||
|
||||
/* message */
|
||||
public static final class MessageInfo {
|
||||
public static final String INFO_MESSAGE = "INFO_MESSAGE";
|
||||
public static final String WARNING_MESSAGE = "WARNING_MESSAGE";
|
||||
public static final String ERROR_MESSAGE = "ERROR_MESSAGE";
|
||||
public static final String EXCEPTION_MESSAGE = "EXCEPTION_MESSAGE";
|
||||
|
||||
}
|
||||
|
||||
|
||||
/* locale id (indonesia / default) and en (english) */
|
||||
public static final class Locale {
|
||||
public static final String INA = "ina";
|
||||
public static final String EN = "en";
|
||||
|
||||
}
|
||||
//Update perubahan di sini, harus disamakan dengan package yang ada di jasamedika-bussiness
|
||||
//com.jasamedika.medifirst2000.logging.hibernate.async
|
||||
|
||||
public static final class HttpHeader {
|
||||
public static final String SUPERVISING = "Supervising";
|
||||
public static final String MODULE = "Module";
|
||||
public static final String FORM = "Form";
|
||||
public static final String ACTION = "Action";
|
||||
|
||||
public static final String URL_FORM = "AlamatUrlForm"; // syamsu
|
||||
public static final String KD_RUANGAN = "KdRuangan"; // syamsu
|
||||
public static final String KD_RUANGAN_T = "KdRuanganT"; // syamsu
|
||||
public static final String KD_RUANGAN_A = "KdRuanganA"; // syamsu
|
||||
public static final String TGL_KIRIM = "tglKirim"; // syamsu
|
||||
// public static final String RUANGAN_TUJUAN = "ruanganTujuan"; // syamsu
|
||||
// public static final String ID_RUANGAN_TUJUAN_ALT = "ruanganTujuanAlt"; // syamsu
|
||||
public static final String TGL_KIRIM = "tglKirim"; // syamsuu
|
||||
public static final String KD_USER = "KdUser"; // syamsu
|
||||
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@ -14,5 +14,4 @@ public final class MessageResource {
|
||||
public static final String LABEL_SUCCESS_CREATED = "label.success.created";
|
||||
public static final String LABEL_SUCCESS_OK = "label.success.ok";
|
||||
public static final String LABEL_UPDATE_DATA_CUTI = "label.update.data.cuti";
|
||||
|
||||
}
|
||||
|
||||
@ -1,35 +1,33 @@
|
||||
package com.jasamedika.medifirst2000.controller;
|
||||
|
||||
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.exception.ServiceVOException;
|
||||
import com.jasamedika.medifirst2000.service.MapRuanganToAkomodasiService;
|
||||
import com.jasamedika.medifirst2000.service.RuanganService;
|
||||
import com.jasamedika.medifirst2000.vo.MapRuanganToAkomodasiVO;
|
||||
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 org.springframework.web.bind.annotation.*;
|
||||
|
||||
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.MapRuanganToAkomodasiService;
|
||||
import com.jasamedika.medifirst2000.service.RuanganService;
|
||||
import com.jasamedika.medifirst2000.util.CommonUtil;
|
||||
import com.jasamedika.medifirst2000.util.rest.RestUtil;
|
||||
import com.jasamedika.medifirst2000.vo.MapRuanganToAkomodasiVO;
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
import javax.validation.Valid;
|
||||
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.LABEL_SUCCESS;
|
||||
import static com.jasamedika.medifirst2000.util.CommonUtil.isNotNullOrEmpty;
|
||||
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.*;
|
||||
|
||||
@RestController
|
||||
@RequestMapping("/akomodasi")
|
||||
@ -41,121 +39,114 @@ public class AkomodasiController extends LocaleController<MapRuanganToAkomodasiV
|
||||
private MapRuanganToAkomodasiService mapRuanganToAkomodasiService;
|
||||
|
||||
@Autowired
|
||||
private RuanganService ruanganService;
|
||||
private RuanganService<?> ruanganService;
|
||||
|
||||
@RequestMapping(value = "/save-mapping", method = RequestMethod.POST, produces = MediaType.APPLICATION_JSON_VALUE, consumes = MediaType.APPLICATION_JSON_VALUE)
|
||||
@RequestMapping(value = "/save-mapping", method = POST, produces = APPLICATION_JSON_VALUE, consumes = APPLICATION_JSON_VALUE)
|
||||
public ResponseEntity<Map<String, Object>> saveMappingAkomodasi(HttpServletRequest request,
|
||||
@Valid @RequestBody MapRuanganToAkomodasiVO vo) {
|
||||
Map<String, Object> result = new HashMap<String, Object>();
|
||||
Map<String, Object> result = new HashMap<>();
|
||||
try {
|
||||
MapRuanganToAkomodasiVO resultVo = new MapRuanganToAkomodasiVO();
|
||||
if (CommonUtil.isNotNullOrEmpty(vo.getId())) {
|
||||
MapRuanganToAkomodasiVO resultVo;
|
||||
if (isNotNullOrEmpty(vo.getId())) {
|
||||
resultVo = mapRuanganToAkomodasiService.update(vo);
|
||||
} else {
|
||||
resultVo = mapRuanganToAkomodasiService.add(vo);
|
||||
}
|
||||
result.put("data", resultVo);
|
||||
if (CommonUtil.isNotNullOrEmpty(result)) {
|
||||
mapHeaderMessage.put(WebConstants.HttpHeaderInfo.LABEL_SUCCESS,
|
||||
getMessage(MessageResource.LABEL_SUCCESS, request));
|
||||
return RestUtil.getJsonResponse(result, HttpStatus.CREATED, mapHeaderMessage);
|
||||
if (isNotNullOrEmpty(result)) {
|
||||
mapHeaderMessage.put(LABEL_SUCCESS, getMessage(MessageResource.LABEL_SUCCESS, request));
|
||||
return getJsonResponse(result, CREATED, mapHeaderMessage);
|
||||
} else {
|
||||
return RestUtil.getJsonHttptatus(HttpStatus.NOT_ACCEPTABLE);
|
||||
return getJsonHttpStatus(NOT_ACCEPTABLE);
|
||||
}
|
||||
} catch (ServiceVOException sve) {
|
||||
LOGGER.error("Got exception {} when add mapping akomodasi", sve.getMessage());
|
||||
addHeaderMessage(Constants.MessageInfo.ERROR_MESSAGE, sve.getMessage());
|
||||
return RestUtil.getJsonHttptatus(HttpStatus.INTERNAL_SERVER_ERROR, mapHeaderMessage);
|
||||
LOGGER.error("Got ServiceVOException {} when add mapping akomodasi", sve.getMessage());
|
||||
addHeaderMessage(ERROR_MESSAGE, sve.getMessage());
|
||||
return getJsonHttpStatus(INTERNAL_SERVER_ERROR, mapHeaderMessage);
|
||||
} catch (JpaSystemException jse) {
|
||||
LOGGER.error("Got exception {} when add mapping akomodasi", jse.getMessage());
|
||||
addHeaderMessage(Constants.MessageInfo.ERROR_MESSAGE, jse.getMessage());
|
||||
return RestUtil.getJsonHttptatus(HttpStatus.CONFLICT, mapHeaderMessage);
|
||||
LOGGER.error("Got JpaSystemException {} when add mapping akomodasi", jse.getMessage());
|
||||
addHeaderMessage(ERROR_MESSAGE, jse.getMessage());
|
||||
return getJsonHttpStatus(CONFLICT, mapHeaderMessage);
|
||||
}
|
||||
}
|
||||
|
||||
@RequestMapping(value = "/delete-mapping", method = RequestMethod.DELETE)
|
||||
@RequestMapping(value = "/delete-mapping", method = DELETE)
|
||||
public ResponseEntity<String> deleteMappingAkomodasi(HttpServletRequest request, @RequestParam("id") Integer id) {
|
||||
try {
|
||||
Boolean result = mapRuanganToAkomodasiService.delete(id);
|
||||
if (result) {
|
||||
return RestUtil.getJsonResponse("Mapping is deleted successsfully", HttpStatus.OK);
|
||||
return getJsonResponse("Mapping is deleted successsfully", OK);
|
||||
} else {
|
||||
return RestUtil.getJsonHttptatus(HttpStatus.NOT_ACCEPTABLE);
|
||||
return getJsonHttpStatus(NOT_ACCEPTABLE);
|
||||
}
|
||||
} catch (ServiceVOException sve) {
|
||||
LOGGER.error("Got exception {} when delete mapping akomodasi", sve.getMessage());
|
||||
addHeaderMessage(Constants.MessageInfo.ERROR_MESSAGE, sve.getMessage());
|
||||
return RestUtil.getJsonHttptatus(HttpStatus.INTERNAL_SERVER_ERROR, mapHeaderMessage);
|
||||
LOGGER.error("Got ServiceVOException {} when delete mapping akomodasi", sve.getMessage());
|
||||
addHeaderMessage(ERROR_MESSAGE, sve.getMessage());
|
||||
return getJsonHttpStatus(INTERNAL_SERVER_ERROR, mapHeaderMessage);
|
||||
} catch (JpaSystemException jse) {
|
||||
LOGGER.error("Got exception {} when delete mapping akomodasi", jse.getMessage());
|
||||
addHeaderMessage(Constants.MessageInfo.ERROR_MESSAGE, jse.getMessage());
|
||||
return RestUtil.getJsonHttptatus(HttpStatus.CONFLICT, mapHeaderMessage);
|
||||
LOGGER.error("Got JpaSystemException {} when delete mapping akomodasi", jse.getMessage());
|
||||
addHeaderMessage(ERROR_MESSAGE, jse.getMessage());
|
||||
return getJsonHttpStatus(CONFLICT, mapHeaderMessage);
|
||||
}
|
||||
}
|
||||
|
||||
@RequestMapping(value = "/get-all-mapping", method = RequestMethod.GET)
|
||||
@RequestMapping(value = "/get-all-mapping", method = GET)
|
||||
public ResponseEntity<List<MapRuanganToAkomodasiVO>> getAllMappingAkomodasi(HttpServletRequest request) {
|
||||
try {
|
||||
List<MapRuanganToAkomodasiVO> result = mapRuanganToAkomodasiService.getAllActiveAkomodasi();
|
||||
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);
|
||||
} catch (ServiceVOException sve) {
|
||||
LOGGER.error("Got exception {} when get all mapping akomodasi", sve.getMessage());
|
||||
addHeaderMessage(Constants.MessageInfo.ERROR_MESSAGE, sve.getMessage());
|
||||
return RestUtil.getJsonHttptatus(HttpStatus.INTERNAL_SERVER_ERROR, mapHeaderMessage);
|
||||
LOGGER.error("Got ServiceVOException {} when get all mapping akomodasi", sve.getMessage());
|
||||
addHeaderMessage(ERROR_MESSAGE, sve.getMessage());
|
||||
return getJsonHttpStatus(INTERNAL_SERVER_ERROR, mapHeaderMessage);
|
||||
} catch (JpaSystemException jse) {
|
||||
LOGGER.error("Got exception {} when get all mapping akomodasi", jse.getMessage());
|
||||
addHeaderMessage(Constants.MessageInfo.ERROR_MESSAGE, jse.getMessage());
|
||||
return RestUtil.getJsonHttptatus(HttpStatus.CONFLICT, mapHeaderMessage);
|
||||
LOGGER.error("Got JpaSystemException {} when get all mapping akomodasi", jse.getMessage());
|
||||
addHeaderMessage(ERROR_MESSAGE, jse.getMessage());
|
||||
return getJsonHttpStatus(CONFLICT, mapHeaderMessage);
|
||||
}
|
||||
}
|
||||
|
||||
@RequestMapping(value = "/get-mapping", method = RequestMethod.GET)
|
||||
@RequestMapping(value = "/get-mapping", method = GET)
|
||||
public ResponseEntity<MapRuanganToAkomodasiVO> getMappingAkomodasi(HttpServletRequest request,
|
||||
@RequestParam("id") Integer id) {
|
||||
try {
|
||||
MapRuanganToAkomodasiVO result = mapRuanganToAkomodasiService.findById(id);
|
||||
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);
|
||||
} catch (ServiceVOException sve) {
|
||||
LOGGER.error("Got exception {} when get all mapping akomodasi", sve.getMessage());
|
||||
addHeaderMessage(Constants.MessageInfo.ERROR_MESSAGE, sve.getMessage());
|
||||
return RestUtil.getJsonHttptatus(HttpStatus.INTERNAL_SERVER_ERROR, mapHeaderMessage);
|
||||
LOGGER.error("Got ServiceVOException {} when findById", sve.getMessage());
|
||||
addHeaderMessage(ERROR_MESSAGE, sve.getMessage());
|
||||
return getJsonHttpStatus(INTERNAL_SERVER_ERROR, mapHeaderMessage);
|
||||
} catch (JpaSystemException jse) {
|
||||
LOGGER.error("Got exception {} when get all mapping akomodasi", jse.getMessage());
|
||||
addHeaderMessage(Constants.MessageInfo.ERROR_MESSAGE, jse.getMessage());
|
||||
return RestUtil.getJsonHttptatus(HttpStatus.CONFLICT, mapHeaderMessage);
|
||||
LOGGER.error("Got JpaSystemException {} when findById", jse.getMessage());
|
||||
addHeaderMessage(ERROR_MESSAGE, jse.getMessage());
|
||||
return getJsonHttpStatus(CONFLICT, mapHeaderMessage);
|
||||
}
|
||||
}
|
||||
|
||||
@RequestMapping(value = "/get-kamar-by-ruangan", method = RequestMethod.GET, produces = MediaType.APPLICATION_JSON_VALUE)
|
||||
@RequestMapping(value = "/get-kamar-by-ruangan", method = GET, produces = APPLICATION_JSON_VALUE)
|
||||
public ResponseEntity<List<Map<String, Object>>> getKamarByRuangan(HttpServletRequest request,
|
||||
@RequestParam(value = "idRuangan", required = true) Integer idRuangan) {
|
||||
List<Map<String, Object>> result = null;
|
||||
@RequestParam(value = "idRuangan") Integer idRuangan) {
|
||||
try {
|
||||
result = ruanganService.findKamarByRuangan(idRuangan);
|
||||
mapHeaderMessage.put(WebConstants.HttpHeaderInfo.LABEL_SUCCESS,
|
||||
getMessage(MessageResource.LABEL_SUCCESS, request));
|
||||
List<Map<String, Object>> result = ruanganService.findKamarByRuangan(idRuangan);
|
||||
mapHeaderMessage.put(LABEL_SUCCESS, getMessage(MessageResource.LABEL_SUCCESS, request));
|
||||
return getJsonResponse(result, OK);
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
throw new ServiceVOException(e.getMessage());
|
||||
}
|
||||
return RestUtil.getJsonResponse(result, HttpStatus.OK);
|
||||
}
|
||||
|
||||
@RequestMapping(value = "/get-akomodasi-ruangan-by-mapping-produk", method = RequestMethod.GET, produces = MediaType.APPLICATION_JSON_VALUE)
|
||||
@RequestMapping(value = "/get-akomodasi-ruangan-by-mapping-produk", method = GET, produces = APPLICATION_JSON_VALUE)
|
||||
public ResponseEntity<List<Map<String, Object>>> getAkomodasiRuanganByMappingProduk(HttpServletRequest request,
|
||||
@RequestParam(value = "idRuangan", required = true) Integer idRuangan) {
|
||||
List<Map<String, Object>> result = null;
|
||||
@RequestParam(value = "idRuangan") Integer idRuangan) {
|
||||
try {
|
||||
result = mapRuanganToAkomodasiService.getAkomodasiRuanganByMapProduk(idRuangan);
|
||||
mapHeaderMessage.put(WebConstants.HttpHeaderInfo.LABEL_SUCCESS,
|
||||
getMessage(MessageResource.LABEL_SUCCESS, request));
|
||||
List<Map<String, Object>> result = mapRuanganToAkomodasiService.getAkomodasiRuanganByMapProduk(idRuangan);
|
||||
mapHeaderMessage.put(LABEL_SUCCESS, getMessage(MessageResource.LABEL_SUCCESS, request));
|
||||
return getJsonResponse(result, HttpStatus.OK);
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
throw new ServiceVOException(e.getMessage());
|
||||
}
|
||||
return RestUtil.getJsonResponse(result, HttpStatus.OK);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@ -1,82 +1,62 @@
|
||||
package com.jasamedika.medifirst2000.controller;
|
||||
|
||||
import java.io.UnsupportedEncodingException;
|
||||
import java.lang.reflect.Field;
|
||||
import java.net.URLDecoder;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import com.jasamedika.medifirst2000.controller.base.LocaleController;
|
||||
import com.jasamedika.medifirst2000.service.ModelService;
|
||||
import com.jasamedika.medifirst2000.util.JsonUtil;
|
||||
import com.jasamedika.medifirst2000.vo.AntrianPasienRegistrasiVO;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.http.HttpHeaders;
|
||||
import org.springframework.http.ResponseEntity;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.bind.annotation.RequestParam;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
|
||||
import javax.persistence.Column;
|
||||
import javax.persistence.JoinColumn;
|
||||
import javax.persistence.OneToMany;
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
import java.io.UnsupportedEncodingException;
|
||||
import java.lang.reflect.Field;
|
||||
import java.net.URLDecoder;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
import org.json.JSONException;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.http.HttpHeaders;
|
||||
import org.springframework.http.HttpStatus;
|
||||
import org.springframework.http.MediaType;
|
||||
import org.springframework.http.ResponseEntity;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.bind.annotation.RequestMethod;
|
||||
import org.springframework.web.bind.annotation.RequestParam;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
|
||||
import com.jasamedika.medifirst2000.base.vo.BaseMasterVO;
|
||||
import com.jasamedika.medifirst2000.base.vo.BaseModelVO;
|
||||
import com.jasamedika.medifirst2000.base.vo.BaseTransactionVO;
|
||||
import com.jasamedika.medifirst2000.controller.base.LocaleController;
|
||||
import com.jasamedika.medifirst2000.service.ModelService;
|
||||
import com.jasamedika.medifirst2000.util.JsonUtil;
|
||||
import com.jasamedika.medifirst2000.util.rest.RestUtil;
|
||||
import com.jasamedika.medifirst2000.vo.AntrianPasienRegistrasiVO;
|
||||
import static com.jasamedika.medifirst2000.util.rest.RestUtil.getJsonResponse;
|
||||
import static org.springframework.http.HttpStatus.CREATED;
|
||||
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;
|
||||
|
||||
@RestController
|
||||
@RequestMapping("/service")
|
||||
public class GenericServiceController extends LocaleController<AntrianPasienRegistrasiVO> {
|
||||
|
||||
@Autowired
|
||||
private ModelService<?> modelService;
|
||||
private static final Logger LOG = LoggerFactory.getLogger(GenericServiceController.class);
|
||||
|
||||
private static final String CONTENT_TYPE = "Content-Type";
|
||||
|
||||
@SuppressWarnings("rawtypes")
|
||||
public static List<Field> GetFields(Class data) {
|
||||
List<Field> items = new ArrayList<Field>();
|
||||
Class parent = data.getSuperclass();
|
||||
Class tmpClass = null;
|
||||
if (BaseModelVO.class.isAssignableFrom(data.getClass())) {
|
||||
tmpClass = BaseTransactionVO.class;
|
||||
} else if (BaseTransactionVO.class.isAssignableFrom(data.getClass())) {
|
||||
tmpClass = BaseMasterVO.class;
|
||||
}
|
||||
@Autowired
|
||||
private ModelService<?> modelService;
|
||||
|
||||
if ((data == tmpClass)) {
|
||||
for (Field field : data.getDeclaredFields()) {
|
||||
items.add(field);
|
||||
}
|
||||
return items;
|
||||
}
|
||||
|
||||
if (parent != null) {
|
||||
for (Field field : GetFields(data.getSuperclass())) {
|
||||
items.add(field);
|
||||
}
|
||||
}
|
||||
|
||||
for (Field field : data.getDeclaredFields()) {
|
||||
items.add(field);
|
||||
}
|
||||
public static List<Field> GetFields(Class<?> data) {
|
||||
List<Field> items = new ArrayList<>();
|
||||
Class<?> parent = data.getSuperclass();
|
||||
if (parent != null)
|
||||
items.addAll(GetFields(data.getSuperclass()));
|
||||
items.addAll(Arrays.asList(data.getDeclaredFields()));
|
||||
return items;
|
||||
}
|
||||
|
||||
@RequestMapping(value = "/get-setting/", method = RequestMethod.GET, produces = MediaType.APPLICATION_JSON_VALUE)
|
||||
@RequestMapping(value = "/get-setting/", method = GET, produces = APPLICATION_JSON_VALUE)
|
||||
public ResponseEntity<String> getData(@RequestParam(value = "prefix", required = false) String prefix) {
|
||||
|
||||
return RestUtil.getJsonResponse(GetSettingDataFixed(prefix), HttpStatus.CREATED, mapHeaderMessage);
|
||||
return getJsonResponse(GetSettingDataFixed(prefix), CREATED, mapHeaderMessage);
|
||||
}
|
||||
|
||||
@RequestMapping(value = "/list-generic/", method = RequestMethod.GET, produces = MediaType.APPLICATION_JSON_VALUE)
|
||||
@RequestMapping(value = "/list-generic/", method = GET, produces = APPLICATION_JSON_VALUE)
|
||||
public ResponseEntity<List<Map<String, Object>>> listGeneric(
|
||||
@RequestParam(value = "view", required = false) String entity,
|
||||
@RequestParam(value = "select", required = false) String field,
|
||||
@ -91,72 +71,59 @@ public class GenericServiceController extends LocaleController<AntrianPasienRegi
|
||||
@RequestParam(value = "filter[filters][0][ignoreCase]", required = false) String ignorecase,
|
||||
@RequestParam(value = "criteria", required = false) String criteria,
|
||||
@RequestParam(value = "values", required = false) String values, HttpServletRequest request)
|
||||
throws SecurityException, ClassNotFoundException, JSONException, UnsupportedEncodingException {
|
||||
|
||||
throws SecurityException, ClassNotFoundException, UnsupportedEncodingException {
|
||||
String data = request.getQueryString();
|
||||
data = URLDecoder.decode(data, "UTF-8");
|
||||
String[] arrQueries = data.split("&");
|
||||
StringBuilder criteriaBuilder = new StringBuilder(criteria);
|
||||
StringBuilder valuesBuilder = new StringBuilder(values);
|
||||
for (String query : arrQueries) {
|
||||
if (query.indexOf("filter[filters][0][filter][field]") >= 0) {
|
||||
if (criteria == null)
|
||||
criteria = query.replace("filter[filters][0][filter][field]=", "");
|
||||
else
|
||||
criteria += "," + query.replace("filter[filters][0][filter][field]=", "");
|
||||
|
||||
} else if (query.indexOf("filter[filters][0][filter][value]") >= 0) {
|
||||
if (values == null)
|
||||
values = query.replace("filter[filters][0][filter][value]=", "");
|
||||
else
|
||||
values += "," + query.replace("filter[filters][0][filter][value]=", "");
|
||||
if (query.contains("filter[filters][0][filter][field]")) {
|
||||
criteriaBuilder.append(",").append(query.replace("filter[filters][0][filter][field]=", ""));
|
||||
} else if (query.contains("filter[filters][0][filter][value]")) {
|
||||
valuesBuilder.append(",").append(query.replace("filter[filters][0][filter][value]=", ""));
|
||||
}
|
||||
}
|
||||
|
||||
values = valuesBuilder.toString();
|
||||
criteria = criteriaBuilder.toString();
|
||||
if (field.equals("*")) {
|
||||
field = "";
|
||||
|
||||
StringBuilder fieldBuilder = new StringBuilder();
|
||||
for (Field fieldItem : GetFields(Class.forName("com.jasamedika.medifirst2000.entities." + entity))) {
|
||||
{
|
||||
String name = fieldItem.getName();
|
||||
if (name.equals("serialVersionsUID"))
|
||||
continue;
|
||||
Boolean valid = false;
|
||||
for (java.lang.annotation.Annotation annotation : fieldItem.getDeclaredAnnotations()) {
|
||||
if (annotation instanceof JoinColumn) {
|
||||
valid = true;
|
||||
} else if (annotation instanceof Column) {
|
||||
Column column = (Column) annotation;
|
||||
if (column.name().endsWith("Fk"))
|
||||
if (fieldItem.getName().endsWith("Id") == false)
|
||||
valid = true;
|
||||
} else if (annotation instanceof OneToMany) {
|
||||
|
||||
valid = true;
|
||||
}
|
||||
|
||||
String name = fieldItem.getName();
|
||||
if (name.equals("serialVersionsUID"))
|
||||
continue;
|
||||
boolean valid = false;
|
||||
for (java.lang.annotation.Annotation annotation : fieldItem.getDeclaredAnnotations()) {
|
||||
if (annotation instanceof JoinColumn) {
|
||||
valid = true;
|
||||
} else if (annotation instanceof Column) {
|
||||
Column column = (Column) annotation;
|
||||
if (column.name().endsWith("Fk"))
|
||||
if (!fieldItem.getName().endsWith("Id"))
|
||||
valid = true;
|
||||
} else if (annotation instanceof OneToMany) {
|
||||
valid = true;
|
||||
}
|
||||
if (valid == false)
|
||||
if (field.equals(""))
|
||||
field += fieldItem.getName();
|
||||
else
|
||||
field += "," + fieldItem.getName();
|
||||
}
|
||||
if (!valid)
|
||||
if (fieldBuilder.toString().isEmpty())
|
||||
fieldBuilder.append(fieldItem.getName());
|
||||
else
|
||||
fieldBuilder.append(",").append(fieldItem.getName());
|
||||
}
|
||||
field = fieldBuilder.toString();
|
||||
} else if (field.equals("**")) {
|
||||
field = "*";
|
||||
}
|
||||
|
||||
// for dateformat using [date]
|
||||
List<Map<String, Object>> modelGenericVO = modelService.getAllData(entity, field, take, skip, page, pageSize,
|
||||
logic, value, fieldS, operator, ignorecase, criteria, values);
|
||||
HttpHeaders headers = new HttpHeaders();
|
||||
headers.set(CONTENT_TYPE, MediaType.APPLICATION_JSON_VALUE);
|
||||
headers.set(CONTENT_TYPE, APPLICATION_JSON_VALUE);
|
||||
try {
|
||||
return new ResponseEntity<List<Map<String, Object>>>(JsonUtil.ToMaps(modelGenericVO), headers,
|
||||
HttpStatus.OK);
|
||||
return new ResponseEntity<>(JsonUtil.ToMaps(modelGenericVO), headers, OK);
|
||||
} catch (IllegalArgumentException | IllegalAccessException e) {
|
||||
e.printStackTrace();
|
||||
LOG.error(e.getMessage());
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
@ -1,29 +1,29 @@
|
||||
package com.jasamedika.medifirst2000.controller;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.http.HttpStatus;
|
||||
import org.springframework.http.MediaType;
|
||||
import org.springframework.http.ResponseEntity;
|
||||
import org.springframework.orm.jpa.JpaSystemException;
|
||||
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.entities.PgStatActivity;
|
||||
import com.jasamedika.medifirst2000.exception.ServiceVOException;
|
||||
import com.jasamedika.medifirst2000.service.PgStatActivityService;
|
||||
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.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.bind.annotation.RequestParam;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
import java.util.List;
|
||||
|
||||
import static com.jasamedika.medifirst2000.core.web.WebConstants.HttpHeaderInfo.LABEL_SUCCESS;
|
||||
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("/integrasi")
|
||||
@ -34,59 +34,61 @@ public class IntegrationController extends LocaleController<LoginUserVO> {
|
||||
@Autowired
|
||||
private PgStatActivityService pgStatActivityService;
|
||||
|
||||
@RequestMapping(value = "/pg-stat-activity/in-state-for-minutes", method = RequestMethod.GET, produces = MediaType.APPLICATION_JSON_VALUE)
|
||||
@RequestMapping(value = "/pg-stat-activity/in-state-for-minutes", method = GET, produces = APPLICATION_JSON_VALUE)
|
||||
public ResponseEntity<List<PgStatActivity>> getPgStatActivityInStateForMinutes(HttpServletRequest request) {
|
||||
try {
|
||||
List<PgStatActivity> result = pgStatActivityService.findByStateAndInterval();
|
||||
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);
|
||||
} catch (ServiceVOException e) {
|
||||
LOGGER.error("Got exception {} when get pg_stat_activity in state for minutes", e.getMessage());
|
||||
mapHeaderMessage.put(WebConstants.HttpHeaderInfo.LABEL_SUCCESS, e.getMessage());
|
||||
return RestUtil.getJsonResponse(HttpStatus.INTERNAL_SERVER_ERROR, mapHeaderMessage);
|
||||
LOGGER.error("Got ServiceVOException {} when pgStatActivityService.findByStateAndInterval", e.getMessage());
|
||||
mapHeaderMessage.put(LABEL_SUCCESS, e.getMessage());
|
||||
return getJsonResponse(INTERNAL_SERVER_ERROR, mapHeaderMessage);
|
||||
} catch (JpaSystemException jse) {
|
||||
LOGGER.error("Got exception {} when get pg_stat_activity in state for minutes", jse.getMessage());
|
||||
mapHeaderMessage.put(WebConstants.HttpHeaderInfo.LABEL_SUCCESS, jse.getMessage());
|
||||
return RestUtil.getJsonResponse(HttpStatus.CONFLICT, mapHeaderMessage);
|
||||
LOGGER.error("Got JpaSystemException {} when pgStatActivityService.findByStateAndInterval",
|
||||
jse.getMessage());
|
||||
mapHeaderMessage.put(LABEL_SUCCESS, jse.getMessage());
|
||||
return getJsonResponse(CONFLICT, mapHeaderMessage);
|
||||
}
|
||||
}
|
||||
|
||||
@RequestMapping(value = "/pg-stat-activity/cancel-backend", method = RequestMethod.POST)
|
||||
@RequestMapping(value = "/pg-stat-activity/cancel-backend", method = POST)
|
||||
public ResponseEntity<Boolean> callPgCancelBackend(HttpServletRequest request,
|
||||
@RequestParam(value = "pid", required = true) Integer pid) {
|
||||
@RequestParam(value = "pid") Integer pid) {
|
||||
try {
|
||||
Boolean result = pgStatActivityService.callCancelBackend(pid);
|
||||
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);
|
||||
} catch (ServiceVOException sve) {
|
||||
LOGGER.error("Got exception {} when call pg_cancel_backend pid : {}", sve.getMessage(), pid);
|
||||
mapHeaderMessage.put(WebConstants.HttpHeaderInfo.LABEL_SUCCESS, sve.getMessage());
|
||||
return RestUtil.getJsonResponse(HttpStatus.INTERNAL_SERVER_ERROR, mapHeaderMessage);
|
||||
LOGGER.error("Got ServiceVOException {} when pgStatActivityService.callCancelBackend : {}",
|
||||
sve.getMessage(), pid);
|
||||
mapHeaderMessage.put(LABEL_SUCCESS, sve.getMessage());
|
||||
return getJsonResponse(INTERNAL_SERVER_ERROR, mapHeaderMessage);
|
||||
} catch (JpaSystemException jse) {
|
||||
LOGGER.error("Got exception {} when call pg_cancel_backend pid : {}", jse.getMessage(), pid);
|
||||
mapHeaderMessage.put(WebConstants.HttpHeaderInfo.LABEL_SUCCESS, jse.getMessage());
|
||||
return RestUtil.getJsonResponse(HttpStatus.CONFLICT, mapHeaderMessage);
|
||||
LOGGER.error("Got JpaSystemException {} when pgStatActivityService.callCancelBackend : {}",
|
||||
jse.getMessage(), pid);
|
||||
mapHeaderMessage.put(LABEL_SUCCESS, jse.getMessage());
|
||||
return getJsonResponse(CONFLICT, mapHeaderMessage);
|
||||
}
|
||||
}
|
||||
|
||||
@RequestMapping(value = "/pg-stat-activity/terminate-backend", method = RequestMethod.POST)
|
||||
@RequestMapping(value = "/pg-stat-activity/terminate-backend", method = POST)
|
||||
public ResponseEntity<Boolean> callPgTerminateBackend(HttpServletRequest request,
|
||||
@RequestParam(value = "pid", required = true) Integer pid) {
|
||||
@RequestParam(value = "pid") Integer pid) {
|
||||
try {
|
||||
Boolean result = pgStatActivityService.callTerminateBackend(pid);
|
||||
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);
|
||||
} catch (ServiceVOException sve) {
|
||||
LOGGER.error("Got exception {} when call pg_terminate_backend pid : {}", sve.getMessage(), pid);
|
||||
mapHeaderMessage.put(WebConstants.HttpHeaderInfo.LABEL_SUCCESS, sve.getMessage());
|
||||
return RestUtil.getJsonResponse(HttpStatus.INTERNAL_SERVER_ERROR, mapHeaderMessage);
|
||||
LOGGER.error("Got ServiceVOException {} when pgStatActivityService.callTerminateBackend : {}",
|
||||
sve.getMessage(), pid);
|
||||
mapHeaderMessage.put(LABEL_SUCCESS, sve.getMessage());
|
||||
return getJsonResponse(INTERNAL_SERVER_ERROR, mapHeaderMessage);
|
||||
} catch (JpaSystemException jse) {
|
||||
LOGGER.error("Got exception {} when call pg_terminate_backend pid : {}", jse.getMessage(), pid);
|
||||
mapHeaderMessage.put(WebConstants.HttpHeaderInfo.LABEL_SUCCESS, jse.getMessage());
|
||||
return RestUtil.getJsonResponse(HttpStatus.CONFLICT, mapHeaderMessage);
|
||||
LOGGER.error("Got JpaSystemException {} when pgStatActivityService.callTerminateBackend : {}",
|
||||
jse.getMessage(), pid);
|
||||
mapHeaderMessage.put(LABEL_SUCCESS, jse.getMessage());
|
||||
return getJsonResponse(CONFLICT, mapHeaderMessage);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@ -1,36 +1,35 @@
|
||||
package com.jasamedika.medifirst2000.controller;
|
||||
|
||||
import java.text.ParseException;
|
||||
import java.util.ArrayList;
|
||||
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.JabatanService;
|
||||
import com.jasamedika.medifirst2000.util.CommonUtil;
|
||||
import com.jasamedika.medifirst2000.vo.JabatanVO;
|
||||
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.JabatanService;
|
||||
import com.jasamedika.medifirst2000.util.CommonUtil;
|
||||
import com.jasamedika.medifirst2000.util.rest.RestUtil;
|
||||
import com.jasamedika.medifirst2000.vo.JabatanVO;
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
import javax.validation.Valid;
|
||||
import java.util.Collection;
|
||||
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.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.*;
|
||||
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("/jabatan")
|
||||
@ -41,137 +40,125 @@ public class JabatanController extends LocaleController<JabatanVO> {
|
||||
@Autowired
|
||||
private JabatanService jabatanService;
|
||||
|
||||
@RequestMapping(value = "/save-jabatan-internal/", method = RequestMethod.POST, produces = MediaType.APPLICATION_JSON_VALUE, consumes = MediaType.APPLICATION_JSON_VALUE)
|
||||
@RequestMapping(value = "/save-jabatan-internal/", method = POST, produces = APPLICATION_JSON_VALUE, consumes = APPLICATION_JSON_VALUE)
|
||||
public ResponseEntity<String> addVO(@Valid @RequestBody JabatanVO vo, HttpServletRequest request) {
|
||||
try {
|
||||
|
||||
Map<String, Object> result = jabatanService.saveJabatan(vo);
|
||||
|
||||
if (null != result)
|
||||
mapHeaderMessage.put(WebConstants.HttpHeaderInfo.LABEL_SUCCESS,
|
||||
getMessage(MessageResource.LABEL_SUCCESS, request));
|
||||
return RestUtil.getJsonResponse(result.toString(), HttpStatus.CREATED, mapHeaderMessage);
|
||||
mapHeaderMessage.put(LABEL_SUCCESS, getMessage(MessageResource.LABEL_SUCCESS, request));
|
||||
return getJsonResponse("New jabatan successfully created", CREATED, mapHeaderMessage);
|
||||
} catch (ServiceVOException e) {
|
||||
LOGGER.error("Got exception {} when add jabatan", e.getMessage());
|
||||
addHeaderMessage(Constants.MessageInfo.ERROR_MESSAGE, e.getMessage());
|
||||
return RestUtil.getJsonHttptatus(HttpStatus.INTERNAL_SERVER_ERROR, mapHeaderMessage);
|
||||
LOGGER.error("Got ServiceVOException {} when saveJabatan", e.getMessage());
|
||||
addHeaderMessage(ERROR_MESSAGE, e.getMessage());
|
||||
return getJsonHttpStatus(INTERNAL_SERVER_ERROR, mapHeaderMessage);
|
||||
} catch (JpaSystemException jse) {
|
||||
LOGGER.error("Got exception {} when add jabatan", jse.getMessage());
|
||||
addHeaderMessage(Constants.MessageInfo.ERROR_MESSAGE, jse.getMessage());
|
||||
return RestUtil.getJsonHttptatus(HttpStatus.CONFLICT, mapHeaderMessage);
|
||||
LOGGER.error("Got JpaSystemException {} when saveJabatan", jse.getMessage());
|
||||
addHeaderMessage(ERROR_MESSAGE, jse.getMessage());
|
||||
return getJsonHttpStatus(CONFLICT, mapHeaderMessage);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@RequestMapping(value = "/update-jabatan/", method = RequestMethod.POST, produces = MediaType.APPLICATION_JSON_VALUE, consumes = MediaType.APPLICATION_JSON_VALUE)
|
||||
@RequestMapping(value = "/update-jabatan/", method = POST, produces = APPLICATION_JSON_VALUE, consumes = APPLICATION_JSON_VALUE)
|
||||
public ResponseEntity<String> editVO(@Valid @RequestBody JabatanVO vo) {
|
||||
try {
|
||||
JabatanVO result = (JabatanVO) jabatanService.update(vo);
|
||||
|
||||
JabatanVO result = jabatanService.update(vo);
|
||||
if (null != result)
|
||||
return RestUtil.getJsonResponse("", HttpStatus.OK);
|
||||
return getJsonResponse("Jabatan successfully updated", OK);
|
||||
} catch (ServiceVOException e) {
|
||||
LOGGER.error("Got exception {} when update Agama", e.getMessage());
|
||||
addHeaderMessage(Constants.MessageInfo.ERROR_MESSAGE, e.getMessage());
|
||||
return RestUtil.getJsonHttptatus(HttpStatus.INTERNAL_SERVER_ERROR, mapHeaderMessage);
|
||||
LOGGER.error("Got ServiceVOException {} when jabatanService.update", e.getMessage());
|
||||
addHeaderMessage(ERROR_MESSAGE, e.getMessage());
|
||||
return getJsonHttpStatus(INTERNAL_SERVER_ERROR, mapHeaderMessage);
|
||||
} catch (JpaSystemException jse) {
|
||||
LOGGER.error("Got exception {} when update Agama", jse.getMessage());
|
||||
addHeaderMessage(Constants.MessageInfo.ERROR_MESSAGE, jse.getMessage());
|
||||
return RestUtil.getJsonHttptatus(HttpStatus.CONFLICT, mapHeaderMessage);
|
||||
LOGGER.error("Got JpaSystemException {} when jabatanService.update", jse.getMessage());
|
||||
addHeaderMessage(ERROR_MESSAGE, jse.getMessage());
|
||||
return getJsonHttpStatus(CONFLICT, mapHeaderMessage);
|
||||
}
|
||||
|
||||
return RestUtil.getJsonHttptatus(HttpStatus.NOT_ACCEPTABLE);
|
||||
return getJsonHttpStatus(NOT_ACCEPTABLE);
|
||||
}
|
||||
|
||||
@RequestMapping(value = "/update-jabatan-false/", method = RequestMethod.POST, produces = MediaType.APPLICATION_JSON_VALUE, consumes = MediaType.APPLICATION_JSON_VALUE)
|
||||
@RequestMapping(value = "/update-jabatan-false/", method = POST, produces = APPLICATION_JSON_VALUE, consumes = APPLICATION_JSON_VALUE)
|
||||
public ResponseEntity<String> editFalseVO(@Valid @RequestBody JabatanVO vo) {
|
||||
try {
|
||||
JabatanVO result = (JabatanVO) jabatanService.deleteJabatan(vo);
|
||||
|
||||
JabatanVO result = jabatanService.deleteJabatan(vo);
|
||||
if (null != result)
|
||||
return RestUtil.getJsonResponse("", HttpStatus.OK);
|
||||
return getJsonResponse("Jabatan successfully updated", OK);
|
||||
} catch (ServiceVOException e) {
|
||||
LOGGER.error("Got exception {} when update Agama", e.getMessage());
|
||||
addHeaderMessage(Constants.MessageInfo.ERROR_MESSAGE, e.getMessage());
|
||||
return RestUtil.getJsonHttptatus(HttpStatus.INTERNAL_SERVER_ERROR, mapHeaderMessage);
|
||||
LOGGER.error("Got ServiceVOException {} when deleteJabatan", e.getMessage());
|
||||
addHeaderMessage(ERROR_MESSAGE, e.getMessage());
|
||||
return getJsonHttpStatus(INTERNAL_SERVER_ERROR, mapHeaderMessage);
|
||||
} catch (JpaSystemException jse) {
|
||||
LOGGER.error("Got exception {} when update Agama", jse.getMessage());
|
||||
addHeaderMessage(Constants.MessageInfo.ERROR_MESSAGE, jse.getMessage());
|
||||
return RestUtil.getJsonHttptatus(HttpStatus.CONFLICT, mapHeaderMessage);
|
||||
LOGGER.error("Got JpaSystemException {} when deleteJabatan", jse.getMessage());
|
||||
addHeaderMessage(ERROR_MESSAGE, jse.getMessage());
|
||||
return getJsonHttpStatus(CONFLICT, mapHeaderMessage);
|
||||
}
|
||||
|
||||
return RestUtil.getJsonHttptatus(HttpStatus.NOT_ACCEPTABLE);
|
||||
return getJsonHttpStatus(NOT_ACCEPTABLE);
|
||||
}
|
||||
|
||||
@RequestMapping(value = "/delete-jabatan/", method = RequestMethod.GET, produces = MediaType.APPLICATION_JSON_VALUE)
|
||||
public ResponseEntity<String> deleteVO(@RequestParam(value = "id", required = true) Integer id,
|
||||
HttpServletRequest request) {
|
||||
@RequestMapping(value = "/delete-jabatan/", method = GET, produces = APPLICATION_JSON_VALUE)
|
||||
public ResponseEntity<String> deleteVO(@RequestParam(value = "id") Integer id, HttpServletRequest request) {
|
||||
try {
|
||||
boolean result = jabatanService.delete(id);
|
||||
|
||||
return RestUtil.getJsonResponse(String.valueOf(result), HttpStatus.CREATED);
|
||||
|
||||
if (result)
|
||||
return getJsonResponse("Jabatan successfully deleted");
|
||||
} catch (ServiceVOException e) {
|
||||
LOGGER.error("Got exception {} when delete Jabatan", e.getMessage());
|
||||
addHeaderMessage(Constants.MessageInfo.ERROR_MESSAGE, e.getMessage());
|
||||
return RestUtil.getJsonHttptatus(HttpStatus.INTERNAL_SERVER_ERROR, mapHeaderMessage);
|
||||
LOGGER.error("Got ServiceVOException {} when jabatanService.delete", e.getMessage());
|
||||
addHeaderMessage(ERROR_MESSAGE, e.getMessage());
|
||||
return getJsonHttpStatus(INTERNAL_SERVER_ERROR, mapHeaderMessage);
|
||||
} catch (JpaSystemException jse) {
|
||||
LOGGER.error("Got exception {} when delete Jabatan", jse.getMessage());
|
||||
addHeaderMessage(Constants.MessageInfo.ERROR_MESSAGE, jse.getMessage());
|
||||
return RestUtil.getJsonHttptatus(HttpStatus.CONFLICT, mapHeaderMessage);
|
||||
LOGGER.error("Got JpaSystemException {} when jabatanService.delete", jse.getMessage());
|
||||
addHeaderMessage(ERROR_MESSAGE, jse.getMessage());
|
||||
return getJsonHttpStatus(CONFLICT, mapHeaderMessage);
|
||||
}
|
||||
return getJsonHttpStatus(NOT_ACCEPTABLE);
|
||||
}
|
||||
|
||||
@RequestMapping(value = "/save-master-jabatan", method = RequestMethod.POST, produces = MediaType.APPLICATION_JSON_VALUE, consumes = MediaType.APPLICATION_JSON_VALUE)
|
||||
@RequestMapping(value = "/save-master-jabatan", method = POST, produces = APPLICATION_JSON_VALUE, consumes = APPLICATION_JSON_VALUE)
|
||||
public ResponseEntity<JabatanVO> saveJabatan(HttpServletRequest request, @Valid @RequestBody JabatanVO vo) {
|
||||
try {
|
||||
JabatanVO result = new JabatanVO();
|
||||
JabatanVO result;
|
||||
if (CommonUtil.isNotNullOrEmpty(vo.getId())) {
|
||||
result = jabatanService.update(vo);
|
||||
} else {
|
||||
result = jabatanService.add(vo);
|
||||
}
|
||||
if (CommonUtil.isNotNullOrEmpty(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);
|
||||
} else {
|
||||
return RestUtil.getJsonHttptatus(HttpStatus.NOT_ACCEPTABLE);
|
||||
return getJsonHttpStatus(NOT_ACCEPTABLE);
|
||||
}
|
||||
} catch (ServiceVOException sve) {
|
||||
LOGGER.error("Got exception {} when add/update master jabatan", sve.getMessage());
|
||||
addHeaderMessage(Constants.MessageInfo.ERROR_MESSAGE, sve.getMessage());
|
||||
return RestUtil.getJsonHttptatus(HttpStatus.INTERNAL_SERVER_ERROR, mapHeaderMessage);
|
||||
LOGGER.error("Got ServiceVOException {} when jabatanService add/update", sve.getMessage());
|
||||
addHeaderMessage(ERROR_MESSAGE, sve.getMessage());
|
||||
return getJsonHttpStatus(INTERNAL_SERVER_ERROR, mapHeaderMessage);
|
||||
} catch (JpaSystemException jse) {
|
||||
LOGGER.error("Got exception {} when add/update master jabatan", jse.getMessage());
|
||||
addHeaderMessage(Constants.MessageInfo.ERROR_MESSAGE, jse.getMessage());
|
||||
return RestUtil.getJsonHttptatus(HttpStatus.CONFLICT, mapHeaderMessage);
|
||||
LOGGER.error("Got JpaSystemException {} when jabatanService add/update", jse.getMessage());
|
||||
addHeaderMessage(ERROR_MESSAGE, jse.getMessage());
|
||||
return getJsonHttpStatus(CONFLICT, mapHeaderMessage);
|
||||
}
|
||||
}
|
||||
|
||||
@RequestMapping(value = "/get-master-jabatan", method = RequestMethod.GET)
|
||||
@RequestMapping(value = "/get-master-jabatan", method = GET)
|
||||
public ResponseEntity<List<Map<String, Object>>> getMasterJabatan(HttpServletRequest request,
|
||||
@RequestParam(value = "namaJabatan", required = false) String namaJabatan,
|
||||
@RequestParam(value = "jenisJabatanId", required = false) Integer idJenisJabatan,
|
||||
@RequestParam(value = "unitKerjaId", required = false) Integer idUnitKerja) throws ParseException {
|
||||
@RequestParam(value = "unitKerjaId", required = false) Integer idUnitKerja) {
|
||||
try {
|
||||
List<Map<String, Object>> result = jabatanService.findJabatan(namaJabatan, idJenisJabatan, idUnitKerja);
|
||||
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);
|
||||
} catch (ServiceVOException sve) {
|
||||
LOGGER.error("Got exception {} when get master jabatan", sve.getMessage());
|
||||
addHeaderMessage(Constants.MessageInfo.ERROR_MESSAGE, sve.getMessage());
|
||||
return RestUtil.getJsonHttptatus(HttpStatus.INTERNAL_SERVER_ERROR, mapHeaderMessage);
|
||||
LOGGER.error("Got ServiceVOException {} when findJabatan", sve.getMessage());
|
||||
addHeaderMessage(ERROR_MESSAGE, sve.getMessage());
|
||||
return getJsonHttpStatus(INTERNAL_SERVER_ERROR, mapHeaderMessage);
|
||||
} catch (JpaSystemException jse) {
|
||||
LOGGER.error("Got exception {} when get master jabatan", jse.getMessage());
|
||||
addHeaderMessage(Constants.MessageInfo.ERROR_MESSAGE, jse.getMessage());
|
||||
return RestUtil.getJsonHttptatus(HttpStatus.CONFLICT, mapHeaderMessage);
|
||||
LOGGER.error("Got JpaSystemException {} when findJabatan", jse.getMessage());
|
||||
addHeaderMessage(ERROR_MESSAGE, jse.getMessage());
|
||||
return getJsonHttpStatus(CONFLICT, mapHeaderMessage);
|
||||
}
|
||||
}
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
@RequestMapping(value = "/search-jabatan", method = RequestMethod.GET, produces = MediaType.APPLICATION_JSON_VALUE)
|
||||
@RequestMapping(value = "/search-jabatan", method = GET, produces = APPLICATION_JSON_VALUE)
|
||||
public ResponseEntity<Collection<JabatanVO>> getAllVOWithQueryString(
|
||||
@RequestParam(value = "page", required = false, defaultValue = "0") Integer page,
|
||||
@RequestParam(value = "limit", required = false, defaultValue = "10") Integer limit,
|
||||
@ -179,116 +166,103 @@ public class JabatanController extends LocaleController<JabatanVO> {
|
||||
@RequestParam(value = "dir", required = false, defaultValue = "asc") String dir) {
|
||||
Map<String, Object> resultPageMap = jabatanService.findAllWithPageAndLimitAndSortByAndDirectionParameter(page,
|
||||
limit, sort, dir);
|
||||
|
||||
return constructListPageResult(resultPageMap);
|
||||
}
|
||||
|
||||
@RequestMapping(value = "/get-all-jabatan-struktural", method = RequestMethod.GET, produces = MediaType.APPLICATION_JSON_VALUE)
|
||||
@RequestMapping(value = "/get-all-jabatan-struktural", method = GET, produces = APPLICATION_JSON_VALUE)
|
||||
public ResponseEntity<List<Map<String, Object>>> getAllJabatanStruktural(HttpServletRequest request) {
|
||||
List<Map<String, Object>> result = null;
|
||||
try {
|
||||
|
||||
result = jabatanService.getJabatanStruktural();
|
||||
|
||||
mapHeaderMessage.put(WebConstants.HttpHeaderInfo.LABEL_SUCCESS,
|
||||
getMessage(MessageResource.LABEL_SUCCESS, request));
|
||||
List<Map<String, Object>> result = jabatanService.getJabatanStruktural();
|
||||
mapHeaderMessage.put(LABEL_SUCCESS, getMessage(MessageResource.LABEL_SUCCESS, request));
|
||||
return getJsonResponse(result, OK);
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
throw new ServiceVOException(e.getMessage());
|
||||
}
|
||||
return RestUtil.getJsonResponse(result, HttpStatus.OK);
|
||||
}
|
||||
|
||||
@RequestMapping(value = "/get-list-jabatan", method = RequestMethod.GET, produces = MediaType.APPLICATION_JSON_VALUE)
|
||||
@RequestMapping(value = "/get-list-jabatan", method = GET, produces = APPLICATION_JSON_VALUE)
|
||||
public ResponseEntity<List<Map<String, Object>>> getAllJabatanByJenisJabatan(HttpServletRequest request,
|
||||
@RequestParam(value = "idJenisJabatan", required = true) Integer idJenisJabatan) {
|
||||
List<Map<String, Object>> result = new ArrayList<Map<String, Object>>();
|
||||
@RequestParam(value = "idJenisJabatan") Integer idJenisJabatan) {
|
||||
try {
|
||||
|
||||
result = jabatanService.findModelJabatan(idJenisJabatan);
|
||||
|
||||
mapHeaderMessage.put(WebConstants.HttpHeaderInfo.LABEL_SUCCESS,
|
||||
getMessage(MessageResource.LABEL_SUCCESS, request));
|
||||
List<Map<String, Object>> result = jabatanService.findModelJabatan(idJenisJabatan);
|
||||
mapHeaderMessage.put(LABEL_SUCCESS, getMessage(MessageResource.LABEL_SUCCESS, request));
|
||||
return getJsonResponse(result, OK);
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
throw new ServiceVOException(e.getMessage());
|
||||
}
|
||||
return RestUtil.getJsonResponse(result, HttpStatus.OK);
|
||||
}
|
||||
|
||||
@RequestMapping(value = "/validate-nama-jabatan/", method = RequestMethod.GET, produces = MediaType.APPLICATION_JSON_VALUE)
|
||||
@RequestMapping(value = "/validate-nama-jabatan/", method = GET, produces = APPLICATION_JSON_VALUE)
|
||||
public ResponseEntity<Map<String, Object>> validateNamaJabatan(HttpServletRequest request,
|
||||
@RequestParam(value = "idJabatan", required = false) Integer idJabatan,
|
||||
@RequestParam(value = "namaJabatan", required = true) String namaJabatan,
|
||||
@RequestParam(value = "idJenisJabatan", required = true) Integer idJenisJabatan,
|
||||
@RequestParam(value = "namaJabatan") String namaJabatan,
|
||||
@RequestParam(value = "idJenisJabatan") Integer idJenisJabatan,
|
||||
@RequestParam(value = "idUnitKerja", required = false) Integer idUnitKerja) {
|
||||
try {
|
||||
Map<String, Object> result = jabatanService.validateNamaJabatan(idJabatan, namaJabatan, idJenisJabatan,
|
||||
idUnitKerja);
|
||||
|
||||
return RestUtil.getJsonResponse(result, HttpStatus.OK);
|
||||
return getJsonResponse(result, OK);
|
||||
} catch (ServiceVOException e) {
|
||||
LOGGER.error("Got exception {} when validate nama jabatan", e.getMessage());
|
||||
addHeaderMessage(Constants.MessageInfo.ERROR_MESSAGE, e.getMessage());
|
||||
return RestUtil.getJsonHttptatus(HttpStatus.INTERNAL_SERVER_ERROR, mapHeaderMessage);
|
||||
LOGGER.error("Got ServiceVOException {} when validateNamaJabatan", e.getMessage());
|
||||
addHeaderMessage(ERROR_MESSAGE, e.getMessage());
|
||||
return getJsonHttpStatus(INTERNAL_SERVER_ERROR, mapHeaderMessage);
|
||||
} catch (JpaSystemException jse) {
|
||||
LOGGER.error("Got exception {} when validate nama jabatan", jse.getMessage());
|
||||
addHeaderMessage(Constants.MessageInfo.ERROR_MESSAGE, jse.getMessage());
|
||||
return RestUtil.getJsonHttptatus(HttpStatus.CONFLICT, mapHeaderMessage);
|
||||
LOGGER.error("Got JpaSystemException {} when validateNamaJabatan", jse.getMessage());
|
||||
addHeaderMessage(ERROR_MESSAGE, jse.getMessage());
|
||||
return getJsonHttpStatus(CONFLICT, mapHeaderMessage);
|
||||
}
|
||||
}
|
||||
|
||||
@RequestMapping(value = "/get-pegawai-jabatan", method = RequestMethod.GET, produces = MediaType.APPLICATION_JSON_VALUE)
|
||||
@RequestMapping(value = "/get-pegawai-jabatan", method = GET, produces = APPLICATION_JSON_VALUE)
|
||||
public ResponseEntity<List<Map<String, Object>>> getPegawaiByJabatan(HttpServletRequest request,
|
||||
@RequestParam(value = "jabatanId", required = true) Integer idJabatan) {
|
||||
@RequestParam(value = "jabatanId") Integer idJabatan) {
|
||||
try {
|
||||
List<Map<String, Object>> result = jabatanService.findPegawaiByJabatan(idJabatan);
|
||||
|
||||
return RestUtil.getJsonResponse(result, HttpStatus.OK);
|
||||
return getJsonResponse(result, OK);
|
||||
} catch (ServiceVOException e) {
|
||||
LOGGER.error("Got exception {} when get pegawai jabatan", e.getMessage());
|
||||
addHeaderMessage(Constants.MessageInfo.ERROR_MESSAGE, e.getMessage());
|
||||
return RestUtil.getJsonHttptatus(HttpStatus.INTERNAL_SERVER_ERROR, mapHeaderMessage);
|
||||
LOGGER.error("Got ServiceVOException {} when findPegawaiByJabatan", e.getMessage());
|
||||
addHeaderMessage(ERROR_MESSAGE, e.getMessage());
|
||||
return getJsonHttpStatus(INTERNAL_SERVER_ERROR, mapHeaderMessage);
|
||||
} catch (JpaSystemException jse) {
|
||||
LOGGER.error("Got exception {} when get pegawai jabatan", jse.getMessage());
|
||||
addHeaderMessage(Constants.MessageInfo.ERROR_MESSAGE, jse.getMessage());
|
||||
return RestUtil.getJsonHttptatus(HttpStatus.CONFLICT, mapHeaderMessage);
|
||||
LOGGER.error("Got JpaSystemException {} when findPegawaiByJabatan", jse.getMessage());
|
||||
addHeaderMessage(ERROR_MESSAGE, jse.getMessage());
|
||||
return getJsonHttpStatus(CONFLICT, mapHeaderMessage);
|
||||
}
|
||||
}
|
||||
|
||||
@RequestMapping(value = "/get-jabatan-dan-batas-nilai", method = RequestMethod.GET, produces = MediaType.APPLICATION_JSON_VALUE)
|
||||
@RequestMapping(value = "/get-jabatan-dan-batas-nilai", method = GET, produces = APPLICATION_JSON_VALUE)
|
||||
public ResponseEntity<List<Map<String, Object>>> getJabatanDanBatasNilai(HttpServletRequest request,
|
||||
@RequestParam(value = "jenisJabatanId", required = true) Integer idJenisJabatan,
|
||||
@RequestParam(value = "unitKerjaId", required = true) Integer idUnitKerja) {
|
||||
@RequestParam(value = "jenisJabatanId") Integer idJenisJabatan,
|
||||
@RequestParam(value = "unitKerjaId") Integer idUnitKerja) {
|
||||
try {
|
||||
List<Map<String, Object>> result = jabatanService.findJabatanDanBatasNilai(idJenisJabatan, idUnitKerja);
|
||||
|
||||
return RestUtil.getJsonResponse(result, HttpStatus.OK);
|
||||
return getJsonResponse(result, OK);
|
||||
} catch (ServiceVOException e) {
|
||||
LOGGER.error("Got exception {} when get jabatan dan batas nilai jabatan", e.getMessage());
|
||||
addHeaderMessage(Constants.MessageInfo.ERROR_MESSAGE, e.getMessage());
|
||||
return RestUtil.getJsonHttptatus(HttpStatus.INTERNAL_SERVER_ERROR, mapHeaderMessage);
|
||||
LOGGER.error("Got ServiceVOException {} when findJabatanDanBatasNilai", e.getMessage());
|
||||
addHeaderMessage(ERROR_MESSAGE, e.getMessage());
|
||||
return getJsonHttpStatus(INTERNAL_SERVER_ERROR, mapHeaderMessage);
|
||||
} catch (JpaSystemException jse) {
|
||||
LOGGER.error("Got exception {} when get jabatan dan batas nilai jabatan", jse.getMessage());
|
||||
addHeaderMessage(Constants.MessageInfo.ERROR_MESSAGE, jse.getMessage());
|
||||
return RestUtil.getJsonHttptatus(HttpStatus.CONFLICT, mapHeaderMessage);
|
||||
LOGGER.error("Got JpaSystemException {} when findJabatanDanBatasNilai", jse.getMessage());
|
||||
addHeaderMessage(ERROR_MESSAGE, jse.getMessage());
|
||||
return getJsonHttpStatus(CONFLICT, mapHeaderMessage);
|
||||
}
|
||||
}
|
||||
|
||||
@RequestMapping(value = "/get-by-unit-kerja", method = RequestMethod.GET, produces = MediaType.APPLICATION_JSON_VALUE)
|
||||
@RequestMapping(value = "/get-by-unit-kerja", method = GET, produces = APPLICATION_JSON_VALUE)
|
||||
public ResponseEntity<List<Map<String, Object>>> getByUnitKerja(HttpServletRequest request,
|
||||
@RequestParam(value = "unitKerjaId", required = true) Integer idUnitKerja) {
|
||||
@RequestParam(value = "unitKerjaId") Integer idUnitKerja) {
|
||||
try {
|
||||
List<Map<String, Object>> result = jabatanService.findByUnitKerja(idUnitKerja);
|
||||
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);
|
||||
} catch (ServiceVOException e) {
|
||||
LOGGER.error("Got exception {} when get jabatan by unit kerja", e.getMessage());
|
||||
mapHeaderMessage.put(WebConstants.HttpHeaderInfo.LABEL_SUCCESS, e.getMessage());
|
||||
return RestUtil.getJsonResponse(HttpStatus.INTERNAL_SERVER_ERROR, mapHeaderMessage);
|
||||
LOGGER.error("Got ServiceVOException {} when get jabatanService.findByUnitKerja", e.getMessage());
|
||||
mapHeaderMessage.put(LABEL_SUCCESS, e.getMessage());
|
||||
return getJsonResponse(INTERNAL_SERVER_ERROR, mapHeaderMessage);
|
||||
} catch (JpaSystemException jse) {
|
||||
LOGGER.error("Got exception {} when get jabatan by unit kerja", jse.getMessage());
|
||||
mapHeaderMessage.put(WebConstants.HttpHeaderInfo.LABEL_SUCCESS, jse.getMessage());
|
||||
return RestUtil.getJsonResponse(HttpStatus.CONFLICT, mapHeaderMessage);
|
||||
LOGGER.error("Got JpaSystemException {} when get jabatanService.findByUnitKerja", jse.getMessage());
|
||||
mapHeaderMessage.put(LABEL_SUCCESS, jse.getMessage());
|
||||
return getJsonResponse(CONFLICT, mapHeaderMessage);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@ -1,31 +1,29 @@
|
||||
package com.jasamedika.medifirst2000.controller;
|
||||
|
||||
import java.util.Collection;
|
||||
import java.util.List;
|
||||
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
import javax.validation.Valid;
|
||||
|
||||
import com.jasamedika.medifirst2000.controller.base.LocaleController;
|
||||
import com.jasamedika.medifirst2000.exception.ServiceVOException;
|
||||
import com.jasamedika.medifirst2000.service.KeluargaPegawaiService;
|
||||
import com.jasamedika.medifirst2000.vo.KeluargaPegawaiVO;
|
||||
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.controller.base.IBaseRestController;
|
||||
import com.jasamedika.medifirst2000.controller.base.LocaleController;
|
||||
import com.jasamedika.medifirst2000.exception.ServiceVOException;
|
||||
import com.jasamedika.medifirst2000.service.KeluargaPegawaiService;
|
||||
import com.jasamedika.medifirst2000.util.rest.RestUtil;
|
||||
import com.jasamedika.medifirst2000.vo.KeluargaPegawaiVO;
|
||||
import javax.validation.Valid;
|
||||
import java.util.List;
|
||||
|
||||
import static com.jasamedika.medifirst2000.constants.Constants.MessageInfo.ERROR_MESSAGE;
|
||||
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;
|
||||
|
||||
/**
|
||||
* Controller class for KeluargaPegawaiController
|
||||
@ -36,89 +34,47 @@ import com.jasamedika.medifirst2000.vo.KeluargaPegawaiVO;
|
||||
*/
|
||||
@RestController
|
||||
@RequestMapping("/keluarga-pegawai")
|
||||
public class KeluargaPegawaiController extends
|
||||
LocaleController<KeluargaPegawaiVO> implements
|
||||
IBaseRestController<KeluargaPegawaiVO> {
|
||||
public class KeluargaPegawaiController extends LocaleController<KeluargaPegawaiVO> {
|
||||
|
||||
@Autowired
|
||||
private KeluargaPegawaiService keluargaPegawaiService;
|
||||
|
||||
private static final Logger LOGGER = LoggerFactory
|
||||
.getLogger(KeluargaPegawaiController.class);
|
||||
private static final Logger LOGGER = LoggerFactory.getLogger(KeluargaPegawaiController.class);
|
||||
|
||||
@RequestMapping(value = "/cari-alamat-id/{id}", method = RequestMethod.GET)
|
||||
public ResponseEntity<KeluargaPegawaiVO> getVO(
|
||||
@PathVariable("id") Integer id) {
|
||||
KeluargaPegawaiVO keluargaPegawaiVO = keluargaPegawaiService
|
||||
.findById(id);
|
||||
@RequestMapping(value = "/cari-alamat-id/{id}", method = GET)
|
||||
public ResponseEntity<KeluargaPegawaiVO> getVO(@PathVariable("id") Integer id) {
|
||||
KeluargaPegawaiVO keluargaPegawaiVO = keluargaPegawaiService.findById(id);
|
||||
|
||||
return RestUtil.getJsonResponse(keluargaPegawaiVO, HttpStatus.OK);
|
||||
}
|
||||
@RequestMapping(value = "/get-all/", method = RequestMethod.GET)
|
||||
public ResponseEntity<List> getAllKeluaraPegawai(
|
||||
@PathVariable("id") Integer id) {
|
||||
List keluargaPegawaiVO = keluargaPegawaiService
|
||||
.findAll();
|
||||
|
||||
return RestUtil.getJsonResponse(keluargaPegawaiVO, HttpStatus.OK);
|
||||
return getJsonResponse(keluargaPegawaiVO, OK);
|
||||
}
|
||||
|
||||
@RequestMapping(value = "/cari-alamat-by-pasien-id/{id}", method = RequestMethod.GET)
|
||||
public ResponseEntity<KeluargaPegawaiVO> getByPasienVO(
|
||||
@PathVariable("id") Integer id) {
|
||||
KeluargaPegawaiVO keluargaPegawaiVO = keluargaPegawaiService
|
||||
.findById(id);
|
||||
|
||||
return RestUtil.getJsonResponse(keluargaPegawaiVO, HttpStatus.OK);
|
||||
@RequestMapping(value = "/get-all/", method = GET)
|
||||
public ResponseEntity<List<KeluargaPegawaiVO>> getAllKeluaraPegawai(@PathVariable("id") Integer id) {
|
||||
List<KeluargaPegawaiVO> keluargaPegawaiVO = keluargaPegawaiService.findAll();
|
||||
return getJsonResponse(keluargaPegawaiVO, OK);
|
||||
}
|
||||
|
||||
@Override
|
||||
public ResponseEntity<Collection<KeluargaPegawaiVO>> getAllVOWithQueryString(
|
||||
HttpServletRequest request, Integer page, Integer limit,
|
||||
String sort, String dir) {
|
||||
return null;
|
||||
@RequestMapping(value = "/cari-alamat-by-pasien-id/{id}", method = GET)
|
||||
public ResponseEntity<KeluargaPegawaiVO> getByPasienVO(@PathVariable("id") Integer id) {
|
||||
KeluargaPegawaiVO keluargaPegawaiVO = keluargaPegawaiService.findById(id);
|
||||
return getJsonResponse(keluargaPegawaiVO, OK);
|
||||
}
|
||||
|
||||
@RequestMapping(value = "/save-keluarga-pegawai", method = RequestMethod.POST, produces = MediaType.APPLICATION_JSON_VALUE, consumes = MediaType.APPLICATION_JSON_VALUE)
|
||||
|
||||
@RequestMapping(value = "/save-keluarga-pegawai", method = POST, produces = APPLICATION_JSON_VALUE, consumes = APPLICATION_JSON_VALUE)
|
||||
public ResponseEntity<String> addVO(@Valid @RequestBody KeluargaPegawaiVO vo) {
|
||||
try {
|
||||
KeluargaPegawaiVO result = keluargaPegawaiService.add(vo);
|
||||
|
||||
if (null != result)
|
||||
return RestUtil.getJsonResponse("Success", HttpStatus.CREATED);
|
||||
|
||||
return getJsonResponse("Success", CREATED);
|
||||
} catch (ServiceVOException e) {
|
||||
LOGGER.error("Got exception {} when add pegawai", e.getMessage());
|
||||
addHeaderMessage(Constants.MessageInfo.ERROR_MESSAGE,
|
||||
e.getMessage());
|
||||
return RestUtil.getJsonHttptatus(HttpStatus.INTERNAL_SERVER_ERROR,
|
||||
mapHeaderMessage);
|
||||
LOGGER.error("Got ServiceVOException {} when keluargaPegawaiService.add", e.getMessage());
|
||||
addHeaderMessage(ERROR_MESSAGE, e.getMessage());
|
||||
return getJsonHttpStatus(INTERNAL_SERVER_ERROR, mapHeaderMessage);
|
||||
} catch (JpaSystemException jse) {
|
||||
LOGGER.error("Got exception {} when add Pegawai", jse.getMessage());
|
||||
addHeaderMessage(Constants.MessageInfo.ERROR_MESSAGE,
|
||||
jse.getMessage());
|
||||
return RestUtil.getJsonHttptatus(HttpStatus.CONFLICT,
|
||||
mapHeaderMessage);
|
||||
LOGGER.error("Got JpaSystemException {} when keluargaPegawaiService.add", jse.getMessage());
|
||||
addHeaderMessage(ERROR_MESSAGE, jse.getMessage());
|
||||
return getJsonHttpStatus(CONFLICT, mapHeaderMessage);
|
||||
}
|
||||
|
||||
return RestUtil.getJsonHttptatus(HttpStatus.NOT_ACCEPTABLE);
|
||||
return getJsonHttpStatus(NOT_ACCEPTABLE);
|
||||
}
|
||||
|
||||
@Override
|
||||
public ResponseEntity<String> editVO(KeluargaPegawaiVO vo) {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public ResponseEntity<String> deleteVO(Integer id) {
|
||||
return null;
|
||||
}
|
||||
@Override
|
||||
public ResponseEntity<List<KeluargaPegawaiVO>> getAllVO() {
|
||||
return null;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
@ -1,38 +1,35 @@
|
||||
package com.jasamedika.medifirst2000.controller;
|
||||
|
||||
import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
|
||||
import com.jasamedika.medifirst2000.constants.MessageResource;
|
||||
import com.jasamedika.medifirst2000.controller.base.LocaleController;
|
||||
import com.jasamedika.medifirst2000.exception.ServiceVOException;
|
||||
import com.jasamedika.medifirst2000.service.KonsultasiService;
|
||||
import com.jasamedika.medifirst2000.service.RegistrasiPelayananService;
|
||||
import com.jasamedika.medifirst2000.vo.KonsultasiVO;
|
||||
import com.jasamedika.medifirst2000.vo.RegistrasiPelayananVO;
|
||||
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.web.bind.annotation.*;
|
||||
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
import javax.validation.Valid;
|
||||
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.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.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.KonsultasiService;
|
||||
import com.jasamedika.medifirst2000.service.RegistrasiPelayananService;
|
||||
import com.jasamedika.medifirst2000.util.rest.RestUtil;
|
||||
import com.jasamedika.medifirst2000.vo.GridAntrianPasienDiPeriksaVO;
|
||||
import com.jasamedika.medifirst2000.vo.KonsultasiVO;
|
||||
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.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;
|
||||
|
||||
/**
|
||||
* Controller class for KonsultasiController
|
||||
@ -41,46 +38,42 @@ import com.jasamedika.medifirst2000.vo.KonsultasiVO;
|
||||
*/
|
||||
@RestController
|
||||
@RequestMapping("/konsultasi")
|
||||
@JsonIgnoreProperties(ignoreUnknown = true)
|
||||
public class KonsultasiController extends LocaleController<KonsultasiVO> implements
|
||||
IBaseRestController<KonsultasiVO> {
|
||||
|
||||
@JsonIgnoreProperties(ignoreUnknown = true)
|
||||
public class KonsultasiController extends LocaleController<KonsultasiVO> {
|
||||
|
||||
private static final Logger LOGGER = LoggerFactory.getLogger(KonsultasiController.class);
|
||||
|
||||
@Autowired
|
||||
private KonsultasiService konsultasiService;
|
||||
private KonsultasiService<KonsultasiVO> konsultasiService;
|
||||
|
||||
@Autowired
|
||||
private RegistrasiPelayananService registrasiPelayananService;
|
||||
private RegistrasiPelayananService<RegistrasiPelayananVO> registrasiPelayananService;
|
||||
|
||||
@RequestMapping(value = "/save-konsultasi", method = RequestMethod.POST, produces = MediaType.APPLICATION_JSON_VALUE, consumes = MediaType.APPLICATION_JSON_VALUE)
|
||||
public ResponseEntity<Map<String,Object>> save(@Valid @RequestBody KonsultasiVO vo,HttpServletRequest request) {
|
||||
@RequestMapping(value = "/save-konsultasi", method = POST, produces = APPLICATION_JSON_VALUE, consumes = APPLICATION_JSON_VALUE)
|
||||
public ResponseEntity<Map<String, Object>> save(@Valid @RequestBody KonsultasiVO vo, HttpServletRequest request) {
|
||||
try {
|
||||
Map<String,Object> result = konsultasiService.addKonsultasi2(vo);
|
||||
if (null != result){
|
||||
mapHeaderMessage.clear();
|
||||
mapHeaderMessage.put(WebConstants.HttpHeaderInfo.LABEL_SUCCESS,getMessage(MessageResource.LABEL_SUCCESS,request ));
|
||||
}else{
|
||||
mapHeaderMessage.clear();
|
||||
mapHeaderMessage.put(WebConstants.HttpHeaderInfo.LABEL_ERROR,getMessage(MessageResource.LABEL_ERROR,request ));
|
||||
Map<String, Object> result = konsultasiService.addKonsultasi(vo);
|
||||
mapHeaderMessage.clear();
|
||||
if (null != result) {
|
||||
mapHeaderMessage.put(LABEL_SUCCESS, getMessage(MessageResource.LABEL_SUCCESS, request));
|
||||
} else {
|
||||
mapHeaderMessage.put(LABEL_ERROR, getMessage(MessageResource.LABEL_ERROR, request));
|
||||
}
|
||||
SaveLog("Konsultasi", "Dokter",request);
|
||||
return RestUtil.getJsonResponse(result, HttpStatus.CREATED,mapHeaderMessage);
|
||||
|
||||
saveLog("Konsultasi", "Dokter");
|
||||
return getJsonResponse(result, CREATED, mapHeaderMessage);
|
||||
} catch (ServiceVOException e) {
|
||||
LOGGER.error("Got exception {} when add kebutuhan dasar", e.getMessage());
|
||||
addHeaderMessage(Constants.MessageInfo.ERROR_MESSAGE, e.getMessage());
|
||||
return RestUtil.getJsonHttptatus(HttpStatus.INTERNAL_SERVER_ERROR, mapHeaderMessage);
|
||||
LOGGER.error("Got ServiceVOException {} when addKonsultasi", e.getMessage());
|
||||
addHeaderMessage(ERROR_MESSAGE, e.getMessage());
|
||||
return getJsonHttpStatus(INTERNAL_SERVER_ERROR, mapHeaderMessage);
|
||||
} catch (JpaSystemException jse) {
|
||||
LOGGER.error("Got exception {} when add kebutuhan dasar", jse.getMessage());
|
||||
addHeaderMessage(Constants.MessageInfo.ERROR_MESSAGE, jse.getMessage());
|
||||
return RestUtil.getJsonHttptatus(HttpStatus.CONFLICT, mapHeaderMessage);
|
||||
LOGGER.error("Got JpaSystemException {} when addKonsultasi", jse.getMessage());
|
||||
addHeaderMessage(ERROR_MESSAGE, jse.getMessage());
|
||||
return getJsonHttpStatus(CONFLICT, mapHeaderMessage);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@RequestMapping(value = "/antrian-pasien-list-konsul/", method = RequestMethod.GET, produces = MediaType.APPLICATION_JSON_VALUE)
|
||||
public ResponseEntity<Collection<GridAntrianPasienDiPeriksaVO>> getAllVOWithQueryString(
|
||||
|
||||
@RequestMapping(value = "/antrian-pasien-list-konsul/", method = GET, produces = APPLICATION_JSON_VALUE)
|
||||
public ResponseEntity<Collection<KonsultasiVO>> getAllVOWithQueryString(
|
||||
@RequestParam(value = "page", required = false, defaultValue = "1") Integer page,
|
||||
@RequestParam(value = "limit", required = false, defaultValue = "50") Integer limit,
|
||||
@RequestParam(value = "sort", required = false, defaultValue = "noRec") String sort,
|
||||
@ -90,73 +83,34 @@ public class KonsultasiController extends LocaleController<KonsultasiVO> impleme
|
||||
@RequestParam(value = "dateEnd", required = false) String dateEnd,
|
||||
@RequestParam(value = "noCm", required = false) String noCm,
|
||||
@RequestParam(value = "pegawaiId", required = false) Integer pegawaiId) {
|
||||
Map<String, Object> resultPageMap = registrasiPelayananService.findAllAntrianPagingKonsultasi(page, limit, sort, dir,
|
||||
ruanganId, dateStart, dateEnd, noCm, pegawaiId);
|
||||
|
||||
Map<String, Object> resultPageMap = registrasiPelayananService.findAllAntrianPagingKonsultasi(page, limit, sort,
|
||||
dir, ruanganId, dateStart, dateEnd, noCm, pegawaiId);
|
||||
return constructListPageResult(resultPageMap);
|
||||
}
|
||||
|
||||
@Override
|
||||
public ResponseEntity<Collection<KonsultasiVO>> getAllVOWithQueryString(HttpServletRequest request,
|
||||
Integer page, Integer limit, String sort, String dir) {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public ResponseEntity<KonsultasiVO> getVO(Integer id) {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public ResponseEntity<String> addVO(KonsultasiVO vo) {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public ResponseEntity<String> editVO(KonsultasiVO vo) {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public ResponseEntity<String> deleteVO(Integer id) {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public ResponseEntity<List<KonsultasiVO>> getAllVO() {
|
||||
return null;
|
||||
}
|
||||
|
||||
@RequestMapping(value = "/get-riwayat-konsultasi/{noCm}/{startDate}/{endDate}", method = RequestMethod.GET, produces = MediaType.APPLICATION_JSON_VALUE)
|
||||
public ResponseEntity<List<Map<String, Object>>> getRiwayatKonsultasi(@PathVariable("noCm") String noCm,@PathVariable("startDate") String startDate,
|
||||
@PathVariable("endDate") String endDate,HttpServletRequest request) {
|
||||
List<Map<String, Object>> result = null;
|
||||
@RequestMapping(value = "/get-riwayat-konsultasi/{noCm}/{startDate}/{endDate}", method = GET, produces = APPLICATION_JSON_VALUE)
|
||||
public ResponseEntity<List<Map<String, Object>>> getRiwayatKonsultasi(@PathVariable("noCm") String noCm,
|
||||
@PathVariable("startDate") String startDate, @PathVariable("endDate") String endDate,
|
||||
HttpServletRequest request) {
|
||||
try {
|
||||
|
||||
result = konsultasiService.getRiwayatKonsultasi(noCm, startDate, endDate);
|
||||
|
||||
mapHeaderMessage.put(WebConstants.HttpHeaderInfo.LABEL_SUCCESS,
|
||||
getMessage(MessageResource.LABEL_SUCCESS, request));
|
||||
List<Map<String, Object>> result = konsultasiService.getRiwayatKonsultasi(noCm, startDate, endDate);
|
||||
mapHeaderMessage.put(LABEL_SUCCESS, getMessage(MessageResource.LABEL_SUCCESS, request));
|
||||
return getJsonResponse(result, OK);
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
throw new ServiceVOException(e.getMessage());
|
||||
}
|
||||
return RestUtil.getJsonResponse(result, HttpStatus.OK);
|
||||
}
|
||||
|
||||
@RequestMapping(value = "/get-konsultasi-kosong", method = RequestMethod.GET, produces = MediaType.APPLICATION_JSON_VALUE)
|
||||
|
||||
@RequestMapping(value = "/get-konsultasi-kosong", method = GET, produces = APPLICATION_JSON_VALUE)
|
||||
public ResponseEntity<List<Map<String, Object>>> getKonsultasiKosong(HttpServletRequest request,
|
||||
@RequestParam(value = "tglAwal", required = true) String strTglAwal,
|
||||
@RequestParam(value = "tglAkhir", required = true) String strTglAkhir) {
|
||||
List<Map<String, Object>> result = null;
|
||||
@RequestParam(value = "tglAwal") String strTglAwal, @RequestParam(value = "tglAkhir") String strTglAkhir) {
|
||||
try {
|
||||
|
||||
result = konsultasiService.findAllKonsultasiTindakanKosong(strTglAwal, strTglAkhir);
|
||||
|
||||
mapHeaderMessage.put(WebConstants.HttpHeaderInfo.LABEL_SUCCESS,
|
||||
getMessage(MessageResource.LABEL_SUCCESS, request));
|
||||
List<Map<String, Object>> result = konsultasiService.findAllKonsultasiTindakanKosong(strTglAwal,
|
||||
strTglAkhir);
|
||||
mapHeaderMessage.put(LABEL_SUCCESS, getMessage(MessageResource.LABEL_SUCCESS, request));
|
||||
return getJsonResponse(result, OK);
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
throw new ServiceVOException(e.getMessage());
|
||||
}
|
||||
return RestUtil.getJsonResponse(result, HttpStatus.OK);
|
||||
}
|
||||
}
|
||||
|
||||
@ -16,7 +16,7 @@ import javax.servlet.http.HttpServletRequest;
|
||||
|
||||
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.getJsonHttptatus;
|
||||
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.ACCEPTED;
|
||||
@ -47,7 +47,7 @@ public class LogbookRemunController extends LocaleController<LogbookKinerjaVO> {
|
||||
} catch (ServiceVOException | JpaSystemException e) {
|
||||
LOGGER.error("Got Exception {} when generateRecap", e.getMessage());
|
||||
mapHeaderMessage.put(ERROR_MESSAGE, e.getMessage());
|
||||
return getJsonHttptatus(INTERNAL_SERVER_ERROR, mapHeaderMessage);
|
||||
return getJsonHttpStatus(INTERNAL_SERVER_ERROR, mapHeaderMessage);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@ -1,20 +1,14 @@
|
||||
package com.jasamedika.medifirst2000.controller;
|
||||
|
||||
import com.jasamedika.medifirst2000.constants.Constants;
|
||||
import com.jasamedika.medifirst2000.constants.Master;
|
||||
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.PegawaiJabatanDto;
|
||||
import com.jasamedika.medifirst2000.exception.ServiceVOException;
|
||||
import com.jasamedika.medifirst2000.service.MapPegawaiJabatanToUnitKerjaService;
|
||||
import com.jasamedika.medifirst2000.util.rest.RestUtil;
|
||||
import com.jasamedika.medifirst2000.vo.MapPegawaiJabatanToUnitKerjaVO;
|
||||
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.*;
|
||||
@ -22,66 +16,72 @@ import org.springframework.web.bind.annotation.*;
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
import javax.validation.Valid;
|
||||
import java.text.ParseException;
|
||||
import java.util.ArrayList;
|
||||
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.constants.Master.TIDAK_ADA_PERUBAHAN_DATA;
|
||||
import static com.jasamedika.medifirst2000.core.web.WebConstants.HttpHeaderInfo.LABEL_SUCCESS;
|
||||
import static com.jasamedika.medifirst2000.core.web.WebConstants.HttpHeaderInfo.LABEL_SUCCESS_OK;
|
||||
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("/map-pegawai-jabatan-unitkerja")
|
||||
public class MapPegawaiJabatanToUnitKerjaController extends LocaleController<MapPegawaiJabatanToUnitKerjaVO> {
|
||||
|
||||
private static final Logger LOGGER = LoggerFactory.getLogger(MapPegawaiJabatanToUnitKerjaController.class);
|
||||
|
||||
@Autowired
|
||||
private MapPegawaiJabatanToUnitKerjaService mapPegawaiJabatanToUnitKerjaService;
|
||||
|
||||
private static final Logger LOGGER = LoggerFactory.getLogger(MapPegawaiJabatanToUnitKerjaController.class);
|
||||
|
||||
@RequestMapping(value = "/save-map", method = RequestMethod.POST, produces = MediaType.APPLICATION_JSON_VALUE, consumes = MediaType.APPLICATION_JSON_VALUE)
|
||||
@RequestMapping(value = "/save-map", method = POST, produces = APPLICATION_JSON_VALUE, consumes = APPLICATION_JSON_VALUE)
|
||||
public ResponseEntity<Map<String, Object>> save(@Valid @RequestBody List<MapPegawaiJabatanToUnitKerjaVO> vo,
|
||||
HttpServletRequest request) throws ParseException {
|
||||
try {
|
||||
Map<String, Object> result = mapPegawaiJabatanToUnitKerjaService.saveRev(vo);
|
||||
if (null != result && result.get("data").equals(Master.TIDAK_ADA_PERUBAHAN_DATA)) {
|
||||
mapHeaderMessage.put(WebConstants.HttpHeaderInfo.LABEL_SUCCESS_OK,
|
||||
getMessage(MessageResource.LABEL_SUCCESS_OK, request));
|
||||
return RestUtil.getJsonResponse(result, HttpStatus.NOT_MODIFIED, mapHeaderMessage);
|
||||
if (null != result && result.get("data").equals(TIDAK_ADA_PERUBAHAN_DATA)) {
|
||||
mapHeaderMessage.put(LABEL_SUCCESS_OK, getMessage(MessageResource.LABEL_SUCCESS_OK, request));
|
||||
return getJsonResponse(result, NOT_MODIFIED, mapHeaderMessage);
|
||||
} else {
|
||||
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 mapping jabatan", e.getMessage());
|
||||
addHeaderMessage(Constants.MessageInfo.ERROR_MESSAGE, e.getMessage());
|
||||
return RestUtil.getJsonHttptatus(HttpStatus.INTERNAL_SERVER_ERROR, mapHeaderMessage);
|
||||
LOGGER.error("Got ServiceVOException {} when mapPegawaiJabatanToUnitKerjaService.saveRev", e.getMessage());
|
||||
addHeaderMessage(ERROR_MESSAGE, e.getMessage());
|
||||
return getJsonHttpStatus(INTERNAL_SERVER_ERROR, mapHeaderMessage);
|
||||
} catch (JpaSystemException jse) {
|
||||
LOGGER.error("Got exception {} when add mapping jabatan", jse.getMessage());
|
||||
addHeaderMessage(Constants.MessageInfo.ERROR_MESSAGE, jse.getMessage());
|
||||
return RestUtil.getJsonHttptatus(HttpStatus.CONFLICT, mapHeaderMessage);
|
||||
LOGGER.error("Got JpaSystemException {} when mapPegawaiJabatanToUnitKerjaService.saveRev",
|
||||
jse.getMessage());
|
||||
addHeaderMessage(ERROR_MESSAGE, jse.getMessage());
|
||||
return getJsonHttpStatus(CONFLICT, mapHeaderMessage);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@RequestMapping(value = "/hapus-map", method = RequestMethod.POST, produces = MediaType.APPLICATION_JSON_VALUE, consumes = MediaType.APPLICATION_JSON_VALUE)
|
||||
@RequestMapping(value = "/hapus-map", method = POST, produces = APPLICATION_JSON_VALUE, consumes = APPLICATION_JSON_VALUE)
|
||||
public ResponseEntity<Map<String, Object>> hapusMap(@Valid @RequestBody List<MapPegawaiJabatanToUnitKerjaVO> vo,
|
||||
HttpServletRequest request) throws ParseException {
|
||||
Map<String, String> mapHeaderMessage = new HashMap<String, String>();
|
||||
HttpServletRequest request) {
|
||||
Map<String, String> mapHeaderMessage = new HashMap<>();
|
||||
try {
|
||||
Map<String, Object> result = mapPegawaiJabatanToUnitKerjaService.save(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 Map", e.getMessage());
|
||||
addHeaderMessage(Constants.MessageInfo.ERROR_MESSAGE, e.getMessage());
|
||||
return RestUtil.getJsonHttptatus(HttpStatus.INTERNAL_SERVER_ERROR, mapHeaderMessage);
|
||||
LOGGER.error("Got ServiceVOException {} when mapPegawaiJabatanToUnitKerjaService.save", e.getMessage());
|
||||
addHeaderMessage(ERROR_MESSAGE, e.getMessage());
|
||||
return getJsonHttpStatus(INTERNAL_SERVER_ERROR, mapHeaderMessage);
|
||||
} catch (JpaSystemException jse) {
|
||||
LOGGER.error("Got exception {} when add Map", jse.getMessage());
|
||||
addHeaderMessage(Constants.MessageInfo.ERROR_MESSAGE, jse.getMessage());
|
||||
return RestUtil.getJsonHttptatus(HttpStatus.CONFLICT, mapHeaderMessage);
|
||||
LOGGER.error("Got JpaSystemException {} when mapPegawaiJabatanToUnitKerjaService.save", jse.getMessage());
|
||||
addHeaderMessage(ERROR_MESSAGE, jse.getMessage());
|
||||
return getJsonHttpStatus(CONFLICT, mapHeaderMessage);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
@ -89,291 +89,271 @@ public class MapPegawaiJabatanToUnitKerjaController extends LocaleController<Map
|
||||
* API inisiasi awal jika data mapping sudah input tp histori belum,
|
||||
* dilakukan hanya satu kali
|
||||
*/
|
||||
@RequestMapping(value = "/get-all-map", method = RequestMethod.GET)
|
||||
@RequestMapping(value = "/get-all-map", method = GET)
|
||||
public ResponseEntity<Map<String, Object>> getAllMap(HttpServletRequest request) {
|
||||
Map<String, Object> result = null;
|
||||
try {
|
||||
result = mapPegawaiJabatanToUnitKerjaService.findAllMap();
|
||||
|
||||
mapHeaderMessage.put(WebConstants.HttpHeaderInfo.LABEL_SUCCESS,
|
||||
getMessage(MessageResource.LABEL_SUCCESS, request));
|
||||
Map<String, Object> result = mapPegawaiJabatanToUnitKerjaService.findAllMap();
|
||||
mapHeaderMessage.put(LABEL_SUCCESS, getMessage(MessageResource.LABEL_SUCCESS, request));
|
||||
return getJsonResponse(result, OK);
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
throw new ServiceVOException(e.getMessage());
|
||||
}
|
||||
return RestUtil.getJsonResponse(result, HttpStatus.OK);
|
||||
}
|
||||
|
||||
@RequestMapping(value = "/get-map-by-pegawai/{id}", method = RequestMethod.GET)
|
||||
@RequestMapping(value = "/get-map-by-pegawai/{id}", method = GET)
|
||||
public ResponseEntity<List<Map<String, Object>>> getMapByPegawai(@PathVariable("id") Integer id) {
|
||||
List<Map<String, Object>> result = new ArrayList<Map<String, Object>>();
|
||||
try {
|
||||
result = mapPegawaiJabatanToUnitKerjaService.findAllDetailByPegawai(id);
|
||||
mapHeaderMessage.put(WebConstants.HttpHeaderInfo.LABEL_SUCCESS, getMessage(MessageResource.LABEL_SUCCESS));
|
||||
return RestUtil.getJsonResponse(result, HttpStatus.OK, mapHeaderMessage);
|
||||
List<Map<String, Object>> result = mapPegawaiJabatanToUnitKerjaService.findAllDetailByPegawai(id);
|
||||
mapHeaderMessage.put(LABEL_SUCCESS, getMessage(MessageResource.LABEL_SUCCESS));
|
||||
return getJsonResponse(result, OK, mapHeaderMessage);
|
||||
} catch (ServiceVOException e) {
|
||||
LOGGER.error("Got exception {} when get mapping jabatan", e.getMessage());
|
||||
addHeaderMessage(Constants.MessageInfo.ERROR_MESSAGE, e.getMessage());
|
||||
return RestUtil.getJsonHttptatus(HttpStatus.INTERNAL_SERVER_ERROR, mapHeaderMessage);
|
||||
LOGGER.error("Got ServiceVOException {} when findAllDetailByPegawai", e.getMessage());
|
||||
addHeaderMessage(ERROR_MESSAGE, e.getMessage());
|
||||
return getJsonHttpStatus(INTERNAL_SERVER_ERROR, mapHeaderMessage);
|
||||
} catch (JpaSystemException jse) {
|
||||
LOGGER.error("Got exception {} when get mapping jabatan", jse.getMessage());
|
||||
addHeaderMessage(Constants.MessageInfo.ERROR_MESSAGE, jse.getMessage());
|
||||
return RestUtil.getJsonHttptatus(HttpStatus.CONFLICT, mapHeaderMessage);
|
||||
LOGGER.error("Got JpaSystemException {} when findAllDetailByPegawai", jse.getMessage());
|
||||
addHeaderMessage(ERROR_MESSAGE, jse.getMessage());
|
||||
return getJsonHttpStatus(CONFLICT, mapHeaderMessage);
|
||||
}
|
||||
}
|
||||
|
||||
@RequestMapping(value = "/get-bawahan-level-jabatan", method = RequestMethod.GET)
|
||||
@RequestMapping(value = "/get-bawahan-level-jabatan", method = GET)
|
||||
public ResponseEntity<List<Map<String, Object>>> getBawahanByLevelJabatan(HttpServletRequest request,
|
||||
@RequestParam(value = "idPegawai", required = true) Integer idPegawai) {
|
||||
List<Map<String, Object>> result = new ArrayList<Map<String, Object>>();
|
||||
@RequestParam(value = "idPegawai") Integer idPegawai) {
|
||||
try {
|
||||
result = mapPegawaiJabatanToUnitKerjaService.findAllDetailByLevelJabatan(idPegawai);
|
||||
mapHeaderMessage.put(WebConstants.HttpHeaderInfo.LABEL_SUCCESS,
|
||||
getMessage(MessageResource.LABEL_SUCCESS, request));
|
||||
return RestUtil.getJsonResponse(result, HttpStatus.OK, mapHeaderMessage);
|
||||
List<Map<String, Object>> result = mapPegawaiJabatanToUnitKerjaService
|
||||
.findAllDetailByLevelJabatan(idPegawai);
|
||||
mapHeaderMessage.put(LABEL_SUCCESS, getMessage(MessageResource.LABEL_SUCCESS, request));
|
||||
return getJsonResponse(result, OK, mapHeaderMessage);
|
||||
} catch (ServiceVOException e) {
|
||||
LOGGER.error("Got exception {} when get bawahan by level jabatan", e.getMessage());
|
||||
addHeaderMessage(Constants.MessageInfo.ERROR_MESSAGE, e.getMessage());
|
||||
return RestUtil.getJsonHttptatus(HttpStatus.INTERNAL_SERVER_ERROR, mapHeaderMessage);
|
||||
LOGGER.error("Got ServiceVOException {} when findAllDetailByLevelJabatan", e.getMessage());
|
||||
addHeaderMessage(ERROR_MESSAGE, e.getMessage());
|
||||
return getJsonHttpStatus(INTERNAL_SERVER_ERROR, mapHeaderMessage);
|
||||
} catch (JpaSystemException jse) {
|
||||
LOGGER.error("Got exception {} when get bawahan by level jabatan", jse.getMessage());
|
||||
addHeaderMessage(Constants.MessageInfo.ERROR_MESSAGE, jse.getMessage());
|
||||
return RestUtil.getJsonHttptatus(HttpStatus.CONFLICT, mapHeaderMessage);
|
||||
LOGGER.error("Got JpaSystemException {} when findAllDetailByLevelJabatan", jse.getMessage());
|
||||
addHeaderMessage(ERROR_MESSAGE, jse.getMessage());
|
||||
return getJsonHttpStatus(CONFLICT, mapHeaderMessage);
|
||||
}
|
||||
}
|
||||
|
||||
@RequestMapping(value = "/get-undefined-bawahan", method = RequestMethod.GET)
|
||||
@RequestMapping(value = "/get-undefined-bawahan", method = GET)
|
||||
public ResponseEntity<List<Map<String, Object>>> getUndefinedBawahan(HttpServletRequest request) {
|
||||
List<Map<String, Object>> result = new ArrayList<Map<String, Object>>();
|
||||
try {
|
||||
result = mapPegawaiJabatanToUnitKerjaService.findAllUndefinedDetail();
|
||||
mapHeaderMessage.put(WebConstants.HttpHeaderInfo.LABEL_SUCCESS,
|
||||
getMessage(MessageResource.LABEL_SUCCESS, request));
|
||||
return RestUtil.getJsonResponse(result, HttpStatus.OK, mapHeaderMessage);
|
||||
List<Map<String, Object>> result = mapPegawaiJabatanToUnitKerjaService.findAllUndefinedDetail();
|
||||
mapHeaderMessage.put(LABEL_SUCCESS, getMessage(MessageResource.LABEL_SUCCESS, request));
|
||||
return getJsonResponse(result, OK, mapHeaderMessage);
|
||||
} catch (ServiceVOException e) {
|
||||
LOGGER.error("Got exception {} when get bawahan belum didefinisikan", e.getMessage());
|
||||
addHeaderMessage(Constants.MessageInfo.ERROR_MESSAGE, e.getMessage());
|
||||
return RestUtil.getJsonHttptatus(HttpStatus.INTERNAL_SERVER_ERROR, mapHeaderMessage);
|
||||
LOGGER.error("Got ServiceVOException {} when findAllUndefinedDetail", e.getMessage());
|
||||
addHeaderMessage(ERROR_MESSAGE, e.getMessage());
|
||||
return getJsonHttpStatus(INTERNAL_SERVER_ERROR, mapHeaderMessage);
|
||||
} catch (JpaSystemException jse) {
|
||||
LOGGER.error("Got exception {} when get bawahan belum didefinisikan", jse.getMessage());
|
||||
addHeaderMessage(Constants.MessageInfo.ERROR_MESSAGE, jse.getMessage());
|
||||
return RestUtil.getJsonHttptatus(HttpStatus.CONFLICT, mapHeaderMessage);
|
||||
LOGGER.error("Got JpaSystemException {} when findAllUndefinedDetail", jse.getMessage());
|
||||
addHeaderMessage(ERROR_MESSAGE, jse.getMessage());
|
||||
return getJsonHttpStatus(CONFLICT, mapHeaderMessage);
|
||||
}
|
||||
}
|
||||
|
||||
@RequestMapping(value = "/get-sub-unit-by-unit/{id}/{idUnit}", method = RequestMethod.GET)
|
||||
@RequestMapping(value = "/get-sub-unit-by-unit/{id}/{idUnit}", method = GET)
|
||||
public ResponseEntity<Map<String, Object>> getSubUnitByUnit(@PathVariable("id") Integer id,
|
||||
@PathVariable("idUnit") Integer idUnit) {
|
||||
return RestUtil.getJsonResponse(mapPegawaiJabatanToUnitKerjaService.findSubUnitByUnit(id, idUnit),
|
||||
HttpStatus.OK);
|
||||
return getJsonResponse(mapPegawaiJabatanToUnitKerjaService.findSubUnitByUnit(id, idUnit), OK);
|
||||
}
|
||||
|
||||
@RequestMapping(value = "/get-unit-by-pegawai/{id}", method = RequestMethod.GET)
|
||||
@RequestMapping(value = "/get-unit-by-pegawai/{id}", method = GET)
|
||||
public ResponseEntity<Map<String, Object>> getSubUnitByUnit(@PathVariable("id") Integer id) {
|
||||
return RestUtil.getJsonResponse(mapPegawaiJabatanToUnitKerjaService.findUnitByPgw(id), HttpStatus.OK);
|
||||
return getJsonResponse(mapPegawaiJabatanToUnitKerjaService.findUnitByPgw(id), OK);
|
||||
}
|
||||
|
||||
@RequestMapping(value = "/get-unit-by-pegawai-jadwal/{id}", method = RequestMethod.GET)
|
||||
@RequestMapping(value = "/get-unit-by-pegawai-jadwal/{id}", method = GET)
|
||||
public ResponseEntity<List<Map<String, Object>>> getSubUnitByUnitJadwal(@PathVariable("id") Integer id) {
|
||||
return RestUtil.getJsonResponse(mapPegawaiJabatanToUnitKerjaService.findUnitByPgwJadwal(id), HttpStatus.OK);
|
||||
return getJsonResponse(mapPegawaiJabatanToUnitKerjaService.findUnitByPgwJadwal(id), OK);
|
||||
}
|
||||
|
||||
@RequestMapping(value = "/get-sub-unit-by-unit-jadwal/{id}/{idUnit}", method = RequestMethod.GET)
|
||||
@RequestMapping(value = "/get-sub-unit-by-unit-jadwal/{id}/{idUnit}", method = GET)
|
||||
public ResponseEntity<List<Map<String, Object>>> getSubUnitByUnitJadwal(@PathVariable("id") Integer id,
|
||||
@PathVariable("idUnit") Integer idUnit) {
|
||||
return RestUtil.getJsonResponse(mapPegawaiJabatanToUnitKerjaService.findSubUnitByUnitJadwal(id, idUnit),
|
||||
HttpStatus.OK);
|
||||
return getJsonResponse(mapPegawaiJabatanToUnitKerjaService.findSubUnitByUnitJadwal(id, idUnit), OK);
|
||||
}
|
||||
|
||||
@RequestMapping(value = "/get-status-create-jadwal", method = RequestMethod.GET)
|
||||
@RequestMapping(value = "/get-status-create-jadwal", method = GET)
|
||||
public ResponseEntity<Map<String, Object>> getStatusCreateJadwal(
|
||||
@RequestParam(value = "id", required = false) Integer id, HttpServletRequest request) {
|
||||
try {
|
||||
Map<String, Object> result = mapPegawaiJabatanToUnitKerjaService
|
||||
.getMapJabatanForMonitoringAbsensiByPegawai(id);
|
||||
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);
|
||||
} catch (ServiceVOException e) {
|
||||
LOGGER.error("Got exception {} when get status create jadwal", e.getMessage());
|
||||
addHeaderMessage(Constants.MessageInfo.ERROR_MESSAGE, e.getMessage());
|
||||
return RestUtil.getJsonHttptatus(HttpStatus.INTERNAL_SERVER_ERROR, mapHeaderMessage);
|
||||
LOGGER.error("Got ServiceVOException {} when getMapJabatanForMonitoringAbsensiByPegawai", e.getMessage());
|
||||
addHeaderMessage(ERROR_MESSAGE, e.getMessage());
|
||||
return getJsonHttpStatus(INTERNAL_SERVER_ERROR, mapHeaderMessage);
|
||||
} catch (JpaSystemException jse) {
|
||||
LOGGER.error("Got exception {} when get status create jadwal", jse.getMessage());
|
||||
addHeaderMessage(Constants.MessageInfo.ERROR_MESSAGE, jse.getMessage());
|
||||
return RestUtil.getJsonHttptatus(HttpStatus.CONFLICT, mapHeaderMessage);
|
||||
LOGGER.error("Got JpaSystemException {} when getMapJabatanForMonitoringAbsensiByPegawai", jse.getMessage());
|
||||
addHeaderMessage(ERROR_MESSAGE, jse.getMessage());
|
||||
return getJsonHttpStatus(CONFLICT, mapHeaderMessage);
|
||||
}
|
||||
}
|
||||
|
||||
@RequestMapping(value = "/get-drop-down-unit", method = RequestMethod.GET)
|
||||
@RequestMapping(value = "/get-drop-down-unit", method = GET)
|
||||
public ResponseEntity<Map<String, Object>> getDropDownUnitKerja(
|
||||
@RequestParam(value = "id", required = false) Integer id, HttpServletRequest request) {
|
||||
Map<String, Object> result = new HashMap<>();
|
||||
try {
|
||||
result.put("data", mapPegawaiJabatanToUnitKerjaService.getMapUnitKerjaByPegawai(id));
|
||||
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);
|
||||
} catch (ServiceVOException e) {
|
||||
LOGGER.error("Got exception {} when get drop down unit", e.getMessage());
|
||||
addHeaderMessage(Constants.MessageInfo.ERROR_MESSAGE, e.getMessage());
|
||||
return RestUtil.getJsonHttptatus(HttpStatus.INTERNAL_SERVER_ERROR, mapHeaderMessage);
|
||||
LOGGER.error("Got ServiceVOException {} when getMapUnitKerjaByPegawai", e.getMessage());
|
||||
addHeaderMessage(ERROR_MESSAGE, e.getMessage());
|
||||
return getJsonHttpStatus(INTERNAL_SERVER_ERROR, mapHeaderMessage);
|
||||
} catch (JpaSystemException jse) {
|
||||
LOGGER.error("Got exception {} when get drop down unit", jse.getMessage());
|
||||
addHeaderMessage(Constants.MessageInfo.ERROR_MESSAGE, jse.getMessage());
|
||||
return RestUtil.getJsonHttptatus(HttpStatus.CONFLICT, mapHeaderMessage);
|
||||
LOGGER.error("Got JpaSystemException {} when getMapUnitKerjaByPegawai", jse.getMessage());
|
||||
addHeaderMessage(ERROR_MESSAGE, jse.getMessage());
|
||||
return getJsonHttpStatus(CONFLICT, mapHeaderMessage);
|
||||
}
|
||||
}
|
||||
|
||||
@RequestMapping(value = "/get-drop-down-subunit", method = RequestMethod.GET)
|
||||
@RequestMapping(value = "/get-drop-down-subunit", method = GET)
|
||||
public ResponseEntity<Map<String, Object>> getDropDownSubUnitKerja(
|
||||
@RequestParam(value = "id", required = false) Integer id,
|
||||
@RequestParam(value = "idUnit", required = false) Integer idUnit, HttpServletRequest request) {
|
||||
Map<String, Object> result = new HashMap<>();
|
||||
try {
|
||||
result.put("data", mapPegawaiJabatanToUnitKerjaService.getMapSubunitKerjaByUnitPegawai(id, idUnit));
|
||||
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);
|
||||
} catch (ServiceVOException e) {
|
||||
LOGGER.error("Got exception {} when get drop down subunit", e.getMessage());
|
||||
addHeaderMessage(Constants.MessageInfo.ERROR_MESSAGE, e.getMessage());
|
||||
return RestUtil.getJsonHttptatus(HttpStatus.INTERNAL_SERVER_ERROR, mapHeaderMessage);
|
||||
LOGGER.error("Got ServiceVOException {} when getMapSubunitKerjaByUnitPegawai", e.getMessage());
|
||||
addHeaderMessage(ERROR_MESSAGE, e.getMessage());
|
||||
return getJsonHttpStatus(INTERNAL_SERVER_ERROR, mapHeaderMessage);
|
||||
} catch (JpaSystemException jse) {
|
||||
LOGGER.error("Got exception {} when get drop down subunit", jse.getMessage());
|
||||
addHeaderMessage(Constants.MessageInfo.ERROR_MESSAGE, jse.getMessage());
|
||||
return RestUtil.getJsonHttptatus(HttpStatus.CONFLICT, mapHeaderMessage);
|
||||
LOGGER.error("Got JpaSystemException {} when getMapSubunitKerjaByUnitPegawai", jse.getMessage());
|
||||
addHeaderMessage(ERROR_MESSAGE, jse.getMessage());
|
||||
return getJsonHttpStatus(CONFLICT, mapHeaderMessage);
|
||||
}
|
||||
}
|
||||
|
||||
@RequestMapping(value = "/list-atasan-langsung-pegawai", method = RequestMethod.GET)
|
||||
@RequestMapping(value = "/list-atasan-langsung-pegawai", method = GET)
|
||||
public ResponseEntity<Map<String, Object>> getAtasanLangsungPegawai(
|
||||
@RequestParam(value = "idPegawai", required = false) Integer idPegawai, HttpServletRequest request) {
|
||||
Map<String, Object> result = new HashMap<>();
|
||||
try {
|
||||
result.put("data", mapPegawaiJabatanToUnitKerjaService.findAtasanLangsungPegawai(idPegawai));
|
||||
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);
|
||||
} catch (ServiceVOException e) {
|
||||
LOGGER.error("Got exception {} when get drop down list atasan langsung", e.getMessage());
|
||||
addHeaderMessage(Constants.MessageInfo.ERROR_MESSAGE, e.getMessage());
|
||||
return RestUtil.getJsonHttptatus(HttpStatus.INTERNAL_SERVER_ERROR, mapHeaderMessage);
|
||||
LOGGER.error("Got ServiceVOException {} when findAtasanLangsungPegawai", e.getMessage());
|
||||
addHeaderMessage(ERROR_MESSAGE, e.getMessage());
|
||||
return getJsonHttpStatus(INTERNAL_SERVER_ERROR, mapHeaderMessage);
|
||||
} catch (JpaSystemException jse) {
|
||||
LOGGER.error("Got exception {} when get drop down list atasan langsung", jse.getMessage());
|
||||
addHeaderMessage(Constants.MessageInfo.ERROR_MESSAGE, jse.getMessage());
|
||||
return RestUtil.getJsonHttptatus(HttpStatus.CONFLICT, mapHeaderMessage);
|
||||
LOGGER.error("Got JpaSystemException {} when findAtasanLangsungPegawai", jse.getMessage());
|
||||
addHeaderMessage(ERROR_MESSAGE, jse.getMessage());
|
||||
return getJsonHttpStatus(CONFLICT, mapHeaderMessage);
|
||||
}
|
||||
}
|
||||
|
||||
@RequestMapping(value = "/list-pejabat-penilai-pegawai", method = RequestMethod.GET)
|
||||
@RequestMapping(value = "/list-pejabat-penilai-pegawai", method = GET)
|
||||
public ResponseEntity<Map<String, Object>> getAtasanPejabatPenilaiPegawai(
|
||||
@RequestParam(value = "idPegawai", required = false) Integer idPegawai, HttpServletRequest request) {
|
||||
Map<String, Object> result = new HashMap<>();
|
||||
try {
|
||||
result.put("data", mapPegawaiJabatanToUnitKerjaService.findPejabatPenilaiPegawai(idPegawai));
|
||||
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);
|
||||
} catch (ServiceVOException e) {
|
||||
LOGGER.error("Got exception {} when get drop down list atasan pejabat penilai", e.getMessage());
|
||||
addHeaderMessage(Constants.MessageInfo.ERROR_MESSAGE, e.getMessage());
|
||||
return RestUtil.getJsonHttptatus(HttpStatus.INTERNAL_SERVER_ERROR, mapHeaderMessage);
|
||||
LOGGER.error("Got ServiceVOException {} when findPejabatPenilaiPegawai", e.getMessage());
|
||||
addHeaderMessage(ERROR_MESSAGE, e.getMessage());
|
||||
return getJsonHttpStatus(INTERNAL_SERVER_ERROR, mapHeaderMessage);
|
||||
} catch (JpaSystemException jse) {
|
||||
LOGGER.error("Got exception {} when get drop down list atasan pejabat penilai", jse.getMessage());
|
||||
addHeaderMessage(Constants.MessageInfo.ERROR_MESSAGE, jse.getMessage());
|
||||
return RestUtil.getJsonHttptatus(HttpStatus.CONFLICT, mapHeaderMessage);
|
||||
LOGGER.error("Got JpaSystemException {} when findPejabatPenilaiPegawai", jse.getMessage());
|
||||
addHeaderMessage(ERROR_MESSAGE, jse.getMessage());
|
||||
return getJsonHttpStatus(CONFLICT, mapHeaderMessage);
|
||||
}
|
||||
}
|
||||
|
||||
@RequestMapping(value = "/get-formasi-jabatan", method = RequestMethod.GET)
|
||||
@RequestMapping(value = "/get-formasi-jabatan", method = GET)
|
||||
public ResponseEntity<List<Map<String, Object>>> getFormasiJabatan(HttpServletRequest request) {
|
||||
List<Map<String, Object>> result = new ArrayList<Map<String, Object>>();
|
||||
try {
|
||||
result = mapPegawaiJabatanToUnitKerjaService.findFormasiJabatan();
|
||||
mapHeaderMessage.put(WebConstants.HttpHeaderInfo.LABEL_SUCCESS,
|
||||
getMessage(MessageResource.LABEL_SUCCESS, request));
|
||||
return RestUtil.getJsonResponse(result, HttpStatus.OK, mapHeaderMessage);
|
||||
List<Map<String, Object>> result = mapPegawaiJabatanToUnitKerjaService.findFormasiJabatan();
|
||||
mapHeaderMessage.put(LABEL_SUCCESS, getMessage(MessageResource.LABEL_SUCCESS, request));
|
||||
return getJsonResponse(result, OK, mapHeaderMessage);
|
||||
} catch (ServiceVOException e) {
|
||||
LOGGER.error("Got exception {} when get formasi jabatan", e.getMessage());
|
||||
addHeaderMessage(Constants.MessageInfo.ERROR_MESSAGE, e.getMessage());
|
||||
return RestUtil.getJsonHttptatus(HttpStatus.INTERNAL_SERVER_ERROR, mapHeaderMessage);
|
||||
LOGGER.error("Got ServiceVOException {} when findFormasiJabatan", e.getMessage());
|
||||
addHeaderMessage(ERROR_MESSAGE, e.getMessage());
|
||||
return getJsonHttpStatus(INTERNAL_SERVER_ERROR, mapHeaderMessage);
|
||||
} catch (JpaSystemException jse) {
|
||||
LOGGER.error("Got exception {} when get formasi jabatan", jse.getMessage());
|
||||
addHeaderMessage(Constants.MessageInfo.ERROR_MESSAGE, jse.getMessage());
|
||||
return RestUtil.getJsonHttptatus(HttpStatus.CONFLICT, mapHeaderMessage);
|
||||
LOGGER.error("Got JpaSystemException {} when findFormasiJabatan", jse.getMessage());
|
||||
addHeaderMessage(ERROR_MESSAGE, jse.getMessage());
|
||||
return getJsonHttpStatus(CONFLICT, mapHeaderMessage);
|
||||
}
|
||||
}
|
||||
|
||||
@RequestMapping(value = "/get-jabatan-pegawai", method = RequestMethod.GET)
|
||||
@RequestMapping(value = "/get-jabatan-pegawai", method = GET)
|
||||
public ResponseEntity<List<Map<String, Object>>> getJabatanPegawai(HttpServletRequest request) {
|
||||
List<Map<String, Object>> result = new ArrayList<Map<String, Object>>();
|
||||
try {
|
||||
result = mapPegawaiJabatanToUnitKerjaService.getJabatanPegawai();
|
||||
mapHeaderMessage.put(WebConstants.HttpHeaderInfo.LABEL_SUCCESS,
|
||||
getMessage(MessageResource.LABEL_SUCCESS, request));
|
||||
return RestUtil.getJsonResponse(result, HttpStatus.OK, mapHeaderMessage);
|
||||
List<Map<String, Object>> result = mapPegawaiJabatanToUnitKerjaService.getJabatanPegawai();
|
||||
mapHeaderMessage.put(LABEL_SUCCESS, getMessage(MessageResource.LABEL_SUCCESS, request));
|
||||
return getJsonResponse(result, OK, mapHeaderMessage);
|
||||
} catch (ServiceVOException e) {
|
||||
LOGGER.error("Got exception {} when get jabatan pegawai", e.getMessage());
|
||||
addHeaderMessage(Constants.MessageInfo.ERROR_MESSAGE, e.getMessage());
|
||||
return RestUtil.getJsonHttptatus(HttpStatus.INTERNAL_SERVER_ERROR, mapHeaderMessage);
|
||||
LOGGER.error("Got ServiceVOException {} when getJabatanPegawai", e.getMessage());
|
||||
addHeaderMessage(ERROR_MESSAGE, e.getMessage());
|
||||
return getJsonHttpStatus(INTERNAL_SERVER_ERROR, mapHeaderMessage);
|
||||
} catch (JpaSystemException jse) {
|
||||
LOGGER.error("Got exception {} when get jabatan pegawai", jse.getMessage());
|
||||
addHeaderMessage(Constants.MessageInfo.ERROR_MESSAGE, jse.getMessage());
|
||||
return RestUtil.getJsonHttptatus(HttpStatus.CONFLICT, mapHeaderMessage);
|
||||
LOGGER.error("Got JpaSystemException {} when getJabatanPegawai", jse.getMessage());
|
||||
addHeaderMessage(ERROR_MESSAGE, jse.getMessage());
|
||||
return getJsonHttpStatus(CONFLICT, mapHeaderMessage);
|
||||
}
|
||||
}
|
||||
|
||||
@RequestMapping(value = "/get-evaluasi-jabatan-pegawai-baru", method = RequestMethod.GET)
|
||||
@RequestMapping(value = "/get-evaluasi-jabatan-pegawai-baru", method = GET)
|
||||
public ResponseEntity<Map<String, Object>> getEvaluasiJabatanPegawaiBaru(
|
||||
@RequestParam(value = "listJabatanId", required = false) List<Integer> listIdJabatan,
|
||||
HttpServletRequest request) {
|
||||
Map<String, Object> result = new HashMap<>();
|
||||
try {
|
||||
result.put("data", mapPegawaiJabatanToUnitKerjaService.getEvaluasiJabatanPegawaiBaru(listIdJabatan));
|
||||
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);
|
||||
} catch (ServiceVOException e) {
|
||||
LOGGER.error("Got exception {} when get evaluasi jabatan pegawai baru", e.getMessage());
|
||||
addHeaderMessage(Constants.MessageInfo.ERROR_MESSAGE, e.getMessage());
|
||||
return RestUtil.getJsonHttptatus(HttpStatus.INTERNAL_SERVER_ERROR, mapHeaderMessage);
|
||||
LOGGER.error("Got ServiceVOException {} when getEvaluasiJabatanPegawaiBaru", e.getMessage());
|
||||
addHeaderMessage(ERROR_MESSAGE, e.getMessage());
|
||||
return getJsonHttpStatus(INTERNAL_SERVER_ERROR, mapHeaderMessage);
|
||||
} catch (JpaSystemException jse) {
|
||||
LOGGER.error("Got exception {} when get evaluasi jabatan pegawai baru", jse.getMessage());
|
||||
addHeaderMessage(Constants.MessageInfo.ERROR_MESSAGE, jse.getMessage());
|
||||
return RestUtil.getJsonHttptatus(HttpStatus.CONFLICT, mapHeaderMessage);
|
||||
LOGGER.error("Got JpaSystemException {} when getEvaluasiJabatanPegawaiBaru", jse.getMessage());
|
||||
addHeaderMessage(ERROR_MESSAGE, jse.getMessage());
|
||||
return getJsonHttpStatus(CONFLICT, mapHeaderMessage);
|
||||
}
|
||||
}
|
||||
|
||||
@RequestMapping(value = "/pegawai/{unitKerjaId}", method = RequestMethod.GET)
|
||||
@RequestMapping(value = "/pegawai/{unitKerjaId}", method = GET)
|
||||
public ResponseEntity<List<Map<String, Object>>> getPegawaiByUnitKerja(@PathVariable Integer unitKerjaId,
|
||||
HttpServletRequest request) {
|
||||
try {
|
||||
List<Map<String, Object>> result = mapPegawaiJabatanToUnitKerjaService
|
||||
.getlistPegawaiByUnitKerja(unitKerjaId);
|
||||
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);
|
||||
} catch (ServiceVOException e) {
|
||||
LOGGER.error("Got exception {} when get jabatan pegawai", e.getMessage());
|
||||
addHeaderMessage(Constants.MessageInfo.ERROR_MESSAGE, e.getMessage());
|
||||
return RestUtil.getJsonHttptatus(HttpStatus.INTERNAL_SERVER_ERROR, mapHeaderMessage);
|
||||
LOGGER.error("Got ServiceVOException {} when getlistPegawaiByUnitKerja", e.getMessage());
|
||||
addHeaderMessage(ERROR_MESSAGE, e.getMessage());
|
||||
return getJsonHttpStatus(INTERNAL_SERVER_ERROR, mapHeaderMessage);
|
||||
} catch (JpaSystemException jse) {
|
||||
LOGGER.error("Got exception {} when get jabatan pegawai", jse.getMessage());
|
||||
addHeaderMessage(Constants.MessageInfo.ERROR_MESSAGE, jse.getMessage());
|
||||
return RestUtil.getJsonHttptatus(HttpStatus.CONFLICT, mapHeaderMessage);
|
||||
LOGGER.error("Got JpaSystemException {} when getlistPegawaiByUnitKerja", jse.getMessage());
|
||||
addHeaderMessage(ERROR_MESSAGE, jse.getMessage());
|
||||
return getJsonHttpStatus(CONFLICT, mapHeaderMessage);
|
||||
}
|
||||
}
|
||||
|
||||
@RequestMapping(value = "/logbook-title/{idPegawai}", method = RequestMethod.GET)
|
||||
@RequestMapping(value = "/logbook-title/{idPegawai}", method = GET)
|
||||
public ResponseEntity<String> logbookTitle(@PathVariable("idPegawai") Integer idPegawai) {
|
||||
String jenisLogbook = mapPegawaiJabatanToUnitKerjaService.getJenisLogbook(idPegawai);
|
||||
return RestUtil.getJsonResponse(jenisLogbook, HttpStatus.OK);
|
||||
return getJsonResponse(jenisLogbook, OK);
|
||||
}
|
||||
|
||||
@RequestMapping(value = "/jabatan/{idPegawai}", method = RequestMethod.GET)
|
||||
@RequestMapping(value = "/jabatan/{idPegawai}", method = GET)
|
||||
public ResponseEntity<PegawaiJabatanDto> pegawaiJabatan(@PathVariable("idPegawai") Integer idPegawai) {
|
||||
PegawaiJabatanDto dataJabatan = mapPegawaiJabatanToUnitKerjaService.getDataJabatan(idPegawai);
|
||||
return RestUtil.getJsonResponse(dataJabatan, HttpStatus.OK);
|
||||
return getJsonResponse(dataJabatan, OK);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@ -1,288 +1,270 @@
|
||||
package com.jasamedika.medifirst2000.controller;
|
||||
|
||||
import com.jasamedika.medifirst2000.constants.MessageResource;
|
||||
import com.jasamedika.medifirst2000.controller.base.LocaleController;
|
||||
import com.jasamedika.medifirst2000.dto.FileUploadExcelDto;
|
||||
import com.jasamedika.medifirst2000.dto.PayRollDto;
|
||||
import com.jasamedika.medifirst2000.dto.PayRollUangMakanDto;
|
||||
import com.jasamedika.medifirst2000.service.PayRollPegawaiService;
|
||||
import com.jasamedika.medifirst2000.vo.StrukHistoriVO;
|
||||
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.RequestParam;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
import javax.validation.Valid;
|
||||
|
||||
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.FileUploadExcelDto;
|
||||
import com.jasamedika.medifirst2000.dto.OrderPelayananGiziDto;
|
||||
import com.jasamedika.medifirst2000.dto.PayRollDto;
|
||||
import com.jasamedika.medifirst2000.dto.PayRollUangMakanDto;
|
||||
import com.jasamedika.medifirst2000.service.PayRollPegawaiService;
|
||||
import com.jasamedika.medifirst2000.util.DateUtil;
|
||||
import com.jasamedika.medifirst2000.util.rest.RestUtil;
|
||||
import com.jasamedika.medifirst2000.vo.StrukHistoriVO;
|
||||
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.DateUtil.toDate;
|
||||
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(value="/pay-roll")
|
||||
@RequestMapping(value = "/pay-roll")
|
||||
public class PayRollPegawaiController extends LocaleController<StrukHistoriVO> {
|
||||
|
||||
|
||||
@Autowired
|
||||
private PayRollPegawaiService payRollPegawaiService;
|
||||
|
||||
@RequestMapping(value="/get-pegawai-blu-pkwt", method = RequestMethod.GET, produces = MediaType.APPLICATION_JSON_VALUE)
|
||||
@RequestMapping(value = "/get-pegawai-blu-pkwt", method = GET, produces = APPLICATION_JSON_VALUE)
|
||||
public ResponseEntity<List<Map<String, Object>>> prosesPegawaiBluPkwt(
|
||||
@RequestParam(value="idKategoryPegawai", required = true) Integer idKategoryPegawai,
|
||||
@RequestParam(value="idJenisGaji" , required = true) Integer idJenisGaji,
|
||||
@RequestParam(value="periode", required = true) String periode,
|
||||
@RequestParam(value="tglHistori", required = false) String tglHistori,
|
||||
HttpServletRequest request) {
|
||||
List<Map<String, Object>> result = payRollPegawaiService.prosesPegawaiBluPkwt(idKategoryPegawai,idJenisGaji,periode,DateUtil.toDate(tglHistori));
|
||||
|
||||
@RequestParam(value = "idKategoryPegawai") Integer idKategoryPegawai,
|
||||
@RequestParam(value = "idJenisGaji") Integer idJenisGaji, @RequestParam(value = "periode") String periode,
|
||||
@RequestParam(value = "tglHistori", required = false) String tglHistori, HttpServletRequest request) {
|
||||
List<Map<String, Object>> result = payRollPegawaiService.prosesPegawaiBluPkwt(idKategoryPegawai, idJenisGaji,
|
||||
periode, toDate(tglHistori));
|
||||
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.getJsonHttptatus(HttpStatus.INTERNAL_SERVER_ERROR, mapHeaderMessage);
|
||||
return getJsonHttpStatus(INTERNAL_SERVER_ERROR, mapHeaderMessage);
|
||||
}
|
||||
|
||||
@RequestMapping(value="/save-pegawai-blu-pkwt", method = RequestMethod.POST, produces = MediaType.APPLICATION_JSON_VALUE)
|
||||
@RequestMapping(value = "/save-pegawai-blu-pkwt", method = POST, produces = APPLICATION_JSON_VALUE)
|
||||
public ResponseEntity<List<PayRollDto>> savePegawaiByStatusPegawai(@RequestBody List<PayRollDto> dtos,
|
||||
HttpServletRequest request) {
|
||||
List<PayRollDto> result = payRollPegawaiService.save(dtos);
|
||||
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.getJsonHttptatus(HttpStatus.INTERNAL_SERVER_ERROR, mapHeaderMessage);
|
||||
return getJsonHttpStatus(INTERNAL_SERVER_ERROR, mapHeaderMessage);
|
||||
}
|
||||
|
||||
@RequestMapping(value="/find-status-pegawai-blu-pkwt", method = RequestMethod.GET, produces = MediaType.APPLICATION_JSON_VALUE)
|
||||
|
||||
@RequestMapping(value = "/find-status-pegawai-blu-pkwt", method = GET, produces = APPLICATION_JSON_VALUE)
|
||||
public ResponseEntity<List<Map<String, Object>>> findPegawaiBluPkwt(HttpServletRequest request) {
|
||||
List<Integer> ids=new ArrayList<Integer>();
|
||||
List<Integer> ids = new ArrayList<>();
|
||||
ids.add(9);
|
||||
ids.add(10);
|
||||
List<Map<String, Object>> result = payRollPegawaiService.findDetailKategoryPegawaiBluPkwt(ids);
|
||||
|
||||
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.getJsonHttptatus(HttpStatus.INTERNAL_SERVER_ERROR, mapHeaderMessage);
|
||||
return getJsonHttpStatus(INTERNAL_SERVER_ERROR, mapHeaderMessage);
|
||||
}
|
||||
|
||||
@RequestMapping(value="/find-jenis-gaji", method = RequestMethod.GET, produces = MediaType.APPLICATION_JSON_VALUE)
|
||||
@RequestMapping(value = "/find-jenis-gaji", method = GET, produces = APPLICATION_JSON_VALUE)
|
||||
public ResponseEntity<List<Map<String, Object>>> findJenisGaji(HttpServletRequest request) {
|
||||
List<Map<String, Object>> result = payRollPegawaiService.findAllJenisGaji();
|
||||
|
||||
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.getJsonHttptatus(HttpStatus.INTERNAL_SERVER_ERROR, mapHeaderMessage);
|
||||
return getJsonHttpStatus(INTERNAL_SERVER_ERROR, mapHeaderMessage);
|
||||
}
|
||||
|
||||
@RequestMapping(value="/get-uang-makan-pegawai", method = RequestMethod.GET, produces = MediaType.APPLICATION_JSON_VALUE)
|
||||
|
||||
@RequestMapping(value = "/get-uang-makan-pegawai", method = GET, produces = APPLICATION_JSON_VALUE)
|
||||
public ResponseEntity<List<Map<String, Object>>> prosesUangMakanPegawai(
|
||||
@RequestParam(value="idKategoryPegawai", required = true) Integer idKategoryPegawai,
|
||||
@RequestParam(value="idJenisGaji" , required = true) Integer idJenisGaji,
|
||||
@RequestParam(value="periode", required = true) String periode,
|
||||
@RequestParam(value="tglHistori", required = false) String tglHistori,
|
||||
HttpServletRequest request) {
|
||||
List<Map<String, Object>> result = payRollPegawaiService.prosesUangMakanPegawai(idKategoryPegawai,idJenisGaji,periode,"uangmakan",DateUtil.toDate(tglHistori));
|
||||
|
||||
@RequestParam(value = "idKategoryPegawai") Integer idKategoryPegawai,
|
||||
@RequestParam(value = "idJenisGaji") Integer idJenisGaji, @RequestParam(value = "periode") String periode,
|
||||
@RequestParam(value = "tglHistori", required = false) String tglHistori, HttpServletRequest request) {
|
||||
List<Map<String, Object>> result = payRollPegawaiService.prosesUangMakanPegawai(idKategoryPegawai, idJenisGaji,
|
||||
periode, "uangmakan", toDate(tglHistori));
|
||||
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.getJsonHttptatus(HttpStatus.INTERNAL_SERVER_ERROR, mapHeaderMessage);
|
||||
return getJsonHttpStatus(INTERNAL_SERVER_ERROR, mapHeaderMessage);
|
||||
}
|
||||
|
||||
@RequestMapping(value="/find-status-pegawai-uang-makan", method = RequestMethod.GET, produces = MediaType.APPLICATION_JSON_VALUE)
|
||||
|
||||
@RequestMapping(value = "/find-status-pegawai-uang-makan", method = GET, produces = APPLICATION_JSON_VALUE)
|
||||
public ResponseEntity<List<Map<String, Object>>> findPegawaiUangMakan(HttpServletRequest request) {
|
||||
List<Integer> ids=new ArrayList<Integer>();
|
||||
List<Integer> ids = new ArrayList<>();
|
||||
ids.add(9);
|
||||
ids.add(10);
|
||||
ids.add(18);
|
||||
ids.add(19);
|
||||
List<Map<String, Object>> result = payRollPegawaiService.findDetailKategoryPegawaiBluPkwt(ids);
|
||||
|
||||
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.getJsonHttptatus(HttpStatus.INTERNAL_SERVER_ERROR, mapHeaderMessage);
|
||||
return getJsonHttpStatus(INTERNAL_SERVER_ERROR, mapHeaderMessage);
|
||||
}
|
||||
|
||||
@RequestMapping(value="/save-pegawai-uang-makan", method = RequestMethod.POST, produces = MediaType.APPLICATION_JSON_VALUE)
|
||||
@RequestMapping(value = "/save-pegawai-uang-makan", method = POST, produces = APPLICATION_JSON_VALUE)
|
||||
public ResponseEntity<List<PayRollUangMakanDto>> savePegawaiUangMakan(@RequestBody List<PayRollUangMakanDto> dtos,
|
||||
HttpServletRequest request) {
|
||||
List<PayRollUangMakanDto> result = payRollPegawaiService.saveUangMakan(dtos,"uangmakan");
|
||||
List<PayRollUangMakanDto> result = payRollPegawaiService.saveUangMakan(dtos, "uangmakan");
|
||||
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.getJsonHttptatus(HttpStatus.INTERNAL_SERVER_ERROR, mapHeaderMessage);
|
||||
return getJsonHttpStatus(INTERNAL_SERVER_ERROR, mapHeaderMessage);
|
||||
}
|
||||
|
||||
@RequestMapping(value="/import-uang-makan", method = RequestMethod.POST, produces = MediaType.APPLICATION_JSON_VALUE)
|
||||
@RequestMapping(value = "/import-uang-makan", method = POST, produces = APPLICATION_JSON_VALUE)
|
||||
public ResponseEntity<List<PayRollUangMakanDto>> importUangMakan(
|
||||
@RequestParam(value="idKategoryPegawai", required = false) Integer idKategoryPegawai,
|
||||
@RequestParam(value="idJenisGaji" , required = false) Integer idJenisGaji,
|
||||
@RequestParam(value="periode", required = false) String periode,
|
||||
@RequestParam(value="file",required = false) String file,
|
||||
@RequestParam(value="tglHistori", required = false) String tglHistori,@RequestBody FileUploadExcelDto dto,
|
||||
HttpServletRequest request) {
|
||||
List<PayRollUangMakanDto> result = payRollPegawaiService.importUangMakan(idKategoryPegawai,idJenisGaji,periode,file,DateUtil.toDate(tglHistori),dto);
|
||||
@RequestParam(value = "idKategoryPegawai", required = false) Integer idKategoryPegawai,
|
||||
@RequestParam(value = "idJenisGaji", required = false) Integer idJenisGaji,
|
||||
@RequestParam(value = "periode", required = false) String periode,
|
||||
@RequestParam(value = "file", required = false) String file,
|
||||
@RequestParam(value = "tglHistori", required = false) String tglHistori,
|
||||
@RequestBody FileUploadExcelDto dto, HttpServletRequest request) {
|
||||
List<PayRollUangMakanDto> result = payRollPegawaiService.importUangMakan(idKategoryPegawai, idJenisGaji,
|
||||
periode, file, toDate(tglHistori), dto);
|
||||
if (result != null) {
|
||||
if (!result.isEmpty()) {
|
||||
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 {
|
||||
mapHeaderMessage.put(WebConstants.HttpHeaderInfo.LABEL_ERROR, "Processing data error returns empty data");
|
||||
return RestUtil.getJsonHttptatus(HttpStatus.INTERNAL_SERVER_ERROR, mapHeaderMessage);
|
||||
mapHeaderMessage.put(LABEL_ERROR, "Processing data error returns empty data");
|
||||
return getJsonHttpStatus(INTERNAL_SERVER_ERROR, mapHeaderMessage);
|
||||
}
|
||||
} else {
|
||||
return RestUtil.getJsonHttptatus(HttpStatus.INTERNAL_SERVER_ERROR, mapHeaderMessage);
|
||||
return getJsonHttpStatus(INTERNAL_SERVER_ERROR, mapHeaderMessage);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@RequestMapping(value="/find-status-pegawai-harianLepas", method = RequestMethod.GET, produces = MediaType.APPLICATION_JSON_VALUE)
|
||||
@RequestMapping(value = "/find-status-pegawai-harianLepas", method = GET, produces = APPLICATION_JSON_VALUE)
|
||||
public ResponseEntity<List<Map<String, Object>>> findPegawaiHarianLepas(HttpServletRequest request) {
|
||||
List<Integer> ids=new ArrayList<Integer>();
|
||||
List<Integer> ids = new ArrayList<>();
|
||||
ids.add(13);
|
||||
List<Map<String, Object>> result = payRollPegawaiService.findDetailKategoryPegawaiBluPkwt(ids);
|
||||
|
||||
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.getJsonHttptatus(HttpStatus.INTERNAL_SERVER_ERROR, mapHeaderMessage);
|
||||
return getJsonHttpStatus(INTERNAL_SERVER_ERROR, mapHeaderMessage);
|
||||
}
|
||||
|
||||
@RequestMapping(value="/get-harian-lepas-pegawai", method = RequestMethod.GET, produces = MediaType.APPLICATION_JSON_VALUE)
|
||||
@RequestMapping(value = "/get-harian-lepas-pegawai", method = GET, produces = APPLICATION_JSON_VALUE)
|
||||
public ResponseEntity<List<Map<String, Object>>> prosesPegawaiHarianLepas(
|
||||
@RequestParam(value="idKategoryPegawai", required = true) Integer idKategoryPegawai,
|
||||
@RequestParam(value="idJenisGaji" , required = true) Integer idJenisGaji,
|
||||
@RequestParam(value="periode", required = true) String periode,
|
||||
@RequestParam(value="tglHistori", required = false) String tglHistori,
|
||||
HttpServletRequest request) {
|
||||
List<Map<String, Object>> result = payRollPegawaiService.prosesUangMakanPegawai(idKategoryPegawai,idJenisGaji,periode,"harianlepas",DateUtil.toDate(tglHistori));
|
||||
|
||||
@RequestParam(value = "idKategoryPegawai") Integer idKategoryPegawai,
|
||||
@RequestParam(value = "idJenisGaji") Integer idJenisGaji, @RequestParam(value = "periode") String periode,
|
||||
@RequestParam(value = "tglHistori", required = false) String tglHistori, HttpServletRequest request) {
|
||||
List<Map<String, Object>> result = payRollPegawaiService.prosesUangMakanPegawai(idKategoryPegawai, idJenisGaji,
|
||||
periode, "harianlepas", toDate(tglHistori));
|
||||
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.getJsonHttptatus(HttpStatus.INTERNAL_SERVER_ERROR, mapHeaderMessage);
|
||||
return getJsonHttpStatus(INTERNAL_SERVER_ERROR, mapHeaderMessage);
|
||||
}
|
||||
|
||||
@RequestMapping(value="/save-pegawai-harian-lepas", method = RequestMethod.POST, produces = MediaType.APPLICATION_JSON_VALUE)
|
||||
@RequestMapping(value = "/save-pegawai-harian-lepas", method = POST, produces = APPLICATION_JSON_VALUE)
|
||||
public ResponseEntity<List<PayRollUangMakanDto>> saveHarianLepas(@RequestBody List<PayRollUangMakanDto> dtos,
|
||||
HttpServletRequest request) {
|
||||
List<PayRollUangMakanDto> result = payRollPegawaiService.saveUangMakan(dtos,"harianlepas");
|
||||
List<PayRollUangMakanDto> result = payRollPegawaiService.saveUangMakan(dtos, "harianlepas");
|
||||
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.getJsonHttptatus(HttpStatus.INTERNAL_SERVER_ERROR, mapHeaderMessage);
|
||||
return getJsonHttpStatus(INTERNAL_SERVER_ERROR, mapHeaderMessage);
|
||||
}
|
||||
|
||||
@RequestMapping(value="/find-status-pegawai-pkwt", method = RequestMethod.GET, produces = MediaType.APPLICATION_JSON_VALUE)
|
||||
|
||||
@RequestMapping(value = "/find-status-pegawai-pkwt", method = GET, produces = APPLICATION_JSON_VALUE)
|
||||
public ResponseEntity<List<Map<String, Object>>> findPegawaiDokterPsikologiPkwt(HttpServletRequest request) {
|
||||
List<Integer> ids=new ArrayList<Integer>();
|
||||
List<Integer> ids = new ArrayList<>();
|
||||
ids.add(10);
|
||||
List<Map<String, Object>> result = payRollPegawaiService.findDetailKategoryPegawaiBluPkwt(ids);
|
||||
|
||||
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.getJsonHttptatus(HttpStatus.INTERNAL_SERVER_ERROR, mapHeaderMessage);
|
||||
return getJsonHttpStatus(INTERNAL_SERVER_ERROR, mapHeaderMessage);
|
||||
}
|
||||
|
||||
@RequestMapping(value="/get-dokter-psikologi-pkwt", method = RequestMethod.GET, produces = MediaType.APPLICATION_JSON_VALUE)
|
||||
@RequestMapping(value = "/get-dokter-psikologi-pkwt", method = GET, produces = APPLICATION_JSON_VALUE)
|
||||
public ResponseEntity<List<Map<String, Object>>> prosesDokterPsikologiPkwt(
|
||||
@RequestParam(value="idKategoryPegawai", required = true) Integer idKategoryPegawai,
|
||||
@RequestParam(value="idJenisGaji" , required = true) Integer idJenisGaji,
|
||||
@RequestParam(value="periode", required = true) String periode,
|
||||
@RequestParam(value="tglHistori", required = false) String tglHistori,
|
||||
HttpServletRequest request) {
|
||||
List<Map<String, Object>> result = payRollPegawaiService.prosesDokterPsikologiPkwt(idKategoryPegawai,idJenisGaji,periode,DateUtil.toDate(tglHistori));
|
||||
|
||||
@RequestParam(value = "idKategoryPegawai") Integer idKategoryPegawai,
|
||||
@RequestParam(value = "idJenisGaji") Integer idJenisGaji, @RequestParam(value = "periode") String periode,
|
||||
@RequestParam(value = "tglHistori", required = false) String tglHistori, HttpServletRequest request) {
|
||||
List<Map<String, Object>> result = payRollPegawaiService.prosesDokterPsikologiPkwt(idKategoryPegawai,
|
||||
idJenisGaji, periode, toDate(tglHistori));
|
||||
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.getJsonHttptatus(HttpStatus.INTERNAL_SERVER_ERROR, mapHeaderMessage);
|
||||
return getJsonHttpStatus(INTERNAL_SERVER_ERROR, mapHeaderMessage);
|
||||
}
|
||||
|
||||
@RequestMapping(value="/save-dokter-psikologi-pkwt", method = RequestMethod.POST, produces = MediaType.APPLICATION_JSON_VALUE)
|
||||
public ResponseEntity<List<PayRollUangMakanDto>> saveDokterPsikologiPkwt(@RequestBody List<PayRollUangMakanDto> dtos,
|
||||
HttpServletRequest request) {
|
||||
List<PayRollUangMakanDto> result = payRollPegawaiService.saveUangMakan(dtos,"tunjanganlayanan");
|
||||
@RequestMapping(value = "/save-dokter-psikologi-pkwt", method = POST, produces = APPLICATION_JSON_VALUE)
|
||||
public ResponseEntity<List<PayRollUangMakanDto>> saveDokterPsikologiPkwt(
|
||||
@RequestBody List<PayRollUangMakanDto> dtos, HttpServletRequest request) {
|
||||
List<PayRollUangMakanDto> result = payRollPegawaiService.saveUangMakan(dtos, "tunjanganlayanan");
|
||||
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.getJsonHttptatus(HttpStatus.INTERNAL_SERVER_ERROR, mapHeaderMessage);
|
||||
return getJsonHttpStatus(INTERNAL_SERVER_ERROR, mapHeaderMessage);
|
||||
}
|
||||
|
||||
@RequestMapping(value="/find-rekanan-penjamin-pasien", method = RequestMethod.GET, produces = MediaType.APPLICATION_JSON_VALUE)
|
||||
@RequestMapping(value = "/find-rekanan-penjamin-pasien", method = GET, produces = APPLICATION_JSON_VALUE)
|
||||
public ResponseEntity<List<Map<String, Object>>> findRekananPenjaminPasien(HttpServletRequest request) {
|
||||
List<Map<String, Object>> result = payRollPegawaiService.findRekananPenjaminPasien();
|
||||
|
||||
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.getJsonHttptatus(HttpStatus.INTERNAL_SERVER_ERROR, mapHeaderMessage);
|
||||
return getJsonHttpStatus(INTERNAL_SERVER_ERROR, mapHeaderMessage);
|
||||
}
|
||||
|
||||
@RequestMapping(value="/find-umr", method = RequestMethod.GET, produces = MediaType.APPLICATION_JSON_VALUE)
|
||||
public ResponseEntity<Map<String, Object>> findUmr(
|
||||
@RequestParam(value="periode", required = true) String periode,
|
||||
@RequestMapping(value = "/find-umr", method = GET, produces = APPLICATION_JSON_VALUE)
|
||||
public ResponseEntity<Map<String, Object>> findUmr(@RequestParam(value = "periode") String periode,
|
||||
HttpServletRequest request) {
|
||||
Map<String, Object> result = payRollPegawaiService.findUmr(periode);
|
||||
|
||||
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.getJsonHttptatus(HttpStatus.INTERNAL_SERVER_ERROR, mapHeaderMessage);
|
||||
return getJsonHttpStatus(INTERNAL_SERVER_ERROR, mapHeaderMessage);
|
||||
}
|
||||
|
||||
@RequestMapping(value="/get-premi-asuransi", method = RequestMethod.GET, produces = MediaType.APPLICATION_JSON_VALUE)
|
||||
@RequestMapping(value = "/get-premi-asuransi", method = GET, produces = APPLICATION_JSON_VALUE)
|
||||
public ResponseEntity<List<Map<String, Object>>> prosesPremiAsuransi(
|
||||
@RequestParam(value="idJenisGaji" , required = true) Integer idJenisGaji,
|
||||
@RequestParam(value="periode", required = true) String periode,
|
||||
@RequestParam(value="idRekanan" , required = true) Integer idRekanan,
|
||||
@RequestParam(value="tglHistori", required = false) String tglHistori,
|
||||
HttpServletRequest request) {
|
||||
List<Map<String, Object>> result = payRollPegawaiService.prosesPremiAsuransi(idJenisGaji,periode,idRekanan,DateUtil.toDate(tglHistori));
|
||||
|
||||
@RequestParam(value = "idJenisGaji") Integer idJenisGaji, @RequestParam(value = "periode") String periode,
|
||||
@RequestParam(value = "idRekanan") Integer idRekanan,
|
||||
@RequestParam(value = "tglHistori", required = false) String tglHistori, HttpServletRequest request) {
|
||||
List<Map<String, Object>> result = payRollPegawaiService.prosesPremiAsuransi(idJenisGaji, periode, idRekanan,
|
||||
toDate(tglHistori));
|
||||
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.getJsonHttptatus(HttpStatus.INTERNAL_SERVER_ERROR, mapHeaderMessage);
|
||||
return getJsonHttpStatus(INTERNAL_SERVER_ERROR, mapHeaderMessage);
|
||||
}
|
||||
|
||||
@RequestMapping(value="/save-premi-asuransi", method = RequestMethod.POST, produces = MediaType.APPLICATION_JSON_VALUE)
|
||||
@RequestMapping(value = "/save-premi-asuransi", method = POST, produces = APPLICATION_JSON_VALUE)
|
||||
public ResponseEntity<List<PayRollUangMakanDto>> savePremiAsuransi(@RequestBody List<PayRollUangMakanDto> dtos,
|
||||
HttpServletRequest request) {
|
||||
List<PayRollUangMakanDto> result = payRollPegawaiService.savePremiAsuransi(dtos);
|
||||
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.getJsonHttptatus(HttpStatus.INTERNAL_SERVER_ERROR, mapHeaderMessage);
|
||||
return getJsonHttpStatus(INTERNAL_SERVER_ERROR, mapHeaderMessage);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
@ -1,31 +1,33 @@
|
||||
package com.jasamedika.medifirst2000.controller;
|
||||
|
||||
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.BatalPaketProdukDto;
|
||||
import com.jasamedika.medifirst2000.dto.TagihanPendaftaranDto;
|
||||
import com.jasamedika.medifirst2000.exception.ServiceVOException;
|
||||
import com.jasamedika.medifirst2000.service.*;
|
||||
import com.jasamedika.medifirst2000.util.rest.RestUtil;
|
||||
import com.jasamedika.medifirst2000.vo.MapProdukPaketToProdukVO;
|
||||
import com.jasamedika.medifirst2000.vo.MapProdukPaketVO;
|
||||
import com.jasamedika.medifirst2000.vo.PelayananPasienVO;
|
||||
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.*;
|
||||
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
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.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.*;
|
||||
import static org.springframework.http.MediaType.APPLICATION_JSON_VALUE;
|
||||
import static org.springframework.web.bind.annotation.RequestMethod.GET;
|
||||
|
||||
@RestController
|
||||
@RequestMapping("/pelayanan")
|
||||
public class PelayananController extends LocaleController<PelayananPasienVO> {
|
||||
@ -50,275 +52,257 @@ public class PelayananController extends LocaleController<PelayananPasienVO> {
|
||||
@Autowired
|
||||
private MapProdukPaketToProdukService mapProdukPaketToProdukService;
|
||||
|
||||
@RequestMapping(value = "/calculate-indikator-pelayanan", method = RequestMethod.GET)
|
||||
@RequestMapping(value = "/calculate-indikator-pelayanan", method = GET)
|
||||
public ResponseEntity<List<Map<String, Object>>> calculateIndikatorPelayanan(HttpServletRequest request,
|
||||
@RequestParam("tahun") String tahun) {
|
||||
try {
|
||||
List<Map<String, Object>> result = pasienDaftarService.findIndikatorPelayanan(tahun);
|
||||
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);
|
||||
} catch (ServiceVOException sve) {
|
||||
LOGGER.error("Got exception {} when calculate indikator pelayanan", sve.getMessage());
|
||||
addHeaderMessage(Constants.MessageInfo.ERROR_MESSAGE, sve.getMessage());
|
||||
return RestUtil.getJsonHttptatus(HttpStatus.INTERNAL_SERVER_ERROR, mapHeaderMessage);
|
||||
LOGGER.error("Got ServiceVOException {} when findIndikatorPelayanan", sve.getMessage());
|
||||
addHeaderMessage(ERROR_MESSAGE, sve.getMessage());
|
||||
return getJsonHttpStatus(INTERNAL_SERVER_ERROR, mapHeaderMessage);
|
||||
} catch (JpaSystemException jse) {
|
||||
LOGGER.error("Got exception {} when calculate indikator pelayanan", jse.getMessage());
|
||||
addHeaderMessage(Constants.MessageInfo.ERROR_MESSAGE, jse.getMessage());
|
||||
return RestUtil.getJsonHttptatus(HttpStatus.CONFLICT, mapHeaderMessage);
|
||||
LOGGER.error("Got JpaSystemException {} when findIndikatorPelayanan", jse.getMessage());
|
||||
addHeaderMessage(ERROR_MESSAGE, jse.getMessage());
|
||||
return getJsonHttpStatus(CONFLICT, mapHeaderMessage);
|
||||
}
|
||||
}
|
||||
|
||||
@RequestMapping(value = "/validate-nama-produk", method = RequestMethod.GET, produces = MediaType.APPLICATION_JSON_VALUE)
|
||||
@RequestMapping(value = "/validate-nama-produk", method = GET, produces = APPLICATION_JSON_VALUE)
|
||||
public ResponseEntity<Map<String, Object>> validateNamaProduk(HttpServletRequest request,
|
||||
@RequestParam(value = "idProduk", required = false) Integer idProduk,
|
||||
@RequestParam(value = "namaProduk") String namaProduk) {
|
||||
try {
|
||||
Map<String, Object> result = produkService.validateNamaProduk(idProduk, namaProduk);
|
||||
|
||||
return RestUtil.getJsonResponse(result, HttpStatus.OK);
|
||||
return getJsonResponse(result, OK);
|
||||
} catch (ServiceVOException e) {
|
||||
LOGGER.error("Got exception {} when validate nama produk", e.getMessage());
|
||||
addHeaderMessage(Constants.MessageInfo.ERROR_MESSAGE, e.getMessage());
|
||||
return RestUtil.getJsonHttptatus(HttpStatus.INTERNAL_SERVER_ERROR, mapHeaderMessage);
|
||||
LOGGER.error("Got ServiceVOException {} when validateNamaProduk", e.getMessage());
|
||||
addHeaderMessage(ERROR_MESSAGE, e.getMessage());
|
||||
return getJsonHttpStatus(INTERNAL_SERVER_ERROR, mapHeaderMessage);
|
||||
} catch (JpaSystemException jse) {
|
||||
LOGGER.error("Got exception {} when validate nama produk", jse.getMessage());
|
||||
addHeaderMessage(Constants.MessageInfo.ERROR_MESSAGE, jse.getMessage());
|
||||
return RestUtil.getJsonHttptatus(HttpStatus.CONFLICT, mapHeaderMessage);
|
||||
LOGGER.error("Got JpaSystemException {} when validateNamaProduk", jse.getMessage());
|
||||
addHeaderMessage(ERROR_MESSAGE, jse.getMessage());
|
||||
return getJsonHttpStatus(CONFLICT, mapHeaderMessage);
|
||||
}
|
||||
}
|
||||
|
||||
@RequestMapping(value = "/paket-to-produk", method = RequestMethod.GET, produces = MediaType.APPLICATION_JSON_VALUE)
|
||||
@RequestMapping(value = "/paket-to-produk", method = GET, produces = APPLICATION_JSON_VALUE)
|
||||
public ResponseEntity<Map<String, Object>> getMappingPaketToProduk(HttpServletRequest request,
|
||||
@RequestParam(value = "idMapping") Integer idMapping) {
|
||||
try {
|
||||
Map<String, Object> result = produkService.getMappingPaketToProduk(idMapping);
|
||||
return RestUtil.getJsonResponse(result, HttpStatus.OK);
|
||||
return getJsonResponse(result, OK);
|
||||
} catch (ServiceVOException e) {
|
||||
LOGGER.error("Got exception {} when get mapping paket to produk", e.getMessage());
|
||||
addHeaderMessage(Constants.MessageInfo.ERROR_MESSAGE, e.getMessage());
|
||||
return RestUtil.getJsonHttptatus(HttpStatus.INTERNAL_SERVER_ERROR, mapHeaderMessage);
|
||||
LOGGER.error("Got ServiceVOException {} when getMappingPaketToProduk", e.getMessage());
|
||||
addHeaderMessage(ERROR_MESSAGE, e.getMessage());
|
||||
return getJsonHttpStatus(INTERNAL_SERVER_ERROR, mapHeaderMessage);
|
||||
} catch (JpaSystemException jse) {
|
||||
LOGGER.error("Got exception {} when get mapping paket to produk", jse.getMessage());
|
||||
addHeaderMessage(Constants.MessageInfo.ERROR_MESSAGE, jse.getMessage());
|
||||
return RestUtil.getJsonHttptatus(HttpStatus.CONFLICT, mapHeaderMessage);
|
||||
LOGGER.error("Got JpaSystemException {} when getMappingPaketToProduk", jse.getMessage());
|
||||
addHeaderMessage(ERROR_MESSAGE, jse.getMessage());
|
||||
return getJsonHttpStatus(CONFLICT, mapHeaderMessage);
|
||||
}
|
||||
}
|
||||
|
||||
@RequestMapping(value = "/all-paket-produk", method = RequestMethod.GET)
|
||||
@RequestMapping(value = "/all-paket-produk", method = GET)
|
||||
public ResponseEntity<List<Map<String, Object>>> getAllPaketToProduk(HttpServletRequest request) {
|
||||
try {
|
||||
List<Map<String, Object>> result = produkService.getAllPaketToProduk();
|
||||
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);
|
||||
} catch (ServiceVOException sve) {
|
||||
LOGGER.error("Got exception {} when get all data paket to produk", sve.getMessage());
|
||||
addHeaderMessage(Constants.MessageInfo.ERROR_MESSAGE, sve.getMessage());
|
||||
return RestUtil.getJsonHttptatus(HttpStatus.INTERNAL_SERVER_ERROR, mapHeaderMessage);
|
||||
LOGGER.error("Got ServiceVOException {} when getAllPaketToProduk", sve.getMessage());
|
||||
addHeaderMessage(ERROR_MESSAGE, sve.getMessage());
|
||||
return getJsonHttpStatus(INTERNAL_SERVER_ERROR, mapHeaderMessage);
|
||||
} catch (JpaSystemException jse) {
|
||||
LOGGER.error("Got exception {} when get all data paket to produk", jse.getMessage());
|
||||
addHeaderMessage(Constants.MessageInfo.ERROR_MESSAGE, jse.getMessage());
|
||||
return RestUtil.getJsonHttptatus(HttpStatus.CONFLICT, mapHeaderMessage);
|
||||
LOGGER.error("Got JpaSystemException {} when getAllPaketToProduk", jse.getMessage());
|
||||
addHeaderMessage(ERROR_MESSAGE, jse.getMessage());
|
||||
return getJsonHttpStatus(CONFLICT, mapHeaderMessage);
|
||||
}
|
||||
}
|
||||
|
||||
@RequestMapping(value = "/master-satuan-standar", method = RequestMethod.GET)
|
||||
@RequestMapping(value = "/master-satuan-standar", method = GET)
|
||||
public ResponseEntity<List<Map<String, Object>>> getAllMasterSatuanStandar(HttpServletRequest request) {
|
||||
try {
|
||||
List<Map<String, Object>> result = satuanStandarService.getAll();
|
||||
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);
|
||||
} catch (ServiceVOException sve) {
|
||||
LOGGER.error("Got exception {} when get all master satuan standar distinct on", sve.getMessage());
|
||||
addHeaderMessage(Constants.MessageInfo.ERROR_MESSAGE, sve.getMessage());
|
||||
return RestUtil.getJsonHttptatus(HttpStatus.INTERNAL_SERVER_ERROR, mapHeaderMessage);
|
||||
LOGGER.error("Got ServiceVOException {} when satuanStandarService.getAll", sve.getMessage());
|
||||
addHeaderMessage(ERROR_MESSAGE, sve.getMessage());
|
||||
return getJsonHttpStatus(INTERNAL_SERVER_ERROR, mapHeaderMessage);
|
||||
} catch (JpaSystemException jse) {
|
||||
LOGGER.error("Got exception {} when get all master satuan standar distinct on", jse.getMessage());
|
||||
addHeaderMessage(Constants.MessageInfo.ERROR_MESSAGE, jse.getMessage());
|
||||
return RestUtil.getJsonHttptatus(HttpStatus.CONFLICT, mapHeaderMessage);
|
||||
LOGGER.error("Got JpaSystemException {} when satuanStandarService.getAll", jse.getMessage());
|
||||
addHeaderMessage(ERROR_MESSAGE, jse.getMessage());
|
||||
return getJsonHttpStatus(CONFLICT, mapHeaderMessage);
|
||||
}
|
||||
}
|
||||
|
||||
@RequestMapping(value = "/klaim-diskon", method = RequestMethod.GET)
|
||||
@RequestMapping(value = "/klaim-diskon", method = GET)
|
||||
public ResponseEntity<List<String>> KlaimDiskon(HttpServletRequest request,
|
||||
@RequestParam(value = "noRegistrasi") String noRegistrasi,
|
||||
@RequestParam(value = "totalKlaim") Double totalKlaim,
|
||||
@RequestParam(value = "jenisDiskon") Integer jenisDiskon) {
|
||||
try {
|
||||
List<String> result = pelayananPasienService.updateKlaimDiskon(noRegistrasi, totalKlaim, jenisDiskon);
|
||||
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);
|
||||
} catch (ServiceVOException e) {
|
||||
LOGGER.error("Got exception {} when klaim diskon karyawan", e.getMessage());
|
||||
addHeaderMessage(Constants.MessageInfo.ERROR_MESSAGE, e.getMessage());
|
||||
return RestUtil.getJsonHttptatus(HttpStatus.INTERNAL_SERVER_ERROR, mapHeaderMessage);
|
||||
LOGGER.error("Got ServiceVOException {} when updateKlaimDiskon", e.getMessage());
|
||||
addHeaderMessage(ERROR_MESSAGE, e.getMessage());
|
||||
return getJsonHttpStatus(INTERNAL_SERVER_ERROR, mapHeaderMessage);
|
||||
} catch (JpaSystemException jse) {
|
||||
LOGGER.error("Got exception {} when klaim diskon karyawan", jse.getMessage());
|
||||
addHeaderMessage(Constants.MessageInfo.ERROR_MESSAGE, jse.getMessage());
|
||||
return RestUtil.getJsonHttptatus(HttpStatus.CONFLICT, mapHeaderMessage);
|
||||
LOGGER.error("Got JpaSystemException {} when updateKlaimDiskon", jse.getMessage());
|
||||
addHeaderMessage(ERROR_MESSAGE, jse.getMessage());
|
||||
return getJsonHttpStatus(CONFLICT, mapHeaderMessage);
|
||||
}
|
||||
}
|
||||
|
||||
@RequestMapping(value = "/reset-klaim-diskon", method = RequestMethod.GET)
|
||||
@RequestMapping(value = "/reset-klaim-diskon", method = GET)
|
||||
public ResponseEntity<String> ResetKlaimDiskon(HttpServletRequest request,
|
||||
@RequestParam(value = "noRegistrasi") String noRegistrasi) {
|
||||
try {
|
||||
String result = pelayananPasienService.resetKlaimDiskon(noRegistrasi);
|
||||
|
||||
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);
|
||||
} catch (ServiceVOException e) {
|
||||
LOGGER.error("Got exception {} when klaim diskon karyawan", e.getMessage());
|
||||
addHeaderMessage(Constants.MessageInfo.ERROR_MESSAGE, e.getMessage());
|
||||
return RestUtil.getJsonHttptatus(HttpStatus.INTERNAL_SERVER_ERROR, mapHeaderMessage);
|
||||
LOGGER.error("Got ServiceVOException {} when resetKlaimDiskon", e.getMessage());
|
||||
addHeaderMessage(ERROR_MESSAGE, e.getMessage());
|
||||
return getJsonHttpStatus(INTERNAL_SERVER_ERROR, mapHeaderMessage);
|
||||
} catch (JpaSystemException jse) {
|
||||
LOGGER.error("Got exception {} when klaim diskon karyawan", jse.getMessage());
|
||||
addHeaderMessage(Constants.MessageInfo.ERROR_MESSAGE, jse.getMessage());
|
||||
return RestUtil.getJsonHttptatus(HttpStatus.CONFLICT, mapHeaderMessage);
|
||||
LOGGER.error("Got JpaSystemException {} when resetKlaimDiskon", jse.getMessage());
|
||||
addHeaderMessage(ERROR_MESSAGE, jse.getMessage());
|
||||
return getJsonHttpStatus(CONFLICT, mapHeaderMessage);
|
||||
}
|
||||
}
|
||||
|
||||
@RequestMapping(value = "/check-existing-harga-produk-kelas", method = RequestMethod.GET)
|
||||
@RequestMapping(value = "/check-existing-harga-produk-kelas", method = GET)
|
||||
public ResponseEntity<List<Map<String, Object>>> checkExistingHargaProdukKelas(HttpServletRequest request,
|
||||
@RequestParam(value = "kelasId") Integer idKelas, @RequestParam(value = "produkId") Integer idProduk,
|
||||
@RequestParam(value = "mappingId", required = false) Integer idMapping) {
|
||||
try {
|
||||
List<Map<String, Object>> result = produkService.findExistingMapHargaKelas(idKelas, idProduk, idMapping);
|
||||
|
||||
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);
|
||||
} catch (ServiceVOException e) {
|
||||
LOGGER.error("Got exception {} when check existing harga produk kelas", e.getMessage());
|
||||
addHeaderMessage(Constants.MessageInfo.ERROR_MESSAGE, e.getMessage());
|
||||
return RestUtil.getJsonHttptatus(HttpStatus.INTERNAL_SERVER_ERROR, mapHeaderMessage);
|
||||
LOGGER.error("Got ServiceVOException {} when findExistingMapHargaKelas", e.getMessage());
|
||||
addHeaderMessage(ERROR_MESSAGE, e.getMessage());
|
||||
return getJsonHttpStatus(INTERNAL_SERVER_ERROR, mapHeaderMessage);
|
||||
} catch (JpaSystemException jse) {
|
||||
LOGGER.error("Got exception {} when check existing harga produk kelas", jse.getMessage());
|
||||
addHeaderMessage(Constants.MessageInfo.ERROR_MESSAGE, jse.getMessage());
|
||||
return RestUtil.getJsonHttptatus(HttpStatus.CONFLICT, mapHeaderMessage);
|
||||
LOGGER.error("Got JpaSystemException {} when findExistingMapHargaKelas", jse.getMessage());
|
||||
addHeaderMessage(ERROR_MESSAGE, jse.getMessage());
|
||||
return getJsonHttpStatus(CONFLICT, mapHeaderMessage);
|
||||
}
|
||||
}
|
||||
|
||||
@RequestMapping(value = "/tagihan/daftar/{noRegistrasi}", method = RequestMethod.GET)
|
||||
@RequestMapping(value = "/tagihan/daftar/{noRegistrasi}", method = GET)
|
||||
public ResponseEntity<List<TagihanPendaftaranDto>> daftarTagihan(HttpServletRequest request,
|
||||
@PathVariable String noRegistrasi) {
|
||||
try {
|
||||
List<TagihanPendaftaranDto> result = pelayananPasienService.tagihan(noRegistrasi);
|
||||
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);
|
||||
} catch (ServiceVOException e) {
|
||||
LOGGER.error("Got exception {} when get daftar tagihan {}", e.getMessage(), noRegistrasi);
|
||||
addHeaderMessage(Constants.MessageInfo.ERROR_MESSAGE, e.getMessage());
|
||||
return RestUtil.getJsonHttptatus(HttpStatus.INTERNAL_SERVER_ERROR, mapHeaderMessage);
|
||||
LOGGER.error("Got ServiceVOException {} when pelayananPasienService.tagihan {}", e.getMessage(),
|
||||
noRegistrasi);
|
||||
addHeaderMessage(ERROR_MESSAGE, e.getMessage());
|
||||
return getJsonHttpStatus(INTERNAL_SERVER_ERROR, mapHeaderMessage);
|
||||
} catch (JpaSystemException jse) {
|
||||
LOGGER.error("Got exception {} when get daftar tagihan {}", jse.getMessage(), noRegistrasi);
|
||||
addHeaderMessage(Constants.MessageInfo.ERROR_MESSAGE, jse.getMessage());
|
||||
return RestUtil.getJsonHttptatus(HttpStatus.CONFLICT, mapHeaderMessage);
|
||||
LOGGER.error("Got JpaSystemException {} when pelayananPasienService.tagihan {}", jse.getMessage(),
|
||||
noRegistrasi);
|
||||
addHeaderMessage(ERROR_MESSAGE, jse.getMessage());
|
||||
return getJsonHttpStatus(CONFLICT, mapHeaderMessage);
|
||||
}
|
||||
}
|
||||
|
||||
@RequestMapping(value = "/tagihan/diskon/save", method = RequestMethod.POST, produces = MediaType.APPLICATION_JSON_VALUE, consumes = MediaType.APPLICATION_JSON_VALUE)
|
||||
@RequestMapping(value = "/tagihan/diskon/save", method = RequestMethod.POST, produces = APPLICATION_JSON_VALUE, consumes = APPLICATION_JSON_VALUE)
|
||||
public ResponseEntity<Object> simpanDiskonTagihan(HttpServletRequest request,
|
||||
@RequestParam(value = "kode-voucher", required = false) String kodeVoucher,
|
||||
@RequestBody List<TagihanPendaftaranDto> dtoList) {
|
||||
try {
|
||||
pelayananPasienService.diskonTagihan(kodeVoucher, dtoList);
|
||||
mapHeaderMessage.put(WebConstants.HttpHeaderInfo.LABEL_SUCCESS,
|
||||
getMessage(MessageResource.LABEL_SUCCESS, request));
|
||||
return RestUtil.getJsonResponse(dtoList, HttpStatus.OK, mapHeaderMessage);
|
||||
mapHeaderMessage.put(LABEL_SUCCESS, getMessage(MessageResource.LABEL_SUCCESS, request));
|
||||
return getJsonResponse(dtoList, OK, mapHeaderMessage);
|
||||
} catch (ServiceVOException e) {
|
||||
LOGGER.error("Got exception {} when simpan diskon tagihan", e.getMessage());
|
||||
Map<String, String> error = new HashMap<>();
|
||||
error.put("bad_request", e.getMessage());
|
||||
return RestUtil.getJsonResponse(null, HttpStatus.BAD_REQUEST, error);
|
||||
LOGGER.error("Got ServiceVOException {} when diskonTagihan", e.getMessage());
|
||||
addHeaderMessage(ERROR_MESSAGE, e.getMessage());
|
||||
return getJsonHttpStatus(BAD_REQUEST, mapHeaderMessage);
|
||||
} catch (JpaSystemException jse) {
|
||||
LOGGER.error("Got exception {} when simpan diskon tagihan", jse.getMessage());
|
||||
addHeaderMessage(Constants.MessageInfo.ERROR_MESSAGE, jse.getMessage());
|
||||
return RestUtil.getJsonHttptatus(HttpStatus.CONFLICT, mapHeaderMessage);
|
||||
LOGGER.error("Got JpaSystemException {} when diskonTagihan", jse.getMessage());
|
||||
addHeaderMessage(ERROR_MESSAGE, jse.getMessage());
|
||||
return getJsonHttpStatus(CONFLICT, mapHeaderMessage);
|
||||
}
|
||||
}
|
||||
|
||||
@RequestMapping(value = "/tagihan/diskon/batal-paket", method = RequestMethod.POST, produces = MediaType.APPLICATION_JSON_VALUE, consumes = MediaType.APPLICATION_JSON_VALUE)
|
||||
@RequestMapping(value = "/tagihan/diskon/batal-paket", method = RequestMethod.POST, produces = APPLICATION_JSON_VALUE, consumes = APPLICATION_JSON_VALUE)
|
||||
public ResponseEntity<Object> batalPaket(HttpServletRequest request, @RequestBody BatalPaketProdukDto dto) {
|
||||
try {
|
||||
pelayananPasienService.batalPaketProduk(request, dto);
|
||||
mapHeaderMessage.put(WebConstants.HttpHeaderInfo.LABEL_SUCCESS,
|
||||
getMessage(MessageResource.LABEL_SUCCESS, request));
|
||||
return RestUtil.getJsonResponse(dto, HttpStatus.OK, mapHeaderMessage);
|
||||
mapHeaderMessage.put(LABEL_SUCCESS, getMessage(MessageResource.LABEL_SUCCESS, request));
|
||||
return getJsonResponse(dto, OK, mapHeaderMessage);
|
||||
} catch (ServiceVOException e) {
|
||||
LOGGER.error("Got exception {} when batal diskon paket", e.getMessage());
|
||||
Map<String, String> error = new HashMap<>();
|
||||
error.put("bad_request", e.getMessage());
|
||||
return RestUtil.getJsonResponse(null, HttpStatus.BAD_REQUEST, error);
|
||||
LOGGER.error("Got ServiceVOException {} when batalPaketProduk", e.getMessage());
|
||||
addHeaderMessage(ERROR_MESSAGE, e.getMessage());
|
||||
return getJsonHttpStatus(BAD_REQUEST, mapHeaderMessage);
|
||||
} catch (JpaSystemException jse) {
|
||||
LOGGER.error("Got exception {} when batal diskon paket", jse.getMessage());
|
||||
addHeaderMessage(Constants.MessageInfo.ERROR_MESSAGE, jse.getMessage());
|
||||
return RestUtil.getJsonHttptatus(HttpStatus.CONFLICT, mapHeaderMessage);
|
||||
LOGGER.error("Got JpaSystemException {} when batalPaketProduk", jse.getMessage());
|
||||
addHeaderMessage(ERROR_MESSAGE, jse.getMessage());
|
||||
return getJsonHttpStatus(CONFLICT, mapHeaderMessage);
|
||||
}
|
||||
}
|
||||
|
||||
@RequestMapping(value = "/vouchers/validity", method = RequestMethod.GET)
|
||||
@RequestMapping(value = "/vouchers/validity", method = GET)
|
||||
public ResponseEntity<Object> isValidVoucher(HttpServletRequest request,
|
||||
@RequestParam("kode-voucher") String kodeVoucher, @RequestParam("no-registrasi") String noRegistrasi) {
|
||||
try {
|
||||
boolean validVoucher = pelayananPasienService.isValidVoucher(kodeVoucher, noRegistrasi);
|
||||
mapHeaderMessage.put(WebConstants.HttpHeaderInfo.LABEL_SUCCESS,
|
||||
getMessage(MessageResource.LABEL_SUCCESS, request));
|
||||
return RestUtil.getJsonResponse(validVoucher, HttpStatus.OK, mapHeaderMessage);
|
||||
mapHeaderMessage.put(LABEL_SUCCESS, getMessage(MessageResource.LABEL_SUCCESS, request));
|
||||
return getJsonResponse(validVoucher, OK, mapHeaderMessage);
|
||||
} catch (ServiceVOException e) {
|
||||
LOGGER.error("Got exception {} when check voucher validity", e.getMessage());
|
||||
Map<String, String> error = new HashMap<>();
|
||||
error.put("bad_request", e.getMessage());
|
||||
return RestUtil.getJsonResponse(false, HttpStatus.BAD_REQUEST, error);
|
||||
LOGGER.error("Got ServiceVOException {} when isValidVoucher", e.getMessage());
|
||||
addHeaderMessage(ERROR_MESSAGE, e.getMessage());
|
||||
return getJsonHttpStatus(BAD_REQUEST, mapHeaderMessage);
|
||||
} catch (JpaSystemException jse) {
|
||||
LOGGER.error("Got exception {} when check voucher validity", jse.getMessage());
|
||||
addHeaderMessage(Constants.MessageInfo.ERROR_MESSAGE, jse.getMessage());
|
||||
return RestUtil.getJsonHttptatus(HttpStatus.CONFLICT, mapHeaderMessage);
|
||||
LOGGER.error("Got JpaSystemException {} when isValidVoucher", jse.getMessage());
|
||||
addHeaderMessage(ERROR_MESSAGE, jse.getMessage());
|
||||
return getJsonHttpStatus(CONFLICT, mapHeaderMessage);
|
||||
}
|
||||
}
|
||||
|
||||
@RequestMapping(value = "/produk-paket/paket", method = RequestMethod.POST, produces = MediaType.APPLICATION_JSON_VALUE, consumes = MediaType.APPLICATION_JSON_VALUE)
|
||||
@RequestMapping(value = "/produk-paket/paket", method = RequestMethod.POST, produces = APPLICATION_JSON_VALUE, consumes = APPLICATION_JSON_VALUE)
|
||||
public ResponseEntity<Object> simpanMappingListProdukPaket(HttpServletRequest request,
|
||||
@RequestBody List<MapProdukPaketVO> vos) {
|
||||
try {
|
||||
mapProdukPaketService.saveAll(vos);
|
||||
mapHeaderMessage.put(WebConstants.HttpHeaderInfo.LABEL_SUCCESS,
|
||||
getMessage(MessageResource.LABEL_SUCCESS, request));
|
||||
return RestUtil.getJsonResponse(vos, HttpStatus.OK, mapHeaderMessage);
|
||||
mapHeaderMessage.put(LABEL_SUCCESS, getMessage(MessageResource.LABEL_SUCCESS, request));
|
||||
return getJsonResponse(vos, OK, mapHeaderMessage);
|
||||
} catch (ServiceVOException e) {
|
||||
LOGGER.error("Got exception {} when simpan mapping list produk paket", e.getMessage());
|
||||
Map<String, String> error = new HashMap<>();
|
||||
error.put("bad_request", e.getMessage());
|
||||
return RestUtil.getJsonResponse(null, HttpStatus.BAD_REQUEST, error);
|
||||
LOGGER.error("Got ServiceVOException {} when mapProdukPaketService.saveAll", e.getMessage());
|
||||
addHeaderMessage(ERROR_MESSAGE, e.getMessage());
|
||||
return getJsonHttpStatus(BAD_REQUEST, mapHeaderMessage);
|
||||
} catch (JpaSystemException jse) {
|
||||
LOGGER.error("Got exception {} when simpan mapping list produk paket", jse.getMessage());
|
||||
addHeaderMessage(Constants.MessageInfo.ERROR_MESSAGE, jse.getMessage());
|
||||
return RestUtil.getJsonHttptatus(HttpStatus.CONFLICT, mapHeaderMessage);
|
||||
LOGGER.error("Got JpaSystemException {} when mapProdukPaketService.saveAll", jse.getMessage());
|
||||
addHeaderMessage(ERROR_MESSAGE, jse.getMessage());
|
||||
return getJsonHttpStatus(CONFLICT, mapHeaderMessage);
|
||||
}
|
||||
}
|
||||
|
||||
@RequestMapping(value = "/produk-paket/produk", method = RequestMethod.POST, produces = MediaType.APPLICATION_JSON_VALUE, consumes = MediaType.APPLICATION_JSON_VALUE)
|
||||
@RequestMapping(value = "/produk-paket/produk", method = RequestMethod.POST, produces = APPLICATION_JSON_VALUE, consumes = APPLICATION_JSON_VALUE)
|
||||
public ResponseEntity<Object> simpanMappingEntriProdukPaket(HttpServletRequest request,
|
||||
@RequestBody List<MapProdukPaketToProdukVO> vos) {
|
||||
try {
|
||||
mapProdukPaketToProdukService.saveAll(vos);
|
||||
mapHeaderMessage.put(WebConstants.HttpHeaderInfo.LABEL_SUCCESS,
|
||||
getMessage(MessageResource.LABEL_SUCCESS, request));
|
||||
return RestUtil.getJsonResponse(vos, HttpStatus.OK, mapHeaderMessage);
|
||||
mapHeaderMessage.put(LABEL_SUCCESS, getMessage(MessageResource.LABEL_SUCCESS, request));
|
||||
return getJsonResponse(vos, OK, mapHeaderMessage);
|
||||
} catch (ServiceVOException e) {
|
||||
LOGGER.error("Got exception {} when simpan mapping entri produk paket", e.getMessage());
|
||||
Map<String, String> error = new HashMap<>();
|
||||
error.put("bad_request", e.getMessage());
|
||||
return RestUtil.getJsonResponse(null, HttpStatus.BAD_REQUEST, error);
|
||||
LOGGER.error("Got ServiceVOException {} when mapProdukPaketToProdukService.saveAll", e.getMessage());
|
||||
addHeaderMessage(ERROR_MESSAGE, e.getMessage());
|
||||
return getJsonHttpStatus(BAD_REQUEST, mapHeaderMessage);
|
||||
} catch (JpaSystemException jse) {
|
||||
LOGGER.error("Got exception {} when simpan mapping entri produk paket", jse.getMessage());
|
||||
addHeaderMessage(Constants.MessageInfo.ERROR_MESSAGE, jse.getMessage());
|
||||
return RestUtil.getJsonHttptatus(HttpStatus.CONFLICT, mapHeaderMessage);
|
||||
LOGGER.error("Got JpaSystemException {} when mapProdukPaketToProdukService.saveAll", jse.getMessage());
|
||||
addHeaderMessage(ERROR_MESSAGE, jse.getMessage());
|
||||
return getJsonHttpStatus(CONFLICT, mapHeaderMessage);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -10,7 +10,6 @@ import com.jasamedika.medifirst2000.vo.LogbookKinerjaVO;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.http.HttpStatus;
|
||||
import org.springframework.http.ResponseEntity;
|
||||
import org.springframework.orm.jpa.JpaSystemException;
|
||||
import org.springframework.web.bind.annotation.PathVariable;
|
||||
@ -22,8 +21,7 @@ import javax.servlet.http.HttpServletRequest;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
import static org.springframework.http.HttpStatus.CREATED;
|
||||
import static org.springframework.http.HttpStatus.INTERNAL_SERVER_ERROR;
|
||||
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;
|
||||
@ -48,10 +46,10 @@ public class RemunerasiController extends LocaleController<LogbookKinerjaVO> {
|
||||
@RequestMapping(value = "/logbook-tarif/{idPegawai}/{bulan}", method = GET)
|
||||
public ResponseEntity<Object> recap(HttpServletRequest request, @PathVariable("idPegawai") Integer idPegawai,
|
||||
@PathVariable("bulan") String bulan) {
|
||||
LOGGER.info("Superapp requesting logbook tarif data id pegawai {} bulan {}", idPegawai, bulan);
|
||||
LOGGER.info("Superapp requesting rekapLogbook id pegawai {} bulan {}", idPegawai, bulan);
|
||||
|
||||
List<Map<String, Object>> result = pelayananPasienService.rekapLogbook(idPegawai, bulan);
|
||||
return new ResponseEntity<>(result, HttpStatus.OK);
|
||||
return new ResponseEntity<>(result, OK);
|
||||
}
|
||||
|
||||
@RequestMapping(value = "/authorization", method = POST, produces = APPLICATION_JSON_VALUE, consumes = APPLICATION_JSON_VALUE)
|
||||
@ -60,7 +58,7 @@ public class RemunerasiController extends LocaleController<LogbookKinerjaVO> {
|
||||
AuthorizationDto result = mapPegawaiJabatanToUnitKerjaService.get(dto);
|
||||
return new ResponseEntity<>(result, CREATED);
|
||||
} catch (ServiceVOException | JpaSystemException e) {
|
||||
LOGGER.error("Got exception {} when get authorization for superapp", e.getMessage());
|
||||
LOGGER.error("Got exception {} when mapPegawaiJabatanToUnitKerjaService.get", e.getMessage());
|
||||
|
||||
return new ResponseEntity<>(null, INTERNAL_SERVER_ERROR);
|
||||
}
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
@ -1,16 +1,12 @@
|
||||
package com.jasamedika.medifirst2000.controller;
|
||||
|
||||
import com.jasamedika.medifirst2000.constants.Constants;
|
||||
import com.jasamedika.medifirst2000.dto.KomponenGajiDto;
|
||||
import com.jasamedika.medifirst2000.dto.SlipGajiDto;
|
||||
import com.jasamedika.medifirst2000.service.SlipGajiService;
|
||||
import com.jasamedika.medifirst2000.util.CommonUtil;
|
||||
import com.jasamedika.medifirst2000.util.ResourceUtils;
|
||||
import com.jasamedika.medifirst2000.util.rest.RestUtil;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.core.io.Resource;
|
||||
import org.springframework.http.HttpHeaders;
|
||||
import org.springframework.http.HttpStatus;
|
||||
import org.springframework.http.MediaType;
|
||||
import org.springframework.http.ResponseEntity;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
@ -22,59 +18,68 @@ 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.util.ResourceUtils.loadFile;
|
||||
import static com.jasamedika.medifirst2000.util.rest.RestUtil.getJsonHttpStatus;
|
||||
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("/slip-gaji")
|
||||
public class SlipGajiController {
|
||||
|
||||
@Autowired
|
||||
private SlipGajiService slipGajiService;
|
||||
|
||||
@RequestMapping(value = "/init", method = RequestMethod.GET, produces = MediaType.APPLICATION_JSON_VALUE)
|
||||
@RequestMapping(value = "/init", method = GET, produces = APPLICATION_JSON_VALUE)
|
||||
public ResponseEntity<Object> init() {
|
||||
try {
|
||||
slipGajiService.init();
|
||||
return new ResponseEntity<>(true, HttpStatus.CREATED);
|
||||
return new ResponseEntity<>(true, CREATED);
|
||||
} catch (Exception e) {
|
||||
return new ResponseEntity<>(e.getMessage(), HttpStatus.INTERNAL_SERVER_ERROR);
|
||||
return new ResponseEntity<>(e.getMessage(), INTERNAL_SERVER_ERROR);
|
||||
}
|
||||
}
|
||||
|
||||
@RequestMapping(value = "/save", method = RequestMethod.POST, produces = MediaType.APPLICATION_JSON_VALUE, consumes = MediaType.APPLICATION_JSON_VALUE)
|
||||
@RequestMapping(value = "/save", method = POST, produces = APPLICATION_JSON_VALUE, consumes = APPLICATION_JSON_VALUE)
|
||||
public ResponseEntity<Object> save(@RequestBody @Valid SlipGajiDto dto) {
|
||||
try {
|
||||
slipGajiService.save(dto);
|
||||
return new ResponseEntity<>(true, HttpStatus.CREATED);
|
||||
return new ResponseEntity<>(true, CREATED);
|
||||
} catch (Exception e) {
|
||||
return new ResponseEntity<>(e.getMessage(), HttpStatus.INTERNAL_SERVER_ERROR);
|
||||
return new ResponseEntity<>(e.getMessage(), INTERNAL_SERVER_ERROR);
|
||||
}
|
||||
}
|
||||
|
||||
@RequestMapping(value = "/unggah", method = RequestMethod.POST, produces = MediaType.APPLICATION_JSON_VALUE, consumes = MediaType.APPLICATION_JSON_VALUE)
|
||||
@RequestMapping(value = "/unggah", method = POST, produces = APPLICATION_JSON_VALUE, consumes = APPLICATION_JSON_VALUE)
|
||||
public ResponseEntity<Object> save(@RequestBody List<SlipGajiDto> dtoList) {
|
||||
try {
|
||||
slipGajiService.save(dtoList);
|
||||
return new ResponseEntity<>(true, HttpStatus.CREATED);
|
||||
return new ResponseEntity<>(true, CREATED);
|
||||
} catch (Exception e) {
|
||||
return new ResponseEntity<>(e.getMessage(), HttpStatus.INTERNAL_SERVER_ERROR);
|
||||
return new ResponseEntity<>(e.getMessage(), INTERNAL_SERVER_ERROR);
|
||||
}
|
||||
}
|
||||
|
||||
@RequestMapping(value = "/detail/update", method = RequestMethod.POST, produces = MediaType.APPLICATION_JSON_VALUE, consumes = MediaType.APPLICATION_JSON_VALUE)
|
||||
@RequestMapping(value = "/detail/update", method = POST, produces = APPLICATION_JSON_VALUE, consumes = APPLICATION_JSON_VALUE)
|
||||
public ResponseEntity<Object> updateDetail(@RequestBody @Valid SlipGajiDto dto) {
|
||||
try {
|
||||
slipGajiService.updateDetail(dto);
|
||||
return new ResponseEntity<>(true, HttpStatus.CREATED);
|
||||
return new ResponseEntity<>(true, CREATED);
|
||||
} catch (Exception e) {
|
||||
return new ResponseEntity<>(e.getMessage(), HttpStatus.INTERNAL_SERVER_ERROR);
|
||||
return new ResponseEntity<>(e.getMessage(), INTERNAL_SERVER_ERROR);
|
||||
}
|
||||
}
|
||||
|
||||
@RequestMapping(value = "/get/{pegawaiId}/{bulan}", method = RequestMethod.GET, produces = MediaType.APPLICATION_JSON_VALUE)
|
||||
@RequestMapping(value = "/get/{pegawaiId}/{bulan}", method = GET, produces = APPLICATION_JSON_VALUE)
|
||||
public ResponseEntity<Object> get(@PathVariable Integer pegawaiId, @PathVariable Long bulan) {
|
||||
SlipGajiDto entity = slipGajiService.get(pegawaiId, bulan);
|
||||
return new ResponseEntity<>(entity, HttpStatus.OK);
|
||||
return new ResponseEntity<>(entity, OK);
|
||||
}
|
||||
|
||||
@RequestMapping(value = "/template/generate/{bulan}", method = RequestMethod.GET)
|
||||
@RequestMapping(value = "/template/generate/{bulan}", method = GET)
|
||||
public ResponseEntity<Object> generateTemplate(@PathVariable Long bulan, HttpServletRequest request,
|
||||
HttpServletResponse response) {
|
||||
try {
|
||||
@ -83,30 +88,30 @@ public class SlipGajiController {
|
||||
response.setHeader("Content-Disposition", "attachment; filename=" + fileNamePath);
|
||||
Map<String, Object> result = new HashMap<>();
|
||||
result.put("filename", fileNamePath);
|
||||
return new ResponseEntity<>(result, HttpStatus.OK);
|
||||
return new ResponseEntity<>(result, OK);
|
||||
} catch (Exception e) {
|
||||
return new ResponseEntity<>(e.getMessage(), HttpStatus.INTERNAL_SERVER_ERROR);
|
||||
return new ResponseEntity<>(e.getMessage(), INTERNAL_SERVER_ERROR);
|
||||
}
|
||||
}
|
||||
|
||||
@RequestMapping(value = "/template/download", method = RequestMethod.GET)
|
||||
@RequestMapping(value = "/template/download", method = GET)
|
||||
public ResponseEntity<Resource> downloadTemplate(@RequestParam(value = "filename") String fileName,
|
||||
HttpServletRequest request) {
|
||||
Resource resource;
|
||||
Map<String, String> mapHeaderMessage = new HashMap<>();
|
||||
if (CommonUtil.isNotNullOrEmpty(fileName)) {
|
||||
try {
|
||||
resource = ResourceUtils.loadFile(fileName);
|
||||
resource = loadFile(fileName);
|
||||
} catch (Exception e) {
|
||||
mapHeaderMessage.put(Constants.MessageInfo.ERROR_MESSAGE, e.getMessage());
|
||||
return RestUtil.getJsonHttptatus(HttpStatus.INTERNAL_SERVER_ERROR, mapHeaderMessage);
|
||||
mapHeaderMessage.put(ERROR_MESSAGE, e.getMessage());
|
||||
return getJsonHttpStatus(INTERNAL_SERVER_ERROR, mapHeaderMessage);
|
||||
}
|
||||
String contentType;
|
||||
try {
|
||||
contentType = request.getServletContext().getMimeType(resource.getFile().getAbsolutePath());
|
||||
} catch (Exception e) {
|
||||
mapHeaderMessage.put(Constants.MessageInfo.ERROR_MESSAGE, e.getMessage());
|
||||
return RestUtil.getJsonHttptatus(HttpStatus.INTERNAL_SERVER_ERROR, mapHeaderMessage);
|
||||
mapHeaderMessage.put(ERROR_MESSAGE, e.getMessage());
|
||||
return getJsonHttpStatus(INTERNAL_SERVER_ERROR, mapHeaderMessage);
|
||||
}
|
||||
if (CommonUtil.isNullOrEmpty(contentType))
|
||||
contentType = "application/octet-stream";
|
||||
@ -114,13 +119,13 @@ public class SlipGajiController {
|
||||
.header(HttpHeaders.CONTENT_DISPOSITION, "attachment; filename=" + resource.getFilename())
|
||||
.body(resource);
|
||||
} else {
|
||||
return RestUtil.getJsonHttptatus(HttpStatus.INTERNAL_SERVER_ERROR, mapHeaderMessage);
|
||||
return getJsonHttpStatus(INTERNAL_SERVER_ERROR, mapHeaderMessage);
|
||||
}
|
||||
}
|
||||
|
||||
@RequestMapping(value = "/komponen/list", method = RequestMethod.GET, produces = MediaType.APPLICATION_JSON_VALUE)
|
||||
@RequestMapping(value = "/komponen/list", method = GET, produces = APPLICATION_JSON_VALUE)
|
||||
public ResponseEntity<Object> get() {
|
||||
List<KomponenGajiDto> entity = slipGajiService.listKomponen();
|
||||
return new ResponseEntity<>(entity, HttpStatus.OK);
|
||||
return new ResponseEntity<>(entity, OK);
|
||||
}
|
||||
}
|
||||
|
||||
@ -1,42 +0,0 @@
|
||||
package com.jasamedika.medifirst2000.controller.base;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
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.ResponseBody;
|
||||
|
||||
import com.jasamedika.medifirst2000.base.vo.BaseModelVO;
|
||||
|
||||
/**
|
||||
* Base Rest Operation for Controller Class
|
||||
*
|
||||
* @author Roberto
|
||||
*/
|
||||
public interface IBaseRestController<V extends BaseModelVO> extends
|
||||
IRestPageController<V> {
|
||||
|
||||
@RequestMapping(value = "/{id}", method = RequestMethod.GET)
|
||||
@ResponseBody
|
||||
public ResponseEntity<V> getVO(@PathVariable("id") Integer id);
|
||||
|
||||
@RequestMapping(value = "/", method = RequestMethod.PUT, consumes = { "application/json" })
|
||||
@ResponseBody
|
||||
public ResponseEntity<String> addVO(@RequestBody V vo);
|
||||
|
||||
@RequestMapping(value = "/", method = RequestMethod.POST, consumes = { "application/json" })
|
||||
@ResponseBody
|
||||
public ResponseEntity<String> editVO(@RequestBody V vo);
|
||||
|
||||
@RequestMapping(value = "/{id}", method = RequestMethod.DELETE)
|
||||
@ResponseBody
|
||||
public ResponseEntity<String> deleteVO(@PathVariable("id") Integer id);
|
||||
|
||||
@RequestMapping(value = "/", method = RequestMethod.GET)
|
||||
@ResponseBody
|
||||
public ResponseEntity<List<V>> getAllVO();
|
||||
|
||||
}
|
||||
@ -1,41 +0,0 @@
|
||||
package com.jasamedika.medifirst2000.controller.base;
|
||||
|
||||
import java.util.Collection;
|
||||
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
|
||||
import org.springframework.http.ResponseEntity;
|
||||
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 com.jasamedika.medifirst2000.base.vo.BaseModelVO;
|
||||
|
||||
/**
|
||||
* Base Rest Operation for 'pagination' Controller Class
|
||||
*
|
||||
* @author Roberto
|
||||
*/
|
||||
public interface IRestPageController<V extends BaseModelVO> {
|
||||
/**
|
||||
*
|
||||
* @param page
|
||||
* : page of
|
||||
* @param limit
|
||||
* : limit query
|
||||
* @param sort
|
||||
* : sort by
|
||||
* @param dir
|
||||
* : direction {asc:desc}
|
||||
* @return Collection of VO, Total-Count & Total Pages on response header
|
||||
*/
|
||||
@RequestMapping(value = "/list", method = RequestMethod.GET)
|
||||
@ResponseBody
|
||||
public ResponseEntity<Collection<V>> getAllVOWithQueryString(
|
||||
HttpServletRequest request,
|
||||
@RequestParam(value = "page", required = false) Integer page,
|
||||
@RequestParam(value = "limit", required = false) Integer limit,
|
||||
@RequestParam(value = "sort", required = false, defaultValue = "id") String sort,
|
||||
@RequestParam(value = "dir", required = false, defaultValue = "asc") String dir);
|
||||
}
|
||||
@ -1,54 +1,47 @@
|
||||
package com.jasamedika.medifirst2000.controller.base;
|
||||
|
||||
import java.io.BufferedReader;
|
||||
import java.io.IOException;
|
||||
import java.io.InputStreamReader;
|
||||
import java.lang.reflect.Type;
|
||||
import java.net.URISyntaxException;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.Collection;
|
||||
import java.util.Date;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Locale;
|
||||
import java.util.Map;
|
||||
|
||||
import javax.servlet.http.Cookie;
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
import javax.servlet.http.HttpServletResponse;
|
||||
|
||||
import com.google.gson.Gson;
|
||||
import com.google.gson.GsonBuilder;
|
||||
import com.google.gson.JsonDeserializer;
|
||||
import com.jasamedika.medifirst2000.base.vo.BaseModelVO;
|
||||
import com.jasamedika.medifirst2000.converter.BaseConverterImpl;
|
||||
import com.jasamedika.medifirst2000.entities.Pegawai;
|
||||
import com.jasamedika.medifirst2000.exception.ServiceVOException;
|
||||
import com.jasamedika.medifirst2000.service.ActivityPegawaiService;
|
||||
import com.jasamedika.medifirst2000.service.LoginUserService;
|
||||
import com.jasamedika.medifirst2000.service.ModelService;
|
||||
import com.jasamedika.medifirst2000.vo.ModelVO;
|
||||
import com.jasamedika.medifirst2000.vo.PegawaiVO;
|
||||
import io.socket.client.IO;
|
||||
import io.socket.client.Socket;
|
||||
import org.json.JSONException;
|
||||
import org.json.JSONObject;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.context.MessageSource;
|
||||
import org.springframework.http.HttpStatus;
|
||||
import org.springframework.http.MediaType;
|
||||
import org.springframework.http.ResponseEntity;
|
||||
import org.springframework.web.bind.annotation.PathVariable;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.bind.annotation.RequestMethod;
|
||||
|
||||
import com.google.gson.Gson;
|
||||
import com.google.gson.GsonBuilder;
|
||||
import com.google.gson.JsonDeserializationContext;
|
||||
import com.google.gson.JsonDeserializer;
|
||||
import com.google.gson.JsonElement;
|
||||
import com.google.gson.JsonParseException;
|
||||
import com.jasamedika.medifirst2000.base.vo.BaseModelVO;
|
||||
import com.jasamedika.medifirst2000.constants.Constants;
|
||||
import com.jasamedika.medifirst2000.converter.BaseConverterImpl;
|
||||
import com.jasamedika.medifirst2000.core.web.WebConstants;
|
||||
import com.jasamedika.medifirst2000.entities.Pegawai;
|
||||
import com.jasamedika.medifirst2000.service.ActivityPegawaiService;
|
||||
import com.jasamedika.medifirst2000.service.LoginUserService;
|
||||
import com.jasamedika.medifirst2000.service.ModelService;
|
||||
import com.jasamedika.medifirst2000.util.rest.RestUtil;
|
||||
import com.jasamedika.medifirst2000.vo.ModelVO;
|
||||
import com.jasamedika.medifirst2000.vo.PasienVO;
|
||||
import com.jasamedika.medifirst2000.vo.PegawaiVO;
|
||||
import javax.servlet.http.Cookie;
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
import javax.servlet.http.HttpServletResponse;
|
||||
import java.io.BufferedReader;
|
||||
import java.io.IOException;
|
||||
import java.io.InputStreamReader;
|
||||
import java.net.URISyntaxException;
|
||||
import java.util.*;
|
||||
|
||||
import io.socket.client.IO;
|
||||
import static com.jasamedika.medifirst2000.constants.Constants.Locale.INA;
|
||||
import static com.jasamedika.medifirst2000.constants.Constants.MessageInfo.ERROR_MESSAGE;
|
||||
import static com.jasamedika.medifirst2000.core.web.WebConstants.HttpHeaderInfo.TOTAL_COUNT_HEADER;
|
||||
import static com.jasamedika.medifirst2000.core.web.WebConstants.HttpHeaderInfo.TOTAL_PAGE_HEADER;
|
||||
import static com.jasamedika.medifirst2000.core.web.WebConstants.PageParameter.*;
|
||||
import static com.jasamedika.medifirst2000.util.rest.RestUtil.getJsonResponse;
|
||||
import static io.socket.client.Socket.EVENT_CONNECT;
|
||||
import static org.springframework.http.HttpStatus.BAD_REQUEST;
|
||||
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;
|
||||
|
||||
/**
|
||||
* Base Controller Class for handling messaga resource for internationalization
|
||||
@ -58,7 +51,7 @@ import io.socket.client.IO;
|
||||
*/
|
||||
public abstract class LocaleController<V extends BaseModelVO> {
|
||||
|
||||
/*
|
||||
/**
|
||||
* messageSource bean injected for each controller for accessing message
|
||||
* source
|
||||
*/
|
||||
@ -74,82 +67,66 @@ public abstract class LocaleController<V extends BaseModelVO> {
|
||||
@Autowired
|
||||
private MessageSource messageSource;
|
||||
|
||||
@SuppressWarnings("rawtypes")
|
||||
@Autowired
|
||||
private ModelService modelService;
|
||||
private ModelService<V> modelService;
|
||||
|
||||
protected Map<String, String> mapHeaderMessage = new HashMap<String, String>();
|
||||
protected Map<String, String> mapHeaderMessage = new HashMap<>();
|
||||
|
||||
/*
|
||||
/**
|
||||
* code locale
|
||||
*/
|
||||
protected String getMessage(String code, HttpServletRequest request) {
|
||||
return messageSource.getMessage(code, null, new Locale(getCoociesLanguage(request)));
|
||||
}
|
||||
|
||||
protected void SaveLog(String keterangan, String group, HttpServletRequest request) {
|
||||
protected void saveLog(String keterangan, String group) {
|
||||
activityPegawaiServiceImpl.record(
|
||||
pegawaiConverter.transferModelToVO(loginUserService.getLoginUser().getPegawai(), new PegawaiVO()),
|
||||
new Date(), keterangan, group);
|
||||
}
|
||||
|
||||
protected Object getItem(HttpServletRequest request, Object vo) {
|
||||
BufferedReader reader;
|
||||
String read = null;
|
||||
String resultData = "";
|
||||
Gson gson = new Gson();
|
||||
try {
|
||||
reader = new BufferedReader(new InputStreamReader(request.getInputStream()));
|
||||
|
||||
StringBuilder resultData = new StringBuilder();
|
||||
BufferedReader reader = new BufferedReader(new InputStreamReader(request.getInputStream()));
|
||||
String read;
|
||||
while ((read = reader.readLine()) != null) {
|
||||
resultData += read;
|
||||
System.out.println(read);
|
||||
resultData.append(read);
|
||||
}
|
||||
|
||||
gson = new GsonBuilder().setDateFormat("yyyy-MM-dd HH:mm:ss").create();
|
||||
Gson gson = new GsonBuilder().setDateFormat("yyyy-MM-dd HH:mm:ss").create();
|
||||
return gson.fromJson(resultData.toString(), vo.getClass());
|
||||
} catch (IOException e) {
|
||||
e.printStackTrace();
|
||||
throw new ServiceVOException(e.getMessage());
|
||||
}
|
||||
return vo = gson.fromJson(resultData, vo.getClass());
|
||||
}
|
||||
|
||||
protected Object getItem2(HttpServletRequest request, Object vo) {
|
||||
BufferedReader reader;
|
||||
String read = null;
|
||||
String resultData = "";
|
||||
Gson gson = new Gson();
|
||||
try {
|
||||
reader = new BufferedReader(new InputStreamReader(request.getInputStream()));
|
||||
|
||||
try {
|
||||
StringBuilder resultData = new StringBuilder();
|
||||
BufferedReader reader = new BufferedReader(new InputStreamReader(request.getInputStream()));
|
||||
String read;
|
||||
while ((read = reader.readLine()) != null) {
|
||||
resultData += read;
|
||||
System.out.println(read);
|
||||
resultData.append(read);
|
||||
}
|
||||
GsonBuilder gsonBuilder = new GsonBuilder();
|
||||
gsonBuilder.registerTypeAdapter(Date.class, new JsonDeserializer<Date>() {
|
||||
@Override
|
||||
public Date deserialize(JsonElement json, Type typeOfT, JsonDeserializationContext context)
|
||||
throws JsonParseException {
|
||||
if (json.getAsString() instanceof String) {
|
||||
return new Date();
|
||||
} else {
|
||||
return new Date(json.getAsJsonPrimitive().getAsLong());
|
||||
}
|
||||
}
|
||||
gsonBuilder.registerTypeAdapter(Date.class, (JsonDeserializer<Date>) (json, typeOfT, context) -> {
|
||||
if (json.getAsString() != null)
|
||||
return new Date();
|
||||
return new Date(json.getAsJsonPrimitive().getAsLong());
|
||||
});
|
||||
gson = gsonBuilder.create();
|
||||
Gson gson = gsonBuilder.create();
|
||||
return gson.fromJson(resultData.toString(), vo.getClass());
|
||||
} catch (IOException e) {
|
||||
e.printStackTrace();
|
||||
throw new ServiceVOException(e.getMessage());
|
||||
}
|
||||
return vo = gson.fromJson(resultData, vo.getClass());
|
||||
}
|
||||
|
||||
@RequestMapping(value = "/lang/{lang}", method = RequestMethod.GET)
|
||||
@RequestMapping(value = "/lang/{lang}", method = GET)
|
||||
public boolean preHandle(HttpServletRequest request, HttpServletResponse response,
|
||||
@PathVariable("lang") String lang) throws Exception {
|
||||
|
||||
@PathVariable("lang") String lang) {
|
||||
Cookie[] cookies = request.getCookies();
|
||||
List<Cookie> cookieList = new ArrayList<Cookie>();
|
||||
List<Cookie> cookieList;
|
||||
if (cookies != null) {
|
||||
cookieList = Arrays.asList(cookies);
|
||||
for (Cookie cookie : cookieList) {
|
||||
@ -161,7 +138,6 @@ public abstract class LocaleController<V extends BaseModelVO> {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (lang.equalsIgnoreCase("en")) {
|
||||
Cookie c = new Cookie("lang", "en");
|
||||
c.setPath("/");
|
||||
@ -178,63 +154,53 @@ public abstract class LocaleController<V extends BaseModelVO> {
|
||||
c.setDomain("localhost");
|
||||
response.addCookie(c);
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
/*
|
||||
/**
|
||||
* default locale ID
|
||||
*/
|
||||
protected String getMessage(String code) {
|
||||
return messageSource.getMessage(code, null, new Locale(Constants.Locale.INA));
|
||||
return messageSource.getMessage(code, null, new Locale(INA));
|
||||
}
|
||||
|
||||
protected void addHeaderMessage(String key, String message) {
|
||||
this.mapHeaderMessage.put(key, message);
|
||||
}
|
||||
|
||||
@RequestMapping(value = "/entity-serelize/{entity}", method = RequestMethod.GET, produces = MediaType.APPLICATION_JSON_VALUE)
|
||||
@RequestMapping(value = "/entity-serelize/{entity}", method = GET, produces = APPLICATION_JSON_VALUE)
|
||||
public ResponseEntity<ModelVO> serializeEntity(@PathVariable("entity") String entity, HttpServletRequest request) {
|
||||
ModelVO modelDTO = modelService.getModelSerializeEntity(entity, getCoociesLanguage(request));
|
||||
return RestUtil.getJsonResponse(modelDTO, HttpStatus.OK);
|
||||
return getJsonResponse(modelDTO, OK);
|
||||
}
|
||||
|
||||
public String getCoociesLanguage(HttpServletRequest request) {
|
||||
Cookie cookie[] = request.getCookies();
|
||||
Cookie[] cookie = request.getCookies();
|
||||
Cookie cook;
|
||||
String lang = Constants.Locale.INA;
|
||||
String lang = INA;
|
||||
if (cookie != null) {
|
||||
for (int i = 0; i < cookie.length; i++) {
|
||||
cook = cookie[i];
|
||||
for (Cookie value : cookie) {
|
||||
cook = value;
|
||||
if (cook.getName().equalsIgnoreCase("lang"))
|
||||
lang = cook.getValue();
|
||||
}
|
||||
}
|
||||
|
||||
return lang;
|
||||
|
||||
}
|
||||
|
||||
@SuppressWarnings("rawtypes")
|
||||
protected ResponseEntity constructListPageResult(Map<String, Object> map) {
|
||||
|
||||
protected ResponseEntity<Collection<V>> constructListPageResult(Map<String, Object> map) {
|
||||
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<PasienVO> vos = (Collection<PasienVO>) 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)));
|
||||
|
||||
return RestUtil.getJsonResponse(vos, HttpStatus.OK, mapHeaderMessage);
|
||||
Collection<V> vos = (Collection<V>) 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)));
|
||||
return getJsonResponse(vos, OK, mapHeaderMessage);
|
||||
}
|
||||
}
|
||||
|
||||
@ -243,86 +209,65 @@ public abstract class LocaleController<V extends BaseModelVO> {
|
||||
}
|
||||
|
||||
protected void BroadcastMessage(final String to, final Object data) {
|
||||
final io.socket.client.Socket socket;
|
||||
final Socket socket;
|
||||
try {
|
||||
String url = GetSettingDataFixed("UrlSocketMessaging");
|
||||
socket = IO.socket(url);
|
||||
|
||||
socket.on(io.socket.client.Socket.EVENT_CONNECT, new io.socket.emitter.Emitter.Listener() {
|
||||
|
||||
@Override
|
||||
public void call(Object... args) {
|
||||
|
||||
try {
|
||||
Gson gson = new Gson();
|
||||
String json = gson.toJson(data);
|
||||
JSONObject item = new JSONObject(
|
||||
"{\"to\":\"" + to + "\",\"message\":\"" + json.replace("\"", "'") + "\"}");
|
||||
socket.emit("subscribe", item);
|
||||
} catch (JSONException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
socket.on(EVENT_CONNECT, args -> {
|
||||
try {
|
||||
Gson gson = new Gson();
|
||||
String json = gson.toJson(data);
|
||||
JSONObject item = new JSONObject(
|
||||
"{\"to\":\"" + to + "\",\"message\":\"" + json.replace("\"", "'") + "\"}");
|
||||
socket.emit("subscribe", item);
|
||||
} catch (JSONException e) {
|
||||
throw new ServiceVOException(e.getMessage());
|
||||
}
|
||||
|
||||
});
|
||||
socket.connect();
|
||||
} catch (URISyntaxException e) {
|
||||
e.printStackTrace();
|
||||
throw new ServiceVOException(e.getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
protected void BroadcastMessage(final String to, final String data) {
|
||||
final io.socket.client.Socket socket;
|
||||
final Socket socket;
|
||||
try {
|
||||
socket = IO.socket(GetSettingDataFixed("UrlSocketMessaging"));
|
||||
|
||||
socket.on(io.socket.client.Socket.EVENT_CONNECT, new io.socket.emitter.Emitter.Listener() {
|
||||
|
||||
@Override
|
||||
public void call(Object... args) {
|
||||
|
||||
try {
|
||||
JSONObject item = new JSONObject("{\"to\":\"" + to + "\",\"message\":\"" + data + "\"}");
|
||||
socket.emit("subscribe", item);
|
||||
} catch (JSONException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
socket.on(EVENT_CONNECT, args -> {
|
||||
try {
|
||||
JSONObject item = new JSONObject("{\"to\":\"" + to + "\",\"message\":\"" + data + "\"}");
|
||||
socket.emit("subscribe", item);
|
||||
} catch (JSONException e) {
|
||||
throw new ServiceVOException(e.getMessage());
|
||||
}
|
||||
|
||||
});
|
||||
socket.connect();
|
||||
} catch (URISyntaxException e) {
|
||||
e.printStackTrace();
|
||||
throw new ServiceVOException(e.getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
protected void BroadcastMessageOther(final String to, final Object data) {
|
||||
final io.socket.client.Socket socket;
|
||||
final Socket socket;
|
||||
try {
|
||||
String url = GetSettingDataFixed("UrlSocketMessaging");
|
||||
socket = IO.socket(url);
|
||||
|
||||
socket.on(io.socket.client.Socket.EVENT_CONNECT, new io.socket.emitter.Emitter.Listener() {
|
||||
|
||||
@Override
|
||||
public void call(Object... args) {
|
||||
try {
|
||||
Map<String, Object> result = new HashMap<>();
|
||||
result.put("message", data);
|
||||
result.put("to", to);
|
||||
|
||||
Gson gson = new Gson();
|
||||
JSONObject item = new JSONObject(gson.toJson(result));
|
||||
socket.emit("subscribe", item);
|
||||
} catch (JSONException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
socket.on(EVENT_CONNECT, args -> {
|
||||
try {
|
||||
Map<String, Object> result = new HashMap<>();
|
||||
result.put("message", data);
|
||||
result.put("to", to);
|
||||
Gson gson = new Gson();
|
||||
JSONObject item = new JSONObject(gson.toJson(result));
|
||||
socket.emit("subscribe", item);
|
||||
} catch (JSONException e) {
|
||||
throw new ServiceVOException(e.getMessage());
|
||||
}
|
||||
});
|
||||
socket.connect();
|
||||
} catch (URISyntaxException e) {
|
||||
e.printStackTrace();
|
||||
throw new ServiceVOException(e.getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@ -1,78 +1,68 @@
|
||||
package com.jasamedika.medifirst2000.controller.base;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import org.springframework.core.GenericTypeResolver;
|
||||
import org.springframework.http.HttpStatus;
|
||||
import org.springframework.http.ResponseEntity;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.bind.annotation.RequestMethod;
|
||||
import org.springframework.web.bind.annotation.RequestParam;
|
||||
|
||||
import com.jasamedika.medifirst2000.base.vo.BaseModelVO;
|
||||
import com.jasamedika.medifirst2000.constants.Constants;
|
||||
import com.jasamedika.medifirst2000.util.rest.RestUtil;
|
||||
import com.monitorjbl.json.JsonResult;
|
||||
import com.monitorjbl.json.JsonView;
|
||||
import com.monitorjbl.json.Match;
|
||||
import org.springframework.core.GenericTypeResolver;
|
||||
import org.springframework.http.ResponseEntity;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.bind.annotation.RequestParam;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import static com.jasamedika.medifirst2000.constants.Constants.COMMA;
|
||||
import static com.jasamedika.medifirst2000.util.rest.RestUtil.getJsonResponse;
|
||||
import static org.springframework.http.HttpStatus.OK;
|
||||
import static org.springframework.web.bind.annotation.RequestMethod.GET;
|
||||
|
||||
/**
|
||||
* Base Controller Class for handling "include" parameter to controller
|
||||
* @see https://github.com/monitorjbl/json-view
|
||||
* Base Controller Class for handling "include" parameter to controller
|
||||
*
|
||||
* @see <a href="https://github.com/monitorjbl/json-view">json view</a>
|
||||
*
|
||||
* @author Roberto
|
||||
*/
|
||||
public abstract class ParamRestController<T extends BaseModelVO> {
|
||||
private JsonResult jsonResult = JsonResult.instance();
|
||||
|
||||
/*
|
||||
* Belum selesai, baru di parameter includes. Untuk field object juga belom.
|
||||
* example :
|
||||
* http://localhost:8080/jasamedika-web/{typeVOClass}/list-using-param
|
||||
* ?includes =id,nama
|
||||
*/
|
||||
@RequestMapping(value = "/list-using-param", method = RequestMethod.GET)
|
||||
public ResponseEntity<List<T>> listUsingParam(
|
||||
@RequestParam(value = "includes", required = false) String includes,
|
||||
private final JsonResult jsonResult = JsonResult.instance();
|
||||
|
||||
@RequestMapping(value = "/list-using-param", method = GET)
|
||||
public ResponseEntity<List<T>> listUsingParam(@RequestParam(value = "includes", required = false) String includes,
|
||||
@RequestParam(value = "excludes", required = false) String excludes) {
|
||||
List<T> listVO = getAllVOFromService();
|
||||
String[] arrExcludes = null;
|
||||
String[] arrIncludes = null;
|
||||
if (excludes != null)
|
||||
arrExcludes = excludes.split(Constants.COMMA);
|
||||
arrExcludes = excludes.split(COMMA);
|
||||
if (includes != null)
|
||||
arrIncludes = includes.split(Constants.COMMA);
|
||||
arrIncludes = includes.split(COMMA);
|
||||
if (arrExcludes != null && arrIncludes != null) {
|
||||
listVO = jsonResult.use(
|
||||
JsonView.with(listVO).onClass(
|
||||
getClazz(),
|
||||
Match.match().exclude(arrExcludes)
|
||||
.include(arrIncludes))).returnValue();
|
||||
JsonView.with(listVO).onClass(getClazz(), Match.match().exclude(arrExcludes).include(arrIncludes)))
|
||||
.returnValue();
|
||||
}
|
||||
if (arrExcludes != null && arrIncludes == null) {
|
||||
listVO = jsonResult.use(
|
||||
JsonView.with(listVO).onClass(getClazz(),
|
||||
Match.match().include("*").exclude(arrExcludes)))
|
||||
listVO = jsonResult
|
||||
.use(JsonView.with(listVO).onClass(getClazz(), Match.match().include("*").exclude(arrExcludes)))
|
||||
.returnValue();
|
||||
}
|
||||
if (arrExcludes == null && arrIncludes != null) {
|
||||
listVO = jsonResult.use(
|
||||
JsonView.with(listVO).onClass(getClazz(),
|
||||
Match.match().exclude("*").include(arrIncludes)))
|
||||
listVO = jsonResult
|
||||
.use(JsonView.with(listVO).onClass(getClazz(), Match.match().exclude("*").include(arrIncludes)))
|
||||
.returnValue();
|
||||
}
|
||||
|
||||
return RestUtil.getJsonResponse(listVO, HttpStatus.OK);
|
||||
return getJsonResponse(listVO, OK);
|
||||
}
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
protected Class<T> getClazz() {
|
||||
return (Class<T>) GenericTypeResolver.resolveTypeArgument(getClass(),
|
||||
ParamRestController.class);
|
||||
protected Class<?> getClazz() {
|
||||
return GenericTypeResolver.resolveTypeArgument(getClass(), ParamRestController.class);
|
||||
}
|
||||
|
||||
/*
|
||||
/**
|
||||
* method untuk mendapatkan all VO from service
|
||||
* */
|
||||
*
|
||||
*/
|
||||
protected abstract List<T> getAllVOFromService();
|
||||
}
|
||||
|
||||
@ -1,164 +1,42 @@
|
||||
package com.jasamedika.medifirst2000.filter;
|
||||
|
||||
import java.io.BufferedReader;
|
||||
import java.io.ByteArrayInputStream;
|
||||
import java.io.IOException;
|
||||
import java.io.InputStream;
|
||||
import java.io.InputStreamReader;
|
||||
import java.util.Iterator;
|
||||
|
||||
import javax.servlet.Filter;
|
||||
import javax.servlet.FilterChain;
|
||||
import javax.servlet.FilterConfig;
|
||||
import javax.servlet.ServletException;
|
||||
import javax.servlet.ServletInputStream;
|
||||
import javax.servlet.ServletRequest;
|
||||
import javax.servlet.ServletResponse;
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
import javax.servlet.http.HttpServletRequestWrapper;
|
||||
import javax.servlet.http.HttpServletResponse;
|
||||
|
||||
import org.json.JSONArray;
|
||||
import org.json.JSONObject;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
import com.jasamedika.medifirst2000.constants.Constants;
|
||||
import javax.servlet.*;
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
import javax.servlet.http.HttpServletRequestWrapper;
|
||||
import javax.servlet.http.HttpServletResponse;
|
||||
import java.io.*;
|
||||
import java.util.Iterator;
|
||||
|
||||
import static com.jasamedika.medifirst2000.constants.Constants.HttpHeader.KD_RUANGAN_A;
|
||||
import static com.jasamedika.medifirst2000.constants.Constants.HttpHeader.KD_RUANGAN_T;
|
||||
|
||||
/**
|
||||
* CORSFilter class
|
||||
*
|
||||
* @author Roberto
|
||||
* @author Roberto, Syamsu
|
||||
*/
|
||||
@Component
|
||||
public class CORSFilter implements Filter {
|
||||
|
||||
// Start Syamsu
|
||||
private static class RequestWrapper extends HttpServletRequestWrapper {
|
||||
final String body;
|
||||
|
||||
public RequestWrapper(ServletRequest req) throws IOException {
|
||||
super((HttpServletRequest) req);
|
||||
|
||||
HttpServletRequest request = (HttpServletRequest) req;
|
||||
|
||||
StringBuilder stringBuilder = new StringBuilder();
|
||||
BufferedReader reader = null;
|
||||
try {
|
||||
InputStream inputStream = request.getInputStream();
|
||||
if (inputStream != null) {
|
||||
reader = new BufferedReader(new InputStreamReader(inputStream));
|
||||
String hasil;
|
||||
while ( (hasil = reader.readLine()) != null) {
|
||||
stringBuilder.append(hasil);
|
||||
}
|
||||
} else {
|
||||
stringBuilder.append("");
|
||||
}
|
||||
} catch (IOException ex) {
|
||||
throw ex;
|
||||
} finally {
|
||||
if (reader != null) {
|
||||
try {
|
||||
reader.close();
|
||||
} catch (IOException ex) {
|
||||
throw ex;
|
||||
}
|
||||
}
|
||||
}
|
||||
body = stringBuilder.toString();
|
||||
|
||||
String idRuanganTujuan = request.getHeader(Constants.HttpHeader.KD_RUANGAN_T) == null ? ""
|
||||
: request.getHeader(Constants.HttpHeader.KD_RUANGAN_T);
|
||||
|
||||
if ("".equals(idRuanganTujuan.trim())){
|
||||
try{
|
||||
JSONObject jObject = new JSONObject(body);
|
||||
ExtractObjectJson(jObject, false);
|
||||
}catch(Exception e){
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public String getHeader(String key){
|
||||
if (key.equals(Constants.HttpHeader.KD_RUANGAN_A)) {
|
||||
if (autoIdTujuan.length() > 0){
|
||||
return autoIdTujuan.toString();
|
||||
}
|
||||
}
|
||||
|
||||
return super.getHeader(key);
|
||||
}
|
||||
|
||||
JSONArray autoIdTujuan = new JSONArray();
|
||||
|
||||
void ExtractObjectJson(JSONObject jObject, boolean ruangan) throws Exception{
|
||||
Iterator iterator = jObject.keys();
|
||||
while (iterator.hasNext()){
|
||||
String key = String.valueOf(iterator.next());
|
||||
Object o = jObject.get(key);
|
||||
|
||||
if (key.toLowerCase().contains("ruangan")){
|
||||
if (o instanceof Integer){
|
||||
autoIdTujuan.put(o);
|
||||
} else if (o instanceof JSONObject){
|
||||
ExtractObjectJson((JSONObject) o, true);
|
||||
}
|
||||
} else if (ruangan && "id".equals(key)){
|
||||
if (o instanceof Integer){
|
||||
autoIdTujuan.put(o);
|
||||
return;
|
||||
}
|
||||
} else if (o instanceof JSONObject && !ruangan) {
|
||||
ExtractObjectJson((JSONObject) o, false);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public ServletInputStream getInputStream() throws IOException {
|
||||
final ByteArrayInputStream byteArrayInputStream = new ByteArrayInputStream(body.getBytes());
|
||||
ServletInputStream servletInputStream = new ServletInputStream() {
|
||||
public int read() throws IOException {
|
||||
return byteArrayInputStream.read();
|
||||
}
|
||||
};
|
||||
return servletInputStream;
|
||||
}
|
||||
|
||||
@Override
|
||||
public BufferedReader getReader() throws IOException {
|
||||
return new BufferedReader(new InputStreamReader(getInputStream()));
|
||||
}
|
||||
|
||||
public String getBody() {
|
||||
return this.body;
|
||||
}
|
||||
}
|
||||
// End Syamsu
|
||||
|
||||
|
||||
private final Logger log = LoggerFactory.getLogger(CORSFilter.class);
|
||||
|
||||
public CORSFilter() {
|
||||
log.info("CORSFilter JasaMedika Web init");
|
||||
LOGGER.info("CORSFilter JasaMedika Web init");
|
||||
}
|
||||
|
||||
private static final Logger LOGGER = LoggerFactory.getLogger(CORSFilter.class);
|
||||
|
||||
@Override
|
||||
public void doFilter(ServletRequest req, ServletResponse res, FilterChain chain)
|
||||
throws IOException, ServletException {
|
||||
|
||||
// Start Syamsu
|
||||
RequestWrapper myReq = new RequestWrapper((HttpServletRequest) req);
|
||||
// End Syamsu
|
||||
HttpServletRequest request = (HttpServletRequest) myReq;
|
||||
RequestWrapper myReq = new RequestWrapper(req);
|
||||
HttpServletResponse response = (HttpServletResponse) res;
|
||||
|
||||
response.setHeader("Access-Control-Allow-Origin", request.getHeader("Origin"));
|
||||
response.setHeader("Access-Control-Allow-Origin", myReq.getHeader("Origin"));
|
||||
response.setHeader("Access-Control-Allow-Credentials", "true");
|
||||
|
||||
response.setHeader("Access-Control-Allow-Methods", "POST, GET, OPTIONS, DELETE");
|
||||
response.setHeader("Access-Control-Max-Age", "3600");
|
||||
response.setHeader("Access-Control-Allow-Headers",
|
||||
@ -166,23 +44,101 @@ public class CORSFilter implements Filter {
|
||||
+ "Supervising, RequestSupervisor, Module, Form, Action, AlamatUrlForm, KdRuangan, KdUser, "
|
||||
+ "MandatoriData, idRuanganTujuan, ruanganTujuan");
|
||||
response.setHeader("Content-Type", "application/json;application/octet-stream");
|
||||
|
||||
|
||||
// String body = myReq.getBody();
|
||||
// if (!"".equals(body.trim())){
|
||||
// log.info("\n\n" + myReq.getBody() + "\n");
|
||||
// }
|
||||
|
||||
chain.doFilter(myReq, res);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void init(FilterConfig filterConfig) {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void destroy() {
|
||||
}
|
||||
|
||||
private static class RequestWrapper extends HttpServletRequestWrapper {
|
||||
|
||||
final String body;
|
||||
|
||||
JSONArray autoIdTujuan = new JSONArray();
|
||||
|
||||
public RequestWrapper(ServletRequest req) throws IOException {
|
||||
super((HttpServletRequest) req);
|
||||
HttpServletRequest request = (HttpServletRequest) req;
|
||||
StringBuilder stringBuilder = getStringBuilder(request);
|
||||
body = stringBuilder.toString();
|
||||
String idRuanganTujuan = request.getHeader(KD_RUANGAN_T) == null ? "" : request.getHeader(KD_RUANGAN_T);
|
||||
if (idRuanganTujuan.trim().isEmpty()) {
|
||||
try {
|
||||
JSONObject jObject = new JSONObject(body);
|
||||
ExtractObjectJson(jObject, false);
|
||||
} catch (Exception e) {
|
||||
LOGGER.error(e.getMessage());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public String getHeader(String key) {
|
||||
if (key.equals(KD_RUANGAN_A) && autoIdTujuan.length() > 0)
|
||||
return autoIdTujuan.toString();
|
||||
return super.getHeader(key);
|
||||
}
|
||||
|
||||
void ExtractObjectJson(JSONObject jObject, boolean ruangan) throws Exception {
|
||||
Iterator<?> iterator = jObject.keys();
|
||||
while (iterator.hasNext()) {
|
||||
String key = String.valueOf(iterator.next());
|
||||
Object o = jObject.get(key);
|
||||
if (key.toLowerCase().contains("ruangan")) {
|
||||
if (o instanceof Integer) {
|
||||
autoIdTujuan.put(o);
|
||||
} else if (o instanceof JSONObject) {
|
||||
ExtractObjectJson((JSONObject) o, true);
|
||||
}
|
||||
} else if (ruangan && "id".equals(key)) {
|
||||
if (o instanceof Integer) {
|
||||
autoIdTujuan.put(o);
|
||||
return;
|
||||
}
|
||||
} else if (o instanceof JSONObject && !ruangan) {
|
||||
ExtractObjectJson((JSONObject) o, false);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public ServletInputStream getInputStream() {
|
||||
final ByteArrayInputStream byteArrayInputStream = new ByteArrayInputStream(body.getBytes());
|
||||
return new ServletInputStream() {
|
||||
public int read() {
|
||||
return byteArrayInputStream.read();
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
@Override
|
||||
public BufferedReader getReader() {
|
||||
return new BufferedReader(new InputStreamReader(getInputStream()));
|
||||
}
|
||||
}
|
||||
|
||||
private static StringBuilder getStringBuilder(HttpServletRequest request) throws IOException {
|
||||
StringBuilder stringBuilder = new StringBuilder();
|
||||
BufferedReader reader = null;
|
||||
try {
|
||||
InputStream inputStream = request.getInputStream();
|
||||
if (inputStream != null) {
|
||||
reader = new BufferedReader(new InputStreamReader(inputStream));
|
||||
String hasil;
|
||||
while ((hasil = reader.readLine()) != null) {
|
||||
stringBuilder.append(hasil);
|
||||
}
|
||||
}
|
||||
} finally {
|
||||
if (reader != null) {
|
||||
reader.close();
|
||||
}
|
||||
}
|
||||
return stringBuilder;
|
||||
}
|
||||
|
||||
}
|
||||
@ -1,8 +1,12 @@
|
||||
package com.jasamedika.medifirst2000.filter;
|
||||
|
||||
import com.fasterxml.jackson.core.JsonParseException;
|
||||
import com.jasamedika.medifirst2000.security.service.TokenAuthenticationService;
|
||||
import io.jsonwebtoken.MalformedJwtException;
|
||||
|
||||
import java.io.IOException;
|
||||
import lombok.AllArgsConstructor;
|
||||
import org.springframework.security.core.Authentication;
|
||||
import org.springframework.security.core.context.SecurityContextHolder;
|
||||
import org.springframework.web.filter.GenericFilterBean;
|
||||
|
||||
import javax.servlet.FilterChain;
|
||||
import javax.servlet.ServletException;
|
||||
@ -10,54 +14,39 @@ import javax.servlet.ServletRequest;
|
||||
import javax.servlet.ServletResponse;
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
import javax.servlet.http.HttpServletResponse;
|
||||
import java.io.IOException;
|
||||
|
||||
import org.springframework.security.core.Authentication;
|
||||
import org.springframework.security.core.context.SecurityContextHolder;
|
||||
import org.springframework.web.filter.GenericFilterBean;
|
||||
|
||||
import com.fasterxml.jackson.core.JsonParseException;
|
||||
import com.jasamedika.medifirst2000.constants.Constants;
|
||||
import com.jasamedika.medifirst2000.security.service.TokenAuthenticationService;
|
||||
import static com.jasamedika.medifirst2000.constants.Constants.MessageInfo.ERROR_MESSAGE;
|
||||
|
||||
/**
|
||||
* StatelessAuthenticationFilter class
|
||||
*
|
||||
* @author Roberto
|
||||
*/
|
||||
@AllArgsConstructor
|
||||
public class StatelessAuthenticationFilter extends GenericFilterBean {
|
||||
|
||||
private final TokenAuthenticationService authenticationService;
|
||||
|
||||
public StatelessAuthenticationFilter(
|
||||
TokenAuthenticationService authenticationService) {
|
||||
this.authenticationService = authenticationService;
|
||||
}
|
||||
|
||||
public void doFilter(ServletRequest request, ServletResponse response,
|
||||
FilterChain filterChain) throws IOException, ServletException {
|
||||
public void doFilter(ServletRequest request, ServletResponse response, FilterChain filterChain)
|
||||
throws IOException, ServletException {
|
||||
HttpServletRequest httpRequest = (HttpServletRequest) request;
|
||||
HttpServletRequest req = (HttpServletRequest) request;
|
||||
HttpServletResponse res = (HttpServletResponse) response;
|
||||
|
||||
res.setHeader("Access-Control-Allow-Origin",
|
||||
req.getHeader("Origin"));
|
||||
res.setHeader("Access-Control-Allow-Origin", req.getHeader("Origin"));
|
||||
res.setHeader("Access-Control-Allow-Credentials", "true");
|
||||
|
||||
res.setHeader("Access-Control-Allow-Methods",
|
||||
"POST, GET, OPTIONS, DELETE");
|
||||
res.setHeader("Access-Control-Allow-Methods", "POST, GET, OPTIONS, DELETE");
|
||||
res.setHeader("Access-Control-Max-Age", "3600");
|
||||
res.setHeader("Access-Control-Allow-Headers",
|
||||
"Content-Type, Accept, X-Requested-With, remember-me, X-AUTH-TOKEN, Supervising, "
|
||||
+ "RequestSupervisor, Module, Form, Action, AlamatUrlForm, KdRuangan, KdUser, "
|
||||
+ "MandatoriData");
|
||||
|
||||
+ "RequestSupervisor, Module, Form, Action, AlamatUrlForm, KdRuangan, KdUser, "
|
||||
+ "MandatoriData");
|
||||
Authentication authentication = null;
|
||||
try {
|
||||
|
||||
authentication = authenticationService.getAuthentication(httpRequest);
|
||||
} catch (JsonParseException | MalformedJwtException e) {
|
||||
HttpServletResponse httpResponse = (HttpServletResponse) response;
|
||||
httpResponse.addHeader(Constants.MessageInfo.ERROR_MESSAGE,
|
||||
"Error Token (Not Valid Token)");
|
||||
httpResponse.addHeader(ERROR_MESSAGE, "Error Token (Not Valid Token)");
|
||||
filterChain.doFilter(request, response);
|
||||
}
|
||||
SecurityContextHolder.getContext().setAuthentication(authentication);
|
||||
|
||||
@ -1,15 +1,12 @@
|
||||
package com.jasamedika.medifirst2000.handler;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Locale;
|
||||
|
||||
import com.jasamedika.medifirst2000.base.vo.validation.ValidationErrorVO;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.context.MessageSource;
|
||||
import org.springframework.context.i18n.LocaleContextHolder;
|
||||
import org.springframework.core.annotation.Order;
|
||||
import org.springframework.http.HttpStatus;
|
||||
import org.springframework.validation.BindingResult;
|
||||
import org.springframework.validation.FieldError;
|
||||
import org.springframework.web.bind.MethodArgumentNotValidException;
|
||||
@ -18,22 +15,24 @@ import org.springframework.web.bind.annotation.ExceptionHandler;
|
||||
import org.springframework.web.bind.annotation.ResponseBody;
|
||||
import org.springframework.web.bind.annotation.ResponseStatus;
|
||||
|
||||
import com.jasamedika.medifirst2000.base.vo.validation.ValidationErrorVO;
|
||||
import com.jasamedika.medifirst2000.constants.Constants;;
|
||||
import java.util.List;
|
||||
import java.util.Locale;
|
||||
|
||||
import static com.jasamedika.medifirst2000.constants.Constants.Locale.INA;
|
||||
import static org.springframework.http.HttpStatus.BAD_REQUEST;
|
||||
|
||||
/**
|
||||
* Exception Handler Rest Controller class
|
||||
*
|
||||
* @author Roberto
|
||||
*/
|
||||
|
||||
@ControllerAdvice
|
||||
@Order(1) // Pertama masuk
|
||||
@Order(1)
|
||||
public class RestErrorHandler {
|
||||
|
||||
private static final Logger LOGGER = LoggerFactory.getLogger(RestErrorHandler.class);
|
||||
|
||||
private MessageSource messageSource;
|
||||
private final MessageSource messageSource;
|
||||
|
||||
@Autowired
|
||||
public RestErrorHandler(MessageSource validationNessageSource) {
|
||||
@ -41,60 +40,45 @@ public class RestErrorHandler {
|
||||
}
|
||||
|
||||
@ExceptionHandler(MethodArgumentNotValidException.class)
|
||||
@ResponseStatus(HttpStatus.BAD_REQUEST)
|
||||
@ResponseStatus(BAD_REQUEST)
|
||||
@ResponseBody
|
||||
public ValidationErrorVO processValidationError(MethodArgumentNotValidException ex) {
|
||||
LOGGER.warn("Handling data validation error");
|
||||
BindingResult result = ex.getBindingResult();
|
||||
List<FieldError> fieldErrors = result.getFieldErrors();
|
||||
|
||||
return processFieldErrors(fieldErrors);
|
||||
}
|
||||
|
||||
private ValidationErrorVO processFieldErrors(List<FieldError> fieldErrors) {
|
||||
ValidationErrorVO dto = new ValidationErrorVO();
|
||||
|
||||
for (FieldError fieldError : fieldErrors) {
|
||||
dto.addFieldError(fieldError.getField(), fieldError.getDefaultMessage());
|
||||
}
|
||||
|
||||
return dto;
|
||||
}
|
||||
|
||||
/*
|
||||
/**
|
||||
* resolve error message with parameter locale
|
||||
*/
|
||||
private String resolveLocalizedErrorMessage(FieldError fieldError, String locale) {
|
||||
Locale currentLocale = LocaleContextHolder.getLocale();
|
||||
String localizedErrorMessage = messageSource.getMessage(fieldError, currentLocale);
|
||||
|
||||
// If the message was not found, return the most accurate field error
|
||||
// code instead.
|
||||
// You can remove this check if you prefer to get the default error
|
||||
// message.
|
||||
if (localizedErrorMessage.equals(fieldError.getDefaultMessage())) {
|
||||
String[] fieldErrorCodes = fieldError.getCodes();
|
||||
localizedErrorMessage = fieldErrorCodes[0];
|
||||
}
|
||||
|
||||
return localizedErrorMessage;
|
||||
}
|
||||
|
||||
/*
|
||||
/**
|
||||
* resolve error message with default locale
|
||||
*/
|
||||
private String resolveLocalizedErrorMessage(FieldError fieldError) {
|
||||
String localizedErrorMessage = messageSource.getMessage(fieldError, new Locale(Constants.Locale.INA));
|
||||
|
||||
// If the message was not found, return the most accurate field error
|
||||
// code instead.
|
||||
// You can remove this check if you prefer to get the default error
|
||||
// message.
|
||||
String localizedErrorMessage = messageSource.getMessage(fieldError, new Locale(INA));
|
||||
if (localizedErrorMessage.equals(fieldError.getDefaultMessage())) {
|
||||
String[] fieldErrorCodes = fieldError.getCodes();
|
||||
localizedErrorMessage = fieldErrorCodes[0];
|
||||
}
|
||||
|
||||
return localizedErrorMessage;
|
||||
}
|
||||
}
|
||||
|
||||
@ -32,9 +32,8 @@ import java.util.List;
|
||||
/**
|
||||
* Interceptor class for All annotation method controller @AppPermission
|
||||
*
|
||||
* @author Roberto, direka ulang oleh Syamsu
|
||||
* @author Roberto, Syamsu
|
||||
*/
|
||||
|
||||
public class AppInterceptor implements HandlerInterceptor {
|
||||
|
||||
private static final String[] PRINT_PATTERN = { "/lap_", "/lap-", "/lap", "/cetak_", "/cetak-", "/print_",
|
||||
|
||||
@ -1,43 +1,34 @@
|
||||
package com.jasamedika.medifirst2000.security;
|
||||
|
||||
import java.io.IOException;
|
||||
|
||||
import javax.servlet.ServletException;
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
import javax.servlet.http.HttpServletResponse;
|
||||
|
||||
import com.jasamedika.medifirst2000.constants.Constants;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
import org.springframework.security.core.AuthenticationException;
|
||||
import org.springframework.security.web.AuthenticationEntryPoint;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
import com.jasamedika.medifirst2000.constants.Constants;
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
import javax.servlet.http.HttpServletResponse;
|
||||
import java.io.IOException;
|
||||
|
||||
/**
|
||||
* RestAuthenticationEntryPoint class
|
||||
* set Unauthorized response from "Unauthorized client"
|
||||
* RestAuthenticationEntryPoint class set Unauthorized response from
|
||||
* "Unauthorized client"
|
||||
*
|
||||
* @author Roberto
|
||||
* @author Roberto, Syamsu
|
||||
*/
|
||||
@Component("RestAuthenticationEntryPoint")
|
||||
public class RestAuthenticationEntryPoint implements AuthenticationEntryPoint {
|
||||
|
||||
private static final Logger LOGGER = LoggerFactory.getLogger(RestAuthenticationEntryPoint.class);
|
||||
|
||||
|
||||
/// Alter Syamsu
|
||||
private static final Logger LOGGER = LoggerFactory.getLogger(RestAuthenticationEntryPoint.class);
|
||||
|
||||
@Override
|
||||
public void commence(HttpServletRequest request,
|
||||
HttpServletResponse response, AuthenticationException ae)
|
||||
throws IOException, ServletException {
|
||||
|
||||
public void commence(HttpServletRequest request, HttpServletResponse response, AuthenticationException ae)
|
||||
throws IOException {
|
||||
LOGGER.error("Mencoba akses tanpa login");
|
||||
|
||||
response.getWriter().write("{" + Constants.MessageInfo.ERROR_MESSAGE + ":'Please login to get access'}");
|
||||
response.setHeader(Constants.MessageInfo.ERROR_MESSAGE, "Please login to get access");
|
||||
response.setStatus(HttpServletResponse.SC_FORBIDDEN);
|
||||
|
||||
//response.sendError(HttpServletResponse.SC_UNAUTHORIZED, "Unauthorized");
|
||||
}
|
||||
|
||||
}
|
||||
@ -1,10 +1,12 @@
|
||||
package com.jasamedika.medifirst2000.security;
|
||||
|
||||
import com.jasamedika.medifirst2000.filter.StatelessAuthenticationFilter;
|
||||
import com.jasamedika.medifirst2000.security.service.TokenAuthenticationService;
|
||||
import com.jasamedika.medifirst2000.security.service.UserService;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.context.annotation.Bean;
|
||||
import org.springframework.context.annotation.Configuration;
|
||||
import org.springframework.core.annotation.Order;
|
||||
import org.springframework.scheduling.annotation.EnableScheduling;
|
||||
import org.springframework.security.authentication.AuthenticationManager;
|
||||
import org.springframework.security.config.annotation.authentication.builders.AuthenticationManagerBuilder;
|
||||
import org.springframework.security.config.annotation.web.builders.HttpSecurity;
|
||||
@ -13,14 +15,11 @@ import org.springframework.security.config.annotation.web.configuration.WebSecur
|
||||
import org.springframework.security.crypto.bcrypt.BCryptPasswordEncoder;
|
||||
import org.springframework.security.web.authentication.UsernamePasswordAuthenticationFilter;
|
||||
|
||||
import com.jasamedika.medifirst2000.constants.Constants;
|
||||
import com.jasamedika.medifirst2000.filter.StatelessAuthenticationFilter;
|
||||
import com.jasamedika.medifirst2000.security.service.TokenAuthenticationService;
|
||||
import com.jasamedika.medifirst2000.security.service.UserService;
|
||||
import static com.jasamedika.medifirst2000.constants.Constants.JASAMEDIKA;
|
||||
|
||||
/**
|
||||
* SpringSecurityConfig class
|
||||
* Di sini Kita tidak menggunakan XML Config untuk Spring Security
|
||||
* SpringSecurityConfig class Di sini Kita tidak menggunakan XML Config untuk
|
||||
* Spring Security
|
||||
*
|
||||
* @author Roberto
|
||||
*/
|
||||
@ -29,94 +28,35 @@ import com.jasamedika.medifirst2000.security.service.UserService;
|
||||
@Order(2)
|
||||
public class SpringSecurityConfig extends WebSecurityConfigurerAdapter {
|
||||
|
||||
private final UserService userService;
|
||||
|
||||
private final TokenAuthenticationService tokenAuthenticationService;
|
||||
|
||||
@Autowired
|
||||
private RestAuthenticationEntryPoint restAuthenticationEntryPoint;
|
||||
|
||||
private final UserService userService;
|
||||
private final TokenAuthenticationService tokenAuthenticationService;
|
||||
|
||||
public SpringSecurityConfig() {
|
||||
super(true);
|
||||
this.userService = new UserService();
|
||||
tokenAuthenticationService = new TokenAuthenticationService(
|
||||
Constants.JASAMEDIKA, userService);
|
||||
tokenAuthenticationService = new TokenAuthenticationService(JASAMEDIKA, userService);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void configure(HttpSecurity http) throws Exception {
|
||||
http.exceptionHandling()
|
||||
//restAuthenticationEntryPoint
|
||||
.authenticationEntryPoint(restAuthenticationEntryPoint)
|
||||
|
||||
.and()
|
||||
.anonymous()
|
||||
.and()
|
||||
.servletApi()
|
||||
.and()
|
||||
.headers()
|
||||
.cacheControl()
|
||||
.and()
|
||||
.authorizeRequests()
|
||||
|
||||
|
||||
// Allow anonymous resource requests
|
||||
.antMatchers("/favicon.ico")
|
||||
.permitAll()
|
||||
.antMatchers("**/*.html")
|
||||
.permitAll()
|
||||
.antMatchers("**/*.css")
|
||||
.permitAll()
|
||||
.antMatchers("**/*.js")
|
||||
.permitAll()
|
||||
|
||||
// Allow anonymous logins
|
||||
.antMatchers("/auth/**")
|
||||
.permitAll()
|
||||
|
||||
// Allow SMS gateway
|
||||
.antMatchers("/registrasi-pasien-sms/**")
|
||||
.permitAll()
|
||||
|
||||
// Allow SMS gateway
|
||||
.antMatchers("/report/**")
|
||||
.permitAll()
|
||||
|
||||
// URL tanpa auth deklarasikan di sini
|
||||
.antMatchers("/test-tanpa-auth/**")
|
||||
.permitAll()
|
||||
.antMatchers("/test/**")
|
||||
.permitAll()
|
||||
|
||||
.antMatchers("/api-docs.json")
|
||||
.permitAll()
|
||||
|
||||
.antMatchers("/api-docs/**")
|
||||
.permitAll()
|
||||
|
||||
/*//Allow Download File Surat Masuk
|
||||
.antMatchers("/surat-masuk/download-dokumen-template/**")
|
||||
.permitAll()
|
||||
.antMatchers("/surat-masuk/get-draft-surat/**")
|
||||
.permitAll()*/
|
||||
|
||||
// All other request need to be authenticated
|
||||
.anyRequest()
|
||||
.authenticated()
|
||||
.and()
|
||||
|
||||
// Custom Token based authentication based on the header
|
||||
// previously given to the client
|
||||
.addFilterBefore(
|
||||
new StatelessAuthenticationFilter(
|
||||
tokenAuthenticationService),
|
||||
http.exceptionHandling().authenticationEntryPoint(restAuthenticationEntryPoint).and().anonymous().and()
|
||||
.servletApi().and().headers().cacheControl().and().authorizeRequests().antMatchers("/favicon.ico")
|
||||
.permitAll().antMatchers("**/*.html").permitAll().antMatchers("**/*.css").permitAll()
|
||||
.antMatchers("**/*.js").permitAll().antMatchers("/auth/**").permitAll()
|
||||
.antMatchers("/registrasi-pasien-sms/**").permitAll().antMatchers("/report/**").permitAll()
|
||||
.antMatchers("/test-tanpa-auth/**").permitAll().antMatchers("/test/**").permitAll()
|
||||
.antMatchers("/api-docs.json").permitAll().antMatchers("/api-docs/**").permitAll().anyRequest()
|
||||
.authenticated().and().addFilterBefore(new StatelessAuthenticationFilter(tokenAuthenticationService),
|
||||
UsernamePasswordAuthenticationFilter.class);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void configure(AuthenticationManagerBuilder auth)
|
||||
throws Exception {
|
||||
auth.userDetailsService(userDetailsService()).passwordEncoder(
|
||||
new BCryptPasswordEncoder());
|
||||
protected void configure(AuthenticationManagerBuilder auth) throws Exception {
|
||||
auth.userDetailsService(userDetailsService()).passwordEncoder(new BCryptPasswordEncoder());
|
||||
}
|
||||
|
||||
@Bean
|
||||
@ -135,11 +75,4 @@ public class SpringSecurityConfig extends WebSecurityConfigurerAdapter {
|
||||
public TokenAuthenticationService tokenAuthenticationService() {
|
||||
return tokenAuthenticationService;
|
||||
}
|
||||
|
||||
|
||||
// @Bean(name = "springSecurityFilterChain", autowire = Autowire.BY_NAME)
|
||||
// public DelegatingFilterProxy springSecurityFilterChain(){
|
||||
// return new DelegatingFilterProxy();
|
||||
// }
|
||||
|
||||
}
|
||||
|
||||
@ -8,33 +8,28 @@ import org.springframework.security.core.userdetails.User;
|
||||
import com.jasamedika.medifirst2000.security.service.UserService;
|
||||
|
||||
/**
|
||||
* TokenHandler class
|
||||
* using jjwt https://github.com/jwtk/jjwt
|
||||
*
|
||||
* TokenHandler class using jjwt <a href="https://github.com/jwtk/jjwt">jjwt</a>
|
||||
*
|
||||
* @author Roberto
|
||||
*/
|
||||
public class TokenHandler {
|
||||
private final String secret;
|
||||
private final UserService userService;
|
||||
|
||||
public TokenHandler(String secret, UserService userService) {
|
||||
this.secret = secret;
|
||||
this.userService = userService;
|
||||
}
|
||||
private final String secret;
|
||||
|
||||
public User parseUserFromToken(String token) {
|
||||
String username = Jwts.parser()
|
||||
.setSigningKey(secret)
|
||||
.parseClaimsJws(token)
|
||||
.getBody()
|
||||
.getSubject();
|
||||
return userService.loadUserByUsername(username);
|
||||
}
|
||||
private final UserService userService;
|
||||
|
||||
public String createTokenForUser(User user) {
|
||||
return Jwts.builder().setHeaderParam("typ", "JWT")
|
||||
.setSubject(user.getUsername())
|
||||
.signWith(SignatureAlgorithm.HS512, secret)
|
||||
.compact();
|
||||
}
|
||||
public TokenHandler(String secret, UserService userService) {
|
||||
this.secret = secret;
|
||||
this.userService = userService;
|
||||
}
|
||||
|
||||
public User parseUserFromToken(String token) {
|
||||
String username = Jwts.parser().setSigningKey(secret).parseClaimsJws(token).getBody().getSubject();
|
||||
return userService.loadUserByUsername(username);
|
||||
}
|
||||
|
||||
public String createTokenForUser(User user) {
|
||||
return Jwts.builder().setHeaderParam("typ", "JWT").setSubject(user.getUsername())
|
||||
.signWith(SignatureAlgorithm.HS512, secret).compact();
|
||||
}
|
||||
}
|
||||
|
||||
@ -6,20 +6,20 @@ import java.lang.annotation.RetentionPolicy;
|
||||
import java.lang.annotation.Target;
|
||||
|
||||
/**
|
||||
* AppPermission annotation, digunakan untuk method yang butuh authorized dari database
|
||||
* can use in method only.
|
||||
* AppPermission annotation, digunakan untuk method yang butuh authorized dari
|
||||
* database can use in method only.
|
||||
*
|
||||
* @author Roberto
|
||||
*/
|
||||
@Retention(RetentionPolicy.RUNTIME)
|
||||
@Target(ElementType.METHOD)
|
||||
public @interface AppPermission {
|
||||
public static final int ADD = 100;
|
||||
public static final int UPDATE = 200;
|
||||
public static final int DELETE = 300;
|
||||
public static final int PRINT = 400;
|
||||
public static final int VIEW = 500;
|
||||
|
||||
public static final int SPECIALS = 600;
|
||||
|
||||
public @interface AppPermission {
|
||||
int ADD = 100;
|
||||
int UPDATE = 200;
|
||||
int DELETE = 300;
|
||||
int PRINT = 400;
|
||||
int VIEW = 500;
|
||||
int SPECIALS = 600;
|
||||
|
||||
int value();
|
||||
}
|
||||
|
||||
@ -1,11 +1,11 @@
|
||||
package com.jasamedika.medifirst2000.security.model;
|
||||
|
||||
import java.util.Collection;
|
||||
|
||||
import org.springframework.security.core.Authentication;
|
||||
import org.springframework.security.core.GrantedAuthority;
|
||||
import org.springframework.security.core.userdetails.User;
|
||||
|
||||
import java.util.Collection;
|
||||
|
||||
/**
|
||||
* UserAuthentication class
|
||||
*
|
||||
@ -16,7 +16,9 @@ public class UserAuthentication implements Authentication {
|
||||
* serialVersionUID
|
||||
*/
|
||||
private static final long serialVersionUID = -7410905698525654537L;
|
||||
|
||||
private final User user;
|
||||
|
||||
private boolean authenticated = true;
|
||||
|
||||
public UserAuthentication(User user) {
|
||||
|
||||
@ -1,71 +1,63 @@
|
||||
package com.jasamedika.medifirst2000.security.service;
|
||||
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
import javax.servlet.http.HttpServletResponse;
|
||||
|
||||
import com.fasterxml.jackson.core.JsonParseException;
|
||||
import com.jasamedika.medifirst2000.security.handler.TokenHandler;
|
||||
import com.jasamedika.medifirst2000.security.model.UserAuthentication;
|
||||
import lombok.NoArgsConstructor;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.security.core.Authentication;
|
||||
import org.springframework.security.core.userdetails.User;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
import com.fasterxml.jackson.core.JsonParseException;
|
||||
import com.jasamedika.medifirst2000.core.web.WebConstants;
|
||||
import com.jasamedika.medifirst2000.security.handler.TokenHandler;
|
||||
import com.jasamedika.medifirst2000.security.model.UserAuthentication;
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
import java.util.Objects;
|
||||
|
||||
import static com.jasamedika.medifirst2000.core.web.WebConstants.AUTH_HEADER_NAME;
|
||||
|
||||
/**
|
||||
* TokenAuthenticationService class
|
||||
*
|
||||
* @author Roberto
|
||||
*/
|
||||
@NoArgsConstructor
|
||||
@Slf4j
|
||||
@Component
|
||||
public class TokenAuthenticationService {
|
||||
|
||||
public static TokenHandler tokenHandler;
|
||||
|
||||
public TokenAuthenticationService() {
|
||||
}
|
||||
public static TokenHandler tokenHandler;
|
||||
|
||||
public TokenAuthenticationService(String secret, UserService userService) {
|
||||
tokenHandler = new TokenHandler(secret, userService);
|
||||
}
|
||||
|
||||
public String addAuthentication(HttpServletResponse response,
|
||||
UserAuthentication authentication) {
|
||||
public String addAuthentication(UserAuthentication authentication) {
|
||||
final User user = authentication.getDetails();
|
||||
return tokenHandler.createTokenForUser(user);
|
||||
return tokenHandler.createTokenForUser(user);
|
||||
}
|
||||
|
||||
public Authentication getAuthentication(HttpServletRequest request)
|
||||
throws JsonParseException {
|
||||
|
||||
String token = request.getHeader(WebConstants.AUTH_HEADER_NAME);
|
||||
public Authentication getAuthentication(HttpServletRequest request) throws JsonParseException {
|
||||
String token = request.getHeader(AUTH_HEADER_NAME);
|
||||
if (token != null) {
|
||||
final User user = tokenHandler.parseUserFromToken(token);
|
||||
if (user != null) {
|
||||
if (user != null)
|
||||
return new UserAuthentication(user);
|
||||
}
|
||||
}
|
||||
else{
|
||||
try
|
||||
{
|
||||
if(request.getQueryString()=="")return null;
|
||||
final String[] tokens= request.getQueryString().split("&");
|
||||
} else {
|
||||
try {
|
||||
if (Objects.equals(request.getQueryString(), ""))
|
||||
return null;
|
||||
final String[] tokens = request.getQueryString().split("&");
|
||||
for (String tokenTemp : tokens) {
|
||||
if(tokenTemp.toLowerCase().indexOf(WebConstants.AUTH_HEADER_NAME.toLowerCase())>=0)
|
||||
{
|
||||
token =tokenTemp.split("=")[1];
|
||||
if (tokenTemp.toLowerCase().contains(AUTH_HEADER_NAME.toLowerCase())) {
|
||||
token = tokenTemp.split("=")[1];
|
||||
final User user = tokenHandler.parseUserFromToken(token);
|
||||
if (user != null) {
|
||||
return new UserAuthentication(user);
|
||||
}
|
||||
}
|
||||
}
|
||||
} catch (Exception e) {
|
||||
log.error(e.getMessage());
|
||||
}
|
||||
catch(Exception e)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
@ -1,61 +1,48 @@
|
||||
package com.jasamedika.medifirst2000.security.service;
|
||||
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
|
||||
import com.jasamedika.medifirst2000.dao.LoginUserDao;
|
||||
import com.jasamedika.medifirst2000.entities.LoginUser;
|
||||
import lombok.NoArgsConstructor;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.security.authentication.AccountStatusUserDetailsChecker;
|
||||
import org.springframework.security.core.GrantedAuthority;
|
||||
import org.springframework.security.core.authority.SimpleGrantedAuthority;
|
||||
import org.springframework.security.core.userdetails.User;
|
||||
import org.springframework.security.core.userdetails.UserDetails;
|
||||
import org.springframework.security.core.userdetails.UserDetailsService;
|
||||
import org.springframework.security.core.userdetails.UsernameNotFoundException;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
import com.jasamedika.medifirst2000.dao.LoginUserDao;
|
||||
import com.jasamedika.medifirst2000.entities.LoginUser;
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* UserService implements
|
||||
org.springframework.security.core.userdetails.UserDetailsService
|
||||
* org.springframework.security.core.userdetails.UserDetailsService
|
||||
*
|
||||
* @author Roberto
|
||||
*/
|
||||
@NoArgsConstructor
|
||||
@Component
|
||||
public class UserService implements
|
||||
org.springframework.security.core.userdetails.UserDetailsService {
|
||||
public class UserService implements UserDetailsService {
|
||||
|
||||
@Autowired
|
||||
private LoginUserDao loginUserDao;
|
||||
|
||||
private final AccountStatusUserDetailsChecker detailsChecker = new AccountStatusUserDetailsChecker();
|
||||
|
||||
public UserService() {
|
||||
super();
|
||||
}
|
||||
|
||||
/**
|
||||
* this method is called for rest authentication from client
|
||||
*
|
||||
* @author Roberto
|
||||
*/
|
||||
@Override
|
||||
public final User loadUserByUsername(String username)
|
||||
throws UsernameNotFoundException {
|
||||
public final User loadUserByUsername(String username) throws UsernameNotFoundException {
|
||||
List<LoginUser> loginUsers = loginUserDao.findByNamaUser(username);
|
||||
if (loginUsers.isEmpty()) {
|
||||
if (loginUsers.isEmpty())
|
||||
throw new UsernameNotFoundException("user not found");
|
||||
}
|
||||
LoginUser loginUser = loginUsers.get(0);
|
||||
//validasi tambahan lakukan di sini
|
||||
|
||||
// GrantedAuthority authority = new SimpleGrantedAuthority(loginUser
|
||||
// .getKelompokUser().getKelompokUser());
|
||||
GrantedAuthority authority = new SimpleGrantedAuthority("USER");
|
||||
UserDetails userDetails = (UserDetails) new User(
|
||||
loginUser.getNamaUser(), loginUser.getKataSandi(),
|
||||
Arrays.asList(authority));
|
||||
User userDetails = new User(loginUser.getNamaUser(), loginUser.getKataSandi(),
|
||||
Collections.singletonList(authority));
|
||||
detailsChecker.check(userDetails);
|
||||
return (User) userDetails;
|
||||
return userDetails;
|
||||
}
|
||||
}
|
||||
@ -1,5 +1,6 @@
|
||||
package com.jasamedika.medifirst2000.util.rest;
|
||||
|
||||
import lombok.NoArgsConstructor;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
import com.fasterxml.jackson.annotation.JsonInclude.Include;
|
||||
@ -7,23 +8,17 @@ import com.fasterxml.jackson.databind.DeserializationFeature;
|
||||
import com.fasterxml.jackson.databind.ObjectMapper;
|
||||
import com.fasterxml.jackson.databind.SerializationFeature;
|
||||
|
||||
@NoArgsConstructor
|
||||
@Component
|
||||
public class JacksonConfiguration {
|
||||
private ObjectMapper mapper;
|
||||
|
||||
public JacksonConfiguration() {
|
||||
}
|
||||
|
||||
public JacksonConfiguration(ObjectMapper mapper) {
|
||||
this.mapper = mapper;
|
||||
configureJackson(mapper);
|
||||
}
|
||||
|
||||
public static ObjectMapper configureJackson(ObjectMapper mapper) {
|
||||
public static void configureJackson(ObjectMapper mapper) {
|
||||
mapper.enable(SerializationFeature.INDENT_OUTPUT);
|
||||
mapper.setSerializationInclusion(Include.NON_NULL);
|
||||
mapper.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES,
|
||||
false);
|
||||
return mapper;
|
||||
mapper.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false);
|
||||
}
|
||||
}
|
||||
|
||||
@ -1,16 +1,17 @@
|
||||
package com.jasamedika.medifirst2000.util.rest;
|
||||
|
||||
import com.google.gson.Gson;
|
||||
import org.springframework.http.HttpHeaders;
|
||||
import org.springframework.http.HttpStatus;
|
||||
import org.springframework.http.ResponseEntity;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Set;
|
||||
|
||||
import org.springframework.http.HttpHeaders;
|
||||
import org.springframework.http.HttpStatus;
|
||||
import org.springframework.http.MediaType;
|
||||
import org.springframework.http.ResponseEntity;
|
||||
|
||||
import com.google.gson.Gson;
|
||||
import static org.springframework.http.HttpStatus.OK;
|
||||
import static org.springframework.http.MediaType.APPLICATION_JSON_VALUE;
|
||||
|
||||
/**
|
||||
* Rest Util Class
|
||||
@ -24,78 +25,49 @@ public class RestUtil {
|
||||
/**
|
||||
* get JSON response from Object
|
||||
*
|
||||
* @param src
|
||||
* @param <T>
|
||||
* source class
|
||||
* @return @ResponseEntity
|
||||
*/
|
||||
public static <T> ResponseEntity<T> getJsonResponse(T src) {
|
||||
|
||||
HttpHeaders headers = new HttpHeaders();
|
||||
headers.set(CONTENT_TYPE, MediaType.APPLICATION_JSON_VALUE);
|
||||
return new ResponseEntity<T>(src, headers, HttpStatus.OK);
|
||||
headers.set(CONTENT_TYPE, APPLICATION_JSON_VALUE);
|
||||
return new ResponseEntity<>(src, headers, OK);
|
||||
}
|
||||
|
||||
/**
|
||||
* get JSON response from Object with HTTP status
|
||||
*
|
||||
* @param src
|
||||
* @param status
|
||||
*
|
||||
* @param <T>
|
||||
* source class
|
||||
* @return @ResponseEntity
|
||||
*/
|
||||
@SuppressWarnings({ "unchecked", "rawtypes" })
|
||||
public static <T> ResponseEntity<T> getJsonResponse(T src, HttpStatus status) {
|
||||
|
||||
HttpHeaders headers = new HttpHeaders();
|
||||
headers.set(CONTENT_TYPE, MediaType.APPLICATION_JSON_VALUE);
|
||||
Map<String, Object> map = new HashMap<String, Object>();
|
||||
headers.set(CONTENT_TYPE, APPLICATION_JSON_VALUE);
|
||||
Map<String, Object> map = new HashMap<>();
|
||||
map.put("data", src);
|
||||
return new ResponseEntity(map, headers, status);
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @param src
|
||||
* @param status
|
||||
* @param mapHeaderMessage
|
||||
* @param <T>
|
||||
* @return
|
||||
*/
|
||||
@SuppressWarnings({ "unchecked", "rawtypes" })
|
||||
public static <T> ResponseEntity<T> getJsonResponse(T src, HttpStatus status,
|
||||
Map<String, String> mapHeaderMessage) {
|
||||
|
||||
HttpHeaders headers = new HttpHeaders();
|
||||
|
||||
if (null != mapHeaderMessage) {
|
||||
for (String key : mapHeaderMessage.keySet()) {
|
||||
if (null != mapHeaderMessage)
|
||||
for (String key : mapHeaderMessage.keySet())
|
||||
headers.add(key, mapHeaderMessage.get(key));
|
||||
}
|
||||
}
|
||||
|
||||
Map<String, Object> map = new HashMap<String, Object>();
|
||||
Map<String, Object> map = new HashMap<>();
|
||||
map.put("messages", mapHeaderMessage);
|
||||
map.put("data", src);
|
||||
headers.set(CONTENT_TYPE, MediaType.APPLICATION_JSON_VALUE);
|
||||
headers.set(CONTENT_TYPE, APPLICATION_JSON_VALUE);
|
||||
return new ResponseEntity(map, headers, status);
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @param status
|
||||
* @param mapHeaderMessage
|
||||
* @return
|
||||
*/
|
||||
@SuppressWarnings({ "unchecked", "rawtypes" })
|
||||
public static <T> ResponseEntity<T> getJsonResponse(HttpStatus status, Map<String, String> mapHeaderMessage) {
|
||||
HttpHeaders headers = new HttpHeaders();
|
||||
headers.set(CONTENT_TYPE, MediaType.APPLICATION_JSON_VALUE);
|
||||
|
||||
Map<String, Object> map = new HashMap<String, Object>();
|
||||
headers.set(CONTENT_TYPE, APPLICATION_JSON_VALUE);
|
||||
Map<String, Object> map = new HashMap<>();
|
||||
map.put("messages", mapHeaderMessage);
|
||||
|
||||
return new ResponseEntity(map, headers, status);
|
||||
}
|
||||
|
||||
@ -106,114 +78,88 @@ public class RestUtil {
|
||||
* source class
|
||||
* @return @ResponseEntity
|
||||
*/
|
||||
public static <T> ResponseEntity<T> getJsonHttptatus(HttpStatus status) {
|
||||
|
||||
return new ResponseEntity<T>(status);
|
||||
|
||||
public static <T> ResponseEntity<T> getJsonHttpStatus(HttpStatus status) {
|
||||
return new ResponseEntity<>(status);
|
||||
}
|
||||
|
||||
public static <T> ResponseEntity<T> getJsonHttptatus(HttpStatus status, Map<String, String> mapHeaderMessage) {
|
||||
|
||||
public static <T> ResponseEntity<T> getJsonHttpStatus(HttpStatus status, Map<String, String> mapHeaderMessage) {
|
||||
HttpHeaders headers = new HttpHeaders();
|
||||
|
||||
if (null != mapHeaderMessage) {
|
||||
for (String key : mapHeaderMessage.keySet()) {
|
||||
if (null != mapHeaderMessage)
|
||||
for (String key : mapHeaderMessage.keySet())
|
||||
headers.add(key, mapHeaderMessage.get(key));
|
||||
}
|
||||
}
|
||||
|
||||
headers.set(CONTENT_TYPE, MediaType.APPLICATION_JSON_VALUE);
|
||||
return new ResponseEntity<T>(headers, status);
|
||||
headers.set(CONTENT_TYPE, APPLICATION_JSON_VALUE);
|
||||
return new ResponseEntity<>(headers, status);
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* get JSON response from Set Object
|
||||
*
|
||||
* @param src
|
||||
* @param <T>
|
||||
* source class
|
||||
* @return @ResponseEntity
|
||||
*/
|
||||
public static <T> ResponseEntity<Set<T>> defaultJsonResponse(Set<T> src) {
|
||||
|
||||
HttpHeaders headers = new HttpHeaders();
|
||||
headers.set(CONTENT_TYPE, MediaType.APPLICATION_JSON_VALUE);
|
||||
return new ResponseEntity<Set<T>>(src, headers, HttpStatus.OK);
|
||||
headers.set(CONTENT_TYPE, APPLICATION_JSON_VALUE);
|
||||
return new ResponseEntity<>(src, headers, OK);
|
||||
}
|
||||
|
||||
/**
|
||||
* get JSON response from Set Object with custom header
|
||||
*
|
||||
* @param src
|
||||
* @param mapHeaderMessage
|
||||
* @param <T>
|
||||
* source class
|
||||
* @return @ResponseEntity
|
||||
*/
|
||||
public static <T> ResponseEntity<Set<T>> defaultJsonResponse(Set<T> src, Map<String, String> mapHeaderMessage) {
|
||||
|
||||
HttpHeaders headers = new HttpHeaders();
|
||||
|
||||
if (null != mapHeaderMessage) {
|
||||
for (String key : mapHeaderMessage.keySet()) {
|
||||
if (null != mapHeaderMessage)
|
||||
for (String key : mapHeaderMessage.keySet())
|
||||
headers.add(key, mapHeaderMessage.get(key));
|
||||
}
|
||||
}
|
||||
headers.set(CONTENT_TYPE, MediaType.APPLICATION_JSON_VALUE);
|
||||
return new ResponseEntity<Set<T>>(src, headers, HttpStatus.OK);
|
||||
headers.set(CONTENT_TYPE, APPLICATION_JSON_VALUE);
|
||||
return new ResponseEntity<>(src, headers, OK);
|
||||
}
|
||||
|
||||
/**
|
||||
* get JSON response from List Object with custom header
|
||||
*
|
||||
* @param src
|
||||
* @param mapHeaderMessage
|
||||
* @param <T>
|
||||
* source class
|
||||
* @return @ResponseEntity
|
||||
*/
|
||||
public static <T> ResponseEntity<List<T>> defaultJsonResponse(List<T> src, Map<String, String> mapHeaderMessage) {
|
||||
HttpHeaders headers = new HttpHeaders();
|
||||
|
||||
if (null != mapHeaderMessage) {
|
||||
for (String key : mapHeaderMessage.keySet()) {
|
||||
if (null != mapHeaderMessage)
|
||||
for (String key : mapHeaderMessage.keySet())
|
||||
headers.add(key, mapHeaderMessage.get(key));
|
||||
}
|
||||
}
|
||||
|
||||
headers.set(CONTENT_TYPE, MediaType.APPLICATION_JSON_VALUE);
|
||||
return new ResponseEntity<List<T>>(src, headers, HttpStatus.OK);
|
||||
headers.set(CONTENT_TYPE, APPLICATION_JSON_VALUE);
|
||||
return new ResponseEntity<>(src, headers, OK);
|
||||
}
|
||||
|
||||
/**
|
||||
* get JSON response from List Object
|
||||
*
|
||||
* @param src
|
||||
* @param <T>
|
||||
* source class
|
||||
* @return @ResponseEntity
|
||||
*/
|
||||
public static <T> ResponseEntity<List<T>> defaultJsonResponse(List<T> src) {
|
||||
|
||||
HttpHeaders headers = new HttpHeaders();
|
||||
headers.set(CONTENT_TYPE, MediaType.APPLICATION_JSON_VALUE);
|
||||
return new ResponseEntity<List<T>>(src, headers, HttpStatus.OK);
|
||||
headers.set(CONTENT_TYPE, APPLICATION_JSON_VALUE);
|
||||
return new ResponseEntity<>(src, headers, OK);
|
||||
}
|
||||
|
||||
/**
|
||||
* get default JSON response from Object
|
||||
*
|
||||
* @param src
|
||||
* @return @ResponseEntity
|
||||
*/
|
||||
public static ResponseEntity<String> defaultJsonResponse(Object src) {
|
||||
|
||||
Gson gson = new Gson();
|
||||
|
||||
HttpHeaders headers = new HttpHeaders();
|
||||
headers.set(CONTENT_TYPE, MediaType.APPLICATION_JSON_VALUE);
|
||||
return new ResponseEntity<String>(gson.toJson(src), headers, HttpStatus.OK);
|
||||
headers.set(CONTENT_TYPE, APPLICATION_JSON_VALUE);
|
||||
return new ResponseEntity<>(gson.toJson(src), headers, OK);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -223,8 +169,6 @@ public class RestUtil {
|
||||
* string source JSON
|
||||
* @param type
|
||||
* class type result
|
||||
* @param <T>
|
||||
* @return
|
||||
*/
|
||||
public static <T> T jsonToObject(String strJson, Class<T> type) {
|
||||
Gson gson = new Gson();
|
||||
@ -234,12 +178,9 @@ public class RestUtil {
|
||||
/**
|
||||
* convert object to json
|
||||
*
|
||||
* @param object
|
||||
* @return
|
||||
*/
|
||||
public static String toJson(Object object) {
|
||||
Gson gson = new Gson();
|
||||
return gson.toJson(object);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@ -1,11 +1,13 @@
|
||||
package com.monitorjbl.json;
|
||||
|
||||
public class JsonResult {
|
||||
private static final JsonResult instance = new JsonResult();
|
||||
private static final ThreadLocal<JsonView> current = new ThreadLocal<>();
|
||||
import lombok.NoArgsConstructor;
|
||||
|
||||
private JsonResult() {
|
||||
}
|
||||
@NoArgsConstructor
|
||||
public class JsonResult {
|
||||
|
||||
private static final JsonResult instance = new JsonResult();
|
||||
|
||||
private static final ThreadLocal<JsonView<?>> current = new ThreadLocal<>();
|
||||
|
||||
/**
|
||||
* Use the provided {@code JsonView} object to serialize the return value.
|
||||
@ -16,7 +18,6 @@ public class JsonResult {
|
||||
* Type of object being rendered
|
||||
* @return ResultWrapper to provide return value
|
||||
*/
|
||||
@SuppressWarnings("unchecked")
|
||||
public <E> ResultWrapper<E> use(JsonView<E> view) {
|
||||
current.set(view);
|
||||
return new ResultWrapper<>(view);
|
||||
@ -26,7 +27,7 @@ public class JsonResult {
|
||||
return instance;
|
||||
}
|
||||
|
||||
static JsonView get() {
|
||||
static JsonView<?> get() {
|
||||
return current.get();
|
||||
}
|
||||
|
||||
@ -35,7 +36,7 @@ public class JsonResult {
|
||||
}
|
||||
|
||||
public static class ResultWrapper<T> {
|
||||
private JsonView<T> obj;
|
||||
private final JsonView<T> obj;
|
||||
|
||||
private ResultWrapper(JsonView<T> obj) {
|
||||
this.obj = obj;
|
||||
|
||||
@ -1,18 +1,14 @@
|
||||
package com.monitorjbl.json;
|
||||
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
public class JsonResultRetriever {
|
||||
private static final Logger log = LoggerFactory.getLogger(JsonResultRetriever.class);
|
||||
|
||||
static boolean hasValue() {
|
||||
return JsonResult.get() != null;
|
||||
}
|
||||
static boolean hasValue() {
|
||||
return JsonResult.get() != null;
|
||||
}
|
||||
|
||||
static JsonView retrieve() {
|
||||
JsonView val = JsonResult.get();
|
||||
JsonResult.unset();
|
||||
return val;
|
||||
}
|
||||
static JsonView<?> retrieve() {
|
||||
JsonView<?> val = JsonResult.get();
|
||||
JsonResult.unset();
|
||||
return val;
|
||||
}
|
||||
}
|
||||
|
||||
@ -11,23 +11,18 @@ import java.util.List;
|
||||
|
||||
public class JsonViewHttpEntityMethodProcessor extends HttpEntityMethodProcessor {
|
||||
|
||||
public JsonViewHttpEntityMethodProcessor(List<HttpMessageConverter<?>> converters) {
|
||||
super(converters);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void handleReturnValue(Object returnValue, MethodParameter returnType,
|
||||
|
||||
ModelAndViewContainer mavContainer, NativeWebRequest webRequest) throws Exception {
|
||||
if(returnValue instanceof ResponseEntity && JsonResultRetriever.hasValue()) {
|
||||
JsonView json = JsonResultRetriever.retrieve();
|
||||
ResponseEntity re = (ResponseEntity) returnValue;
|
||||
returnValue = ResponseEntity.status(re.getStatusCode())
|
||||
.headers(re.getHeaders())
|
||||
.body(json);
|
||||
}
|
||||
|
||||
super.handleReturnValue(returnValue, returnType, mavContainer, webRequest);
|
||||
}
|
||||
public JsonViewHttpEntityMethodProcessor(List<HttpMessageConverter<?>> converters) {
|
||||
super(converters);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void handleReturnValue(Object returnValue, MethodParameter returnType, ModelAndViewContainer mavContainer,
|
||||
NativeWebRequest webRequest) throws Exception {
|
||||
if (returnValue instanceof ResponseEntity && JsonResultRetriever.hasValue()) {
|
||||
JsonView<?> json = JsonResultRetriever.retrieve();
|
||||
ResponseEntity<?> re = (ResponseEntity<?>) returnValue;
|
||||
returnValue = ResponseEntity.status(re.getStatusCode()).headers(re.getHeaders()).body(json);
|
||||
}
|
||||
super.handleReturnValue(returnValue, returnType, mavContainer, webRequest);
|
||||
}
|
||||
}
|
||||
|
||||
@ -11,30 +11,32 @@ import org.springframework.web.method.support.ModelAndViewContainer;
|
||||
import java.util.List;
|
||||
|
||||
public class JsonViewReturnValueHandler implements HandlerMethodReturnValueHandler {
|
||||
private static final Logger log = LoggerFactory.getLogger(JsonViewReturnValueHandler.class);
|
||||
|
||||
private final HandlerMethodReturnValueHandler delegate;
|
||||
private static final Logger log = LoggerFactory.getLogger(JsonViewReturnValueHandler.class);
|
||||
|
||||
public JsonViewReturnValueHandler(List<HttpMessageConverter<?>> converters) {
|
||||
this.delegate = new JsonViewResponseProcessor(converters);
|
||||
}
|
||||
private final HandlerMethodReturnValueHandler delegate;
|
||||
|
||||
@Override
|
||||
public boolean supportsReturnType(MethodParameter returnType) {
|
||||
return delegate.supportsReturnType(returnType);
|
||||
}
|
||||
public JsonViewReturnValueHandler(List<HttpMessageConverter<?>> converters) {
|
||||
this.delegate = new JsonViewResponseProcessor(converters);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void handleReturnValue(Object returnValue, MethodParameter returnType, ModelAndViewContainer mavContainer, NativeWebRequest webRequest) throws Exception {
|
||||
Object val = returnValue;
|
||||
if(JsonResultRetriever.hasValue()) {
|
||||
val = JsonResultRetriever.retrieve();
|
||||
log.debug("Found [" + ((JsonView) val).getValue().getClass() + "] to serialize");
|
||||
} else {
|
||||
log.debug("No JsonView found for thread, using returned value");
|
||||
}
|
||||
@Override
|
||||
public boolean supportsReturnType(MethodParameter returnType) {
|
||||
return delegate.supportsReturnType(returnType);
|
||||
}
|
||||
|
||||
delegate.handleReturnValue(val, returnType, mavContainer, webRequest);
|
||||
}
|
||||
@Override
|
||||
public void handleReturnValue(Object returnValue, MethodParameter returnType, ModelAndViewContainer mavContainer,
|
||||
NativeWebRequest webRequest) throws Exception {
|
||||
Object val = returnValue;
|
||||
|
||||
if (JsonResultRetriever.hasValue()) {
|
||||
val = JsonResultRetriever.retrieve();
|
||||
log.debug("Found [{}] to serialize", ((JsonView<?>) val).getValue().getClass());
|
||||
} else {
|
||||
log.debug("No JsonView found for thread, using returned value");
|
||||
}
|
||||
|
||||
delegate.handleReturnValue(val, returnType, mavContainer, webRequest);
|
||||
}
|
||||
}
|
||||
@ -15,38 +15,38 @@ import java.util.List;
|
||||
|
||||
public class JsonViewSupportFactoryBean implements InitializingBean {
|
||||
|
||||
@Autowired
|
||||
private RequestMappingHandlerAdapter adapter;
|
||||
private final JsonViewMessageConverter converter;
|
||||
private final JsonViewMessageConverter converter;
|
||||
|
||||
public JsonViewSupportFactoryBean() {
|
||||
this(new ObjectMapper());
|
||||
}
|
||||
@Autowired
|
||||
private RequestMappingHandlerAdapter adapter;
|
||||
|
||||
public JsonViewSupportFactoryBean(ObjectMapper mapper) {
|
||||
this.converter = new JsonViewMessageConverter(mapper.copy());
|
||||
}
|
||||
public JsonViewSupportFactoryBean() {
|
||||
this(new ObjectMapper());
|
||||
}
|
||||
|
||||
@Override
|
||||
public void afterPropertiesSet() throws Exception {
|
||||
List<HandlerMethodReturnValueHandler> handlers = new ArrayList<>(adapter.getReturnValueHandlers());
|
||||
adapter.setMessageConverters(Collections.<HttpMessageConverter<?>>singletonList(converter));
|
||||
decorateHandlers(handlers);
|
||||
adapter.setReturnValueHandlers(handlers);
|
||||
}
|
||||
public JsonViewSupportFactoryBean(ObjectMapper mapper) {
|
||||
this.converter = new JsonViewMessageConverter(mapper.copy());
|
||||
}
|
||||
|
||||
private void decorateHandlers(List<HandlerMethodReturnValueHandler> handlers) {
|
||||
List<HttpMessageConverter<?>> converters = new ArrayList<>(adapter.getMessageConverters());
|
||||
converters.add(converter);
|
||||
for(HandlerMethodReturnValueHandler handler : handlers) {
|
||||
int index = handlers.indexOf(handler);
|
||||
if(handler instanceof HttpEntityMethodProcessor) {
|
||||
handlers.set(index, new JsonViewHttpEntityMethodProcessor(converters));
|
||||
} else if(handler instanceof RequestResponseBodyMethodProcessor) {
|
||||
handlers.set(index, new JsonViewReturnValueHandler(converters));
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
@Override
|
||||
public void afterPropertiesSet() {
|
||||
List<HandlerMethodReturnValueHandler> handlers = new ArrayList<>(adapter.getReturnValueHandlers());
|
||||
adapter.setMessageConverters(Collections.singletonList(converter));
|
||||
decorateHandlers(handlers);
|
||||
adapter.setReturnValueHandlers(handlers);
|
||||
}
|
||||
|
||||
private void decorateHandlers(List<HandlerMethodReturnValueHandler> handlers) {
|
||||
List<HttpMessageConverter<?>> converters = new ArrayList<>(adapter.getMessageConverters());
|
||||
converters.add(converter);
|
||||
for (HandlerMethodReturnValueHandler handler : handlers) {
|
||||
int index = handlers.indexOf(handler);
|
||||
if (handler instanceof HttpEntityMethodProcessor) {
|
||||
handlers.set(index, new JsonViewHttpEntityMethodProcessor(converters));
|
||||
} else if (handler instanceof RequestResponseBodyMethodProcessor) {
|
||||
handlers.set(index, new JsonViewReturnValueHandler(converters));
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -6,5 +6,5 @@
|
||||
http://www.springframework.org/schema/security
|
||||
http://www.springframework.org/schema/security/spring-security.xsd">
|
||||
|
||||
<!-- implmentasi nya by anotasi di com.jasamedika.medifirst2000.security.SpringSecurityCOnfig -->
|
||||
<!-- implmentasi nya by anotasi di com.jasamedika.medifirst2000.security.SpringSecurityConfig -->
|
||||
</beans:beans>
|
||||
@ -7,24 +7,25 @@
|
||||
http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context.xsd
|
||||
http://www.springframework.org/schema/mvc http://www.springframework.org/schema/mvc/spring-mvc.xsd
|
||||
http://www.springframework.org/schema/aop http://www.springframework.org/schema/aop/spring-aop.xsd">
|
||||
|
||||
<context:component-scan base-package="com.jasamedika.medifirst2000.controller" />
|
||||
|
||||
|
||||
<!-- Configures interceptor to all controller with annotation @AppPermission -->
|
||||
<mvc:interceptors>
|
||||
<bean class="com.jasamedika.medifirst2000.interceptor.AppInterceptor" />
|
||||
</mvc:interceptors>
|
||||
|
||||
<!-- Configures the @Controller programming model -->
|
||||
<mvc:annotation-driven>
|
||||
<mvc:argument-resolvers>
|
||||
<bean class="org.springframework.data.web.PageableArgumentResolver" />
|
||||
<bean class="net.kaczmarzyk.spring.data.jpa.web.SpecificationArgumentResolver"/>
|
||||
<ref bean="customArgumentResolver" />
|
||||
<bean
|
||||
class="net.kaczmarzyk.spring.data.jpa.web.SpecificationArgumentResolver" />
|
||||
<ref bean="customArgumentResolver" />
|
||||
</mvc:argument-resolvers>
|
||||
</mvc:annotation-driven>
|
||||
|
||||
<bean id="customArgumentResolver" class="net.kaczmarzyk.spring.data.jpa.web.SpecificationArgumentResolver"/>
|
||||
<bean id="customArgumentResolver"
|
||||
class="net.kaczmarzyk.spring.data.jpa.web.SpecificationArgumentResolver" />
|
||||
|
||||
<mvc:default-servlet-handler />
|
||||
|
||||
@ -38,23 +39,21 @@
|
||||
class="com.jasamedika.medifirst2000.util.rest.JacksonConfiguration">
|
||||
<constructor-arg ref="mapper" />
|
||||
</bean>
|
||||
<!-- <bean id="jsonViewSupport" class="com.monitorjbl.json.JsonViewSupportFactoryBean">
|
||||
<constructor-arg ref="mapper" />
|
||||
</bean> -->
|
||||
|
||||
<bean id="mapper" class="com.fasterxml.jackson.databind.ObjectMapper" />
|
||||
|
||||
<bean id="jsonMessageConverter"
|
||||
class="org.springframework.http.converter.json.MappingJackson2HttpMessageConverter" />
|
||||
|
||||
<bean id="xmlMessageConverter"
|
||||
|
||||
<bean id="jsonMessageConverter"
|
||||
class="org.springframework.http.converter.json.MappingJackson2HttpMessageConverter" />
|
||||
|
||||
<bean id="xmlMessageConverter"
|
||||
class="org.springframework.http.converter.xml.Jaxb2RootElementHttpMessageConverter" />
|
||||
|
||||
<bean class="org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerAdapter">
|
||||
|
||||
<bean
|
||||
class="org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerAdapter">
|
||||
<property name="messageConverters">
|
||||
<list>
|
||||
<ref bean="jsonMessageConverter"/>
|
||||
<ref bean="xmlMessageConverter"/>
|
||||
<ref bean="jsonMessageConverter" />
|
||||
<ref bean="xmlMessageConverter" />
|
||||
</list>
|
||||
</property>
|
||||
</bean>
|
||||
@ -64,12 +63,12 @@
|
||||
class="com.mangofactory.swagger.configuration.DocumentationConfig" />
|
||||
|
||||
<context:property-placeholder location="classpath:swagger.properties" />
|
||||
|
||||
<bean id="jasperViewResolver" class="org.springframework.web.servlet.view.ResourceBundleViewResolver">
|
||||
<property name="basename" value="views"/>
|
||||
<property name="order" value="0"/>
|
||||
</bean>
|
||||
|
||||
|
||||
<aop:aspectj-autoproxy />
|
||||
<bean id="jasperViewResolver"
|
||||
class="org.springframework.web.servlet.view.ResourceBundleViewResolver">
|
||||
<property name="basename" value="views" />
|
||||
<property name="order" value="0" />
|
||||
</bean>
|
||||
|
||||
<aop:aspectj-autoproxy />
|
||||
</beans>
|
||||
Loading…
x
Reference in New Issue
Block a user