| | |
| | | "github.com/flipped-aurora/gin-vue-admin/server/service" |
| | | "github.com/gin-gonic/gin" |
| | | "go.uber.org/zap" |
| | | "strconv" |
| | | ) |
| | | |
| | | type ContractApi struct { |
| | |
| | | // @Security ApiKeyAuth |
| | | // @accept application/json |
| | | // @Produce application/json |
| | | // @Param data query testReq.ContractSearch true "预览Contract" |
| | | // @Param data query test.Contract true "用id查询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) |
| | | } |
| | | } |
| | |
| | | "summary": "预览Contract", |
| | | "parameters": [ |
| | | { |
| | | "type": "string", |
| | | "name": "endCreatedAt", |
| | | "in": "query" |
| | | }, |
| | | { |
| | | "type": "array", |
| | | "items": { |
| | | "type": "integer" |
| | |
| | | "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" |
| | | }, |
| | | { |
| | |
| | | "summary": "预览Contract", |
| | | "parameters": [ |
| | | { |
| | | "type": "string", |
| | | "name": "endCreatedAt", |
| | | "in": "query" |
| | | }, |
| | | { |
| | | "type": "array", |
| | | "items": { |
| | | "type": "integer" |
| | |
| | | "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" |
| | | }, |
| | | { |
| | |
| | | consumes: |
| | | - application/json |
| | | parameters: |
| | | - in: query |
| | | name: endCreatedAt |
| | | type: string |
| | | - collectionFormat: csv |
| | | in: query |
| | | items: |
| | |
| | | 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 |
| | |
| | | { |
| | | conRouterWithoutRecord.GET("findContract", conApi.FindContract) // 根据ID获取Contract |
| | | conRouterWithoutRecord.GET("getContractList", conApi.GetContractList) // 获取Contract列表 |
| | | conRouterWithoutRecord.GET("previewContract", conApi.PreviewContract) // 预览Contract |
| | | } |
| | | } |