hainguyen201 / misa.vue.employee

0 stars 0 forks source link

form data resolve #4

Open hainguyen201 opened 2 years ago

hainguyen201 commented 2 years ago

@PostMapping(value="/employee", headers="Content-Type=multipart/form-data") public ResponseEntity addEmployee(@RequestParam("employee") String employee, @RequestParam(value = "file", required = false) MultipartFile file){ return new ResponseEntity<>(HttpStatus.OK); // return new ResponseEntity<>(employeeRepository.save(employee), HttpStatus.OK); }

hainguyen201 commented 2 years ago

@PostMapping(value="/employee" ) public ResponseEntity addEmployee(@RequestParam(value = "employee") String employee, @RequestParam(value = "file") MultipartFile file){ ObjectMapper objectMapper = new ObjectMapper(); try { Employee employee1= objectMapper.readValue(employee, Employee.class); return new ResponseEntity<>(HttpStatus.OK); } catch (JsonProcessingException e) { e.printStackTrace(); return new ResponseEntity<>(HttpStatus.FORBIDDEN); }

    //        return new ResponseEntity<>(employeeRepository.save(employee), HttpStatus.OK);
}