fix
add download functionality to contract
| | |
| | | package test |
| | | |
| | | import ( |
| | | "bytes" |
| | | "fmt" |
| | | "github.com/gin-gonic/gin" |
| | | "go.uber.org/zap" |
| | | "net/http" |
| | | "srm/global" |
| | | "srm/model/common/request" |
| | | "srm/model/common/response" |
| | |
| | | testReq "srm/model/test/request" |
| | | "srm/service" |
| | | "strconv" |
| | | "time" |
| | | ) |
| | | |
| | | type ContractApi struct { |
| | |
| | | //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) |
| | | //c.Data(200, "application/octect-stream", contract.FileContent) |
| | | //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.Writer.Header().Set("Content-Disposition", "inline; filename="+contract.FileName) |
| | | http.ServeContent(c.Writer, c.Request, contract.FileName, time.Now(), reader) |
| | | } |
| | | } |
| | | |
| | | // DownloadContract 下载Contract |
| | | // @Tags Contract |
| | | // @Summary 下载Contract |
| | | // @Security ApiKeyAuth |
| | | // @accept application/json |
| | | // @Produce application/json |
| | | // @Param data query test.Contract true "用id查询Contract" |
| | | // @Success 200 {string} string "{"success":true,"data":{},"msg":"下载成功"}" |
| | | // @Router /con/downloadContract [get] |
| | | func (conApi *ContractApi) DownloadContract(c *gin.Context) { |
| | | var con test.Contract |
| | | err := c.ShouldBindQuery(&con) |
| | | if err != nil { |
| | | response.FailWithMessage(err.Error(), c) |
| | | return |
| | | } |
| | | |
| | | 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 { |
| | | reader := bytes.NewReader(contract.FileContent) |
| | | // 设置必要的头信息 |
| | | c.Header("Content-Description", "File Transfer") |
| | | c.Header("Content-Transfer-Encoding", "binary") |
| | | c.Header("Content-Disposition", fmt.Sprintf("attachment; filename=%s", contract.FileName)) |
| | | c.Header("Content-Type", "application/pdf") |
| | | |
| | | // 将文件作为响应体发送 |
| | | http.ServeContent(c.Writer, c.Request, contract.FileName, time.Now(), reader) |
| | | c.File(contract.FileName) |
| | | } |
| | | } |
| | |
| | | } |
| | | } |
| | | }, |
| | | "/con/downloadContract": { |
| | | "get": { |
| | | "security": [ |
| | | { |
| | | "ApiKeyAuth": [] |
| | | } |
| | | ], |
| | | "consumes": [ |
| | | "application/json" |
| | | ], |
| | | "produces": [ |
| | | "application/json" |
| | | ], |
| | | "tags": [ |
| | | "Contract" |
| | | ], |
| | | "summary": "下载Contract", |
| | | "parameters": [ |
| | | { |
| | | "type": "string", |
| | | "description": "创建时间", |
| | | "name": "created_at", |
| | | "in": "query" |
| | | }, |
| | | { |
| | | "type": "array", |
| | | "items": { |
| | | "type": "integer" |
| | | }, |
| | | "collectionFormat": "csv", |
| | | "name": "fileContent", |
| | | "in": "query" |
| | | }, |
| | | { |
| | | "type": "string", |
| | | "name": "fileName", |
| | | "in": "query" |
| | | }, |
| | | { |
| | | "type": "integer", |
| | | "description": "主键ID", |
| | | "name": "id", |
| | | "in": "query" |
| | | }, |
| | | { |
| | | "type": "integer", |
| | | "name": "supplierID", |
| | | "in": "query" |
| | | } |
| | | ], |
| | | "responses": { |
| | | "200": { |
| | | "description": "{\"success\":true,\"data\":{},\"msg\":\"下载成功\"}", |
| | | "schema": { |
| | | "type": "string" |
| | | } |
| | | } |
| | | } |
| | | } |
| | | }, |
| | | "/con/findContract": { |
| | | "get": { |
| | | "security": [ |
| | |
| | | ], |
| | | "summary": "用id查询Contract", |
| | | "parameters": [ |
| | | { |
| | | "type": "string", |
| | | "description": "创建时间", |
| | | "name": "created_at", |
| | | "in": "query" |
| | | }, |
| | | { |
| | | "type": "array", |
| | | "items": { |
| | |
| | | ], |
| | | "summary": "分页获取Contract列表", |
| | | "parameters": [ |
| | | { |
| | | "type": "string", |
| | | "description": "创建时间", |
| | | "name": "created_at", |
| | | "in": "query" |
| | | }, |
| | | { |
| | | "type": "string", |
| | | "name": "endCreatedAt", |
| | |
| | | ], |
| | | "summary": "预览Contract", |
| | | "parameters": [ |
| | | { |
| | | "type": "string", |
| | | "description": "创建时间", |
| | | "name": "created_at", |
| | | "in": "query" |
| | | }, |
| | | { |
| | | "type": "array", |
| | | "items": { |
| | |
| | | ], |
| | | "summary": "获取单一客户信息", |
| | | "parameters": [ |
| | | { |
| | | "type": "string", |
| | | "description": "创建时间", |
| | | "name": "created_at", |
| | | "in": "query" |
| | | }, |
| | | { |
| | | "type": "string", |
| | | "description": "客户名", |
| | |
| | | "summary": "用id查询Industry", |
| | | "parameters": [ |
| | | { |
| | | "type": "string", |
| | | "description": "创建时间", |
| | | "name": "created_at", |
| | | "in": "query" |
| | | }, |
| | | { |
| | | "type": "integer", |
| | | "description": "主键ID", |
| | | "name": "id", |
| | |
| | | ], |
| | | "summary": "分页获取Industry列表", |
| | | "parameters": [ |
| | | { |
| | | "type": "string", |
| | | "description": "创建时间", |
| | | "name": "created_at", |
| | | "in": "query" |
| | | }, |
| | | { |
| | | "type": "string", |
| | | "name": "endCreatedAt", |
| | |
| | | "summary": "用id查询Member", |
| | | "parameters": [ |
| | | { |
| | | "type": "string", |
| | | "description": "创建时间", |
| | | "name": "created_at", |
| | | "in": "query" |
| | | }, |
| | | { |
| | | "type": "integer", |
| | | "description": "主键ID", |
| | | "name": "id", |
| | |
| | | ], |
| | | "summary": "分页获取Member列表", |
| | | "parameters": [ |
| | | { |
| | | "type": "string", |
| | | "description": "创建时间", |
| | | "name": "created_at", |
| | | "in": "query" |
| | | }, |
| | | { |
| | | "type": "string", |
| | | "name": "endCreatedAt", |
| | |
| | | ], |
| | | "summary": "分页获取Member列表", |
| | | "parameters": [ |
| | | { |
| | | "type": "string", |
| | | "description": "创建时间", |
| | | "name": "created_at", |
| | | "in": "query" |
| | | }, |
| | | { |
| | | "type": "string", |
| | | "name": "endCreatedAt", |
| | |
| | | "summary": "用id查询Product", |
| | | "parameters": [ |
| | | { |
| | | "type": "string", |
| | | "description": "创建时间", |
| | | "name": "created_at", |
| | | "in": "query" |
| | | }, |
| | | { |
| | | "type": "integer", |
| | | "name": "deliveryTime", |
| | | "in": "query" |
| | |
| | | ], |
| | | "summary": "分页获取Product列表", |
| | | "parameters": [ |
| | | { |
| | | "type": "string", |
| | | "description": "创建时间", |
| | | "name": "created_at", |
| | | "in": "query" |
| | | }, |
| | | { |
| | | "type": "integer", |
| | | "name": "deliveryTime", |
| | |
| | | ], |
| | | "summary": "分页获取Product列表", |
| | | "parameters": [ |
| | | { |
| | | "type": "string", |
| | | "description": "创建时间", |
| | | "name": "created_at", |
| | | "in": "query" |
| | | }, |
| | | { |
| | | "type": "integer", |
| | | "name": "deliveryTime", |
| | |
| | | }, |
| | | { |
| | | "type": "string", |
| | | "description": "创建时间", |
| | | "name": "created_at", |
| | | "in": "query" |
| | | }, |
| | | { |
| | | "type": "string", |
| | | "name": "detailAddress", |
| | | "in": "query" |
| | | }, |
| | |
| | | { |
| | | "type": "string", |
| | | "name": "contact", |
| | | "in": "query" |
| | | }, |
| | | { |
| | | "type": "string", |
| | | "description": "创建时间", |
| | | "name": "created_at", |
| | | "in": "query" |
| | | }, |
| | | { |
| | |
| | | "summary": "用id查询SupplierType", |
| | | "parameters": [ |
| | | { |
| | | "type": "string", |
| | | "description": "创建时间", |
| | | "name": "created_at", |
| | | "in": "query" |
| | | }, |
| | | { |
| | | "type": "integer", |
| | | "description": "主键ID", |
| | | "name": "id", |
| | |
| | | ], |
| | | "summary": "分页获取SupplierType列表", |
| | | "parameters": [ |
| | | { |
| | | "type": "string", |
| | | "description": "创建时间", |
| | | "name": "created_at", |
| | | "in": "query" |
| | | }, |
| | | { |
| | | "type": "string", |
| | | "name": "endCreatedAt", |
| | |
| | | "parameters": [ |
| | | { |
| | | "type": "string", |
| | | "description": "创建时间", |
| | | "name": "created_at", |
| | | "in": "query" |
| | | }, |
| | | { |
| | | "type": "string", |
| | | "description": "描述", |
| | | "name": "desc", |
| | | "in": "query" |
| | |
| | | ], |
| | | "summary": "分页获取SysDictionary列表", |
| | | "parameters": [ |
| | | { |
| | | "type": "string", |
| | | "description": "创建时间", |
| | | "name": "created_at", |
| | | "in": "query" |
| | | }, |
| | | { |
| | | "type": "string", |
| | | "description": "描述", |
| | |
| | | "summary": "用id查询SysDictionaryDetail", |
| | | "parameters": [ |
| | | { |
| | | "type": "string", |
| | | "description": "创建时间", |
| | | "name": "created_at", |
| | | "in": "query" |
| | | }, |
| | | { |
| | | "type": "integer", |
| | | "description": "主键ID", |
| | | "name": "id", |
| | |
| | | ], |
| | | "summary": "分页获取SysDictionaryDetail列表", |
| | | "parameters": [ |
| | | { |
| | | "type": "string", |
| | | "description": "创建时间", |
| | | "name": "created_at", |
| | | "in": "query" |
| | | }, |
| | | { |
| | | "type": "integer", |
| | | "description": "主键ID", |
| | |
| | | }, |
| | | { |
| | | "type": "string", |
| | | "description": "创建时间", |
| | | "name": "created_at", |
| | | "in": "query" |
| | | }, |
| | | { |
| | | "type": "string", |
| | | "description": "错误信息", |
| | | "name": "error_message", |
| | | "in": "query" |
| | |
| | | "type": "string", |
| | | "description": "请求Body", |
| | | "name": "body", |
| | | "in": "query" |
| | | }, |
| | | { |
| | | "type": "string", |
| | | "description": "创建时间", |
| | | "name": "created_at", |
| | | "in": "query" |
| | | }, |
| | | { |
| | |
| | | "example.ExaCustomer": { |
| | | "type": "object", |
| | | "properties": { |
| | | "created_at": { |
| | | "description": "创建时间", |
| | | "type": "string" |
| | | }, |
| | | "customerName": { |
| | | "description": "客户名", |
| | | "type": "string" |
| | |
| | | "chunkTotal": { |
| | | "type": "integer" |
| | | }, |
| | | "created_at": { |
| | | "description": "创建时间", |
| | | "type": "string" |
| | | }, |
| | | "exaFileChunk": { |
| | | "type": "array", |
| | | "items": { |
| | |
| | | "example.ExaFileChunk": { |
| | | "type": "object", |
| | | "properties": { |
| | | "created_at": { |
| | | "description": "创建时间", |
| | | "type": "string" |
| | | }, |
| | | "exaFileID": { |
| | | "type": "integer" |
| | | }, |
| | |
| | | "example.ExaFileUploadAndDownload": { |
| | | "type": "object", |
| | | "properties": { |
| | | "created_at": { |
| | | "description": "创建时间", |
| | | "type": "string" |
| | | }, |
| | | "id": { |
| | | "description": "主键ID", |
| | | "type": "integer" |
| | |
| | | "properties": { |
| | | "contact": { |
| | | "description": "联系人", |
| | | "type": "string" |
| | | }, |
| | | "created_at": { |
| | | "description": "创建时间", |
| | | "type": "string" |
| | | }, |
| | | "deliveryDate": { |
| | |
| | | "amount": { |
| | | "description": "采购数量", |
| | | "type": "number" |
| | | }, |
| | | "created_at": { |
| | | "description": "创建时间", |
| | | "type": "string" |
| | | }, |
| | | "id": { |
| | | "description": "主键ID", |
| | |
| | | "properties": { |
| | | "apiGroup": { |
| | | "description": "api组", |
| | | "type": "string" |
| | | }, |
| | | "created_at": { |
| | | "description": "创建时间", |
| | | "type": "string" |
| | | }, |
| | | "desc": { |
| | |
| | | "description": "api组", |
| | | "type": "string" |
| | | }, |
| | | "created_at": { |
| | | "description": "创建时间", |
| | | "type": "string" |
| | | }, |
| | | "description": { |
| | | "description": "api中文描述", |
| | | "type": "string" |
| | |
| | | "system.SysAutoCode": { |
| | | "type": "object", |
| | | "properties": { |
| | | "created_at": { |
| | | "description": "创建时间", |
| | | "type": "string" |
| | | }, |
| | | "desc": { |
| | | "type": "string" |
| | | }, |
| | |
| | | }, |
| | | "component": { |
| | | "description": "对应前端文件路径", |
| | | "type": "string" |
| | | }, |
| | | "created_at": { |
| | | "description": "创建时间", |
| | | "type": "string" |
| | | }, |
| | | "hidden": { |
| | |
| | | "system.SysBaseMenuBtn": { |
| | | "type": "object", |
| | | "properties": { |
| | | "created_at": { |
| | | "description": "创建时间", |
| | | "type": "string" |
| | | }, |
| | | "desc": { |
| | | "type": "string" |
| | | }, |
| | |
| | | "system.SysBaseMenuParameter": { |
| | | "type": "object", |
| | | "properties": { |
| | | "created_at": { |
| | | "description": "创建时间", |
| | | "type": "string" |
| | | }, |
| | | "id": { |
| | | "description": "主键ID", |
| | | "type": "integer" |
| | |
| | | "system.SysDictionary": { |
| | | "type": "object", |
| | | "properties": { |
| | | "created_at": { |
| | | "description": "创建时间", |
| | | "type": "string" |
| | | }, |
| | | "desc": { |
| | | "description": "描述", |
| | | "type": "string" |
| | |
| | | "system.SysDictionaryDetail": { |
| | | "type": "object", |
| | | "properties": { |
| | | "created_at": { |
| | | "description": "创建时间", |
| | | "type": "string" |
| | | }, |
| | | "id": { |
| | | "description": "主键ID", |
| | | "type": "integer" |
| | |
| | | }, |
| | | "component": { |
| | | "description": "对应前端文件路径", |
| | | "type": "string" |
| | | }, |
| | | "created_at": { |
| | | "description": "创建时间", |
| | | "type": "string" |
| | | }, |
| | | "hidden": { |
| | |
| | | }, |
| | | "body": { |
| | | "description": "请求Body", |
| | | "type": "string" |
| | | }, |
| | | "created_at": { |
| | | "description": "创建时间", |
| | | "type": "string" |
| | | }, |
| | | "error_message": { |
| | |
| | | "description": "基础颜色", |
| | | "type": "string" |
| | | }, |
| | | "created_at": { |
| | | "description": "创建时间", |
| | | "type": "string" |
| | | }, |
| | | "email": { |
| | | "description": "用户邮箱", |
| | | "type": "string" |
| | |
| | | "test.Contract": { |
| | | "type": "object", |
| | | "properties": { |
| | | "created_at": { |
| | | "description": "创建时间", |
| | | "type": "string" |
| | | }, |
| | | "fileContent": { |
| | | "type": "array", |
| | | "items": { |
| | |
| | | "test.Industry": { |
| | | "type": "object", |
| | | "properties": { |
| | | "created_at": { |
| | | "description": "创建时间", |
| | | "type": "string" |
| | | }, |
| | | "id": { |
| | | "description": "主键ID", |
| | | "type": "integer" |
| | |
| | | "test.Member": { |
| | | "type": "object", |
| | | "properties": { |
| | | "created_at": { |
| | | "description": "创建时间", |
| | | "type": "string" |
| | | }, |
| | | "id": { |
| | | "description": "主键ID", |
| | | "type": "integer" |
| | |
| | | "test.Product": { |
| | | "type": "object", |
| | | "properties": { |
| | | "created_at": { |
| | | "description": "创建时间", |
| | | "type": "string" |
| | | }, |
| | | "deliveryTime": { |
| | | "type": "integer" |
| | | }, |
| | |
| | | "contact": { |
| | | "type": "string" |
| | | }, |
| | | "created_at": { |
| | | "description": "创建时间", |
| | | "type": "string" |
| | | }, |
| | | "detailAddress": { |
| | | "type": "string" |
| | | }, |
| | |
| | | "test.SupplierType": { |
| | | "type": "object", |
| | | "properties": { |
| | | "created_at": { |
| | | "description": "创建时间", |
| | | "type": "string" |
| | | }, |
| | | "id": { |
| | | "description": "主键ID", |
| | | "type": "integer" |
| | |
| | | } |
| | | } |
| | | }, |
| | | "/con/downloadContract": { |
| | | "get": { |
| | | "security": [ |
| | | { |
| | | "ApiKeyAuth": [] |
| | | } |
| | | ], |
| | | "consumes": [ |
| | | "application/json" |
| | | ], |
| | | "produces": [ |
| | | "application/json" |
| | | ], |
| | | "tags": [ |
| | | "Contract" |
| | | ], |
| | | "summary": "下载Contract", |
| | | "parameters": [ |
| | | { |
| | | "type": "string", |
| | | "description": "创建时间", |
| | | "name": "created_at", |
| | | "in": "query" |
| | | }, |
| | | { |
| | | "type": "array", |
| | | "items": { |
| | | "type": "integer" |
| | | }, |
| | | "collectionFormat": "csv", |
| | | "name": "fileContent", |
| | | "in": "query" |
| | | }, |
| | | { |
| | | "type": "string", |
| | | "name": "fileName", |
| | | "in": "query" |
| | | }, |
| | | { |
| | | "type": "integer", |
| | | "description": "主键ID", |
| | | "name": "id", |
| | | "in": "query" |
| | | }, |
| | | { |
| | | "type": "integer", |
| | | "name": "supplierID", |
| | | "in": "query" |
| | | } |
| | | ], |
| | | "responses": { |
| | | "200": { |
| | | "description": "{\"success\":true,\"data\":{},\"msg\":\"下载成功\"}", |
| | | "schema": { |
| | | "type": "string" |
| | | } |
| | | } |
| | | } |
| | | } |
| | | }, |
| | | "/con/findContract": { |
| | | "get": { |
| | | "security": [ |
| | |
| | | ], |
| | | "summary": "用id查询Contract", |
| | | "parameters": [ |
| | | { |
| | | "type": "string", |
| | | "description": "创建时间", |
| | | "name": "created_at", |
| | | "in": "query" |
| | | }, |
| | | { |
| | | "type": "array", |
| | | "items": { |
| | |
| | | ], |
| | | "summary": "分页获取Contract列表", |
| | | "parameters": [ |
| | | { |
| | | "type": "string", |
| | | "description": "创建时间", |
| | | "name": "created_at", |
| | | "in": "query" |
| | | }, |
| | | { |
| | | "type": "string", |
| | | "name": "endCreatedAt", |
| | |
| | | ], |
| | | "summary": "预览Contract", |
| | | "parameters": [ |
| | | { |
| | | "type": "string", |
| | | "description": "创建时间", |
| | | "name": "created_at", |
| | | "in": "query" |
| | | }, |
| | | { |
| | | "type": "array", |
| | | "items": { |
| | |
| | | ], |
| | | "summary": "获取单一客户信息", |
| | | "parameters": [ |
| | | { |
| | | "type": "string", |
| | | "description": "创建时间", |
| | | "name": "created_at", |
| | | "in": "query" |
| | | }, |
| | | { |
| | | "type": "string", |
| | | "description": "客户名", |
| | |
| | | "summary": "用id查询Industry", |
| | | "parameters": [ |
| | | { |
| | | "type": "string", |
| | | "description": "创建时间", |
| | | "name": "created_at", |
| | | "in": "query" |
| | | }, |
| | | { |
| | | "type": "integer", |
| | | "description": "主键ID", |
| | | "name": "id", |
| | |
| | | ], |
| | | "summary": "分页获取Industry列表", |
| | | "parameters": [ |
| | | { |
| | | "type": "string", |
| | | "description": "创建时间", |
| | | "name": "created_at", |
| | | "in": "query" |
| | | }, |
| | | { |
| | | "type": "string", |
| | | "name": "endCreatedAt", |
| | |
| | | "summary": "用id查询Member", |
| | | "parameters": [ |
| | | { |
| | | "type": "string", |
| | | "description": "创建时间", |
| | | "name": "created_at", |
| | | "in": "query" |
| | | }, |
| | | { |
| | | "type": "integer", |
| | | "description": "主键ID", |
| | | "name": "id", |
| | |
| | | ], |
| | | "summary": "分页获取Member列表", |
| | | "parameters": [ |
| | | { |
| | | "type": "string", |
| | | "description": "创建时间", |
| | | "name": "created_at", |
| | | "in": "query" |
| | | }, |
| | | { |
| | | "type": "string", |
| | | "name": "endCreatedAt", |
| | |
| | | ], |
| | | "summary": "分页获取Member列表", |
| | | "parameters": [ |
| | | { |
| | | "type": "string", |
| | | "description": "创建时间", |
| | | "name": "created_at", |
| | | "in": "query" |
| | | }, |
| | | { |
| | | "type": "string", |
| | | "name": "endCreatedAt", |
| | |
| | | "summary": "用id查询Product", |
| | | "parameters": [ |
| | | { |
| | | "type": "string", |
| | | "description": "创建时间", |
| | | "name": "created_at", |
| | | "in": "query" |
| | | }, |
| | | { |
| | | "type": "integer", |
| | | "name": "deliveryTime", |
| | | "in": "query" |
| | |
| | | ], |
| | | "summary": "分页获取Product列表", |
| | | "parameters": [ |
| | | { |
| | | "type": "string", |
| | | "description": "创建时间", |
| | | "name": "created_at", |
| | | "in": "query" |
| | | }, |
| | | { |
| | | "type": "integer", |
| | | "name": "deliveryTime", |
| | |
| | | ], |
| | | "summary": "分页获取Product列表", |
| | | "parameters": [ |
| | | { |
| | | "type": "string", |
| | | "description": "创建时间", |
| | | "name": "created_at", |
| | | "in": "query" |
| | | }, |
| | | { |
| | | "type": "integer", |
| | | "name": "deliveryTime", |
| | |
| | | }, |
| | | { |
| | | "type": "string", |
| | | "description": "创建时间", |
| | | "name": "created_at", |
| | | "in": "query" |
| | | }, |
| | | { |
| | | "type": "string", |
| | | "name": "detailAddress", |
| | | "in": "query" |
| | | }, |
| | |
| | | { |
| | | "type": "string", |
| | | "name": "contact", |
| | | "in": "query" |
| | | }, |
| | | { |
| | | "type": "string", |
| | | "description": "创建时间", |
| | | "name": "created_at", |
| | | "in": "query" |
| | | }, |
| | | { |
| | |
| | | "summary": "用id查询SupplierType", |
| | | "parameters": [ |
| | | { |
| | | "type": "string", |
| | | "description": "创建时间", |
| | | "name": "created_at", |
| | | "in": "query" |
| | | }, |
| | | { |
| | | "type": "integer", |
| | | "description": "主键ID", |
| | | "name": "id", |
| | |
| | | ], |
| | | "summary": "分页获取SupplierType列表", |
| | | "parameters": [ |
| | | { |
| | | "type": "string", |
| | | "description": "创建时间", |
| | | "name": "created_at", |
| | | "in": "query" |
| | | }, |
| | | { |
| | | "type": "string", |
| | | "name": "endCreatedAt", |
| | |
| | | "parameters": [ |
| | | { |
| | | "type": "string", |
| | | "description": "创建时间", |
| | | "name": "created_at", |
| | | "in": "query" |
| | | }, |
| | | { |
| | | "type": "string", |
| | | "description": "描述", |
| | | "name": "desc", |
| | | "in": "query" |
| | |
| | | ], |
| | | "summary": "分页获取SysDictionary列表", |
| | | "parameters": [ |
| | | { |
| | | "type": "string", |
| | | "description": "创建时间", |
| | | "name": "created_at", |
| | | "in": "query" |
| | | }, |
| | | { |
| | | "type": "string", |
| | | "description": "描述", |
| | |
| | | "summary": "用id查询SysDictionaryDetail", |
| | | "parameters": [ |
| | | { |
| | | "type": "string", |
| | | "description": "创建时间", |
| | | "name": "created_at", |
| | | "in": "query" |
| | | }, |
| | | { |
| | | "type": "integer", |
| | | "description": "主键ID", |
| | | "name": "id", |
| | |
| | | ], |
| | | "summary": "分页获取SysDictionaryDetail列表", |
| | | "parameters": [ |
| | | { |
| | | "type": "string", |
| | | "description": "创建时间", |
| | | "name": "created_at", |
| | | "in": "query" |
| | | }, |
| | | { |
| | | "type": "integer", |
| | | "description": "主键ID", |
| | |
| | | }, |
| | | { |
| | | "type": "string", |
| | | "description": "创建时间", |
| | | "name": "created_at", |
| | | "in": "query" |
| | | }, |
| | | { |
| | | "type": "string", |
| | | "description": "错误信息", |
| | | "name": "error_message", |
| | | "in": "query" |
| | |
| | | "type": "string", |
| | | "description": "请求Body", |
| | | "name": "body", |
| | | "in": "query" |
| | | }, |
| | | { |
| | | "type": "string", |
| | | "description": "创建时间", |
| | | "name": "created_at", |
| | | "in": "query" |
| | | }, |
| | | { |
| | |
| | | "example.ExaCustomer": { |
| | | "type": "object", |
| | | "properties": { |
| | | "created_at": { |
| | | "description": "创建时间", |
| | | "type": "string" |
| | | }, |
| | | "customerName": { |
| | | "description": "客户名", |
| | | "type": "string" |
| | |
| | | "chunkTotal": { |
| | | "type": "integer" |
| | | }, |
| | | "created_at": { |
| | | "description": "创建时间", |
| | | "type": "string" |
| | | }, |
| | | "exaFileChunk": { |
| | | "type": "array", |
| | | "items": { |
| | |
| | | "example.ExaFileChunk": { |
| | | "type": "object", |
| | | "properties": { |
| | | "created_at": { |
| | | "description": "创建时间", |
| | | "type": "string" |
| | | }, |
| | | "exaFileID": { |
| | | "type": "integer" |
| | | }, |
| | |
| | | "example.ExaFileUploadAndDownload": { |
| | | "type": "object", |
| | | "properties": { |
| | | "created_at": { |
| | | "description": "创建时间", |
| | | "type": "string" |
| | | }, |
| | | "id": { |
| | | "description": "主键ID", |
| | | "type": "integer" |
| | |
| | | "properties": { |
| | | "contact": { |
| | | "description": "联系人", |
| | | "type": "string" |
| | | }, |
| | | "created_at": { |
| | | "description": "创建时间", |
| | | "type": "string" |
| | | }, |
| | | "deliveryDate": { |
| | |
| | | "amount": { |
| | | "description": "采购数量", |
| | | "type": "number" |
| | | }, |
| | | "created_at": { |
| | | "description": "创建时间", |
| | | "type": "string" |
| | | }, |
| | | "id": { |
| | | "description": "主键ID", |
| | |
| | | "properties": { |
| | | "apiGroup": { |
| | | "description": "api组", |
| | | "type": "string" |
| | | }, |
| | | "created_at": { |
| | | "description": "创建时间", |
| | | "type": "string" |
| | | }, |
| | | "desc": { |
| | |
| | | "description": "api组", |
| | | "type": "string" |
| | | }, |
| | | "created_at": { |
| | | "description": "创建时间", |
| | | "type": "string" |
| | | }, |
| | | "description": { |
| | | "description": "api中文描述", |
| | | "type": "string" |
| | |
| | | "system.SysAutoCode": { |
| | | "type": "object", |
| | | "properties": { |
| | | "created_at": { |
| | | "description": "创建时间", |
| | | "type": "string" |
| | | }, |
| | | "desc": { |
| | | "type": "string" |
| | | }, |
| | |
| | | }, |
| | | "component": { |
| | | "description": "对应前端文件路径", |
| | | "type": "string" |
| | | }, |
| | | "created_at": { |
| | | "description": "创建时间", |
| | | "type": "string" |
| | | }, |
| | | "hidden": { |
| | |
| | | "system.SysBaseMenuBtn": { |
| | | "type": "object", |
| | | "properties": { |
| | | "created_at": { |
| | | "description": "创建时间", |
| | | "type": "string" |
| | | }, |
| | | "desc": { |
| | | "type": "string" |
| | | }, |
| | |
| | | "system.SysBaseMenuParameter": { |
| | | "type": "object", |
| | | "properties": { |
| | | "created_at": { |
| | | "description": "创建时间", |
| | | "type": "string" |
| | | }, |
| | | "id": { |
| | | "description": "主键ID", |
| | | "type": "integer" |
| | |
| | | "system.SysDictionary": { |
| | | "type": "object", |
| | | "properties": { |
| | | "created_at": { |
| | | "description": "创建时间", |
| | | "type": "string" |
| | | }, |
| | | "desc": { |
| | | "description": "描述", |
| | | "type": "string" |
| | |
| | | "system.SysDictionaryDetail": { |
| | | "type": "object", |
| | | "properties": { |
| | | "created_at": { |
| | | "description": "创建时间", |
| | | "type": "string" |
| | | }, |
| | | "id": { |
| | | "description": "主键ID", |
| | | "type": "integer" |
| | |
| | | }, |
| | | "component": { |
| | | "description": "对应前端文件路径", |
| | | "type": "string" |
| | | }, |
| | | "created_at": { |
| | | "description": "创建时间", |
| | | "type": "string" |
| | | }, |
| | | "hidden": { |
| | |
| | | }, |
| | | "body": { |
| | | "description": "请求Body", |
| | | "type": "string" |
| | | }, |
| | | "created_at": { |
| | | "description": "创建时间", |
| | | "type": "string" |
| | | }, |
| | | "error_message": { |
| | |
| | | "description": "基础颜色", |
| | | "type": "string" |
| | | }, |
| | | "created_at": { |
| | | "description": "创建时间", |
| | | "type": "string" |
| | | }, |
| | | "email": { |
| | | "description": "用户邮箱", |
| | | "type": "string" |
| | |
| | | "test.Contract": { |
| | | "type": "object", |
| | | "properties": { |
| | | "created_at": { |
| | | "description": "创建时间", |
| | | "type": "string" |
| | | }, |
| | | "fileContent": { |
| | | "type": "array", |
| | | "items": { |
| | |
| | | "test.Industry": { |
| | | "type": "object", |
| | | "properties": { |
| | | "created_at": { |
| | | "description": "创建时间", |
| | | "type": "string" |
| | | }, |
| | | "id": { |
| | | "description": "主键ID", |
| | | "type": "integer" |
| | |
| | | "test.Member": { |
| | | "type": "object", |
| | | "properties": { |
| | | "created_at": { |
| | | "description": "创建时间", |
| | | "type": "string" |
| | | }, |
| | | "id": { |
| | | "description": "主键ID", |
| | | "type": "integer" |
| | |
| | | "test.Product": { |
| | | "type": "object", |
| | | "properties": { |
| | | "created_at": { |
| | | "description": "创建时间", |
| | | "type": "string" |
| | | }, |
| | | "deliveryTime": { |
| | | "type": "integer" |
| | | }, |
| | |
| | | "contact": { |
| | | "type": "string" |
| | | }, |
| | | "created_at": { |
| | | "description": "创建时间", |
| | | "type": "string" |
| | | }, |
| | | "detailAddress": { |
| | | "type": "string" |
| | | }, |
| | |
| | | "test.SupplierType": { |
| | | "type": "object", |
| | | "properties": { |
| | | "created_at": { |
| | | "description": "创建时间", |
| | | "type": "string" |
| | | }, |
| | | "id": { |
| | | "description": "主键ID", |
| | | "type": "integer" |
| | |
| | | type: object |
| | | example.ExaCustomer: |
| | | properties: |
| | | created_at: |
| | | description: 创建时间 |
| | | type: string |
| | | customerName: |
| | | description: 客户名 |
| | | type: string |
| | |
| | | properties: |
| | | chunkTotal: |
| | | type: integer |
| | | created_at: |
| | | description: 创建时间 |
| | | type: string |
| | | exaFileChunk: |
| | | items: |
| | | $ref: '#/definitions/example.ExaFileChunk' |
| | |
| | | type: object |
| | | example.ExaFileChunk: |
| | | properties: |
| | | created_at: |
| | | description: 创建时间 |
| | | type: string |
| | | exaFileID: |
| | | type: integer |
| | | fileChunkNumber: |
| | |
| | | type: object |
| | | example.ExaFileUploadAndDownload: |
| | | properties: |
| | | created_at: |
| | | description: 创建时间 |
| | | type: string |
| | | id: |
| | | description: 主键ID |
| | | type: integer |
| | |
| | | properties: |
| | | contact: |
| | | description: 联系人 |
| | | type: string |
| | | created_at: |
| | | description: 创建时间 |
| | | type: string |
| | | deliveryDate: |
| | | description: 交付日期 |
| | |
| | | amount: |
| | | description: 采购数量 |
| | | type: number |
| | | created_at: |
| | | description: 创建时间 |
| | | type: string |
| | | id: |
| | | description: 主键ID |
| | | type: integer |
| | |
| | | properties: |
| | | apiGroup: |
| | | description: api组 |
| | | type: string |
| | | created_at: |
| | | description: 创建时间 |
| | | type: string |
| | | desc: |
| | | description: 排序方式:升序false(默认)|降序true |
| | |
| | | apiGroup: |
| | | description: api组 |
| | | type: string |
| | | created_at: |
| | | description: 创建时间 |
| | | type: string |
| | | description: |
| | | description: api中文描述 |
| | | type: string |
| | |
| | | type: object |
| | | system.SysAutoCode: |
| | | properties: |
| | | created_at: |
| | | description: 创建时间 |
| | | type: string |
| | | desc: |
| | | type: string |
| | | id: |
| | |
| | | type: array |
| | | component: |
| | | description: 对应前端文件路径 |
| | | type: string |
| | | created_at: |
| | | description: 创建时间 |
| | | type: string |
| | | hidden: |
| | | description: 是否在列表隐藏 |
| | |
| | | type: object |
| | | system.SysBaseMenuBtn: |
| | | properties: |
| | | created_at: |
| | | description: 创建时间 |
| | | type: string |
| | | desc: |
| | | type: string |
| | | id: |
| | |
| | | type: object |
| | | system.SysBaseMenuParameter: |
| | | properties: |
| | | created_at: |
| | | description: 创建时间 |
| | | type: string |
| | | id: |
| | | description: 主键ID |
| | | type: integer |
| | |
| | | type: object |
| | | system.SysDictionary: |
| | | properties: |
| | | created_at: |
| | | description: 创建时间 |
| | | type: string |
| | | desc: |
| | | description: 描述 |
| | | type: string |
| | |
| | | type: object |
| | | system.SysDictionaryDetail: |
| | | properties: |
| | | created_at: |
| | | description: 创建时间 |
| | | type: string |
| | | id: |
| | | description: 主键ID |
| | | type: integer |
| | |
| | | type: array |
| | | component: |
| | | description: 对应前端文件路径 |
| | | type: string |
| | | created_at: |
| | | description: 创建时间 |
| | | type: string |
| | | hidden: |
| | | description: 是否在列表隐藏 |
| | |
| | | type: string |
| | | body: |
| | | description: 请求Body |
| | | type: string |
| | | created_at: |
| | | description: 创建时间 |
| | | type: string |
| | | error_message: |
| | | description: 错误信息 |
| | |
| | | baseColor: |
| | | description: 基础颜色 |
| | | type: string |
| | | created_at: |
| | | description: 创建时间 |
| | | type: string |
| | | email: |
| | | description: 用户邮箱 |
| | | type: string |
| | |
| | | type: object |
| | | test.Contract: |
| | | properties: |
| | | created_at: |
| | | description: 创建时间 |
| | | type: string |
| | | fileContent: |
| | | items: |
| | | type: integer |
| | |
| | | type: object |
| | | test.Industry: |
| | | properties: |
| | | created_at: |
| | | description: 创建时间 |
| | | type: string |
| | | id: |
| | | description: 主键ID |
| | | type: integer |
| | |
| | | type: object |
| | | test.Member: |
| | | properties: |
| | | created_at: |
| | | description: 创建时间 |
| | | type: string |
| | | id: |
| | | description: 主键ID |
| | | type: integer |
| | |
| | | type: object |
| | | test.Product: |
| | | properties: |
| | | created_at: |
| | | description: 创建时间 |
| | | type: string |
| | | deliveryTime: |
| | | type: integer |
| | | id: |
| | |
| | | type: string |
| | | contact: |
| | | type: string |
| | | created_at: |
| | | description: 创建时间 |
| | | type: string |
| | | detailAddress: |
| | | type: string |
| | | email: |
| | |
| | | type: object |
| | | test.SupplierType: |
| | | properties: |
| | | created_at: |
| | | description: 创建时间 |
| | | type: string |
| | | id: |
| | | description: 主键ID |
| | | type: integer |
| | |
| | | summary: 批量删除Contract |
| | | tags: |
| | | - Contract |
| | | /con/downloadContract: |
| | | get: |
| | | consumes: |
| | | - application/json |
| | | parameters: |
| | | - description: 创建时间 |
| | | in: query |
| | | name: created_at |
| | | type: string |
| | | - collectionFormat: csv |
| | | in: query |
| | | items: |
| | | type: integer |
| | | name: fileContent |
| | | type: array |
| | | - in: query |
| | | name: fileName |
| | | type: string |
| | | - description: 主键ID |
| | | in: query |
| | | name: id |
| | | type: integer |
| | | - in: query |
| | | name: supplierID |
| | | type: integer |
| | | produces: |
| | | - application/json |
| | | responses: |
| | | "200": |
| | | description: '{"success":true,"data":{},"msg":"下载成功"}' |
| | | schema: |
| | | type: string |
| | | security: |
| | | - ApiKeyAuth: [] |
| | | summary: 下载Contract |
| | | tags: |
| | | - Contract |
| | | /con/findContract: |
| | | get: |
| | | consumes: |
| | | - application/json |
| | | parameters: |
| | | - description: 创建时间 |
| | | in: query |
| | | name: created_at |
| | | type: string |
| | | - collectionFormat: csv |
| | | in: query |
| | | items: |
| | |
| | | consumes: |
| | | - application/json |
| | | parameters: |
| | | - description: 创建时间 |
| | | in: query |
| | | name: created_at |
| | | type: string |
| | | - in: query |
| | | name: endCreatedAt |
| | | type: string |
| | |
| | | consumes: |
| | | - application/json |
| | | parameters: |
| | | - description: 创建时间 |
| | | in: query |
| | | name: created_at |
| | | type: string |
| | | - collectionFormat: csv |
| | | in: query |
| | | items: |
| | |
| | | consumes: |
| | | - application/json |
| | | parameters: |
| | | - description: 创建时间 |
| | | in: query |
| | | name: created_at |
| | | type: string |
| | | - description: 客户名 |
| | | in: query |
| | | name: customerName |
| | |
| | | consumes: |
| | | - application/json |
| | | parameters: |
| | | - description: 创建时间 |
| | | in: query |
| | | name: created_at |
| | | type: string |
| | | - description: 主键ID |
| | | in: query |
| | | name: id |
| | |
| | | consumes: |
| | | - application/json |
| | | parameters: |
| | | - description: 创建时间 |
| | | in: query |
| | | name: created_at |
| | | type: string |
| | | - in: query |
| | | name: endCreatedAt |
| | | type: string |
| | |
| | | consumes: |
| | | - application/json |
| | | parameters: |
| | | - description: 创建时间 |
| | | in: query |
| | | name: created_at |
| | | type: string |
| | | - description: 主键ID |
| | | in: query |
| | | name: id |
| | |
| | | consumes: |
| | | - application/json |
| | | parameters: |
| | | - description: 创建时间 |
| | | in: query |
| | | name: created_at |
| | | type: string |
| | | - in: query |
| | | name: endCreatedAt |
| | | type: string |
| | |
| | | consumes: |
| | | - application/json |
| | | parameters: |
| | | - description: 创建时间 |
| | | in: query |
| | | name: created_at |
| | | type: string |
| | | - in: query |
| | | name: endCreatedAt |
| | | type: string |
| | |
| | | consumes: |
| | | - application/json |
| | | parameters: |
| | | - description: 创建时间 |
| | | in: query |
| | | name: created_at |
| | | type: string |
| | | - in: query |
| | | name: deliveryTime |
| | | type: integer |
| | |
| | | consumes: |
| | | - application/json |
| | | parameters: |
| | | - description: 创建时间 |
| | | in: query |
| | | name: created_at |
| | | type: string |
| | | - in: query |
| | | name: deliveryTime |
| | | type: integer |
| | |
| | | consumes: |
| | | - application/json |
| | | parameters: |
| | | - description: 创建时间 |
| | | in: query |
| | | name: created_at |
| | | type: string |
| | | - in: query |
| | | name: deliveryTime |
| | | type: integer |
| | |
| | | - in: query |
| | | name: contact |
| | | type: string |
| | | - description: 创建时间 |
| | | in: query |
| | | name: created_at |
| | | type: string |
| | | - in: query |
| | | name: detailAddress |
| | | type: string |
| | |
| | | type: string |
| | | - in: query |
| | | name: contact |
| | | type: string |
| | | - description: 创建时间 |
| | | in: query |
| | | name: created_at |
| | | type: string |
| | | - in: query |
| | | name: detailAddress |
| | |
| | | consumes: |
| | | - application/json |
| | | parameters: |
| | | - description: 创建时间 |
| | | in: query |
| | | name: created_at |
| | | type: string |
| | | - description: 主键ID |
| | | in: query |
| | | name: id |
| | |
| | | consumes: |
| | | - application/json |
| | | parameters: |
| | | - description: 创建时间 |
| | | in: query |
| | | name: created_at |
| | | type: string |
| | | - in: query |
| | | name: endCreatedAt |
| | | type: string |
| | |
| | | consumes: |
| | | - application/json |
| | | parameters: |
| | | - description: 创建时间 |
| | | in: query |
| | | name: created_at |
| | | type: string |
| | | - description: 描述 |
| | | in: query |
| | | name: desc |
| | |
| | | consumes: |
| | | - application/json |
| | | parameters: |
| | | - description: 创建时间 |
| | | in: query |
| | | name: created_at |
| | | type: string |
| | | - description: 描述 |
| | | in: query |
| | | name: desc |
| | |
| | | consumes: |
| | | - application/json |
| | | parameters: |
| | | - description: 创建时间 |
| | | in: query |
| | | name: created_at |
| | | type: string |
| | | - description: 主键ID |
| | | in: query |
| | | name: id |
| | |
| | | consumes: |
| | | - application/json |
| | | parameters: |
| | | - description: 创建时间 |
| | | in: query |
| | | name: created_at |
| | | type: string |
| | | - description: 主键ID |
| | | in: query |
| | | name: id |
| | |
| | | in: query |
| | | name: body |
| | | type: string |
| | | - description: 创建时间 |
| | | in: query |
| | | name: created_at |
| | | type: string |
| | | - description: 错误信息 |
| | | in: query |
| | | name: error_message |
| | |
| | | in: query |
| | | name: body |
| | | type: string |
| | | - description: 创建时间 |
| | | in: query |
| | | name: created_at |
| | | type: string |
| | | - description: 错误信息 |
| | | in: query |
| | | name: error_message |
| | |
| | | |
| | | type GVA_MODEL struct { |
| | | ID uint `gorm:"primarykey"` // 主键ID |
| | | CreatedAt *time.Time `json:"-"` // 创建时间 |
| | | CreatedAt *time.Time `json:"created_at"` // 创建时间 |
| | | UpdatedAt *time.Time `json:"-"` // 更新时间 |
| | | DeletedAt gorm.DeletedAt `gorm:"index" json:"-"` // 删除时间 |
| | | } |
| | |
| | | SupplierID *int `json:"supplierID" form:"supplierID" gorm:"column:supplier_id;comment:供应商id;"` |
| | | FileName string `json:"fileName" form:"fileName" gorm:"column:file_name;comment:文件名称;size:255;"` |
| | | FileContent []byte `json:"fileContent" form:"fileContent" gorm:"type:mediumblob;column:file_content;comment:文件内容;"` |
| | | FileType string `json:"fileType" form:"fileType" gorm:"column:file_type;comment:文件类型;size:255;"` |
| | | } |
| | | |
| | | // TableName Contract 表名 |
| | |
| | | conRouter.PUT("updateContract", conApi.UpdateContract) // 更新Contract |
| | | } |
| | | { |
| | | conRouterWithoutRecord.GET("findContract", conApi.FindContract) // 根据ID获取Contract |
| | | conRouterWithoutRecord.GET("getContractList", conApi.GetContractList) // 获取Contract列表 |
| | | conRouterWithoutRecord.GET("previewContract", conApi.PreviewContract) // 预览Contract |
| | | conRouterWithoutRecord.GET("findContract", conApi.FindContract) // 根据ID获取Contract |
| | | conRouterWithoutRecord.GET("getContractList", conApi.GetContractList) // 获取Contract列表 |
| | | conRouterWithoutRecord.GET("previewContract", conApi.PreviewContract) // 预览Contract |
| | | conRouterWithoutRecord.GET("downloadContract", conApi.DownloadContract) // 下载Contract |
| | | } |
| | | } |
| | |
| | | // UpdateSupplier 更新Supplier记录 |
| | | // Author [piexlmax](https://github.com/piexlmax) |
| | | func (sService *SupplierService) UpdateSupplier(s test.Supplier) (err error) { |
| | | err = global.GVA_DB.Save(&s).Error |
| | | err = global.GVA_DB.Updates(&s).Error |
| | | return err |
| | | } |
| | | |