@ApiOperation("excel导入成品价格")
@PostMapping(value = "xxxx",consumes = "multipart/*",headers = "content-type=multipart/form-data")
public Result importData(@ModelAttribute ProductPriceImportQO priceImportQO) {
if(priceImportQO.getPre().indexOf("529")<=0){
return Result.failure(ResultCodeEnum.BAD_REQUEST, "没有导入权限");
}
try {
Map<Integer, String> map = priceService.impPriceByExcel(priceImportQO.getFile(), priceImportQO.getUser());
if(map.size()>0){
return Result.failure(ResultCodeEnum.BAD_REQUEST, map.toString());
}
return Result.success(ResultCodeEnum.OK);
} catch (Exception e) {
return Result.failure(ResultCodeEnum.OPERATION_FAILED, e.getMessage());
}
}
@ApiModel("成品价格导入")
@Data
public class ProductPriceImportQO {
@NotNull(message = "文件不能为空")
@ApiModelProperty(value = "价格模板文件",dataType = "MultipartFile")
private MultipartFile file;
@NotNull(message = "导入人不能为空")
@ApiModelProperty(value = "导入人",dataType = "98000001")
private String user;
@NotNull(message = "用户权限不能为空")
@ApiModelProperty(value = "权限列表",example = "111,222,529")
private String pre;
}
![上传1.png](https://i-blog.csdnimg.cn/blog_migrate/e821848e7b7528736e1e35804df13d61.png)
![在这里插入图片描述](https://i-blog.csdnimg.cn/blog_migrate/bb5fb69879e5a692ab484c19fa8b308c.png#pic_center)