use of com.github.lybgeek.common.model.Result in project springboot-learning by lyb-geek.
the class CustomerserviceWagesController method importExcel.
/**
* 本方法用的模板是位于excel-template下的-->复杂表头样例.xls
* @param file
* @return
* @throws Exception
*/
@PostMapping(value = "/import")
@ResponseBody
public Result<CustomerserviceWagesDTO> importExcel(MultipartFile file) throws Exception {
ExcelImportResult<CustomerserviceWagesVO> excelData = ExcelReader.builder().titleRows(1).headRowNumber(2).sheetNo(0).inputStream(file.getInputStream()).build().read(CustomerserviceWagesVO.class, true);
boolean verifyFail = excelData.isVerifyFail();
if (verifyFail) {
String errorMsg = ExcelUtils.getErrorMsg(excelData.getFailList());
throw new BizException(errorMsg);
}
List<CustomerserviceWagesDTO> customerserviceWagesDTOS = customerserviceWagesConverter.convertVOList2DTOList(excelData.getList());
customerserviceWagesService.saveCustomerserviceWages(customerserviceWagesDTOS);
Result result = new Result().builder().data(customerserviceWagesDTOS).build();
return result;
}
use of com.github.lybgeek.common.model.Result in project springboot-learning by lyb-geek.
the class BookController method upadteBook.
@PostMapping(value = "/update")
public Result<BookDTO> upadteBook(BookDTO bookDTO) {
Result<BookDTO> result = new Result<>();
if (bookDTO.getId() == null) {
result.setStatus(Result.fail);
result.setMessage("id不能为空");
return result;
}
BookDTO book = bookService.editBook(bookDTO);
result.setData(book);
return result;
}
use of com.github.lybgeek.common.model.Result in project springboot-learning by lyb-geek.
the class BookController method addBook.
@PostMapping(value = "/add")
public Result<BookDTO> addBook(@Valid BookDTO bookDTO, BindingResult bindingResult) {
Result<BookDTO> result = new Result<>();
if (bindingResult.hasErrors()) {
return ResultUtil.INSTANCE.getFailResult(bindingResult, result);
}
try {
BookDTO book = bookService.addBook(bookDTO);
result.setData(book);
} catch (Exception e) {
log.error("addBook error:" + e.getMessage(), e);
result.setStatus(Result.fail);
result.setMessage(e.getMessage());
}
return result;
}
use of com.github.lybgeek.common.model.Result in project springboot-learning by lyb-geek.
the class BookController method addBook.
@PostMapping(value = "/add")
public Result<BookDTO> addBook(@Valid BookDTO bookDTO, BindingResult bindingResult) {
Result<BookDTO> result = new Result<>();
if (bindingResult.hasErrors()) {
return ResultUtil.INSTANCE.getFailResult(bindingResult, result);
}
try {
BookDTO book = bookService.addBook(bookDTO);
result.setData(book);
} catch (Exception e) {
log.error("addBook error:" + e.getMessage(), e);
result.setStatus(Result.fail);
result.setMessage(e.getMessage());
}
return result;
}
use of com.github.lybgeek.common.model.Result in project springboot-learning by lyb-geek.
the class HttpClientProxy method getResponse.
private Object getResponse(Method method, String response) {
Result result = JSON.parseObject(response, Result.class);
String jsonResult = JSON.toJSONString(result.getData());
return this.getResult(method, jsonResult);
}
Aggregations