|
@@ -4,15 +4,13 @@ import com.bosshand.virgo.core.response.Response;
|
|
|
import com.bosshand.virgo.exception.BadRequestException;
|
|
|
import com.bosshand.virgo.exception.Constant;
|
|
|
import com.bosshand.virgo.file.model.WorkarkContract;
|
|
|
+import com.bosshand.virgo.file.model.WorkarkContractPdf;
|
|
|
import com.bosshand.virgo.file.service.WorkarkContractService;
|
|
|
import io.swagger.annotations.Api;
|
|
|
import io.swagger.annotations.ApiOperation;
|
|
|
import io.swagger.annotations.ApiParam;
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
|
-import org.springframework.web.bind.annotation.PathVariable;
|
|
|
-import org.springframework.web.bind.annotation.RequestMapping;
|
|
|
-import org.springframework.web.bind.annotation.RequestMethod;
|
|
|
-import org.springframework.web.bind.annotation.RestController;
|
|
|
+import org.springframework.web.bind.annotation.*;
|
|
|
import org.springframework.web.multipart.MultipartFile;
|
|
|
|
|
|
import javax.servlet.http.HttpServletResponse;
|
|
@@ -131,5 +129,49 @@ public class WorkarkContractController {
|
|
|
}
|
|
|
}
|
|
|
|
|
|
+ @ApiOperation("绑定合同")
|
|
|
+ @RequestMapping(value = "/pdf", method = RequestMethod.POST)
|
|
|
+ public Response updateWorkarkContractPdf(@RequestBody WorkarkContractPdf workarkContractPdf) {
|
|
|
+ WorkarkContractPdf orderNo = workarkContractService.getOrderNo(workarkContractPdf.getOrderNo());
|
|
|
+ if (orderNo != null) {
|
|
|
+ return Response.fail(20000, orderNo.getOrderNo() + "该订单已经绑定过合同了");
|
|
|
+ }
|
|
|
+ workarkContractService.saveWorkarkContractPdf(workarkContractPdf);
|
|
|
+ return Response.ok();
|
|
|
+ }
|
|
|
+
|
|
|
+ @ApiOperation("修改合同状态")
|
|
|
+ @RequestMapping(value = "/pdf", method = RequestMethod.PUT)
|
|
|
+ public Response contractStatus(@RequestBody WorkarkContractPdf workarkContractPdf) {
|
|
|
+ workarkContractService.updateWorkarkContractPdf(workarkContractPdf);
|
|
|
+ return Response.ok();
|
|
|
+ }
|
|
|
+
|
|
|
+ @ApiOperation("展示绑定后合同PDF")
|
|
|
+ @RequestMapping(value = "/show/{pdfId}", method = RequestMethod.GET)
|
|
|
+ public void getShowPdf(@PathVariable long pdfId, final HttpServletResponse response) {
|
|
|
+ byte[] data = null;
|
|
|
+ OutputStream outputStream = null;
|
|
|
+ try {
|
|
|
+ WorkarkContractPdf workarkContractPdf = workarkContractService.getWorkarkContractPdf(pdfId);
|
|
|
+ data = workarkContractService.getWorkarkContractPdfData(pdfId);
|
|
|
+ response.setCharacterEncoding("UTF-8");
|
|
|
+ response.setContentType("application/x-msdownload");
|
|
|
+ response.setHeader("Content-Disposition", "attachment; filename=" + URLEncoder.encode(workarkContractPdf.getName(), "UTF-8"));
|
|
|
+ OutputStream outputSream = response.getOutputStream();
|
|
|
+ outputSream.write(data);
|
|
|
+ outputSream.flush();
|
|
|
+ } catch (IOException e) {
|
|
|
+ throw new BadRequestException("Fail to write stream", Constant.RET_DOCUMENT_ERROR, e);
|
|
|
+ } finally {
|
|
|
+ if (outputStream != null) {
|
|
|
+ try {
|
|
|
+ outputStream.close();
|
|
|
+ } catch (IOException e) {
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
|
|
|
}
|