Create service setting data fix
Pembuatan endpoint setting data fix list of string
This commit is contained in:
parent
030d6a2035
commit
aade9d1666
@ -0,0 +1,14 @@
|
||||
package com.jasamedika.medifirst2000.service;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* @author salmanoe
|
||||
* @version 1.0.0
|
||||
* @since 03/01/2025
|
||||
*/
|
||||
public interface SettingDataFixedService {
|
||||
|
||||
List<String> getSetting(String prefix);
|
||||
|
||||
}
|
||||
@ -0,0 +1,21 @@
|
||||
package com.jasamedika.medifirst2000.service.impl;
|
||||
|
||||
import com.jasamedika.medifirst2000.service.SettingDataFixedService;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* @author salmanoe
|
||||
* @version 1.0.0
|
||||
* @since 03/01/2025
|
||||
*/
|
||||
@Service("settingDataFixedService")
|
||||
public class SettingDataFixedServiceImpl extends BaseVoServiceImpl implements SettingDataFixedService {
|
||||
|
||||
@Override
|
||||
public List<String> getSetting(String prefix) {
|
||||
return stringSplitDataSettingDatafixed(prefix);
|
||||
}
|
||||
|
||||
}
|
||||
@ -0,0 +1,54 @@
|
||||
package com.jasamedika.medifirst2000.controller;
|
||||
|
||||
import com.jasamedika.medifirst2000.constants.MessageResource;
|
||||
import com.jasamedika.medifirst2000.controller.base.LocaleController;
|
||||
import com.jasamedika.medifirst2000.exception.ServiceVOException;
|
||||
import com.jasamedika.medifirst2000.service.SettingDataFixedService;
|
||||
import com.jasamedika.medifirst2000.vo.SettingDataFixedVO;
|
||||
import org.slf4j.Logger;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.http.ResponseEntity;
|
||||
import org.springframework.orm.jpa.JpaSystemException;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
import java.util.List;
|
||||
|
||||
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.getJsonResponse;
|
||||
import static org.slf4j.LoggerFactory.getLogger;
|
||||
import static org.springframework.http.HttpStatus.INTERNAL_SERVER_ERROR;
|
||||
import static org.springframework.http.HttpStatus.OK;
|
||||
import static org.springframework.web.bind.annotation.RequestMethod.GET;
|
||||
|
||||
/**
|
||||
* @author salmanoe
|
||||
* @version 1.0.0
|
||||
* @since 03/01/2025
|
||||
*/
|
||||
@RestController
|
||||
@RequestMapping("/setting-data-fixed")
|
||||
public class SettingDataFixedController extends LocaleController<SettingDataFixedVO> {
|
||||
|
||||
private static final Logger LOGGER = getLogger(SettingDataFixedController.class);
|
||||
|
||||
@Autowired
|
||||
private SettingDataFixedService settingDataFixedService;
|
||||
|
||||
@RequestMapping(value = "/ip-addr", method = GET)
|
||||
public ResponseEntity<List<String>> get(HttpServletRequest request) {
|
||||
try {
|
||||
List<String> result = settingDataFixedService.getSetting("ip_addr");
|
||||
mapHeaderMessage.put(LABEL_SUCCESS, getMessage(MessageResource.LABEL_SUCCESS, request));
|
||||
return getJsonResponse(result, OK, mapHeaderMessage);
|
||||
} catch (ServiceVOException | JpaSystemException e) {
|
||||
LOGGER.error("Got exception {} when settingDataFixedService.getSetting", e.getMessage());
|
||||
addHeaderMessage(ERROR_MESSAGE, e.getMessage());
|
||||
return getJsonHttptatus(INTERNAL_SERVER_ERROR, mapHeaderMessage);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
Loading…
x
Reference in New Issue
Block a user