From 9d131465500ca1a135f63c3e338726075fcd957d Mon Sep 17 00:00:00 2001
From: wangpengfei <274878379@qq.com>
Date: 星期五, 25 八月 2023 17:55:10 +0800
Subject: [PATCH] fix

---
 router/test/contract.go |    1 
 docs/swagger.yaml       |   18 ---------
 api/v1/test/contract.go |   30 ++++++++++++--
 docs/docs.go            |   28 --------------
 docs/swagger.json       |   28 --------------
 5 files changed, 26 insertions(+), 79 deletions(-)

diff --git a/api/v1/test/contract.go b/api/v1/test/contract.go
index 886bab3..b47a1eb 100644
--- a/api/v1/test/contract.go
+++ b/api/v1/test/contract.go
@@ -9,6 +9,7 @@
 	"github.com/flipped-aurora/gin-vue-admin/server/service"
 	"github.com/gin-gonic/gin"
 	"go.uber.org/zap"
+	"strconv"
 )
 
 type ContractApi struct {
@@ -184,22 +185,41 @@
 // @Security ApiKeyAuth
 // @accept application/json
 // @Produce application/json
-// @Param data query testReq.ContractSearch true "棰勮Contract"
+// @Param data query test.Contract true "鐢╥d鏌ヨContract"
 // @Success 200 {string} string "{"success":true,"data":{},"msg":"棰勮鎴愬姛"}"
 // @Router /con/previewContract [get]
 func (conApi *ContractApi) PreviewContract(c *gin.Context) {
-	var pageInfo testReq.ContractSearch
-	err := c.ShouldBindQuery(&pageInfo)
+	var con test.Contract
+	err := c.ShouldBindQuery(&con)
 	if err != nil {
 		response.FailWithMessage(err.Error(), c)
 		return
 	}
-	contract, err := conService.GetContract(pageInfo.ID)
+
+	id := c.Query("id")
+	if id == "" {
+		response.FailWithMessage("id涓嶈兘涓虹┖", c)
+		return
+	}
+
+	val64, err := strconv.ParseUint(id, 10, 64)
+	if err != nil {
+		response.FailWithMessage("id鏍煎紡閿欒", c)
+		return
+	}
+
+	// Convert uint64 to uint
+	conId := uint(val64)
+
+	contract, err := conService.GetContract(conId)
 	if err != nil {
 		global.GVA_LOG.Error("鑾峰彇澶辫触!", zap.Error(err))
 		response.FailWithMessage("鑾峰彇澶辫触", c)
 		return
 	} else {
-		c.Data(200, "application/pdf", contract.FileContent)
+		//c.Writer.Header().Set("Content-Type", "application/octect-stream")
+		//c.Writer.Header().Set("Content-Disposition", "attachment;filename="+contract.FileName)
+		//c.Writer.Write(contract.FileContent)
+		c.Data(200, "application/octect-stream", contract.FileContent)
 	}
 }
diff --git a/docs/docs.go b/docs/docs.go
index 58e36d4..a0deda1 100644
--- a/docs/docs.go
+++ b/docs/docs.go
@@ -2054,11 +2054,6 @@
                 "summary": "棰勮Contract",
                 "parameters": [
                     {
-                        "type": "string",
-                        "name": "endCreatedAt",
-                        "in": "query"
-                    },
-                    {
                         "type": "array",
                         "items": {
                             "type": "integer"
@@ -2076,29 +2071,6 @@
                         "type": "integer",
                         "description": "涓婚敭ID",
                         "name": "id",
-                        "in": "query"
-                    },
-                    {
-                        "type": "string",
-                        "description": "鍏抽敭瀛�",
-                        "name": "keyword",
-                        "in": "query"
-                    },
-                    {
-                        "type": "integer",
-                        "description": "椤电爜",
-                        "name": "page",
-                        "in": "query"
-                    },
-                    {
-                        "type": "integer",
-                        "description": "姣忛〉澶у皬",
-                        "name": "pageSize",
-                        "in": "query"
-                    },
-                    {
-                        "type": "string",
-                        "name": "startCreatedAt",
                         "in": "query"
                     },
                     {
diff --git a/docs/swagger.json b/docs/swagger.json
index cd202da..a21e155 100644
--- a/docs/swagger.json
+++ b/docs/swagger.json
@@ -2045,11 +2045,6 @@
                 "summary": "棰勮Contract",
                 "parameters": [
                     {
-                        "type": "string",
-                        "name": "endCreatedAt",
-                        "in": "query"
-                    },
-                    {
                         "type": "array",
                         "items": {
                             "type": "integer"
@@ -2067,29 +2062,6 @@
                         "type": "integer",
                         "description": "涓婚敭ID",
                         "name": "id",
-                        "in": "query"
-                    },
-                    {
-                        "type": "string",
-                        "description": "鍏抽敭瀛�",
-                        "name": "keyword",
-                        "in": "query"
-                    },
-                    {
-                        "type": "integer",
-                        "description": "椤电爜",
-                        "name": "page",
-                        "in": "query"
-                    },
-                    {
-                        "type": "integer",
-                        "description": "姣忛〉澶у皬",
-                        "name": "pageSize",
-                        "in": "query"
-                    },
-                    {
-                        "type": "string",
-                        "name": "startCreatedAt",
                         "in": "query"
                     },
                     {
diff --git a/docs/swagger.yaml b/docs/swagger.yaml
index 83d355e..12b41c7 100644
--- a/docs/swagger.yaml
+++ b/docs/swagger.yaml
@@ -2717,9 +2717,6 @@
       consumes:
       - application/json
       parameters:
-      - in: query
-        name: endCreatedAt
-        type: string
       - collectionFormat: csv
         in: query
         items:
@@ -2733,21 +2730,6 @@
         in: query
         name: id
         type: integer
-      - description: 鍏抽敭瀛�
-        in: query
-        name: keyword
-        type: string
-      - description: 椤电爜
-        in: query
-        name: page
-        type: integer
-      - description: 姣忛〉澶у皬
-        in: query
-        name: pageSize
-        type: integer
-      - in: query
-        name: startCreatedAt
-        type: string
       - in: query
         name: supplierID
         type: integer
diff --git a/router/test/contract.go b/router/test/contract.go
index 3a7845c..99ddabe 100644
--- a/router/test/contract.go
+++ b/router/test/contract.go
@@ -22,5 +22,6 @@
 	{
 		conRouterWithoutRecord.GET("findContract", conApi.FindContract)       // 鏍规嵁ID鑾峰彇Contract
 		conRouterWithoutRecord.GET("getContractList", conApi.GetContractList) // 鑾峰彇Contract鍒楄〃
+		conRouterWithoutRecord.GET("previewContract", conApi.PreviewContract) // 棰勮Contract
 	}
 }

--
Gitblit v1.8.0