Fakultas Ilmu Komputer UI

Skip to content
Snippets Groups Projects

fix Vulnerabilities Sonarqube

Merged David Johan Hasiholan Parhusip requested to merge david-2 into deploy
27 files
+ 440
117
Compare changes
  • Side-by-side
  • Inline
Files
27
package apap.tk.rumahSehat.controller.restController;
import apap.tk.rumahSehat.model.ApotekerModel;
import apap.tk.rumahSehat.service.ApotekerServiceImpl;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.HttpStatus;
import org.springframework.security.core.Authentication;
import org.springframework.validation.BindingResult;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.server.ResponseStatusException;
import javax.validation.Valid;
@Slf4j
@RestController
@RequestMapping("/api/apoteker")
public class ApotekerRestController {
@Autowired
private ApotekerServiceImpl apotekerService;
@PostMapping(value = "/add")
public ApotekerModel createApoteker(@Valid @RequestBody ApotekerModel apoteker, BindingResult bindingResult, Authentication authentication) {
if (bindingResult.hasFieldErrors()) {
log.info("Body has invalid type or missing field when creating Apoteker.");
throw new ResponseStatusException(
HttpStatus.BAD_REQUEST, "Request body has invalid type or missing field.");
} else {
log.info(authentication.getName() + " added new Apoteker.");
return apotekerService.addApoteker(apoteker);
}
}
}
Loading