Commit a2c027ec authored by Vu Duy Anh's avatar Vu Duy Anh

anhvd commit merge

parent d99b493b
...@@ -393,17 +393,15 @@ public class ScenarioServiceImpl implements ScenarioService { ...@@ -393,17 +393,15 @@ public class ScenarioServiceImpl implements ScenarioService {
//insert data //insert data
if (isValid) { if (isValid) {
logger.info("----- Data valid, start import scenario question -----");
List<ScenarioQuestionDTO> lstQuestion = buildQuestionsLst(rawDataList, scenarioId, campaignId, companySiteId); List<ScenarioQuestionDTO> lstQuestion = buildQuestionsLst(rawDataList, scenarioId, campaignId, companySiteId);
lstQuestion.forEach(question -> { lstQuestion.forEach(question -> {
// questionService.add(question); questionService.add(question);
}); });
FileOutputStream fos = new FileOutputStream(file); FileOutputStream fos = new FileOutputStream(file);
workbook.write(fos); workbook.write(fos);
result.put("file", file); result.put("file", file);
result.put("message", BundleUtils.getLangString("customer.importSuccess", locale)); result.put("message", BundleUtils.getLangString("customer.importSuccess", locale));
} else { } else {
logger.info("----- Data invalid, can't import scenario question -----");
FileOutputStream fos = new FileOutputStream(file); FileOutputStream fos = new FileOutputStream(file);
workbook.write(fos); workbook.write(fos);
result.put("file", file); result.put("file", file);
......
...@@ -121,20 +121,18 @@ public class ScenarioController { ...@@ -121,20 +121,18 @@ public class ScenarioController {
Map<String, Object> map = scenarioService.readAndValidateCustomer(path, scenarioId, campaignId, userSession.getCompanySiteId()); Map<String, Object> map = scenarioService.readAndValidateCustomer(path, scenarioId, campaignId, userSession.getCompanySiteId());
File fileExport = (File) map.get("file"); File fileExport = (File) map.get("file");
String message = (String) map.get("message"); String message = (String) map.get("message");
ResultDTO resultDTO = new ResultDTO(); ResultDTO resultDTO= new ResultDTO();
resultDTO.setErrorCode(Constants.ApiErrorCode.SUCCESS); resultDTO.setErrorCode("00");
resultDTO.setDescription(message); resultDTO.setDescription(message);
return new ResponseEntity<>(resultDTO, HttpStatus.OK); resultDTO.setData(fileExport);
// return ResponseEntity.ok() HttpHeaders headers = new HttpHeaders();
// .header("Content-Type", Constants.MIME_TYPE.EXCEL_XLSX) headers.add("Content-Type", Constants.MIME_TYPE.EXCEL_XLSX);
// .header(HttpHeaders.CONTENT_DISPOSITION, "attachment; filename=import_scenario_result.xlsx") headers.add("Message", message);
// .header("Message", message) return ResponseEntity.ok()
// .body(Files.readAllBytes(fileExport.toPath())); .headers(headers)
.body(Files.readAllBytes(fileExport.toPath()));
} catch (Exception e) { } catch (Exception e) {
logger.error(e.getMessage()); logger.error(e.getMessage());
ResultDTO resultDTO = new ResultDTO();
resultDTO.setErrorCode(Constants.ApiErrorCode.ERROR);
resultDTO.setDescription(Constants.ApiErrorDesc.ERROR);
return new ResponseEntity<>(HttpStatus.BAD_REQUEST); return new ResponseEntity<>(HttpStatus.BAD_REQUEST);
} }
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment