package com.jasamedika.medifirst2000.controller; import com.jasamedika.medifirst2000.dto.JumlahDiskonDokterDto; import com.jasamedika.medifirst2000.exception.ServiceVOException; import com.jasamedika.medifirst2000.service.JumlahDiskonDokterService; import com.jasamedika.medifirst2000.util.rest.RestUtil; import org.apache.commons.collections4.map.SingletonMap; import org.slf4j.Logger; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.http.ResponseEntity; import org.springframework.web.bind.annotation.RequestBody; import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.bind.annotation.RestController; import javax.servlet.http.HttpServletRequest; import javax.validation.Valid; import java.util.List; import static org.slf4j.LoggerFactory.getLogger; import static org.springframework.http.HttpStatus.CREATED; import static org.springframework.http.HttpStatus.INTERNAL_SERVER_ERROR; import static org.springframework.http.MediaType.APPLICATION_JSON_VALUE; import static org.springframework.web.bind.annotation.RequestMethod.POST; /** * @author salmanoe * @version 1.0.0 * @since 07/02/2024 */ @RestController @RequestMapping("/master/dokter/jumlah-diskon") public class JumlahDiskonDokterController { private static final Logger LOGGER = getLogger(JumlahDiskonDokterController.class); @Autowired private JumlahDiskonDokterService jumlahDiskonDokterService; @RequestMapping(method = POST, produces = APPLICATION_JSON_VALUE, consumes = APPLICATION_JSON_VALUE) public ResponseEntity> save(HttpServletRequest request, @Valid @RequestBody List dtos) { try { jumlahDiskonDokterService.save(dtos); return RestUtil.getJsonResponse(dtos, CREATED, new SingletonMap<>("status", CREATED.getReasonPhrase())); } catch (ServiceVOException e) { LOGGER.error("Got exception {} when add jumlah diskon dokter", e.getMessage()); return RestUtil.getJsonHttptatus(INTERNAL_SERVER_ERROR); } } }