| | |
| | | // @Produce application/json |
| | | // @Param data query test.Contract true "用id查询Contract" |
| | | // @Success 200 {string} string "{"success":true,"data":{},"msg":"预览成功"}" |
| | | // @Router /con/previewContract [get] |
| | | // @Router /previewContract [get] |
| | | func (conApi *ContractApi) PreviewContract(c *gin.Context) { |
| | | var con test.Contract |
| | | err := c.ShouldBindQuery(&con) |
| | |
| | | //reader := bytes.NewReader(contract.FileContent) |
| | | //c.DataFromReader(http.StatusOK, int64(len(contract.FileContent)), "application/pdf", reader, map[string]string{"Content-Disposition": fmt.Sprintf("attachment; filename=%s", contract.FileName)}) |
| | | reader := bytes.NewReader(contract.FileContent) |
| | | c.Writer.Header().Set("Content-Type", "application/pdf") |
| | | c.Header("Content-Type", contract.FileType) |
| | | c.Writer.Header().Set("Content-Disposition", "inline; filename="+contract.FileName) |
| | | http.ServeContent(c.Writer, c.Request, contract.FileName, time.Now(), reader) |
| | | } |
| | |
| | | // @Produce application/json |
| | | // @Param data query test.Contract true "用id查询Contract" |
| | | // @Success 200 {string} string "{"success":true,"data":{},"msg":"下载成功"}" |
| | | // @Router /con/downloadContract [get] |
| | | // @Router /downloadContract [get] |
| | | func (conApi *ContractApi) DownloadContract(c *gin.Context) { |
| | | var con test.Contract |
| | | err := c.ShouldBindQuery(&con) |