package com.whyc.controller;
|
|
import com.google.gson.reflect.TypeToken;
|
import com.whyc.dto.Response;
|
import com.whyc.pojo.TechnicalSpecification;
|
import com.whyc.service.TechnicalSpecificationService;
|
import com.whyc.util.ActionUtil;
|
import io.swagger.annotations.Api;
|
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.PostMapping;
|
import org.springframework.web.bind.annotation.RequestMapping;
|
import org.springframework.web.bind.annotation.RequestParam;
|
import org.springframework.web.bind.annotation.RestController;
|
import org.springframework.web.multipart.MultipartFile;
|
|
import java.io.IOException;
|
import java.text.ParseException;
|
|
@Api(tags = "技术规格书")
|
@RestController
|
@RequestMapping("technicalSpecification")
|
public class TechnicalSpecificationController {
|
|
@Autowired
|
private TechnicalSpecificationService service;
|
|
@ApiOperation("excel解析")
|
@PostMapping("excelParse")
|
public Response excelParse(@RequestParam MultipartFile multipartFile) throws IOException, InvalidFormatException, ParseException {
|
Response<Object> 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{
|
response = service.excelParse(multipartFile.getInputStream());
|
}
|
return response;
|
}
|
|
@ApiOperation("软件上传")
|
@PostMapping("upload")
|
public Response upload(@RequestParam MultipartFile file1,@RequestParam MultipartFile file2,@RequestParam String technicalSpecificationStr) throws IOException {
|
TechnicalSpecification specification = ActionUtil.getGson().fromJson(technicalSpecificationStr,new TypeToken<TechnicalSpecification>(){}.getType());
|
return service.upload(file1,file2,specification);
|
}
|
|
@ApiOperation("更新锁定状态")
|
@PostMapping("updateLock")
|
public Response updateLock(@RequestParam int id,@RequestParam int lockFlag,@RequestParam(required = false) String reason) throws IOException {
|
return service.updateLock(id,lockFlag,reason);
|
}
|
|
@ApiOperation("查询技术规格书")
|
@PostMapping("getInfo")
|
public Response getInfo(@RequestParam(required = false) String applyMaterialCode ,@RequestParam(required = false) String applyModel,@RequestParam(required = false) String applyCustomCode
|
,@RequestParam(required = false) String owner,@RequestParam(required = false) Integer lockFlag
|
,@RequestParam int pageNum,@RequestParam int pageSize) {
|
return service.getInfo(applyMaterialCode,applyModel,applyCustomCode,owner,lockFlag,pageNum,pageSize);
|
}
|
|
@ApiOperation("查询指定技术规格书的所有版本")
|
@PostMapping("getVersionByInfo")
|
public Response getVersionByInfo(@RequestParam(required = false) String applyMaterialCode ,@RequestParam(required = false) String applyModel,@RequestParam(required = false) String applyCustomCode) {
|
return service.getVersionByInfo(applyMaterialCode,applyModel,applyCustomCode);
|
}
|
}
|