From ecd0774318cbf43cc2b32bc80c9b8aef311dc809 Mon Sep 17 00:00:00 2001 From: zhangqian <zhangqian@123.com> Date: 星期三, 09 八月 2023 13:49:13 +0800 Subject: [PATCH] merge --- service/file.go | 9 model/request/product.go | 7 api/v1/product.go | 107 +++ model/request/file.go | 7 go.mod | 11 docs/swagger.yaml | 215 ++++-- model/file.go | 4 docs/docs.go | 324 ++++++--- router/file.go | 4 docs/swagger.json | 324 ++++++--- conf/aps-crm.json | 9 api/v1/file.go | 102 ++ go.sum | 19 proto/product.proto | 43 + model/request/common.go | 10 proto/product/product.pb.go | 565 +++++++++++++++++ proto/product/product_grpc.pb.go | 146 ++++ conf/config.go | 14 model/response/common.go | 36 router/index.go | 1 main.go | 4 router/product.go | 15 22 files changed, 1,616 insertions(+), 360 deletions(-) diff --git a/api/v1/file.go b/api/v1/file.go index 9fbdc78..348a72c 100644 --- a/api/v1/file.go +++ b/api/v1/file.go @@ -3,7 +3,6 @@ import ( "aps_crm/model" "aps_crm/model/request" - "aps_crm/model/response" "aps_crm/pkg/contextx" "aps_crm/pkg/ecode" "aps_crm/pkg/httpx" @@ -11,6 +10,7 @@ "aps_crm/utils/upload" "github.com/gin-gonic/gin" "github.com/spf13/cast" + "io" "os" "path/filepath" ) @@ -131,28 +131,100 @@ // ctx.Ok() //} -// List -// @Tags 闄勪欢绠$悊 -// @Summary 鑾峰彇闄勪欢鍒楄〃 +//// List +//// @Tags 闄勪欢绠$悊 +//// @Summary 鑾峰彇闄勪欢鍒楄〃 +//// @Produce application/json +//// @Param object query request.GetFileList true "鍙傛暟" +//// @Success 200 {object} response.ListResponse{data=[]model.File} +//// @Router /api/file/list [get] +//func (s *FileApi) List(c *gin.Context) { +// var params request.GetFileList +// ctx, ok := contextx.NewContext(c, ¶ms) +// if !ok { +// return +// } +// +// file, total, errCode := service.NewFileService().GetFileList() +// if errCode != ecode.OK { +// ctx.Fail(errCode) +// return +// } +// +// ctx.OkWithDetailed(response.ListResponse{ +// Data: file, +// Count: total, +// }) +//} + +// Download +// @Tags 闄勪欢绠$悊 +// @Summary 闄勪欢涓嬭浇 // @Produce application/json -// @Param object query request.GetFileList true "鍙傛暟" -// @Success 200 {object} response.ListResponse{data=[]model.File} -// @Router /api/file/list [get] -func (s *FileApi) List(c *gin.Context) { - var params request.GetFileList +// @Param object body request.DownloadFile true "鍙傛暟" +// @Success 200 {object} contextx.Response{} +// @Router /api/file/download [post] +func (s *FileApi) Download(c *gin.Context) { + var params request.DownloadFile ctx, ok := contextx.NewContext(c, ¶ms) if !ok { return } - - file, total, errCode := service.NewFileService().GetFileList() + file, errCode := service.NewFileService().GetFile(params.Id) if errCode != ecode.OK { ctx.Fail(errCode) return } + if file.SourceType != params.SourceType || file.SourceId != params.SourceId || file.Key != params.Key { + ctx.FailWithMsg(ecode.ParamsErr, "鏂囦欢涓嶅瓨鍦�") + return + } + f, err := os.Open(file.FilePath) + if err != nil { + ctx.FailWithMsg(ecode.ParamsErr, "鏂囦欢涓嶅瓨鍦�") + return + } + file.DownloadCount++ + service.NewFileService().UpdateFile(file) - ctx.OkWithDetailed(response.ListResponse{ - Data: file, - Count: total, - }) + data, err := io.ReadAll(f) + c.Writer.Header().Set("Content-Type", "application/octect-stream") + c.Writer.Header().Set("Content-Disposition", "attachment;filename="+file.Name) + c.Writer.Write(data) +} + +// Preview +// @Tags 闄勪欢绠$悊 +// @Summary 闄勪欢棰勮 +// @Produce application/json +// @Param object body request.DownloadFile true "鍙傛暟" +// @Success 200 {object} contextx.Response{} +// @Router /api/file/preview [post] +func (s *FileApi) Preview(c *gin.Context) { + var params request.DownloadFile + ctx, ok := contextx.NewContext(c, ¶ms) + if !ok { + return + } + file, errCode := service.NewFileService().GetFile(params.Id) + if errCode != ecode.OK { + ctx.Fail(errCode) + return + } + if file.SourceType != params.SourceType || file.SourceId != params.SourceId || file.Key != params.Key { + ctx.FailWithMsg(ecode.ParamsErr, "鏂囦欢涓嶅瓨鍦�") + return + } + f, err := os.Open(file.FilePath) + if err != nil { + ctx.FailWithMsg(ecode.ParamsErr, "鏂囦欢涓嶅瓨鍦�") + return + } + file.PreviewCount++ + service.NewFileService().UpdateFile(file) + + data, err := io.ReadAll(f) + c.Writer.Header().Set("Content-Type", "application/octect-stream") + c.Writer.Header().Set("Content-Disposition", "attachment;filename="+file.Name) + c.Writer.Write(data) } diff --git a/api/v1/product.go b/api/v1/product.go new file mode 100644 index 0000000..f77d0a6 --- /dev/null +++ b/api/v1/product.go @@ -0,0 +1,107 @@ +package v1 + +import ( + "aps_crm/conf" + "aps_crm/model/request" + "aps_crm/model/response" + "aps_crm/pkg/contextx" + "aps_crm/pkg/ecode" + "aps_crm/pkg/logx" + "aps_crm/proto/product" + "fmt" + "github.com/gin-gonic/gin" + "github.com/spf13/cast" + "google.golang.org/grpc" + "google.golang.org/grpc/credentials/insecure" +) + +type ProductApi struct{} + +var ( + productServiceConn *grpc.ClientConn +) + +func InitProductServiceConn() { + fmt.Println(conf.Conf.GrpcServiceAddr.Aps) + var err error + productServiceConn, err = grpc.Dial(conf.Conf.GrpcServiceAddr.Aps, grpc.WithTransportCredentials(insecure.NewCredentials())) + if err != nil { + logx.Errorf("grpc dial product service error: %v", err.Error()) + return + } +} + +// List +// +// @Tags 浜у搧 +// @Summary 鑾峰彇浜у搧鍒楄〃 +// @Produce application/json +// @Param object query request.GetProductList true "鍙傛暟" +// @Success 200 {object} response.ListResponse{data=[]product.Product} +// +// @Router /api/product/list [get] +func (ci *ProductApi) List(c *gin.Context) { + var params request.GetProductList + ctx, ok := contextx.NewContext(c, ¶ms) + if !ok { + return + } + if !params.Check() { + ctx.FailWithMsg(ecode.ParamsErr, "page, pageSize瓒呭嚭鑼冨洿") + return + } + + cli := product.NewProductServiceClient(productServiceConn) + + getProductListResponse, err := cli.GetProductList(ctx.GetCtx(), &product.GetProductListRequest{ + Page: cast.ToInt32(params.Page), + PageSize: cast.ToInt32(params.PageSize), + ProductNumber: params.ProductNumber, + ProductName: params.ProductName, + }) + if err != nil { + logx.Errorf("GetProductList err: %v", err.Error()) + ctx.FailWithMsg(ecode.UnknownErr, "鍐呴儴閿欒") + return + } + if getProductListResponse.Code != 0 { + logx.Errorf("GetProductList err: %v", err.Error()) + ctx.FailWithMsg(ecode.UnknownErr, "鍐呴儴閿欒") + return + } + ctx.OkWithDetailed(response.ListResponse{ + Data: getProductListResponse.List, + Count: getProductListResponse.Total, + }) +} + +// Info +// @Tags 浜у搧 +// @Summary 鑾峰彇浜у搧璇︽儏 +// @Produce application/json +// @Param productNumber query string true "鍙傛暟" +// @Success 200 {object} contextx.Response{data=product.Product} "鎴愬姛" +// @Router /api/product/info [get] +func (ci *ProductApi) Info(c *gin.Context) { + ctx, ok := contextx.NewContext(c, nil) + if !ok { + return + } + + // 鑾峰彇浜у搧ID + productId := c.Query("productNumber") + cli := product.NewProductServiceClient(productServiceConn) + + getProductInfoResponse, err := cli.GetProductInfo(ctx.GetCtx(), &product.GetProductInfoRequest{ProductId: productId}) + if err != nil { + logx.Errorf("GetProductInfo err: %v", err.Error()) + ctx.FailWithMsg(ecode.UnknownErr, "鍐呴儴閿欒") + return + } + if getProductInfoResponse.Code != 0 { + logx.Errorf("GetProductInfo err: %v", err.Error()) + ctx.FailWithMsg(ecode.UnknownErr, "鍐呴儴閿欒") + return + } + ctx.OkWithDetailed(getProductInfoResponse.Data) +} diff --git a/conf/aps-crm.json b/conf/aps-crm.json index a3d0ffd..a616fdd 100644 --- a/conf/aps-crm.json +++ b/conf/aps-crm.json @@ -40,6 +40,15 @@ "ExpiresTime": "7d", "BufferTime": "1d", "Issuer": "qmPlus" + }, + "jwt2": { + "SigningKey": "327a9457-899a-481e-8b30-58cc97e5b808", + "ExpiresTime": "7d", + "BufferTime": "1d", + "Issuer": "qmPlus" + }, + "GrpcServiceAddr": { + "Aps": "192.168.20.120:9091" } } diff --git a/conf/config.go b/conf/config.go index a998029..36a1dcd 100644 --- a/conf/config.go +++ b/conf/config.go @@ -38,6 +38,13 @@ Issuer string // 绛惧彂鑰� } + JWT2 struct { + SigningKey string // jwt绛惧悕 + ExpiresTime string // 杩囨湡鏃堕棿 + BufferTime string // 缂撳啿鏃堕棿 + Issuer string // 绛惧彂鑰� + } + System struct { Env string // 鐜鍊� develop test public Port int // 绔彛 @@ -48,6 +55,10 @@ LimitTimeIP int RouterPrefix string // 璺敱鍓嶇紑 SudoPassword string // sudo瀵嗙爜 + } + + GrpcServiceAddr struct { + Aps string // jwt绛惧悕 } config struct { @@ -68,6 +79,8 @@ // JWT閰嶇疆 JWT JWT + + GrpcServiceAddr GrpcServiceAddr } ) @@ -117,5 +130,6 @@ log.Printf(" Mysql: %+v", Conf.Mysql) log.Printf(" Captcha: %+v", Conf.Captcha) log.Printf(" JWT: %+v", Conf.JWT) + log.Printf(" GrpcServiceAddr: %+v", Conf.GrpcServiceAddr) log.Println("......................................................") } diff --git a/docs/docs.go b/docs/docs.go index 1f6e1d3..9be43ac 100644 --- a/docs/docs.go +++ b/docs/docs.go @@ -2727,76 +2727,61 @@ } } }, - "/api/file/list": { - "get": { + "/api/file/download": { + "post": { "produces": [ "application/json" ], "tags": [ "闄勪欢绠$悊" ], - "summary": "鑾峰彇闄勪欢鍒楄〃", + "summary": "闄勪欢涓嬭浇", "parameters": [ { - "type": "string", - "name": "keyword", - "in": "query" - }, - { - "enum": [ - "" - ], - "type": "string", - "x-enum-varnames": [ - "FileKeywordCustomerName" - ], - "name": "keywordType", - "in": "query" - }, - { - "type": "integer", - "description": "椤电爜", - "name": "page", - "in": "query" - }, - { - "type": "integer", - "description": "姣忛〉澶у皬", - "name": "pageSize", - "in": "query" - }, - { - "enum": [ - "" - ], - "type": "string", - "x-enum-varnames": [ - "FileQueryClassExpireLessThen60Days" - ], - "name": "queryClass", - "in": "query" + "description": "鍙傛暟", + "name": "object", + "in": "body", + "required": true, + "schema": { + "$ref": "#/definitions/request.DownloadFile" + } } ], "responses": { "200": { "description": "OK", "schema": { - "allOf": [ - { - "$ref": "#/definitions/response.ListResponse" - }, - { - "type": "object", - "properties": { - "data": { - "type": "array", - "items": { - "$ref": "#/definitions/model.File" - } - } - } - } - ] + "$ref": "#/definitions/contextx.Response" + } + } + } + } + }, + "/api/file/preview": { + "post": { + "produces": [ + "application/json" + ], + "tags": [ + "闄勪欢绠$悊" + ], + "summary": "闄勪欢棰勮", + "parameters": [ + { + "description": "鍙傛暟", + "name": "object", + "in": "body", + "required": true, + "schema": { + "$ref": "#/definitions/request.DownloadFile" + } + } + ], + "responses": { + "200": { + "description": "OK", + "schema": { + "$ref": "#/definitions/contextx.Response" } } } @@ -4766,6 +4751,106 @@ "description": "OK", "schema": { "$ref": "#/definitions/contextx.Response" + } + } + } + } + }, + "/api/product/info": { + "get": { + "produces": [ + "application/json" + ], + "tags": [ + "浜у搧" + ], + "summary": "鑾峰彇浜у搧璇︽儏", + "parameters": [ + { + "type": "string", + "description": "鍙傛暟", + "name": "productNumber", + "in": "query", + "required": true + } + ], + "responses": { + "200": { + "description": "鎴愬姛", + "schema": { + "allOf": [ + { + "$ref": "#/definitions/contextx.Response" + }, + { + "type": "object", + "properties": { + "data": { + "$ref": "#/definitions/product.Product" + } + } + } + ] + } + } + } + } + }, + "/api/product/list": { + "get": { + "produces": [ + "application/json" + ], + "tags": [ + "浜у搧" + ], + "summary": "鑾峰彇浜у搧鍒楄〃", + "parameters": [ + { + "type": "integer", + "description": "椤电爜", + "name": "page", + "in": "query" + }, + { + "type": "integer", + "description": "姣忛〉澶у皬", + "name": "pageSize", + "in": "query" + }, + { + "type": "string", + "description": "浜у搧鍚嶇О", + "name": "productName", + "in": "query" + }, + { + "type": "string", + "description": "浜у搧缂栫爜", + "name": "productNumber", + "in": "query" + } + ], + "responses": { + "200": { + "description": "OK", + "schema": { + "allOf": [ + { + "$ref": "#/definitions/response.ListResponse" + }, + { + "type": "object", + "properties": { + "data": { + "type": "array", + "items": { + "$ref": "#/definitions/product.Product" + } + } + } + } + ] } } } @@ -9470,24 +9555,6 @@ "FaqQueryClassExpireLessThen60Days" ] }, - "constvar.FileKeywordType": { - "type": "string", - "enum": [ - "" - ], - "x-enum-varnames": [ - "FileKeywordCustomerName" - ] - }, - "constvar.FileQueryClass": { - "type": "string", - "enum": [ - "" - ], - "x-enum-varnames": [ - "FileQueryClassExpireLessThen60Days" - ] - }, "constvar.InvoiceKeywordType": { "type": "string", "enum": [ @@ -10269,50 +10336,6 @@ "type": "integer" }, "name": { - "type": "string" - } - } - }, - "model.File": { - "type": "object", - "properties": { - "bucket": { - "description": "瀵硅薄瀛樺偍bucket", - "type": "string" - }, - "downloadCount": { - "description": "涓嬫娆℃暟", - "type": "integer" - }, - "filePath": { - "description": "鏂囦欢璺緞", - "type": "string" - }, - "fileType": { - "description": "鏂囦欢绫诲瀷", - "type": "string" - }, - "key": { - "description": "瀵硅薄瀛樺偍key", - "type": "string" - }, - "name": { - "type": "string" - }, - "previewCount": { - "description": "棰勮娆℃暟", - "type": "integer" - }, - "size": { - "description": "鏂囦欢澶у皬", - "type": "integer" - }, - "sourceId": { - "description": "鏉ユ簮id", - "type": "integer" - }, - "sourceType": { - "description": "闄勪欢鏉ユ簮", "type": "string" } } @@ -11799,6 +11822,44 @@ "type": "string" }, "uuid": { + "type": "string" + } + } + }, + "product.Product": { + "type": "object", + "properties": { + "Amount": { + "description": "搴撳瓨鍓╀綑閲�", + "type": "number" + }, + "IsSale": { + "description": "鏄惁閿�鍞�", + "type": "boolean" + }, + "MaterialMode": { + "description": "鐗╂枡绫诲瀷", + "type": "string" + }, + "MinInventory": { + "description": "瀹夊叏搴撳瓨", + "type": "integer" + }, + "Name": { + "type": "string" + }, + "Number": { + "type": "string" + }, + "PurchaseType": { + "description": "閲囪喘绫诲瀷", + "type": "string" + }, + "SalePrice": { + "description": "閿�鍞环鏍�", + "type": "number" + }, + "Unit": { "type": "string" } } @@ -13516,6 +13577,33 @@ } } }, + "request.DownloadFile": { + "type": "object", + "required": [ + "id", + "key", + "sourceId", + "sourceType" + ], + "properties": { + "id": { + "description": "闄勪欢id", + "type": "integer" + }, + "key": { + "description": "闄勪欢瀛樺偍key", + "type": "string" + }, + "sourceId": { + "description": "鏉ユ簮id", + "type": "integer" + }, + "sourceType": { + "description": "闄勪欢鏉ユ簮", + "type": "string" + } + } + }, "request.FollowRecord": { "type": "object", "properties": { diff --git a/docs/swagger.json b/docs/swagger.json index e81bb3f..ab6def1 100644 --- a/docs/swagger.json +++ b/docs/swagger.json @@ -2715,76 +2715,61 @@ } } }, - "/api/file/list": { - "get": { + "/api/file/download": { + "post": { "produces": [ "application/json" ], "tags": [ "闄勪欢绠$悊" ], - "summary": "鑾峰彇闄勪欢鍒楄〃", + "summary": "闄勪欢涓嬭浇", "parameters": [ { - "type": "string", - "name": "keyword", - "in": "query" - }, - { - "enum": [ - "" - ], - "type": "string", - "x-enum-varnames": [ - "FileKeywordCustomerName" - ], - "name": "keywordType", - "in": "query" - }, - { - "type": "integer", - "description": "椤电爜", - "name": "page", - "in": "query" - }, - { - "type": "integer", - "description": "姣忛〉澶у皬", - "name": "pageSize", - "in": "query" - }, - { - "enum": [ - "" - ], - "type": "string", - "x-enum-varnames": [ - "FileQueryClassExpireLessThen60Days" - ], - "name": "queryClass", - "in": "query" + "description": "鍙傛暟", + "name": "object", + "in": "body", + "required": true, + "schema": { + "$ref": "#/definitions/request.DownloadFile" + } } ], "responses": { "200": { "description": "OK", "schema": { - "allOf": [ - { - "$ref": "#/definitions/response.ListResponse" - }, - { - "type": "object", - "properties": { - "data": { - "type": "array", - "items": { - "$ref": "#/definitions/model.File" - } - } - } - } - ] + "$ref": "#/definitions/contextx.Response" + } + } + } + } + }, + "/api/file/preview": { + "post": { + "produces": [ + "application/json" + ], + "tags": [ + "闄勪欢绠$悊" + ], + "summary": "闄勪欢棰勮", + "parameters": [ + { + "description": "鍙傛暟", + "name": "object", + "in": "body", + "required": true, + "schema": { + "$ref": "#/definitions/request.DownloadFile" + } + } + ], + "responses": { + "200": { + "description": "OK", + "schema": { + "$ref": "#/definitions/contextx.Response" } } } @@ -4754,6 +4739,106 @@ "description": "OK", "schema": { "$ref": "#/definitions/contextx.Response" + } + } + } + } + }, + "/api/product/info": { + "get": { + "produces": [ + "application/json" + ], + "tags": [ + "浜у搧" + ], + "summary": "鑾峰彇浜у搧璇︽儏", + "parameters": [ + { + "type": "string", + "description": "鍙傛暟", + "name": "productNumber", + "in": "query", + "required": true + } + ], + "responses": { + "200": { + "description": "鎴愬姛", + "schema": { + "allOf": [ + { + "$ref": "#/definitions/contextx.Response" + }, + { + "type": "object", + "properties": { + "data": { + "$ref": "#/definitions/product.Product" + } + } + } + ] + } + } + } + } + }, + "/api/product/list": { + "get": { + "produces": [ + "application/json" + ], + "tags": [ + "浜у搧" + ], + "summary": "鑾峰彇浜у搧鍒楄〃", + "parameters": [ + { + "type": "integer", + "description": "椤电爜", + "name": "page", + "in": "query" + }, + { + "type": "integer", + "description": "姣忛〉澶у皬", + "name": "pageSize", + "in": "query" + }, + { + "type": "string", + "description": "浜у搧鍚嶇О", + "name": "productName", + "in": "query" + }, + { + "type": "string", + "description": "浜у搧缂栫爜", + "name": "productNumber", + "in": "query" + } + ], + "responses": { + "200": { + "description": "OK", + "schema": { + "allOf": [ + { + "$ref": "#/definitions/response.ListResponse" + }, + { + "type": "object", + "properties": { + "data": { + "type": "array", + "items": { + "$ref": "#/definitions/product.Product" + } + } + } + } + ] } } } @@ -9458,24 +9543,6 @@ "FaqQueryClassExpireLessThen60Days" ] }, - "constvar.FileKeywordType": { - "type": "string", - "enum": [ - "" - ], - "x-enum-varnames": [ - "FileKeywordCustomerName" - ] - }, - "constvar.FileQueryClass": { - "type": "string", - "enum": [ - "" - ], - "x-enum-varnames": [ - "FileQueryClassExpireLessThen60Days" - ] - }, "constvar.InvoiceKeywordType": { "type": "string", "enum": [ @@ -10257,50 +10324,6 @@ "type": "integer" }, "name": { - "type": "string" - } - } - }, - "model.File": { - "type": "object", - "properties": { - "bucket": { - "description": "瀵硅薄瀛樺偍bucket", - "type": "string" - }, - "downloadCount": { - "description": "涓嬫娆℃暟", - "type": "integer" - }, - "filePath": { - "description": "鏂囦欢璺緞", - "type": "string" - }, - "fileType": { - "description": "鏂囦欢绫诲瀷", - "type": "string" - }, - "key": { - "description": "瀵硅薄瀛樺偍key", - "type": "string" - }, - "name": { - "type": "string" - }, - "previewCount": { - "description": "棰勮娆℃暟", - "type": "integer" - }, - "size": { - "description": "鏂囦欢澶у皬", - "type": "integer" - }, - "sourceId": { - "description": "鏉ユ簮id", - "type": "integer" - }, - "sourceType": { - "description": "闄勪欢鏉ユ簮", "type": "string" } } @@ -11787,6 +11810,44 @@ "type": "string" }, "uuid": { + "type": "string" + } + } + }, + "product.Product": { + "type": "object", + "properties": { + "Amount": { + "description": "搴撳瓨鍓╀綑閲�", + "type": "number" + }, + "IsSale": { + "description": "鏄惁閿�鍞�", + "type": "boolean" + }, + "MaterialMode": { + "description": "鐗╂枡绫诲瀷", + "type": "string" + }, + "MinInventory": { + "description": "瀹夊叏搴撳瓨", + "type": "integer" + }, + "Name": { + "type": "string" + }, + "Number": { + "type": "string" + }, + "PurchaseType": { + "description": "閲囪喘绫诲瀷", + "type": "string" + }, + "SalePrice": { + "description": "閿�鍞环鏍�", + "type": "number" + }, + "Unit": { "type": "string" } } @@ -13504,6 +13565,33 @@ } } }, + "request.DownloadFile": { + "type": "object", + "required": [ + "id", + "key", + "sourceId", + "sourceType" + ], + "properties": { + "id": { + "description": "闄勪欢id", + "type": "integer" + }, + "key": { + "description": "闄勪欢瀛樺偍key", + "type": "string" + }, + "sourceId": { + "description": "鏉ユ簮id", + "type": "integer" + }, + "sourceType": { + "description": "闄勪欢鏉ユ簮", + "type": "string" + } + } + }, "request.FollowRecord": { "type": "object", "properties": { diff --git a/docs/swagger.yaml b/docs/swagger.yaml index 0d41be3..9c4a623 100644 --- a/docs/swagger.yaml +++ b/docs/swagger.yaml @@ -46,18 +46,6 @@ type: string x-enum-varnames: - FaqQueryClassExpireLessThen60Days - constvar.FileKeywordType: - enum: - - "" - type: string - x-enum-varnames: - - FileKeywordCustomerName - constvar.FileQueryClass: - enum: - - "" - type: string - x-enum-varnames: - - FileQueryClassExpireLessThen60Days constvar.InvoiceKeywordType: enum: - "" @@ -601,38 +589,6 @@ id: type: integer name: - type: string - type: object - model.File: - properties: - bucket: - description: 瀵硅薄瀛樺偍bucket - type: string - downloadCount: - description: 涓嬫娆℃暟 - type: integer - filePath: - description: 鏂囦欢璺緞 - type: string - fileType: - description: 鏂囦欢绫诲瀷 - type: string - key: - description: 瀵硅薄瀛樺偍key - type: string - name: - type: string - previewCount: - description: 棰勮娆℃暟 - type: integer - size: - description: 鏂囦欢澶у皬 - type: integer - sourceId: - description: 鏉ユ簮id - type: integer - sourceType: - description: 闄勪欢鏉ユ簮 type: string type: object model.FollowRecord: @@ -1625,6 +1581,33 @@ username: type: string uuid: + type: string + type: object + product.Product: + properties: + Amount: + description: 搴撳瓨鍓╀綑閲� + type: number + IsSale: + description: 鏄惁閿�鍞� + type: boolean + MaterialMode: + description: 鐗╂枡绫诲瀷 + type: string + MinInventory: + description: 瀹夊叏搴撳瓨 + type: integer + Name: + type: string + Number: + type: string + PurchaseType: + description: 閲囪喘绫诲瀷 + type: string + SalePrice: + description: 閿�鍞环鏍� + type: number + Unit: type: string type: object request.AddAccountId: @@ -2788,6 +2771,26 @@ items: type: integer type: array + type: object + request.DownloadFile: + properties: + id: + description: 闄勪欢id + type: integer + key: + description: 闄勪欢瀛樺偍key + type: string + sourceId: + description: 鏉ユ簮id + type: integer + sourceType: + description: 闄勪欢鏉ユ簮 + type: string + required: + - id + - key + - sourceId + - sourceType type: object request.FollowRecord: properties: @@ -6960,49 +6963,42 @@ summary: 鍒犻櫎闄勪欢 tags: - 闄勪欢绠$悊 - /api/file/list: - get: + /api/file/download: + post: parameters: - - in: query - name: keyword - type: string - - enum: - - "" - in: query - name: keywordType - type: string - x-enum-varnames: - - FileKeywordCustomerName - - description: 椤电爜 - in: query - name: page - type: integer - - description: 姣忛〉澶у皬 - in: query - name: pageSize - type: integer - - enum: - - "" - in: query - name: queryClass - type: string - x-enum-varnames: - - FileQueryClassExpireLessThen60Days + - description: 鍙傛暟 + in: body + name: object + required: true + schema: + $ref: '#/definitions/request.DownloadFile' produces: - application/json responses: "200": description: OK schema: - allOf: - - $ref: '#/definitions/response.ListResponse' - - properties: - data: - items: - $ref: '#/definitions/model.File' - type: array - type: object - summary: 鑾峰彇闄勪欢鍒楄〃 + $ref: '#/definitions/contextx.Response' + summary: 闄勪欢涓嬭浇 + tags: + - 闄勪欢绠$悊 + /api/file/preview: + post: + parameters: + - description: 鍙傛暟 + in: body + name: object + required: true + schema: + $ref: '#/definitions/request.DownloadFile' + produces: + - application/json + responses: + "200": + description: OK + schema: + $ref: '#/definitions/contextx.Response' + summary: 闄勪欢棰勮 tags: - 闄勪欢绠$悊 /api/followRecord/add: @@ -8213,6 +8209,65 @@ summary: 鏇存柊浼樺厛绾у埆 tags: - 浼樺厛绾у埆绠$悊 + /api/product/info: + get: + parameters: + - description: 鍙傛暟 + in: query + name: productNumber + required: true + type: string + produces: + - application/json + responses: + "200": + description: 鎴愬姛 + schema: + allOf: + - $ref: '#/definitions/contextx.Response' + - properties: + data: + $ref: '#/definitions/product.Product' + type: object + summary: 鑾峰彇浜у搧璇︽儏 + tags: + - 浜у搧 + /api/product/list: + get: + parameters: + - description: 椤电爜 + in: query + name: page + type: integer + - description: 姣忛〉澶у皬 + in: query + name: pageSize + type: integer + - description: 浜у搧鍚嶇О + in: query + name: productName + type: string + - description: 浜у搧缂栫爜 + in: query + name: productNumber + type: string + produces: + - application/json + responses: + "200": + description: OK + schema: + allOf: + - $ref: '#/definitions/response.ListResponse' + - properties: + data: + items: + $ref: '#/definitions/product.Product' + type: array + type: object + summary: 鑾峰彇浜у搧鍒楄〃 + tags: + - 浜у搧 /api/province/add: post: parameters: diff --git a/go.mod b/go.mod index 04409f1..ac5dfee 100644 --- a/go.mod +++ b/go.mod @@ -35,6 +35,8 @@ moul.io/zapgorm2 v1.3.0 ) +require google.golang.org/genproto/googleapis/api v0.0.0-20230726155614-23370e0ffb3e // indirect + require ( github.com/Knetic/govaluate v3.0.1-0.20171022003610-9aa49832a739+incompatible // indirect github.com/KyleBanks/depth v1.2.1 // indirect @@ -100,13 +102,14 @@ go.uber.org/multierr v1.10.0 // indirect golang.org/x/arch v0.3.0 // indirect golang.org/x/image v0.5.0 // indirect - golang.org/x/net v0.10.0 // indirect + golang.org/x/net v0.14.0 // indirect golang.org/x/sys v0.11.0 // indirect golang.org/x/text v0.12.0 // indirect golang.org/x/tools v0.9.1 // indirect - google.golang.org/genproto v0.0.0-20230410155749-daa745c078e1 // indirect - google.golang.org/grpc v1.55.0 // indirect - google.golang.org/protobuf v1.30.0 // indirect + google.golang.org/genproto v0.0.0-20230803162519-f966b187b2e5 // indirect + google.golang.org/genproto/googleapis/rpc v0.0.0-20230807174057-1744710a1577 // indirect + google.golang.org/grpc v1.57.0 + google.golang.org/protobuf v1.31.0 gopkg.in/ini.v1 v1.67.0 // indirect gopkg.in/yaml.v3 v3.0.1 // indirect gorm.io/driver/postgres v1.5.2 // indirect diff --git a/go.sum b/go.sum index 8c08e3b..da3bc7c 100644 --- a/go.sum +++ b/go.sum @@ -501,8 +501,9 @@ golang.org/x/net v0.6.0/go.mod h1:2Tu9+aMcznHK/AK1HMvgo6xiTLG5rD5rZLDS+rp2Bjs= golang.org/x/net v0.7.0/go.mod h1:2Tu9+aMcznHK/AK1HMvgo6xiTLG5rD5rZLDS+rp2Bjs= golang.org/x/net v0.8.0/go.mod h1:QVkue5JL9kW//ek3r6jTKnTFis1tRmNAW2P1shuFdJc= -golang.org/x/net v0.10.0 h1:X2//UzNDwYmtCLn7To6G58Wr6f5ahEAQgKNzv9Y951M= golang.org/x/net v0.10.0/go.mod h1:0qNGK6F8kojg2nk9dLZ2mShWaEBan6FAoqfSigmmuDg= +golang.org/x/net v0.14.0 h1:BONx9s002vGdD9umnlX1Po8vOZmrgH34qlHcD1MfK14= +golang.org/x/net v0.14.0/go.mod h1:PpSgVXXLK0OxS0F31C1/tv6XNguvCrnXIDrFMspZIUI= golang.org/x/oauth2 v0.0.0-20180821212333-d2e6202438be/go.mod h1:N/0e6XlmueqKjAGxoOufVs8QHGRruUQn6yWY3a++T0U= golang.org/x/oauth2 v0.0.0-20190226205417-e64efc72b421/go.mod h1:gOpvHmFTYa4IltrdGE7lF6nIHvwfUNPOp7c8zoXwtLw= golang.org/x/oauth2 v0.0.0-20190604053449-0f29369cfe45/go.mod h1:gOpvHmFTYa4IltrdGE7lF6nIHvwfUNPOp7c8zoXwtLw= @@ -717,8 +718,12 @@ google.golang.org/genproto v0.0.0-20201214200347-8c77b98c765d/go.mod h1:FWY/as6DDZQgahTzZj3fqbO1CbirC29ZNUFHwi0/+no= google.golang.org/genproto v0.0.0-20210108203827-ffc7fda8c3d7/go.mod h1:FWY/as6DDZQgahTzZj3fqbO1CbirC29ZNUFHwi0/+no= google.golang.org/genproto v0.0.0-20210226172003-ab064af71705/go.mod h1:FWY/as6DDZQgahTzZj3fqbO1CbirC29ZNUFHwi0/+no= -google.golang.org/genproto v0.0.0-20230410155749-daa745c078e1 h1:KpwkzHKEF7B9Zxg18WzOa7djJ+Ha5DzthMyZYQfEn2A= -google.golang.org/genproto v0.0.0-20230410155749-daa745c078e1/go.mod h1:nKE/iIaLqn2bQwXBg8f1g2Ylh6r5MN5CmZvuzZCgsCU= +google.golang.org/genproto v0.0.0-20230803162519-f966b187b2e5 h1:L6iMMGrtzgHsWofoFcihmDEMYeDR9KN/ThbPWGrh++g= +google.golang.org/genproto v0.0.0-20230803162519-f966b187b2e5/go.mod h1:oH/ZOT02u4kWEp7oYBGYFFkCdKS/uYR9Z7+0/xuuFp8= +google.golang.org/genproto/googleapis/api v0.0.0-20230726155614-23370e0ffb3e h1:z3vDksarJxsAKM5dmEGv0GHwE2hKJ096wZra71Vs4sw= +google.golang.org/genproto/googleapis/api v0.0.0-20230726155614-23370e0ffb3e/go.mod h1:rsr7RhLuwsDKL7RmgDDCUc6yaGr1iqceVb5Wv6f6YvQ= +google.golang.org/genproto/googleapis/rpc v0.0.0-20230807174057-1744710a1577 h1:wukfNtZmZUurLN/atp2hiIeTKn7QJWIQdHzqmsOnAOk= +google.golang.org/genproto/googleapis/rpc v0.0.0-20230807174057-1744710a1577/go.mod h1:+Bk1OCOj40wS2hwAMA+aCW9ypzm63QTBBHp6lQ3p+9M= google.golang.org/grpc v1.19.0/go.mod h1:mqu4LbDTu4XGKhr4mRzUsmM4RtVoemTSY81AxZiDr8c= google.golang.org/grpc v1.20.1/go.mod h1:10oTOabMzJvdu6/UiuZezV6QK5dSlG84ov/aaiqXj38= google.golang.org/grpc v1.21.1/go.mod h1:oYelfM1adQP15Ek0mdvEgi9Df8B9CZIaU1084ijfRaM= @@ -735,8 +740,8 @@ google.golang.org/grpc v1.33.2/go.mod h1:JMHMWHQWaTccqQQlmk3MJZS+GWXOdAesneDmEnv2fbc= google.golang.org/grpc v1.34.0/go.mod h1:WotjhfgOW/POjDeRt8vscBtXq+2VjORFy659qA51WJ8= google.golang.org/grpc v1.35.0/go.mod h1:qjiiYl8FncCW8feJPdyg3v6XW24KsRHe+dy9BAGRRjU= -google.golang.org/grpc v1.55.0 h1:3Oj82/tFSCeUrRTg/5E/7d/W5A1tj6Ky1ABAuZuv5ag= -google.golang.org/grpc v1.55.0/go.mod h1:iYEXKGkEBhg1PjZQvoYEVPTDkHo1/bjTnfwTeGONTY8= +google.golang.org/grpc v1.57.0 h1:kfzNeI/klCGD2YPMUlaGNT3pxvYfga7smW3Vth8Zsiw= +google.golang.org/grpc v1.57.0/go.mod h1:Sd+9RMTACXwmub0zcNY2c4arhtrbBYD1AUHI/dt16Mo= google.golang.org/protobuf v0.0.0-20200109180630-ec00e32a8dfd/go.mod h1:DFci5gLYBciE7Vtevhsrf46CRTquxDuWsQurQQe4oz8= google.golang.org/protobuf v0.0.0-20200221191635-4d8936d0db64/go.mod h1:kwYJMbMJ01Woi6D6+Kah6886xMZcty6N08ah7+eCXa0= google.golang.org/protobuf v0.0.0-20200228230310-ab0ca4ff8a60/go.mod h1:cfTl7dwQJ+fmap5saPgwCLgHXTUD7jkjRqWcaiX5VyM= @@ -750,8 +755,8 @@ google.golang.org/protobuf v1.26.0-rc.1/go.mod h1:jlhhOSvTdKEhbULTjvd4ARK9grFBp09yW+WbY/TyQbw= google.golang.org/protobuf v1.26.0/go.mod h1:9q0QmTI4eRPtz6boOQmLYwt+qCgq0jsYwAQnmE0givc= google.golang.org/protobuf v1.28.0/go.mod h1:HV8QOd/L58Z+nl8r43ehVNZIU/HEI6OcFqwMG9pJV4I= -google.golang.org/protobuf v1.30.0 h1:kPPoIgf3TsEvrm0PFe15JQ+570QVxYzEvvHqChK+cng= -google.golang.org/protobuf v1.30.0/go.mod h1:HV8QOd/L58Z+nl8r43ehVNZIU/HEI6OcFqwMG9pJV4I= +google.golang.org/protobuf v1.31.0 h1:g0LDEJHgrBl9N9r17Ru3sqWhkIx2NB67okBHPwC7hs8= +google.golang.org/protobuf v1.31.0/go.mod h1:HV8QOd/L58Z+nl8r43ehVNZIU/HEI6OcFqwMG9pJV4I= gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= gopkg.in/check.v1 v1.0.0-20180628173108-788fd7840127/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= gopkg.in/check.v1 v1.0.0-20200227125254-8fa46927fb4f/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= diff --git a/main.go b/main.go index 29b0377..98b7547 100644 --- a/main.go +++ b/main.go @@ -1,6 +1,7 @@ package main import ( + v1 "aps_crm/api/v1" "aps_crm/conf" "aps_crm/initialize" "aps_crm/model" @@ -43,6 +44,9 @@ ReadTimeout: 5 * time.Second, WriteTimeout: 5 * time.Second, } + + go v1.InitProductServiceConn() + logx.Error(server.ListenAndServe().Error()) } diff --git a/model/file.go b/model/file.go index bd1c46a..11225f1 100644 --- a/model/file.go +++ b/model/file.go @@ -13,9 +13,9 @@ File struct { Name string `gorm:"name" json:"name"` Size int64 `gorm:"size" json:"size"` // 鏂囦欢澶у皬 - FilePath string `gorm:"file_path" json:"filePath"` // 鏂囦欢璺緞 + FilePath string `gorm:"file_path" json:"-"` // 鏂囦欢璺緞 Key string `gorm:"key" json:"key"` // 瀵硅薄瀛樺偍key - Bucket string `gorm:"bucket" json:"bucket"` // 瀵硅薄瀛樺偍bucket + Bucket string `gorm:"bucket" json:"-"` // 瀵硅薄瀛樺偍bucket DownloadCount int `gorm:"download_count" json:"downloadCount"` // 涓嬫娆℃暟 PreviewCount int `gorm:"preview_count" json:"previewCount"` // 棰勮娆℃暟 FileType string `gorm:"file_type" json:"fileType"` // 鏂囦欢绫诲瀷 diff --git a/model/request/common.go b/model/request/common.go index 492de9d..18cadf5 100644 --- a/model/request/common.go +++ b/model/request/common.go @@ -12,3 +12,13 @@ type GetByUserId struct { UserId string `json:"userId"` // 鐢ㄦ埛ID } + +func (p PageInfo) Check() bool { + if p.Page <= 0 { + return false + } + if p.PageSize <= 0 || p.PageSize > 500 { + return false + } + return true +} diff --git a/model/request/file.go b/model/request/file.go index 096675b..749b82f 100644 --- a/model/request/file.go +++ b/model/request/file.go @@ -21,3 +21,10 @@ KeywordType constvar.FileKeywordType `json:"keywordType" form:"keywordType"` Keyword string `json:"keyword" form:"keyword"` } + +type DownloadFile struct { + SourceType string `json:"sourceType" form:"sourceType" binding:"required"` // 闄勪欢鏉ユ簮 + SourceId int `json:"sourceId" form:"sourceId" binding:"required"` // 鏉ユ簮id + Id uint `json:"id" form:"id" binding:"required"` // 闄勪欢id + Key string `json:"key" form:"key" binding:"required"` // 闄勪欢瀛樺偍key +} diff --git a/model/request/product.go b/model/request/product.go new file mode 100644 index 0000000..a81e429 --- /dev/null +++ b/model/request/product.go @@ -0,0 +1,7 @@ +package request + +type GetProductList struct { + PageInfo + ProductNumber string `json:"productNumber" form:"productNumber"` // 浜у搧缂栫爜 + ProductName string `json:"productName" form:"productName"` // 浜у搧鍚嶇О +} diff --git a/model/response/common.go b/model/response/common.go index 03433be..7687174 100644 --- a/model/response/common.go +++ b/model/response/common.go @@ -1,15 +1,21 @@ -package response - -type PageResult struct { - List interface{} `json:"list"` - Total int64 `json:"total"` - Page int `json:"page"` - PageSize int `json:"pageSize"` -} - -type ListResponse struct { - Code int `json:"code"` - Msg string `json:"msg"` - Data interface{} `json:"data"` - Count int64 `json:"count"` -} +package response + +type PageResult struct { + List interface{} `json:"list"` + Total int64 `json:"total"` + Page int `json:"page"` + PageSize int `json:"pageSize"` +} + +type ListResponse struct { + Code int `json:"code"` + Msg string `json:"msg"` + Data interface{} `json:"data"` + Count int64 `json:"count"` +} + +type Response struct { + Code int `json:"code"` + Msg string `json:"msg"` + Data interface{} `json:"data"` +} diff --git a/proto/product.proto b/proto/product.proto new file mode 100644 index 0000000..e2cf073 --- /dev/null +++ b/proto/product.proto @@ -0,0 +1,43 @@ +syntax = "proto3"; + +option go_package = "./product"; + +service productService { + rpc GetProductInfo(GetProductInfoRequest) returns(GetProductInfoResponse) {} + rpc GetProductList(GetProductListRequest) returns(GetProductListResponse) {} +} + +message GetProductInfoRequest{ + string ProductId = 1; //浜у搧id +} + +message GetProductInfoResponse{ + int32 Code = 1; + string Msg = 2; + Product Data = 3; +} +message Product { + string Number = 1; + string Name = 2; + string Unit = 3; + bool IsSale = 4; //鏄惁閿�鍞� + float SalePrice = 5; //閿�鍞环鏍� + float Amount = 6;//搴撳瓨鍓╀綑閲� + int32 MinInventory = 7;//瀹夊叏搴撳瓨 + string MaterialMode = 8; //鐗╂枡绫诲瀷 + string PurchaseType = 9;//閲囪喘绫诲瀷 +} + +message GetProductListRequest{ + int32 page = 1; + int32 pageSize = 2; + string ProductNumber = 3; + string ProductName = 4; +} + +message GetProductListResponse{ + int32 Code = 1; + string Msg = 2; + repeated Product List = 3; + int64 Total = 4; +} \ No newline at end of file diff --git a/proto/product/product.pb.go b/proto/product/product.pb.go new file mode 100644 index 0000000..37f100d --- /dev/null +++ b/proto/product/product.pb.go @@ -0,0 +1,565 @@ +// Code generated by protoc-gen-go. DO NOT EDIT. +// versions: +// protoc-gen-go v1.31.0 +// protoc v3.19.0 +// source: product.proto + +package product + +import ( + protoreflect "google.golang.org/protobuf/reflect/protoreflect" + protoimpl "google.golang.org/protobuf/runtime/protoimpl" + reflect "reflect" + sync "sync" +) + +const ( + // Verify that this generated code is sufficiently up-to-date. + _ = protoimpl.EnforceVersion(20 - protoimpl.MinVersion) + // Verify that runtime/protoimpl is sufficiently up-to-date. + _ = protoimpl.EnforceVersion(protoimpl.MaxVersion - 20) +) + +type GetProductInfoRequest struct { + state protoimpl.MessageState + sizeCache protoimpl.SizeCache + unknownFields protoimpl.UnknownFields + + ProductId string `protobuf:"bytes,1,opt,name=ProductId,proto3" json:"ProductId,omitempty"` //浜у搧id +} + +func (x *GetProductInfoRequest) Reset() { + *x = GetProductInfoRequest{} + if protoimpl.UnsafeEnabled { + mi := &file_product_proto_msgTypes[0] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) + } +} + +func (x *GetProductInfoRequest) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*GetProductInfoRequest) ProtoMessage() {} + +func (x *GetProductInfoRequest) ProtoReflect() protoreflect.Message { + mi := &file_product_proto_msgTypes[0] + if protoimpl.UnsafeEnabled && x != nil { + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + if ms.LoadMessageInfo() == nil { + ms.StoreMessageInfo(mi) + } + return ms + } + return mi.MessageOf(x) +} + +// Deprecated: Use GetProductInfoRequest.ProtoReflect.Descriptor instead. +func (*GetProductInfoRequest) Descriptor() ([]byte, []int) { + return file_product_proto_rawDescGZIP(), []int{0} +} + +func (x *GetProductInfoRequest) GetProductId() string { + if x != nil { + return x.ProductId + } + return "" +} + +type GetProductInfoResponse struct { + state protoimpl.MessageState + sizeCache protoimpl.SizeCache + unknownFields protoimpl.UnknownFields + + Code int32 `protobuf:"varint,1,opt,name=Code,proto3" json:"Code,omitempty"` + Msg string `protobuf:"bytes,2,opt,name=Msg,proto3" json:"Msg,omitempty"` + Data *Product `protobuf:"bytes,3,opt,name=Data,proto3" json:"Data,omitempty"` +} + +func (x *GetProductInfoResponse) Reset() { + *x = GetProductInfoResponse{} + if protoimpl.UnsafeEnabled { + mi := &file_product_proto_msgTypes[1] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) + } +} + +func (x *GetProductInfoResponse) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*GetProductInfoResponse) ProtoMessage() {} + +func (x *GetProductInfoResponse) ProtoReflect() protoreflect.Message { + mi := &file_product_proto_msgTypes[1] + if protoimpl.UnsafeEnabled && x != nil { + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + if ms.LoadMessageInfo() == nil { + ms.StoreMessageInfo(mi) + } + return ms + } + return mi.MessageOf(x) +} + +// Deprecated: Use GetProductInfoResponse.ProtoReflect.Descriptor instead. +func (*GetProductInfoResponse) Descriptor() ([]byte, []int) { + return file_product_proto_rawDescGZIP(), []int{1} +} + +func (x *GetProductInfoResponse) GetCode() int32 { + if x != nil { + return x.Code + } + return 0 +} + +func (x *GetProductInfoResponse) GetMsg() string { + if x != nil { + return x.Msg + } + return "" +} + +func (x *GetProductInfoResponse) GetData() *Product { + if x != nil { + return x.Data + } + return nil +} + +type Product struct { + state protoimpl.MessageState + sizeCache protoimpl.SizeCache + unknownFields protoimpl.UnknownFields + + Number string `protobuf:"bytes,1,opt,name=Number,proto3" json:"Number,omitempty"` + Name string `protobuf:"bytes,2,opt,name=Name,proto3" json:"Name,omitempty"` + Unit string `protobuf:"bytes,3,opt,name=Unit,proto3" json:"Unit,omitempty"` + IsSale bool `protobuf:"varint,4,opt,name=IsSale,proto3" json:"IsSale,omitempty"` //鏄惁閿�鍞� + SalePrice float32 `protobuf:"fixed32,5,opt,name=SalePrice,proto3" json:"SalePrice,omitempty"` //閿�鍞环鏍� + Amount float32 `protobuf:"fixed32,6,opt,name=Amount,proto3" json:"Amount,omitempty"` //搴撳瓨鍓╀綑閲� + MinInventory int32 `protobuf:"varint,7,opt,name=MinInventory,proto3" json:"MinInventory,omitempty"` //瀹夊叏搴撳瓨 + MaterialMode string `protobuf:"bytes,8,opt,name=MaterialMode,proto3" json:"MaterialMode,omitempty"` //鐗╂枡绫诲瀷 + PurchaseType string `protobuf:"bytes,9,opt,name=PurchaseType,proto3" json:"PurchaseType,omitempty"` //閲囪喘绫诲瀷 +} + +func (x *Product) Reset() { + *x = Product{} + if protoimpl.UnsafeEnabled { + mi := &file_product_proto_msgTypes[2] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) + } +} + +func (x *Product) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*Product) ProtoMessage() {} + +func (x *Product) ProtoReflect() protoreflect.Message { + mi := &file_product_proto_msgTypes[2] + if protoimpl.UnsafeEnabled && x != nil { + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + if ms.LoadMessageInfo() == nil { + ms.StoreMessageInfo(mi) + } + return ms + } + return mi.MessageOf(x) +} + +// Deprecated: Use Product.ProtoReflect.Descriptor instead. +func (*Product) Descriptor() ([]byte, []int) { + return file_product_proto_rawDescGZIP(), []int{2} +} + +func (x *Product) GetNumber() string { + if x != nil { + return x.Number + } + return "" +} + +func (x *Product) GetName() string { + if x != nil { + return x.Name + } + return "" +} + +func (x *Product) GetUnit() string { + if x != nil { + return x.Unit + } + return "" +} + +func (x *Product) GetIsSale() bool { + if x != nil { + return x.IsSale + } + return false +} + +func (x *Product) GetSalePrice() float32 { + if x != nil { + return x.SalePrice + } + return 0 +} + +func (x *Product) GetAmount() float32 { + if x != nil { + return x.Amount + } + return 0 +} + +func (x *Product) GetMinInventory() int32 { + if x != nil { + return x.MinInventory + } + return 0 +} + +func (x *Product) GetMaterialMode() string { + if x != nil { + return x.MaterialMode + } + return "" +} + +func (x *Product) GetPurchaseType() string { + if x != nil { + return x.PurchaseType + } + return "" +} + +type GetProductListRequest struct { + state protoimpl.MessageState + sizeCache protoimpl.SizeCache + unknownFields protoimpl.UnknownFields + + Page int32 `protobuf:"varint,1,opt,name=page,proto3" json:"page,omitempty"` + PageSize int32 `protobuf:"varint,2,opt,name=pageSize,proto3" json:"pageSize,omitempty"` + ProductNumber string `protobuf:"bytes,3,opt,name=ProductNumber,proto3" json:"ProductNumber,omitempty"` + ProductName string `protobuf:"bytes,4,opt,name=ProductName,proto3" json:"ProductName,omitempty"` +} + +func (x *GetProductListRequest) Reset() { + *x = GetProductListRequest{} + if protoimpl.UnsafeEnabled { + mi := &file_product_proto_msgTypes[3] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) + } +} + +func (x *GetProductListRequest) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*GetProductListRequest) ProtoMessage() {} + +func (x *GetProductListRequest) ProtoReflect() protoreflect.Message { + mi := &file_product_proto_msgTypes[3] + if protoimpl.UnsafeEnabled && x != nil { + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + if ms.LoadMessageInfo() == nil { + ms.StoreMessageInfo(mi) + } + return ms + } + return mi.MessageOf(x) +} + +// Deprecated: Use GetProductListRequest.ProtoReflect.Descriptor instead. +func (*GetProductListRequest) Descriptor() ([]byte, []int) { + return file_product_proto_rawDescGZIP(), []int{3} +} + +func (x *GetProductListRequest) GetPage() int32 { + if x != nil { + return x.Page + } + return 0 +} + +func (x *GetProductListRequest) GetPageSize() int32 { + if x != nil { + return x.PageSize + } + return 0 +} + +func (x *GetProductListRequest) GetProductNumber() string { + if x != nil { + return x.ProductNumber + } + return "" +} + +func (x *GetProductListRequest) GetProductName() string { + if x != nil { + return x.ProductName + } + return "" +} + +type GetProductListResponse struct { + state protoimpl.MessageState + sizeCache protoimpl.SizeCache + unknownFields protoimpl.UnknownFields + + Code int32 `protobuf:"varint,1,opt,name=Code,proto3" json:"Code,omitempty"` + Msg string `protobuf:"bytes,2,opt,name=Msg,proto3" json:"Msg,omitempty"` + List []*Product `protobuf:"bytes,3,rep,name=List,proto3" json:"List,omitempty"` + Total int64 `protobuf:"varint,4,opt,name=Total,proto3" json:"Total,omitempty"` +} + +func (x *GetProductListResponse) Reset() { + *x = GetProductListResponse{} + if protoimpl.UnsafeEnabled { + mi := &file_product_proto_msgTypes[4] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) + } +} + +func (x *GetProductListResponse) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*GetProductListResponse) ProtoMessage() {} + +func (x *GetProductListResponse) ProtoReflect() protoreflect.Message { + mi := &file_product_proto_msgTypes[4] + if protoimpl.UnsafeEnabled && x != nil { + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + if ms.LoadMessageInfo() == nil { + ms.StoreMessageInfo(mi) + } + return ms + } + return mi.MessageOf(x) +} + +// Deprecated: Use GetProductListResponse.ProtoReflect.Descriptor instead. +func (*GetProductListResponse) Descriptor() ([]byte, []int) { + return file_product_proto_rawDescGZIP(), []int{4} +} + +func (x *GetProductListResponse) GetCode() int32 { + if x != nil { + return x.Code + } + return 0 +} + +func (x *GetProductListResponse) GetMsg() string { + if x != nil { + return x.Msg + } + return "" +} + +func (x *GetProductListResponse) GetList() []*Product { + if x != nil { + return x.List + } + return nil +} + +func (x *GetProductListResponse) GetTotal() int64 { + if x != nil { + return x.Total + } + return 0 +} + +var File_product_proto protoreflect.FileDescriptor + +var file_product_proto_rawDesc = []byte{ + 0x0a, 0x0d, 0x70, 0x72, 0x6f, 0x64, 0x75, 0x63, 0x74, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x22, + 0x35, 0x0a, 0x15, 0x47, 0x65, 0x74, 0x50, 0x72, 0x6f, 0x64, 0x75, 0x63, 0x74, 0x49, 0x6e, 0x66, + 0x6f, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x12, 0x1c, 0x0a, 0x09, 0x50, 0x72, 0x6f, 0x64, + 0x75, 0x63, 0x74, 0x49, 0x64, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x09, 0x50, 0x72, 0x6f, + 0x64, 0x75, 0x63, 0x74, 0x49, 0x64, 0x22, 0x5c, 0x0a, 0x16, 0x47, 0x65, 0x74, 0x50, 0x72, 0x6f, + 0x64, 0x75, 0x63, 0x74, 0x49, 0x6e, 0x66, 0x6f, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, + 0x12, 0x12, 0x0a, 0x04, 0x43, 0x6f, 0x64, 0x65, 0x18, 0x01, 0x20, 0x01, 0x28, 0x05, 0x52, 0x04, + 0x43, 0x6f, 0x64, 0x65, 0x12, 0x10, 0x0a, 0x03, 0x4d, 0x73, 0x67, 0x18, 0x02, 0x20, 0x01, 0x28, + 0x09, 0x52, 0x03, 0x4d, 0x73, 0x67, 0x12, 0x1c, 0x0a, 0x04, 0x44, 0x61, 0x74, 0x61, 0x18, 0x03, + 0x20, 0x01, 0x28, 0x0b, 0x32, 0x08, 0x2e, 0x50, 0x72, 0x6f, 0x64, 0x75, 0x63, 0x74, 0x52, 0x04, + 0x44, 0x61, 0x74, 0x61, 0x22, 0x83, 0x02, 0x0a, 0x07, 0x50, 0x72, 0x6f, 0x64, 0x75, 0x63, 0x74, + 0x12, 0x16, 0x0a, 0x06, 0x4e, 0x75, 0x6d, 0x62, 0x65, 0x72, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, + 0x52, 0x06, 0x4e, 0x75, 0x6d, 0x62, 0x65, 0x72, 0x12, 0x12, 0x0a, 0x04, 0x4e, 0x61, 0x6d, 0x65, + 0x18, 0x02, 0x20, 0x01, 0x28, 0x09, 0x52, 0x04, 0x4e, 0x61, 0x6d, 0x65, 0x12, 0x12, 0x0a, 0x04, + 0x55, 0x6e, 0x69, 0x74, 0x18, 0x03, 0x20, 0x01, 0x28, 0x09, 0x52, 0x04, 0x55, 0x6e, 0x69, 0x74, + 0x12, 0x16, 0x0a, 0x06, 0x49, 0x73, 0x53, 0x61, 0x6c, 0x65, 0x18, 0x04, 0x20, 0x01, 0x28, 0x08, + 0x52, 0x06, 0x49, 0x73, 0x53, 0x61, 0x6c, 0x65, 0x12, 0x1c, 0x0a, 0x09, 0x53, 0x61, 0x6c, 0x65, + 0x50, 0x72, 0x69, 0x63, 0x65, 0x18, 0x05, 0x20, 0x01, 0x28, 0x02, 0x52, 0x09, 0x53, 0x61, 0x6c, + 0x65, 0x50, 0x72, 0x69, 0x63, 0x65, 0x12, 0x16, 0x0a, 0x06, 0x41, 0x6d, 0x6f, 0x75, 0x6e, 0x74, + 0x18, 0x06, 0x20, 0x01, 0x28, 0x02, 0x52, 0x06, 0x41, 0x6d, 0x6f, 0x75, 0x6e, 0x74, 0x12, 0x22, + 0x0a, 0x0c, 0x4d, 0x69, 0x6e, 0x49, 0x6e, 0x76, 0x65, 0x6e, 0x74, 0x6f, 0x72, 0x79, 0x18, 0x07, + 0x20, 0x01, 0x28, 0x05, 0x52, 0x0c, 0x4d, 0x69, 0x6e, 0x49, 0x6e, 0x76, 0x65, 0x6e, 0x74, 0x6f, + 0x72, 0x79, 0x12, 0x22, 0x0a, 0x0c, 0x4d, 0x61, 0x74, 0x65, 0x72, 0x69, 0x61, 0x6c, 0x4d, 0x6f, + 0x64, 0x65, 0x18, 0x08, 0x20, 0x01, 0x28, 0x09, 0x52, 0x0c, 0x4d, 0x61, 0x74, 0x65, 0x72, 0x69, + 0x61, 0x6c, 0x4d, 0x6f, 0x64, 0x65, 0x12, 0x22, 0x0a, 0x0c, 0x50, 0x75, 0x72, 0x63, 0x68, 0x61, + 0x73, 0x65, 0x54, 0x79, 0x70, 0x65, 0x18, 0x09, 0x20, 0x01, 0x28, 0x09, 0x52, 0x0c, 0x50, 0x75, + 0x72, 0x63, 0x68, 0x61, 0x73, 0x65, 0x54, 0x79, 0x70, 0x65, 0x22, 0x8f, 0x01, 0x0a, 0x15, 0x47, + 0x65, 0x74, 0x50, 0x72, 0x6f, 0x64, 0x75, 0x63, 0x74, 0x4c, 0x69, 0x73, 0x74, 0x52, 0x65, 0x71, + 0x75, 0x65, 0x73, 0x74, 0x12, 0x12, 0x0a, 0x04, 0x70, 0x61, 0x67, 0x65, 0x18, 0x01, 0x20, 0x01, + 0x28, 0x05, 0x52, 0x04, 0x70, 0x61, 0x67, 0x65, 0x12, 0x1a, 0x0a, 0x08, 0x70, 0x61, 0x67, 0x65, + 0x53, 0x69, 0x7a, 0x65, 0x18, 0x02, 0x20, 0x01, 0x28, 0x05, 0x52, 0x08, 0x70, 0x61, 0x67, 0x65, + 0x53, 0x69, 0x7a, 0x65, 0x12, 0x24, 0x0a, 0x0d, 0x50, 0x72, 0x6f, 0x64, 0x75, 0x63, 0x74, 0x4e, + 0x75, 0x6d, 0x62, 0x65, 0x72, 0x18, 0x03, 0x20, 0x01, 0x28, 0x09, 0x52, 0x0d, 0x50, 0x72, 0x6f, + 0x64, 0x75, 0x63, 0x74, 0x4e, 0x75, 0x6d, 0x62, 0x65, 0x72, 0x12, 0x20, 0x0a, 0x0b, 0x50, 0x72, + 0x6f, 0x64, 0x75, 0x63, 0x74, 0x4e, 0x61, 0x6d, 0x65, 0x18, 0x04, 0x20, 0x01, 0x28, 0x09, 0x52, + 0x0b, 0x50, 0x72, 0x6f, 0x64, 0x75, 0x63, 0x74, 0x4e, 0x61, 0x6d, 0x65, 0x22, 0x72, 0x0a, 0x16, + 0x47, 0x65, 0x74, 0x50, 0x72, 0x6f, 0x64, 0x75, 0x63, 0x74, 0x4c, 0x69, 0x73, 0x74, 0x52, 0x65, + 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x12, 0x12, 0x0a, 0x04, 0x43, 0x6f, 0x64, 0x65, 0x18, 0x01, + 0x20, 0x01, 0x28, 0x05, 0x52, 0x04, 0x43, 0x6f, 0x64, 0x65, 0x12, 0x10, 0x0a, 0x03, 0x4d, 0x73, + 0x67, 0x18, 0x02, 0x20, 0x01, 0x28, 0x09, 0x52, 0x03, 0x4d, 0x73, 0x67, 0x12, 0x1c, 0x0a, 0x04, + 0x4c, 0x69, 0x73, 0x74, 0x18, 0x03, 0x20, 0x03, 0x28, 0x0b, 0x32, 0x08, 0x2e, 0x50, 0x72, 0x6f, + 0x64, 0x75, 0x63, 0x74, 0x52, 0x04, 0x4c, 0x69, 0x73, 0x74, 0x12, 0x14, 0x0a, 0x05, 0x54, 0x6f, + 0x74, 0x61, 0x6c, 0x18, 0x04, 0x20, 0x01, 0x28, 0x03, 0x52, 0x05, 0x54, 0x6f, 0x74, 0x61, 0x6c, + 0x32, 0x9a, 0x01, 0x0a, 0x0e, 0x70, 0x72, 0x6f, 0x64, 0x75, 0x63, 0x74, 0x53, 0x65, 0x72, 0x76, + 0x69, 0x63, 0x65, 0x12, 0x43, 0x0a, 0x0e, 0x47, 0x65, 0x74, 0x50, 0x72, 0x6f, 0x64, 0x75, 0x63, + 0x74, 0x49, 0x6e, 0x66, 0x6f, 0x12, 0x16, 0x2e, 0x47, 0x65, 0x74, 0x50, 0x72, 0x6f, 0x64, 0x75, + 0x63, 0x74, 0x49, 0x6e, 0x66, 0x6f, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x17, 0x2e, + 0x47, 0x65, 0x74, 0x50, 0x72, 0x6f, 0x64, 0x75, 0x63, 0x74, 0x49, 0x6e, 0x66, 0x6f, 0x52, 0x65, + 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x22, 0x00, 0x12, 0x43, 0x0a, 0x0e, 0x47, 0x65, 0x74, 0x50, + 0x72, 0x6f, 0x64, 0x75, 0x63, 0x74, 0x4c, 0x69, 0x73, 0x74, 0x12, 0x16, 0x2e, 0x47, 0x65, 0x74, + 0x50, 0x72, 0x6f, 0x64, 0x75, 0x63, 0x74, 0x4c, 0x69, 0x73, 0x74, 0x52, 0x65, 0x71, 0x75, 0x65, + 0x73, 0x74, 0x1a, 0x17, 0x2e, 0x47, 0x65, 0x74, 0x50, 0x72, 0x6f, 0x64, 0x75, 0x63, 0x74, 0x4c, + 0x69, 0x73, 0x74, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x22, 0x00, 0x42, 0x0b, 0x5a, + 0x09, 0x2e, 0x2f, 0x70, 0x72, 0x6f, 0x64, 0x75, 0x63, 0x74, 0x62, 0x06, 0x70, 0x72, 0x6f, 0x74, + 0x6f, 0x33, +} + +var ( + file_product_proto_rawDescOnce sync.Once + file_product_proto_rawDescData = file_product_proto_rawDesc +) + +func file_product_proto_rawDescGZIP() []byte { + file_product_proto_rawDescOnce.Do(func() { + file_product_proto_rawDescData = protoimpl.X.CompressGZIP(file_product_proto_rawDescData) + }) + return file_product_proto_rawDescData +} + +var file_product_proto_msgTypes = make([]protoimpl.MessageInfo, 5) +var file_product_proto_goTypes = []interface{}{ + (*GetProductInfoRequest)(nil), // 0: GetProductInfoRequest + (*GetProductInfoResponse)(nil), // 1: GetProductInfoResponse + (*Product)(nil), // 2: Product + (*GetProductListRequest)(nil), // 3: GetProductListRequest + (*GetProductListResponse)(nil), // 4: GetProductListResponse +} +var file_product_proto_depIdxs = []int32{ + 2, // 0: GetProductInfoResponse.Data:type_name -> Product + 2, // 1: GetProductListResponse.List:type_name -> Product + 0, // 2: productService.GetProductInfo:input_type -> GetProductInfoRequest + 3, // 3: productService.GetProductList:input_type -> GetProductListRequest + 1, // 4: productService.GetProductInfo:output_type -> GetProductInfoResponse + 4, // 5: productService.GetProductList:output_type -> GetProductListResponse + 4, // [4:6] is the sub-list for method output_type + 2, // [2:4] is the sub-list for method input_type + 2, // [2:2] is the sub-list for extension type_name + 2, // [2:2] is the sub-list for extension extendee + 0, // [0:2] is the sub-list for field type_name +} + +func init() { file_product_proto_init() } +func file_product_proto_init() { + if File_product_proto != nil { + return + } + if !protoimpl.UnsafeEnabled { + file_product_proto_msgTypes[0].Exporter = func(v interface{}, i int) interface{} { + switch v := v.(*GetProductInfoRequest); i { + case 0: + return &v.state + case 1: + return &v.sizeCache + case 2: + return &v.unknownFields + default: + return nil + } + } + file_product_proto_msgTypes[1].Exporter = func(v interface{}, i int) interface{} { + switch v := v.(*GetProductInfoResponse); i { + case 0: + return &v.state + case 1: + return &v.sizeCache + case 2: + return &v.unknownFields + default: + return nil + } + } + file_product_proto_msgTypes[2].Exporter = func(v interface{}, i int) interface{} { + switch v := v.(*Product); i { + case 0: + return &v.state + case 1: + return &v.sizeCache + case 2: + return &v.unknownFields + default: + return nil + } + } + file_product_proto_msgTypes[3].Exporter = func(v interface{}, i int) interface{} { + switch v := v.(*GetProductListRequest); i { + case 0: + return &v.state + case 1: + return &v.sizeCache + case 2: + return &v.unknownFields + default: + return nil + } + } + file_product_proto_msgTypes[4].Exporter = func(v interface{}, i int) interface{} { + switch v := v.(*GetProductListResponse); i { + case 0: + return &v.state + case 1: + return &v.sizeCache + case 2: + return &v.unknownFields + default: + return nil + } + } + } + type x struct{} + out := protoimpl.TypeBuilder{ + File: protoimpl.DescBuilder{ + GoPackagePath: reflect.TypeOf(x{}).PkgPath(), + RawDescriptor: file_product_proto_rawDesc, + NumEnums: 0, + NumMessages: 5, + NumExtensions: 0, + NumServices: 1, + }, + GoTypes: file_product_proto_goTypes, + DependencyIndexes: file_product_proto_depIdxs, + MessageInfos: file_product_proto_msgTypes, + }.Build() + File_product_proto = out.File + file_product_proto_rawDesc = nil + file_product_proto_goTypes = nil + file_product_proto_depIdxs = nil +} diff --git a/proto/product/product_grpc.pb.go b/proto/product/product_grpc.pb.go new file mode 100644 index 0000000..16e851e --- /dev/null +++ b/proto/product/product_grpc.pb.go @@ -0,0 +1,146 @@ +// Code generated by protoc-gen-go-grpc. DO NOT EDIT. +// versions: +// - protoc-gen-go-grpc v1.3.0 +// - protoc v3.19.0 +// source: product.proto + +package product + +import ( + context "context" + grpc "google.golang.org/grpc" + codes "google.golang.org/grpc/codes" + status "google.golang.org/grpc/status" +) + +// This is a compile-time assertion to ensure that this generated file +// is compatible with the grpc package it is being compiled against. +// Requires gRPC-Go v1.32.0 or later. +const _ = grpc.SupportPackageIsVersion7 + +const ( + ProductService_GetProductInfo_FullMethodName = "/productService/GetProductInfo" + ProductService_GetProductList_FullMethodName = "/productService/GetProductList" +) + +// ProductServiceClient is the client API for ProductService service. +// +// For semantics around ctx use and closing/ending streaming RPCs, please refer to https://pkg.go.dev/google.golang.org/grpc/?tab=doc#ClientConn.NewStream. +type ProductServiceClient interface { + GetProductInfo(ctx context.Context, in *GetProductInfoRequest, opts ...grpc.CallOption) (*GetProductInfoResponse, error) + GetProductList(ctx context.Context, in *GetProductListRequest, opts ...grpc.CallOption) (*GetProductListResponse, error) +} + +type productServiceClient struct { + cc grpc.ClientConnInterface +} + +func NewProductServiceClient(cc grpc.ClientConnInterface) ProductServiceClient { + return &productServiceClient{cc} +} + +func (c *productServiceClient) GetProductInfo(ctx context.Context, in *GetProductInfoRequest, opts ...grpc.CallOption) (*GetProductInfoResponse, error) { + out := new(GetProductInfoResponse) + err := c.cc.Invoke(ctx, ProductService_GetProductInfo_FullMethodName, in, out, opts...) + if err != nil { + return nil, err + } + return out, nil +} + +func (c *productServiceClient) GetProductList(ctx context.Context, in *GetProductListRequest, opts ...grpc.CallOption) (*GetProductListResponse, error) { + out := new(GetProductListResponse) + err := c.cc.Invoke(ctx, ProductService_GetProductList_FullMethodName, in, out, opts...) + if err != nil { + return nil, err + } + return out, nil +} + +// ProductServiceServer is the server API for ProductService service. +// All implementations must embed UnimplementedProductServiceServer +// for forward compatibility +type ProductServiceServer interface { + GetProductInfo(context.Context, *GetProductInfoRequest) (*GetProductInfoResponse, error) + GetProductList(context.Context, *GetProductListRequest) (*GetProductListResponse, error) + mustEmbedUnimplementedProductServiceServer() +} + +// UnimplementedProductServiceServer must be embedded to have forward compatible implementations. +type UnimplementedProductServiceServer struct { +} + +func (UnimplementedProductServiceServer) GetProductInfo(context.Context, *GetProductInfoRequest) (*GetProductInfoResponse, error) { + return nil, status.Errorf(codes.Unimplemented, "method GetProductInfo not implemented") +} +func (UnimplementedProductServiceServer) GetProductList(context.Context, *GetProductListRequest) (*GetProductListResponse, error) { + return nil, status.Errorf(codes.Unimplemented, "method GetProductList not implemented") +} +func (UnimplementedProductServiceServer) mustEmbedUnimplementedProductServiceServer() {} + +// UnsafeProductServiceServer may be embedded to opt out of forward compatibility for this service. +// Use of this interface is not recommended, as added methods to ProductServiceServer will +// result in compilation errors. +type UnsafeProductServiceServer interface { + mustEmbedUnimplementedProductServiceServer() +} + +func RegisterProductServiceServer(s grpc.ServiceRegistrar, srv ProductServiceServer) { + s.RegisterService(&ProductService_ServiceDesc, srv) +} + +func _ProductService_GetProductInfo_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { + in := new(GetProductInfoRequest) + if err := dec(in); err != nil { + return nil, err + } + if interceptor == nil { + return srv.(ProductServiceServer).GetProductInfo(ctx, in) + } + info := &grpc.UnaryServerInfo{ + Server: srv, + FullMethod: ProductService_GetProductInfo_FullMethodName, + } + handler := func(ctx context.Context, req interface{}) (interface{}, error) { + return srv.(ProductServiceServer).GetProductInfo(ctx, req.(*GetProductInfoRequest)) + } + return interceptor(ctx, in, info, handler) +} + +func _ProductService_GetProductList_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { + in := new(GetProductListRequest) + if err := dec(in); err != nil { + return nil, err + } + if interceptor == nil { + return srv.(ProductServiceServer).GetProductList(ctx, in) + } + info := &grpc.UnaryServerInfo{ + Server: srv, + FullMethod: ProductService_GetProductList_FullMethodName, + } + handler := func(ctx context.Context, req interface{}) (interface{}, error) { + return srv.(ProductServiceServer).GetProductList(ctx, req.(*GetProductListRequest)) + } + return interceptor(ctx, in, info, handler) +} + +// ProductService_ServiceDesc is the grpc.ServiceDesc for ProductService service. +// It's only intended for direct use with grpc.RegisterService, +// and not to be introspected or modified (even as a copy) +var ProductService_ServiceDesc = grpc.ServiceDesc{ + ServiceName: "productService", + HandlerType: (*ProductServiceServer)(nil), + Methods: []grpc.MethodDesc{ + { + MethodName: "GetProductInfo", + Handler: _ProductService_GetProductInfo_Handler, + }, + { + MethodName: "GetProductList", + Handler: _ProductService_GetProductList_Handler, + }, + }, + Streams: []grpc.StreamDesc{}, + Metadata: "product.proto", +} diff --git a/router/file.go b/router/file.go index 3946e5d..a44ff23 100644 --- a/router/file.go +++ b/router/file.go @@ -11,6 +11,8 @@ { FileRouter.POST("add", FileApi.Add) // 娣诲姞闄勪欢 FileRouter.DELETE("delete/:id", FileApi.Delete) // 鍒犻櫎闄勪欢 - FileRouter.GET("list", FileApi.List) // 闄勪欢鍒楄〃 + //FileRouter.GET("list", FileApi.List) // 闄勪欢鍒楄〃 + FileRouter.POST("download", FileApi.Download) // 闄勪欢涓嬭浇 + FileRouter.POST("preview", FileApi.Preview) // 闄勪欢棰勮 } } diff --git a/router/index.go b/router/index.go index 8d830e5..1b0ecd3 100644 --- a/router/index.go +++ b/router/index.go @@ -175,6 +175,7 @@ InitInvoiceStatusRouter(PrivateGroup) InitInvoiceTypeRouter(PrivateGroup) InitCourierCompanyRouter(PrivateGroup) + InitProductRouter(PrivateGroup) } return Router diff --git a/router/product.go b/router/product.go new file mode 100644 index 0000000..7add36b --- /dev/null +++ b/router/product.go @@ -0,0 +1,15 @@ +package router + +import ( + v1 "aps_crm/api/v1" + "github.com/gin-gonic/gin" +) + +func InitProductRouter(router *gin.RouterGroup) { + productRouter := router.Group("product") + productApi := v1.ProductApi{} + { + productRouter.GET("info", productApi.Info) // 浜у搧璇︽儏 + productRouter.GET("list", productApi.List) // 浜у搧鍒楄〃 + } +} diff --git a/service/file.go b/service/file.go index 584aa11..4ed8750 100644 --- a/service/file.go +++ b/service/file.go @@ -12,6 +12,15 @@ return FileService{} } +func (FileService) GetFile(id uint) (*model.File, int) { + file, err := model.NewFileSearch().SetId(id).First() + if err != nil { + return nil, ecode.DBErr + } + + return file, ecode.OK +} + func (FileService) AddFile(fileRecord *model.File) int { err := model.NewFileSearch().Create(fileRecord) -- Gitblit v1.8.0