package com.whyc.controller; import com.whyc.dto.Response; import com.whyc.pojo.Software; import com.whyc.service.SoftwareService; import io.swagger.annotations.Api; import io.swagger.annotations.ApiModelProperty; import io.swagger.annotations.ApiOperation; import org.apache.poi.openxml4j.exceptions.InvalidFormatException; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.web.bind.annotation.*; import org.springframework.web.multipart.MultipartFile; import java.io.IOException; import java.util.List; @Api(tags = "软件管理-新版") @RestController @RequestMapping("software") public class SoftwareController { @Autowired private SoftwareService service; @ApiModelProperty("excel解析") @PostMapping("excelParse") public Response excelParse(@RequestParam MultipartFile multipartFile) throws IOException, InvalidFormatException { Response response = new Response<>(); String name=multipartFile.getOriginalFilename(); assert name != null; if(!name.substring(name.length()-4).equals(".xls") && !name.substring(name.length()-5).equals(".xlsx")){ response.set(1,false,"文件解析错误:上传格式非excel格式"); }else{ List list = service.excelParse(multipartFile.getInputStream()); response.setII(1,true,list,"文件解析成功"); } return response; } @ApiOperation(value = "查询软件列表的信息") @GetMapping("getAllSoftware") public Response getAllSoftware(@RequestParam(required = false) String fileName,@RequestParam int pageCurr,@RequestParam int pageSize ){ return service.getAllSoftware(fileName,pageCurr,pageSize); } }