Merge branch 'master' of http://192.168.5.5:10010/r/aps/SRM
# Conflicts:
# main.go
# model/purchase/purchase_products.go
# model/test/product.go
| | |
| | | |
| | | import ( |
| | | "github.com/gin-gonic/gin" |
| | | "github.com/spf13/cast" |
| | | "go.uber.org/zap" |
| | | "google.golang.org/grpc" |
| | | "google.golang.org/grpc/credentials/insecure" |
| | |
| | | "srm/model/common/response" |
| | | "srm/model/test" |
| | | testReq "srm/model/test/request" |
| | | "srm/proto/product" |
| | | testResp "srm/model/test/response" |
| | | "srm/service" |
| | | ) |
| | | |
| | |
| | | } |
| | | for _, t := range p.List { |
| | | var num int64 |
| | | db := global.GVA_DB.Model(&test.Product{}) |
| | | db := global.GVA_DB.Model(&test.SupplierMaterial{}) |
| | | err := db.Where("number = ?", t.Number).Where("supplier_id = ?", t.SupplierId).Count(&num).Error |
| | | if err != nil { |
| | | response.FailWithMessage(err.Error(), c) |
| | |
| | | // @Security ApiKeyAuth |
| | | // @accept application/json |
| | | // @Produce application/json |
| | | // @Param data body test.Product true "删除Product" |
| | | // @Param data body request.GetById true "删除Product" |
| | | // @Success 200 {string} string "{"success":true,"data":{},"msg":"删除成功"}" |
| | | // @Router /p/deleteProduct [delete] |
| | | func (pApi *ProductApi) DeleteProduct(c *gin.Context) { |
| | | var p test.Product |
| | | var p request.GetById |
| | | err := c.ShouldBindJSON(&p) |
| | | if err != nil { |
| | | response.FailWithMessage(err.Error(), c) |
| | | return |
| | | } |
| | | if err := pService.DeleteProduct(p); err != nil { |
| | | if err := pService.DeleteProduct(p.ID); err != nil { |
| | | global.GVA_LOG.Error("删除失败!", zap.Error(err)) |
| | | response.FailWithMessage("删除失败", c) |
| | | } else { |
| | |
| | | // @Security ApiKeyAuth |
| | | // @accept application/json |
| | | // @Produce application/json |
| | | // @Param data body test.Product true "更新Product" |
| | | // @Param data body test.SupplierMaterial true "更新Product" |
| | | // @Success 200 {string} string "{"success":true,"data":{},"msg":"更新成功"}" |
| | | // @Router /p/updateProduct [put] |
| | | func (pApi *ProductApi) UpdateProduct(c *gin.Context) { |
| | | var p test.Product |
| | | var p test.SupplierMaterial |
| | | err := c.ShouldBindJSON(&p) |
| | | if err != nil { |
| | | response.FailWithMessage(err.Error(), c) |
| | |
| | | // @Security ApiKeyAuth |
| | | // @accept application/json |
| | | // @Produce application/json |
| | | // @Param data query test.Product true "用id查询Product" |
| | | // @Param data query request.GetById true "用id查询Product" |
| | | // @Success 200 {string} string "{"success":true,"data":{},"msg":"查询成功"}" |
| | | // @Router /p/findProduct [get] |
| | | func (pApi *ProductApi) FindProduct(c *gin.Context) { |
| | | var p test.Product |
| | | var p request.GetById |
| | | err := c.ShouldBindQuery(&p) |
| | | if err != nil { |
| | | response.FailWithMessage(err.Error(), c) |
| | |
| | | response.FailWithMessage(err.Error(), c) |
| | | return |
| | | } |
| | | if list, total, err := pService.GetProductInfoList(pageInfo); err != nil { |
| | | list, total, err := pService.GetProductInfoList(pageInfo) |
| | | if err != nil { |
| | | global.GVA_LOG.Error("获取失败!", zap.Error(err)) |
| | | response.FailWithMessage("获取失败", c) |
| | | } else { |
| | | //添加供应商名称 |
| | | for i := 0; i < len(list); i++ { |
| | | list[i].SupplierName = list[i].Supplier.Name |
| | | } |
| | | response.OkWithDetailed(response.PageResult{ |
| | | List: list, |
| | | Total: total, |
| | | Page: pageInfo.Page, |
| | | PageSize: pageInfo.PageSize, |
| | | }, "获取成功", c) |
| | | return |
| | | } |
| | | |
| | | productList := make([]testResp.Product, 0, len(list)) |
| | | |
| | | for _, item := range list { |
| | | productList = append(productList, testResp.Product{ |
| | | Name: item.Name, |
| | | Number: item.Number, |
| | | SupplierId: item.SupplierId, |
| | | Unit: item.Unit, |
| | | PurchasePrice: item.PurchasePrice, |
| | | DeliveryTime: item.DeliveryTime, |
| | | ShippingDuration: item.ShippingDuration, |
| | | Specifications: item.Specifications, |
| | | ModelNumber: item.ModelNumber, |
| | | ProductType: "", |
| | | MinimumStock: item.MinimumStock, |
| | | MaximumStock: item.MaximumStock, |
| | | Remark: "", |
| | | SupplierName: item.Supplier.Name, |
| | | CategoryName: item.CategoryName, |
| | | }) |
| | | } |
| | | |
| | | response.OkWithDetailed(response.PageResult{ |
| | | List: list, |
| | | Total: total, |
| | | Page: pageInfo.Page, |
| | | PageSize: pageInfo.PageSize, |
| | | }, "获取成功", c) |
| | | } |
| | | |
| | | var ( |
| | |
| | | return |
| | | } |
| | | |
| | | cli := product.NewProductServiceClient(productServiceConn) |
| | | getProductListResponse, err := cli.GetProductList(c, &product.GetProductListRequest{ |
| | | Page: cast.ToInt32(pageInfo.Page), |
| | | PageSize: cast.ToInt32(pageInfo.PageSize), |
| | | ProductNumber: pageInfo.Number, |
| | | ProductName: pageInfo.Name, |
| | | }) |
| | | rawProductList := getProductListResponse.List |
| | | productList := make([]test.Product, len(rawProductList)) |
| | | |
| | | for k, v := range rawProductList { |
| | | productList[k].Number = v.Number |
| | | productList[k].Name = v.Name |
| | | productList[k].Unit = v.Unit |
| | | productList[k].PurchasePrice = v.SalePrice |
| | | min := int(v.MinInventory) |
| | | productList[k].MinimumStock = min |
| | | max := int(v.MaxInventory) |
| | | productList[k].MaximumStock = max |
| | | productList[k].Remark = v.Node |
| | | productList[k].ProductType = v.MaterialMode |
| | | } |
| | | |
| | | if err != nil || getProductListResponse.Code != 0 { |
| | | list, total, err := pService.GetMaterials(pageInfo) |
| | | if err != nil { |
| | | global.GVA_LOG.Error("获取失败!", zap.Error(err)) |
| | | response.FailWithMessage("获取失败", c) |
| | | } else { |
| | | response.OkWithDetailed(response.PageResult{ |
| | | List: productList, |
| | | Total: int64(len(productList)), |
| | | Page: pageInfo.Page, |
| | | PageSize: pageInfo.PageSize, |
| | | }, "获取成功", c) |
| | | return |
| | | } |
| | | |
| | | productList := make([]testResp.Material, len(list)) |
| | | |
| | | for _, item := range list { |
| | | productList = append(productList, testResp.Material{ |
| | | Name: item.Name, |
| | | Number: item.ID, |
| | | Unit: item.Unit, |
| | | Specifications: item.Specs, |
| | | ModelNumber: string(item.Model), |
| | | MinimumStock: item.MinInventory.IntPart(), |
| | | MaximumStock: item.MaxInventory.IntPart(), |
| | | Remark: "", |
| | | CategoryName: item.CategoryName, |
| | | }) |
| | | } |
| | | |
| | | if err != nil { |
| | | global.GVA_LOG.Error("获取失败!", zap.Error(err)) |
| | | response.FailWithMessage("获取失败", c) |
| | | } |
| | | |
| | | response.OkWithDetailed(response.PageResult{ |
| | | List: productList, |
| | | Total: total, |
| | | Page: pageInfo.Page, |
| | | PageSize: pageInfo.PageSize, |
| | | }, "获取成功", c) |
| | | |
| | | } |
| | |
| | | singular: false |
| | | log-zap: false |
| | | disable: true |
| | | mssql: |
| | | prefix: "" |
| | | port: "" |
| | | config: "" |
| | | db-name: "" |
| | | username: "" |
| | | password: "" |
| | | path: "" |
| | | engine: "" |
| | | log-mode: "" |
| | | max-idle-conns: 10 |
| | | max-open-conns: 100 |
| | | singular: false |
| | | log-zap: false |
| | | mysql: |
| | | prefix: "" |
| | | port: "3306" |
| | |
| | | password: c++java123 |
| | | path: 192.168.20.119 |
| | | engine: "" |
| | | log-mode: error |
| | | log-mode: info |
| | | max-idle-conns: 10 |
| | | max-open-conns: 100 |
| | | singular: false |
| | | log-zap: false |
| | | oracle: |
| | | prefix: "" |
| | | port: "" |
| | | config: "" |
| | | db-name: "" |
| | | username: "" |
| | | password: "" |
| | | path: "" |
| | | engine: "" |
| | | log-mode: "" |
| | | max-idle-conns: 10 |
| | | max-open-conns: 100 |
| | | singular: false |
| | | log-zap: false |
| | | pgsql: |
| | | prefix: "" |
| | | port: "" |
| | | config: "" |
| | | db-name: "" |
| | | username: "" |
| | | password: "" |
| | | path: "" |
| | | engine: "" |
| | | log-mode: "" |
| | | max-idle-conns: 10 |
| | | max-open-conns: 100 |
| | | singular: false |
| | | log-zap: false |
| | | sqlite: |
| | | prefix: "" |
| | | port: "" |
| | | config: "" |
| | | db-name: "" |
| | | username: "" |
| | | password: "" |
| | | path: "" |
| | | engine: "" |
| | | log-mode: "" |
| | | max-idle-conns: 10 |
| | | max-open-conns: 100 |
| | | singular: false |
| | | log-zap: false |
| | | log-zap: true |
| | | system: |
| | | env: public |
| | | db-type: mysql |
| | |
| | | start: true |
| | | with_seconds: false |
| | | zap: |
| | | level: info |
| | | level: debug |
| | | prefix: '[srm]' |
| | | format: console |
| | | director: log |
| | |
| | | // Author [SliverHorn](https://github.com/SliverHorn) |
| | | func (r *fileRotatelogs) GetWriteSyncer(level string) (zapcore.WriteSyncer, error) { |
| | | fileWriter, err := rotatelogs.New( |
| | | path.Join(global.GVA_CONFIG.Zap.Director, "%Y-%m-%d", level+".log"), |
| | | path.Join(global.GVA_CONFIG.Zap.Director, level+".log"), |
| | | rotatelogs.WithClock(rotatelogs.Local), |
| | | rotatelogs.WithMaxAge(time.Duration(global.GVA_CONFIG.Zap.MaxAge)*24*time.Hour), // 日志留存时间 |
| | | rotatelogs.WithRotationTime(time.Hour*24), |
| | |
| | | "in": "body", |
| | | "required": true, |
| | | "schema": { |
| | | "$ref": "#/definitions/test.Product" |
| | | "$ref": "#/definitions/request.GetById" |
| | | } |
| | | } |
| | | ], |
| | |
| | | "summary": "用id查询Product", |
| | | "parameters": [ |
| | | { |
| | | "type": "string", |
| | | "name": "created_at", |
| | | "in": "query" |
| | | }, |
| | | { |
| | | "type": "integer", |
| | | "name": "deliveryTime", |
| | | "in": "query" |
| | | }, |
| | | { |
| | | "type": "integer", |
| | | "description": "主键ID", |
| | | "name": "id", |
| | | "in": "query" |
| | | }, |
| | | { |
| | | "type": "integer", |
| | | "name": "maximumStock", |
| | | "in": "query" |
| | | }, |
| | | { |
| | | "type": "integer", |
| | | "name": "minimumStock", |
| | | "in": "query" |
| | | }, |
| | | { |
| | | "type": "string", |
| | | "name": "modelNumber", |
| | | "in": "query" |
| | | }, |
| | | { |
| | | "type": "string", |
| | | "name": "name", |
| | | "in": "query" |
| | | }, |
| | | { |
| | | "type": "string", |
| | | "name": "number", |
| | | "in": "query" |
| | | }, |
| | | { |
| | | "type": "string", |
| | | "name": "productType", |
| | | "in": "query" |
| | | }, |
| | | { |
| | | "type": "number", |
| | | "name": "purchasePrice", |
| | | "in": "query" |
| | | }, |
| | | { |
| | | "type": "string", |
| | | "name": "remark", |
| | | "in": "query" |
| | | }, |
| | | { |
| | | "type": "integer", |
| | | "name": "shippingDuration", |
| | | "in": "query" |
| | | }, |
| | | { |
| | | "type": "string", |
| | | "name": "specifications", |
| | | "in": "query" |
| | | }, |
| | | { |
| | | "type": "integer", |
| | | "name": "supplierId", |
| | | "in": "query" |
| | | }, |
| | | { |
| | | "type": "string", |
| | | "name": "supplierName", |
| | | "in": "query" |
| | | }, |
| | | { |
| | | "type": "string", |
| | | "name": "unit", |
| | | "in": "query" |
| | | }, |
| | | { |
| | | "type": "string", |
| | | "name": "updated_at", |
| | | "in": "query" |
| | | } |
| | | ], |
| | |
| | | "parameters": [ |
| | | { |
| | | "type": "string", |
| | | "name": "created_at", |
| | | "name": "categoryName", |
| | | "in": "query" |
| | | }, |
| | | { |
| | |
| | | }, |
| | | { |
| | | "type": "string", |
| | | "name": "endCreatedAt", |
| | | "in": "query" |
| | | }, |
| | | { |
| | | "type": "integer", |
| | | "description": "主键ID", |
| | | "name": "id", |
| | | "in": "query" |
| | | }, |
| | | { |
| | | "type": "string", |
| | | "description": "关键字", |
| | | "name": "keyword", |
| | | "in": "query" |
| | | }, |
| | | { |
| | | "type": "integer", |
| | | "name": "maximumStock", |
| | | "in": "query" |
| | | }, |
| | | { |
| | | "type": "integer", |
| | | "name": "minimumStock", |
| | | "in": "query" |
| | | }, |
| | | { |
| | |
| | | "in": "query" |
| | | }, |
| | | { |
| | | "type": "string", |
| | | "name": "productType", |
| | | "in": "query" |
| | | }, |
| | | { |
| | | "type": "number", |
| | | "name": "purchasePrice", |
| | | "in": "query" |
| | | }, |
| | | { |
| | | "type": "string", |
| | | "name": "remark", |
| | | "in": "query" |
| | | }, |
| | | { |
| | |
| | | }, |
| | | { |
| | | "type": "string", |
| | | "name": "startCreatedAt", |
| | | "name": "supplier", |
| | | "in": "query" |
| | | }, |
| | | { |
| | |
| | | { |
| | | "type": "string", |
| | | "name": "unit", |
| | | "in": "query" |
| | | }, |
| | | { |
| | | "type": "string", |
| | | "name": "updated_at", |
| | | "in": "query" |
| | | } |
| | | ], |
| | |
| | | "parameters": [ |
| | | { |
| | | "type": "string", |
| | | "name": "created_at", |
| | | "name": "categoryName", |
| | | "in": "query" |
| | | }, |
| | | { |
| | |
| | | }, |
| | | { |
| | | "type": "string", |
| | | "name": "endCreatedAt", |
| | | "in": "query" |
| | | }, |
| | | { |
| | | "type": "integer", |
| | | "description": "主键ID", |
| | | "name": "id", |
| | | "in": "query" |
| | | }, |
| | | { |
| | | "type": "string", |
| | | "description": "关键字", |
| | | "name": "keyword", |
| | | "in": "query" |
| | | }, |
| | | { |
| | | "type": "integer", |
| | | "name": "maximumStock", |
| | | "in": "query" |
| | | }, |
| | | { |
| | | "type": "integer", |
| | | "name": "minimumStock", |
| | | "in": "query" |
| | | }, |
| | | { |
| | |
| | | "in": "query" |
| | | }, |
| | | { |
| | | "type": "string", |
| | | "name": "productType", |
| | | "in": "query" |
| | | }, |
| | | { |
| | | "type": "number", |
| | | "name": "purchasePrice", |
| | | "in": "query" |
| | | }, |
| | | { |
| | | "type": "string", |
| | | "name": "remark", |
| | | "in": "query" |
| | | }, |
| | | { |
| | |
| | | }, |
| | | { |
| | | "type": "string", |
| | | "name": "startCreatedAt", |
| | | "name": "supplier", |
| | | "in": "query" |
| | | }, |
| | | { |
| | |
| | | { |
| | | "type": "string", |
| | | "name": "unit", |
| | | "in": "query" |
| | | }, |
| | | { |
| | | "type": "string", |
| | | "name": "updated_at", |
| | | "in": "query" |
| | | } |
| | | ], |
| | |
| | | "in": "body", |
| | | "required": true, |
| | | "schema": { |
| | | "$ref": "#/definitions/test.Product" |
| | | "$ref": "#/definitions/test.SupplierMaterial" |
| | | } |
| | | } |
| | | ], |
| | |
| | | }, |
| | | "productId": { |
| | | "description": "产品id", |
| | | "type": "integer" |
| | | "type": "string" |
| | | }, |
| | | "purchaseId": { |
| | | "description": "采购id", |
| | |
| | | } |
| | | } |
| | | }, |
| | | "request.GetById": { |
| | | "type": "object", |
| | | "properties": { |
| | | "id": { |
| | | "description": "主键ID", |
| | | "type": "integer" |
| | | } |
| | | } |
| | | }, |
| | | "request.IdsReq": { |
| | | "type": "object", |
| | | "properties": { |
| | |
| | | } |
| | | } |
| | | }, |
| | | "request.Product": { |
| | | "type": "object", |
| | | "properties": { |
| | | "categoryName": { |
| | | "type": "string" |
| | | }, |
| | | "deliveryTime": { |
| | | "type": "integer" |
| | | }, |
| | | "modelNumber": { |
| | | "type": "string" |
| | | }, |
| | | "name": { |
| | | "type": "string" |
| | | }, |
| | | "number": { |
| | | "type": "string" |
| | | }, |
| | | "purchasePrice": { |
| | | "type": "number" |
| | | }, |
| | | "shippingDuration": { |
| | | "type": "integer" |
| | | }, |
| | | "specifications": { |
| | | "type": "string" |
| | | }, |
| | | "supplier": { |
| | | "type": "string" |
| | | }, |
| | | "supplierId": { |
| | | "type": "integer" |
| | | }, |
| | | "supplierName": { |
| | | "type": "string" |
| | | }, |
| | | "supplierNumber": { |
| | | "type": "string" |
| | | }, |
| | | "unit": { |
| | | "type": "string" |
| | | } |
| | | } |
| | | }, |
| | | "request.ProductCreate": { |
| | | "type": "object", |
| | | "properties": { |
| | | "list": { |
| | | "type": "array", |
| | | "items": { |
| | | "$ref": "#/definitions/test.Product" |
| | | "$ref": "#/definitions/request.Product" |
| | | } |
| | | } |
| | | } |
| | |
| | | } |
| | | } |
| | | }, |
| | | "test.Product": { |
| | | "type": "object", |
| | | "properties": { |
| | | "created_at": { |
| | | "type": "string" |
| | | }, |
| | | "deliveryTime": { |
| | | "type": "integer" |
| | | }, |
| | | "id": { |
| | | "description": "主键ID", |
| | | "type": "integer" |
| | | }, |
| | | "maximumStock": { |
| | | "type": "integer" |
| | | }, |
| | | "minimumStock": { |
| | | "type": "integer" |
| | | }, |
| | | "modelNumber": { |
| | | "type": "string" |
| | | }, |
| | | "name": { |
| | | "type": "string" |
| | | }, |
| | | "number": { |
| | | "type": "string" |
| | | }, |
| | | "productType": { |
| | | "type": "string" |
| | | }, |
| | | "purchasePrice": { |
| | | "type": "number" |
| | | }, |
| | | "remark": { |
| | | "type": "string" |
| | | }, |
| | | "shippingDuration": { |
| | | "type": "integer" |
| | | }, |
| | | "specifications": { |
| | | "type": "string" |
| | | }, |
| | | "supplier": { |
| | | "$ref": "#/definitions/test.Supplier" |
| | | }, |
| | | "supplierId": { |
| | | "type": "integer" |
| | | }, |
| | | "supplierName": { |
| | | "type": "string" |
| | | }, |
| | | "unit": { |
| | | "type": "string" |
| | | }, |
| | | "updated_at": { |
| | | "type": "string" |
| | | } |
| | | } |
| | | }, |
| | | "test.Supplier": { |
| | | "type": "object", |
| | | "properties": { |
| | |
| | | } |
| | | } |
| | | }, |
| | | "test.SupplierMaterial": { |
| | | "type": "object", |
| | | "properties": { |
| | | "categoryName": { |
| | | "description": "产品类别名称", |
| | | "type": "string" |
| | | }, |
| | | "created_at": { |
| | | "type": "string" |
| | | }, |
| | | "deliveryTime": { |
| | | "description": "供货时长", |
| | | "type": "integer" |
| | | }, |
| | | "id": { |
| | | "description": "主键ID", |
| | | "type": "integer" |
| | | }, |
| | | "maximumStock": { |
| | | "type": "integer" |
| | | }, |
| | | "minimumStock": { |
| | | "type": "integer" |
| | | }, |
| | | "modelNumber": { |
| | | "type": "string" |
| | | }, |
| | | "name": { |
| | | "type": "string" |
| | | }, |
| | | "number": { |
| | | "type": "string" |
| | | }, |
| | | "purchasePrice": { |
| | | "type": "number" |
| | | }, |
| | | "shippingDuration": { |
| | | "description": "物流时长", |
| | | "type": "integer" |
| | | }, |
| | | "specifications": { |
| | | "type": "string" |
| | | }, |
| | | "supplier": { |
| | | "$ref": "#/definitions/test.Supplier" |
| | | }, |
| | | "supplierId": { |
| | | "type": "integer" |
| | | }, |
| | | "unit": { |
| | | "type": "string" |
| | | }, |
| | | "updated_at": { |
| | | "type": "string" |
| | | } |
| | | } |
| | | }, |
| | | "test.SupplierType": { |
| | | "type": "object", |
| | | "properties": { |
| | |
| | | "in": "body", |
| | | "required": true, |
| | | "schema": { |
| | | "$ref": "#/definitions/test.Product" |
| | | "$ref": "#/definitions/request.GetById" |
| | | } |
| | | } |
| | | ], |
| | |
| | | "summary": "用id查询Product", |
| | | "parameters": [ |
| | | { |
| | | "type": "string", |
| | | "name": "created_at", |
| | | "in": "query" |
| | | }, |
| | | { |
| | | "type": "integer", |
| | | "name": "deliveryTime", |
| | | "in": "query" |
| | | }, |
| | | { |
| | | "type": "integer", |
| | | "description": "主键ID", |
| | | "name": "id", |
| | | "in": "query" |
| | | }, |
| | | { |
| | | "type": "integer", |
| | | "name": "maximumStock", |
| | | "in": "query" |
| | | }, |
| | | { |
| | | "type": "integer", |
| | | "name": "minimumStock", |
| | | "in": "query" |
| | | }, |
| | | { |
| | | "type": "string", |
| | | "name": "modelNumber", |
| | | "in": "query" |
| | | }, |
| | | { |
| | | "type": "string", |
| | | "name": "name", |
| | | "in": "query" |
| | | }, |
| | | { |
| | | "type": "string", |
| | | "name": "number", |
| | | "in": "query" |
| | | }, |
| | | { |
| | | "type": "string", |
| | | "name": "productType", |
| | | "in": "query" |
| | | }, |
| | | { |
| | | "type": "number", |
| | | "name": "purchasePrice", |
| | | "in": "query" |
| | | }, |
| | | { |
| | | "type": "string", |
| | | "name": "remark", |
| | | "in": "query" |
| | | }, |
| | | { |
| | | "type": "integer", |
| | | "name": "shippingDuration", |
| | | "in": "query" |
| | | }, |
| | | { |
| | | "type": "string", |
| | | "name": "specifications", |
| | | "in": "query" |
| | | }, |
| | | { |
| | | "type": "integer", |
| | | "name": "supplierId", |
| | | "in": "query" |
| | | }, |
| | | { |
| | | "type": "string", |
| | | "name": "supplierName", |
| | | "in": "query" |
| | | }, |
| | | { |
| | | "type": "string", |
| | | "name": "unit", |
| | | "in": "query" |
| | | }, |
| | | { |
| | | "type": "string", |
| | | "name": "updated_at", |
| | | "in": "query" |
| | | } |
| | | ], |
| | |
| | | "parameters": [ |
| | | { |
| | | "type": "string", |
| | | "name": "created_at", |
| | | "name": "categoryName", |
| | | "in": "query" |
| | | }, |
| | | { |
| | |
| | | }, |
| | | { |
| | | "type": "string", |
| | | "name": "endCreatedAt", |
| | | "in": "query" |
| | | }, |
| | | { |
| | | "type": "integer", |
| | | "description": "主键ID", |
| | | "name": "id", |
| | | "in": "query" |
| | | }, |
| | | { |
| | | "type": "string", |
| | | "description": "关键字", |
| | | "name": "keyword", |
| | | "in": "query" |
| | | }, |
| | | { |
| | | "type": "integer", |
| | | "name": "maximumStock", |
| | | "in": "query" |
| | | }, |
| | | { |
| | | "type": "integer", |
| | | "name": "minimumStock", |
| | | "in": "query" |
| | | }, |
| | | { |
| | |
| | | "in": "query" |
| | | }, |
| | | { |
| | | "type": "string", |
| | | "name": "productType", |
| | | "in": "query" |
| | | }, |
| | | { |
| | | "type": "number", |
| | | "name": "purchasePrice", |
| | | "in": "query" |
| | | }, |
| | | { |
| | | "type": "string", |
| | | "name": "remark", |
| | | "in": "query" |
| | | }, |
| | | { |
| | |
| | | }, |
| | | { |
| | | "type": "string", |
| | | "name": "startCreatedAt", |
| | | "name": "supplier", |
| | | "in": "query" |
| | | }, |
| | | { |
| | |
| | | { |
| | | "type": "string", |
| | | "name": "unit", |
| | | "in": "query" |
| | | }, |
| | | { |
| | | "type": "string", |
| | | "name": "updated_at", |
| | | "in": "query" |
| | | } |
| | | ], |
| | |
| | | "parameters": [ |
| | | { |
| | | "type": "string", |
| | | "name": "created_at", |
| | | "name": "categoryName", |
| | | "in": "query" |
| | | }, |
| | | { |
| | |
| | | }, |
| | | { |
| | | "type": "string", |
| | | "name": "endCreatedAt", |
| | | "in": "query" |
| | | }, |
| | | { |
| | | "type": "integer", |
| | | "description": "主键ID", |
| | | "name": "id", |
| | | "in": "query" |
| | | }, |
| | | { |
| | | "type": "string", |
| | | "description": "关键字", |
| | | "name": "keyword", |
| | | "in": "query" |
| | | }, |
| | | { |
| | | "type": "integer", |
| | | "name": "maximumStock", |
| | | "in": "query" |
| | | }, |
| | | { |
| | | "type": "integer", |
| | | "name": "minimumStock", |
| | | "in": "query" |
| | | }, |
| | | { |
| | |
| | | "in": "query" |
| | | }, |
| | | { |
| | | "type": "string", |
| | | "name": "productType", |
| | | "in": "query" |
| | | }, |
| | | { |
| | | "type": "number", |
| | | "name": "purchasePrice", |
| | | "in": "query" |
| | | }, |
| | | { |
| | | "type": "string", |
| | | "name": "remark", |
| | | "in": "query" |
| | | }, |
| | | { |
| | |
| | | }, |
| | | { |
| | | "type": "string", |
| | | "name": "startCreatedAt", |
| | | "name": "supplier", |
| | | "in": "query" |
| | | }, |
| | | { |
| | |
| | | { |
| | | "type": "string", |
| | | "name": "unit", |
| | | "in": "query" |
| | | }, |
| | | { |
| | | "type": "string", |
| | | "name": "updated_at", |
| | | "in": "query" |
| | | } |
| | | ], |
| | |
| | | "in": "body", |
| | | "required": true, |
| | | "schema": { |
| | | "$ref": "#/definitions/test.Product" |
| | | "$ref": "#/definitions/test.SupplierMaterial" |
| | | } |
| | | } |
| | | ], |
| | |
| | | }, |
| | | "productId": { |
| | | "description": "产品id", |
| | | "type": "integer" |
| | | "type": "string" |
| | | }, |
| | | "purchaseId": { |
| | | "description": "采购id", |
| | |
| | | } |
| | | } |
| | | }, |
| | | "request.GetById": { |
| | | "type": "object", |
| | | "properties": { |
| | | "id": { |
| | | "description": "主键ID", |
| | | "type": "integer" |
| | | } |
| | | } |
| | | }, |
| | | "request.IdsReq": { |
| | | "type": "object", |
| | | "properties": { |
| | |
| | | } |
| | | } |
| | | }, |
| | | "request.Product": { |
| | | "type": "object", |
| | | "properties": { |
| | | "categoryName": { |
| | | "type": "string" |
| | | }, |
| | | "deliveryTime": { |
| | | "type": "integer" |
| | | }, |
| | | "modelNumber": { |
| | | "type": "string" |
| | | }, |
| | | "name": { |
| | | "type": "string" |
| | | }, |
| | | "number": { |
| | | "type": "string" |
| | | }, |
| | | "purchasePrice": { |
| | | "type": "number" |
| | | }, |
| | | "shippingDuration": { |
| | | "type": "integer" |
| | | }, |
| | | "specifications": { |
| | | "type": "string" |
| | | }, |
| | | "supplier": { |
| | | "type": "string" |
| | | }, |
| | | "supplierId": { |
| | | "type": "integer" |
| | | }, |
| | | "supplierName": { |
| | | "type": "string" |
| | | }, |
| | | "supplierNumber": { |
| | | "type": "string" |
| | | }, |
| | | "unit": { |
| | | "type": "string" |
| | | } |
| | | } |
| | | }, |
| | | "request.ProductCreate": { |
| | | "type": "object", |
| | | "properties": { |
| | | "list": { |
| | | "type": "array", |
| | | "items": { |
| | | "$ref": "#/definitions/test.Product" |
| | | "$ref": "#/definitions/request.Product" |
| | | } |
| | | } |
| | | } |
| | |
| | | } |
| | | } |
| | | }, |
| | | "test.Product": { |
| | | "type": "object", |
| | | "properties": { |
| | | "created_at": { |
| | | "type": "string" |
| | | }, |
| | | "deliveryTime": { |
| | | "type": "integer" |
| | | }, |
| | | "id": { |
| | | "description": "主键ID", |
| | | "type": "integer" |
| | | }, |
| | | "maximumStock": { |
| | | "type": "integer" |
| | | }, |
| | | "minimumStock": { |
| | | "type": "integer" |
| | | }, |
| | | "modelNumber": { |
| | | "type": "string" |
| | | }, |
| | | "name": { |
| | | "type": "string" |
| | | }, |
| | | "number": { |
| | | "type": "string" |
| | | }, |
| | | "productType": { |
| | | "type": "string" |
| | | }, |
| | | "purchasePrice": { |
| | | "type": "number" |
| | | }, |
| | | "remark": { |
| | | "type": "string" |
| | | }, |
| | | "shippingDuration": { |
| | | "type": "integer" |
| | | }, |
| | | "specifications": { |
| | | "type": "string" |
| | | }, |
| | | "supplier": { |
| | | "$ref": "#/definitions/test.Supplier" |
| | | }, |
| | | "supplierId": { |
| | | "type": "integer" |
| | | }, |
| | | "supplierName": { |
| | | "type": "string" |
| | | }, |
| | | "unit": { |
| | | "type": "string" |
| | | }, |
| | | "updated_at": { |
| | | "type": "string" |
| | | } |
| | | } |
| | | }, |
| | | "test.Supplier": { |
| | | "type": "object", |
| | | "properties": { |
| | |
| | | } |
| | | } |
| | | }, |
| | | "test.SupplierMaterial": { |
| | | "type": "object", |
| | | "properties": { |
| | | "categoryName": { |
| | | "description": "产品类别名称", |
| | | "type": "string" |
| | | }, |
| | | "created_at": { |
| | | "type": "string" |
| | | }, |
| | | "deliveryTime": { |
| | | "description": "供货时长", |
| | | "type": "integer" |
| | | }, |
| | | "id": { |
| | | "description": "主键ID", |
| | | "type": "integer" |
| | | }, |
| | | "maximumStock": { |
| | | "type": "integer" |
| | | }, |
| | | "minimumStock": { |
| | | "type": "integer" |
| | | }, |
| | | "modelNumber": { |
| | | "type": "string" |
| | | }, |
| | | "name": { |
| | | "type": "string" |
| | | }, |
| | | "number": { |
| | | "type": "string" |
| | | }, |
| | | "purchasePrice": { |
| | | "type": "number" |
| | | }, |
| | | "shippingDuration": { |
| | | "description": "物流时长", |
| | | "type": "integer" |
| | | }, |
| | | "specifications": { |
| | | "type": "string" |
| | | }, |
| | | "supplier": { |
| | | "$ref": "#/definitions/test.Supplier" |
| | | }, |
| | | "supplierId": { |
| | | "type": "integer" |
| | | }, |
| | | "unit": { |
| | | "type": "string" |
| | | }, |
| | | "updated_at": { |
| | | "type": "string" |
| | | } |
| | | } |
| | | }, |
| | | "test.SupplierType": { |
| | | "type": "object", |
| | | "properties": { |
| | |
| | | type: number |
| | | productId: |
| | | description: 产品id |
| | | type: integer |
| | | type: string |
| | | purchaseId: |
| | | description: 采购id |
| | | type: integer |
| | |
| | | purchase: |
| | | $ref: '#/definitions/purchaserequest.Purchase' |
| | | type: object |
| | | request.GetById: |
| | | properties: |
| | | id: |
| | | description: 主键ID |
| | | type: integer |
| | | type: object |
| | | request.IdsReq: |
| | | properties: |
| | | ids: |
| | |
| | | $ref: '#/definitions/test.Industry' |
| | | type: array |
| | | type: object |
| | | request.Product: |
| | | properties: |
| | | categoryName: |
| | | type: string |
| | | deliveryTime: |
| | | type: integer |
| | | modelNumber: |
| | | type: string |
| | | name: |
| | | type: string |
| | | number: |
| | | type: string |
| | | purchasePrice: |
| | | type: number |
| | | shippingDuration: |
| | | type: integer |
| | | specifications: |
| | | type: string |
| | | supplier: |
| | | type: string |
| | | supplierId: |
| | | type: integer |
| | | supplierName: |
| | | type: string |
| | | supplierNumber: |
| | | type: string |
| | | unit: |
| | | type: string |
| | | type: object |
| | | request.ProductCreate: |
| | | properties: |
| | | list: |
| | | items: |
| | | $ref: '#/definitions/test.Product' |
| | | $ref: '#/definitions/request.Product' |
| | | type: array |
| | | type: object |
| | | request.SupplierStatus: |
| | |
| | | uuid: |
| | | type: string |
| | | type: object |
| | | test.Product: |
| | | properties: |
| | | created_at: |
| | | type: string |
| | | deliveryTime: |
| | | type: integer |
| | | id: |
| | | description: 主键ID |
| | | type: integer |
| | | maximumStock: |
| | | type: integer |
| | | minimumStock: |
| | | type: integer |
| | | modelNumber: |
| | | type: string |
| | | name: |
| | | type: string |
| | | number: |
| | | type: string |
| | | productType: |
| | | type: string |
| | | purchasePrice: |
| | | type: number |
| | | remark: |
| | | type: string |
| | | shippingDuration: |
| | | type: integer |
| | | specifications: |
| | | type: string |
| | | supplier: |
| | | $ref: '#/definitions/test.Supplier' |
| | | supplierId: |
| | | type: integer |
| | | supplierName: |
| | | type: string |
| | | unit: |
| | | type: string |
| | | updated_at: |
| | | type: string |
| | | type: object |
| | | test.Supplier: |
| | | properties: |
| | | account: |
| | |
| | | updated_at: |
| | | type: string |
| | | url: |
| | | type: string |
| | | type: object |
| | | test.SupplierMaterial: |
| | | properties: |
| | | categoryName: |
| | | description: 产品类别名称 |
| | | type: string |
| | | created_at: |
| | | type: string |
| | | deliveryTime: |
| | | description: 供货时长 |
| | | type: integer |
| | | id: |
| | | description: 主键ID |
| | | type: integer |
| | | maximumStock: |
| | | type: integer |
| | | minimumStock: |
| | | type: integer |
| | | modelNumber: |
| | | type: string |
| | | name: |
| | | type: string |
| | | number: |
| | | type: string |
| | | purchasePrice: |
| | | type: number |
| | | shippingDuration: |
| | | description: 物流时长 |
| | | type: integer |
| | | specifications: |
| | | type: string |
| | | supplier: |
| | | $ref: '#/definitions/test.Supplier' |
| | | supplierId: |
| | | type: integer |
| | | unit: |
| | | type: string |
| | | updated_at: |
| | | type: string |
| | | type: object |
| | | test.SupplierType: |
| | |
| | | name: data |
| | | required: true |
| | | schema: |
| | | $ref: '#/definitions/test.Product' |
| | | $ref: '#/definitions/request.GetById' |
| | | produces: |
| | | - application/json |
| | | responses: |
| | |
| | | consumes: |
| | | - application/json |
| | | parameters: |
| | | - in: query |
| | | name: created_at |
| | | type: string |
| | | - in: query |
| | | name: deliveryTime |
| | | type: integer |
| | | - description: 主键ID |
| | | in: query |
| | | name: id |
| | | type: integer |
| | | - in: query |
| | | name: maximumStock |
| | | type: integer |
| | | - in: query |
| | | name: minimumStock |
| | | type: integer |
| | | - in: query |
| | | name: modelNumber |
| | | type: string |
| | | - in: query |
| | | name: name |
| | | type: string |
| | | - in: query |
| | | name: number |
| | | type: string |
| | | - in: query |
| | | name: productType |
| | | type: string |
| | | - in: query |
| | | name: purchasePrice |
| | | type: number |
| | | - in: query |
| | | name: remark |
| | | type: string |
| | | - in: query |
| | | name: shippingDuration |
| | | type: integer |
| | | - in: query |
| | | name: specifications |
| | | type: string |
| | | - in: query |
| | | name: supplierId |
| | | type: integer |
| | | - in: query |
| | | name: supplierName |
| | | type: string |
| | | - in: query |
| | | name: unit |
| | | type: string |
| | | - in: query |
| | | name: updated_at |
| | | type: string |
| | | produces: |
| | | - application/json |
| | | responses: |
| | |
| | | - application/json |
| | | parameters: |
| | | - in: query |
| | | name: created_at |
| | | name: categoryName |
| | | type: string |
| | | - in: query |
| | | name: deliveryTime |
| | | type: integer |
| | | - in: query |
| | | name: endCreatedAt |
| | | type: string |
| | | - description: 主键ID |
| | | in: query |
| | | name: id |
| | | type: integer |
| | | - description: 关键字 |
| | | in: query |
| | | name: keyword |
| | | type: string |
| | | - in: query |
| | | name: maximumStock |
| | | type: integer |
| | | - in: query |
| | | name: minimumStock |
| | | type: integer |
| | | - in: query |
| | | name: modelNumber |
| | | type: string |
| | |
| | | name: pageSize |
| | | type: integer |
| | | - in: query |
| | | name: productType |
| | | type: string |
| | | - in: query |
| | | name: purchasePrice |
| | | type: number |
| | | - in: query |
| | | name: remark |
| | | type: string |
| | | - in: query |
| | | name: shippingDuration |
| | | type: integer |
| | |
| | | name: specifications |
| | | type: string |
| | | - in: query |
| | | name: startCreatedAt |
| | | name: supplier |
| | | type: string |
| | | - in: query |
| | | name: supplierId |
| | |
| | | type: string |
| | | - in: query |
| | | name: unit |
| | | type: string |
| | | - in: query |
| | | name: updated_at |
| | | type: string |
| | | produces: |
| | | - application/json |
| | |
| | | - application/json |
| | | parameters: |
| | | - in: query |
| | | name: created_at |
| | | name: categoryName |
| | | type: string |
| | | - in: query |
| | | name: deliveryTime |
| | | type: integer |
| | | - in: query |
| | | name: endCreatedAt |
| | | type: string |
| | | - description: 主键ID |
| | | in: query |
| | | name: id |
| | | type: integer |
| | | - description: 关键字 |
| | | in: query |
| | | name: keyword |
| | | type: string |
| | | - in: query |
| | | name: maximumStock |
| | | type: integer |
| | | - in: query |
| | | name: minimumStock |
| | | type: integer |
| | | - in: query |
| | | name: modelNumber |
| | | type: string |
| | |
| | | name: pageSize |
| | | type: integer |
| | | - in: query |
| | | name: productType |
| | | type: string |
| | | - in: query |
| | | name: purchasePrice |
| | | type: number |
| | | - in: query |
| | | name: remark |
| | | type: string |
| | | - in: query |
| | | name: shippingDuration |
| | | type: integer |
| | |
| | | name: specifications |
| | | type: string |
| | | - in: query |
| | | name: startCreatedAt |
| | | name: supplier |
| | | type: string |
| | | - in: query |
| | | name: supplierId |
| | |
| | | type: string |
| | | - in: query |
| | | name: unit |
| | | type: string |
| | | - in: query |
| | | name: updated_at |
| | | type: string |
| | | produces: |
| | | - application/json |
| | |
| | | name: data |
| | | required: true |
| | | schema: |
| | | $ref: '#/definitions/test.Product' |
| | | $ref: '#/definitions/test.SupplierMaterial' |
| | | produces: |
| | | - application/json |
| | | responses: |
| | |
| | | gorm.io/driver/postgres v1.5.2 |
| | | gorm.io/driver/sqlserver v1.5.1 |
| | | gorm.io/gorm v1.25.2 |
| | | moul.io/zapgorm2 v1.3.0 |
| | | ) |
| | | |
| | | require ( |
| | |
| | | github.com/KyleBanks/depth v1.2.1 h1:5h8fQADFrWtarTdtDudMmGsC7GPbOAu6RVB3ffsVFHc= |
| | | github.com/KyleBanks/depth v1.2.1/go.mod h1:jzSb9d0L43HxTQfT+oSA1EEp2q+ne2uh6XgeJcm8brE= |
| | | github.com/PuerkitoBio/purell v1.1.0/go.mod h1:c11w/QuzBsJSee3cPx9rAFu61PvFxuPbtSwDGJws/X0= |
| | | github.com/PuerkitoBio/purell v1.1.1/go.mod h1:c11w/QuzBsJSee3cPx9rAFu61PvFxuPbtSwDGJws/X0= |
| | | github.com/PuerkitoBio/urlesc v0.0.0-20170810143723-de5bf2ad4578/go.mod h1:uGdkoq3SwY9Y+13GIhn11/XLaGBb4BfwItxLd5jeuXE= |
| | | github.com/alecthomas/template v0.0.0-20190718012654-fb15b899a751 h1:JYp7IbQjafoB+tBA3gMyHYHrpOtNuDiK/uB5uXxq5wM= |
| | | github.com/alecthomas/template v0.0.0-20190718012654-fb15b899a751/go.mod h1:LOuyumcjzFXgccqObfd/Ljyb9UuFJ6TxHnclSeseNhc= |
| | | github.com/benbjohnson/clock v1.1.0 h1:Q92kusRqC1XV2MjkWETPvjJVqKetz1OzxZB7mHJLju8= |
| | | github.com/benbjohnson/clock v1.1.0/go.mod h1:J11/hYXuz8f4ySSvYwY0FKfm+ezbsZBKZxNJlLklBHA= |
| | | github.com/bsm/ginkgo/v2 v2.7.0 h1:ItPMPH90RbmZJt5GtkcNvIRuGEdwlBItdNVoyzaNQao= |
| | | github.com/bsm/gomega v1.26.0 h1:LhQm+AFcgV2M0WyKroMASzAzCAJVpAxQXv4SaI9a69Y= |
| | | github.com/bytedance/sonic v1.5.0/go.mod h1:ED5hyg4y6t3/9Ku1R6dU/4KyJ48DZ4jPhfY1O2AihPM= |
| | |
| | | github.com/go-sql-driver/mysql v1.7.0/go.mod h1:OXbVy3sEdcQ2Doequ6Z5BW6fXNQTmx+9S1MCJN5yJMI= |
| | | github.com/go-sql-driver/mysql v1.7.1 h1:lUIinVbN1DY0xBg0eMOzmmtGoHwWBbvnWubQUrtU8EI= |
| | | github.com/go-sql-driver/mysql v1.7.1/go.mod h1:OXbVy3sEdcQ2Doequ6Z5BW6fXNQTmx+9S1MCJN5yJMI= |
| | | github.com/go-stack/stack v1.8.0/go.mod h1:v0f6uXyyMGvRgIKkXu+yp6POWl0qKG85gN/melR3HDY= |
| | | github.com/goccy/go-json v0.10.2 h1:CrxCmQqYDkv1z7lO7Wbh2HN93uovUHgrECaO5ZrCXAU= |
| | | github.com/goccy/go-json v0.10.2/go.mod h1:6MelG93GURQebXPDq3khkgXZkazVtN9CRI+MGFi0w8I= |
| | | github.com/golang-jwt/jwt/v4 v4.4.3/go.mod h1:m21LjoU+eqJr34lmDMbreY2eSTRJ1cv77w39/MY0Ch0= |
| | |
| | | github.com/hashicorp/hcl v1.0.0/go.mod h1:E5yfLk+7swimpb2L/Alb/PJmXilQ/rhwaUYs4T20WEQ= |
| | | github.com/ianlancetaylor/demangle v0.0.0-20181102032728-5e5cf60278f6/go.mod h1:aSSvb/t6k1mPoxDqO4vJh6VOCGPwU4O0C2/Eqndh1Sc= |
| | | github.com/ianlancetaylor/demangle v0.0.0-20200824232613-28f6c0f3b639/go.mod h1:aSSvb/t6k1mPoxDqO4vJh6VOCGPwU4O0C2/Eqndh1Sc= |
| | | github.com/jackc/chunkreader/v2 v2.0.1/go.mod h1:odVSm741yZoC3dpHEUXIqA9tQRhFrgOHwnPIn9lDKlk= |
| | | github.com/jackc/pgconn v1.10.1/go.mod h1:4z2w8XhRbP1hYxkpTuBjTS3ne3J48K83+u0zoyvg2pI= |
| | | github.com/jackc/pgio v1.0.0/go.mod h1:oP+2QK2wFfUWgr+gxjoBH9KGBb31Eio69xUb0w5bYf8= |
| | | github.com/jackc/pgpassfile v1.0.0 h1:/6Hmqy13Ss2zCq62VdNG8tM1wchn8zjSGOBJ6icpsIM= |
| | | github.com/jackc/pgpassfile v1.0.0/go.mod h1:CEx0iS5ambNFdcRtxPj5JhEz+xB6uRky5eyVu/W2HEg= |
| | | github.com/jackc/pgproto3/v2 v2.2.0/go.mod h1:WfJCnwN3HIg9Ish/j3sgWXnAfK8A9Y0bwXYU5xKaEdA= |
| | | github.com/jackc/pgservicefile v0.0.0-20221227161230-091c0ba34f0a h1:bbPeKD0xmW/Y25WS6cokEszi5g+S0QxI/d45PkRi7Nk= |
| | | github.com/jackc/pgservicefile v0.0.0-20221227161230-091c0ba34f0a/go.mod h1:5TJZWKEWniPve33vlWYSoGYefn3gLQRzjfDlhSJ9ZKM= |
| | | github.com/jackc/pgtype v1.9.0/go.mod h1:LUMuVrfsFfdKGLw+AFFVv6KtHOFMwRgDDzBt76IqCA4= |
| | | github.com/jackc/pgx/v4 v4.14.0/go.mod h1:jT3ibf/A0ZVCp89rtCIN0zCJxcE74ypROmHEZYsG/j8= |
| | | github.com/jackc/pgx/v5 v5.3.1 h1:Fcr8QJ1ZeLi5zsPZqQeUZhNhxfkkKBOgJuYkJHoBOtU= |
| | | github.com/jackc/pgx/v5 v5.3.1/go.mod h1:t3JDKnCBlYIc0ewLF0Q7B8MXmoIaBOZj/ic7iHozM/8= |
| | | github.com/jcmturner/aescts/v2 v2.0.0/go.mod h1:AiaICIRyfYg35RUkr8yESTqvSy7csK90qZ5xfvvsoNs= |
| | |
| | | github.com/jcmturner/rpc/v2 v2.0.3/go.mod h1:VUJYCIDm3PVOEHw8sgt091/20OJjskO/YJki3ELg/Hc= |
| | | github.com/jinzhu/inflection v1.0.0 h1:K317FqzuhWc8YvSVlFMCCUb36O/S9MCKRDI7QkRKD/E= |
| | | github.com/jinzhu/inflection v1.0.0/go.mod h1:h+uFLlag+Qp1Va5pdKtLDYj+kHp5pxUVkryuEj+Srlc= |
| | | github.com/jinzhu/now v1.1.4/go.mod h1:d3SSVoowX0Lcu0IBviAWJpolVfI5UJVZZ7cO71lE/z8= |
| | | github.com/jinzhu/now v1.1.5 h1:/o9tlHleP7gOFmsnYNz3RGnqzefHA47wQpKrrdTIwXQ= |
| | | github.com/jinzhu/now v1.1.5/go.mod h1:d3SSVoowX0Lcu0IBviAWJpolVfI5UJVZZ7cO71lE/z8= |
| | | github.com/jonboulle/clockwork v0.4.0 h1:p4Cf1aMWXnXAUh8lVfewRBx1zaTSYKrKMF2g3ST4RZ4= |
| | |
| | | github.com/yuin/goldmark v1.1.27/go.mod h1:3hX8gzYuyVAZsxl0MRgGTJEmQBFcNTphYh9decYSb74= |
| | | github.com/yuin/goldmark v1.1.32/go.mod h1:3hX8gzYuyVAZsxl0MRgGTJEmQBFcNTphYh9decYSb74= |
| | | github.com/yuin/goldmark v1.2.1/go.mod h1:3hX8gzYuyVAZsxl0MRgGTJEmQBFcNTphYh9decYSb74= |
| | | github.com/yuin/goldmark v1.3.5/go.mod h1:mwnBkeHKe2W/ZEtQ+71ViKU8L12m81fl3OWwC1Zlc8k= |
| | | github.com/yuin/goldmark v1.4.13/go.mod h1:6yULJ656Px+3vBD8DxQVa3kxgyrAnzto9xy5taEt/CY= |
| | | github.com/yusufpapurcu/wmi v1.2.3 h1:E1ctvB7uKFMOJw3fdOW32DwGE9I7t++CRUEMKvFoFiw= |
| | | github.com/yusufpapurcu/wmi v1.2.3/go.mod h1:SBZ9tNy3G9/m5Oi98Zks0QjeHVDvuK0qfxQmPyzfmi0= |
| | |
| | | go.uber.org/atomic v1.9.0 h1:ECmE8Bn/WFTYwEW/bpKD3M8VtR/zQVbavAoalC1PYyE= |
| | | go.uber.org/atomic v1.9.0/go.mod h1:fEN4uk6kAWBTFdckzkM89CLk9XfWZrxpCo0nPH17wJc= |
| | | go.uber.org/goleak v1.1.11 h1:wy28qYRKZgnJTxGxvye5/wgWr1EKjmUDGYox5mGlRlI= |
| | | go.uber.org/goleak v1.1.11/go.mod h1:cwTWslyiVhfpKIDGSZEM2HlOvcqm+tG4zioyIeLoqMQ= |
| | | go.uber.org/multierr v1.6.0/go.mod h1:cdWPpRnG4AhwMwsgIHip0KRBQjJy5kYEpYjJxpXp9iU= |
| | | go.uber.org/multierr v1.7.0/go.mod h1:7EAYxJLBy9rStEaz58O2t4Uvip6FSURkq8/ppBp95ak= |
| | | go.uber.org/multierr v1.8.0 h1:dg6GjLku4EH+249NNmoIciG9N/jURbDG+pFlTkhzIC8= |
| | | go.uber.org/multierr v1.8.0/go.mod h1:7EAYxJLBy9rStEaz58O2t4Uvip6FSURkq8/ppBp95ak= |
| | | go.uber.org/zap v1.21.0/go.mod h1:wjWOCqI0f2ZZrJF/UufIOkiC8ii6tm1iqIsLo76RfJw= |
| | | go.uber.org/zap v1.24.0 h1:FiJd5l1UOLj0wCgbSE0rwwXHzEdAZS6hiiSnxJN/D60= |
| | | go.uber.org/zap v1.24.0/go.mod h1:2kMP+WWQ8aoFoedH3T2sq6iJ2yDWpHbP0f6MQbS9Gkg= |
| | | golang.org/x/arch v0.0.0-20210923205945-b76863e36670/go.mod h1:5om86z9Hs0C8fWVUuoMHwpExlXzs5Tkyp9hOrfG7pp8= |
| | |
| | | golang.org/x/mod v0.3.0/go.mod h1:s0Qsj1ACt9ePp/hMypM3fl4fZqREWJwdYDEqhRiZZUA= |
| | | golang.org/x/mod v0.4.0/go.mod h1:s0Qsj1ACt9ePp/hMypM3fl4fZqREWJwdYDEqhRiZZUA= |
| | | golang.org/x/mod v0.4.1/go.mod h1:s0Qsj1ACt9ePp/hMypM3fl4fZqREWJwdYDEqhRiZZUA= |
| | | golang.org/x/mod v0.4.2/go.mod h1:s0Qsj1ACt9ePp/hMypM3fl4fZqREWJwdYDEqhRiZZUA= |
| | | golang.org/x/mod v0.6.0-dev.0.20220419223038-86c51ed26bb4/go.mod h1:jJ57K6gSWd91VN4djpZkiMVwK6gcyfeH4XE8wZrZaV4= |
| | | golang.org/x/mod v0.8.0/go.mod h1:iBbtSCu2XBx23ZKBPSOrRkjjQPZFPuis4dIYUhu/chs= |
| | | golang.org/x/mod v0.10.0 h1:lFO9qtOdlre5W1jxS3r/4szv2/6iXxScdzjoBMXNhYk= |
| | |
| | | golang.org/x/net v0.0.0-20201209123823-ac852fbbde11/go.mod h1:m0MpNAwzfU5UDzcl9v0D8zg8gWTRqZa9RBIspLL5mdg= |
| | | golang.org/x/net v0.0.0-20201224014010-6772e930b67b/go.mod h1:m0MpNAwzfU5UDzcl9v0D8zg8gWTRqZa9RBIspLL5mdg= |
| | | golang.org/x/net v0.0.0-20210226172049-e18ecbb05110/go.mod h1:m0MpNAwzfU5UDzcl9v0D8zg8gWTRqZa9RBIspLL5mdg= |
| | | golang.org/x/net v0.0.0-20210405180319-a5a99cb37ef4/go.mod h1:p54w0d4576C0XHj96bSt6lcn1PtDYWL6XObtHCRCNQM= |
| | | golang.org/x/net v0.0.0-20211112202133-69e39bad7dc2/go.mod h1:9nx3DQGgdP8bBQD5qxJ1jj9UTztislL4KSBs9R2vV5Y= |
| | | golang.org/x/net v0.0.0-20220722155237-a158d28d115b/go.mod h1:XRhObCWvk6IyKnWLug+ECip1KBveYUHfp+8e9klMJ9c= |
| | | golang.org/x/net v0.6.0/go.mod h1:2Tu9+aMcznHK/AK1HMvgo6xiTLG5rD5rZLDS+rp2Bjs= |
| | |
| | | golang.org/x/sync v0.0.0-20200625203802-6e8e738ad208/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= |
| | | golang.org/x/sync v0.0.0-20201020160332-67f06af15bc9/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= |
| | | golang.org/x/sync v0.0.0-20201207232520-09787c993a3a/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= |
| | | golang.org/x/sync v0.0.0-20210220032951-036812b2e83c/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= |
| | | golang.org/x/sync v0.0.0-20220722155255-886fb9371eb4/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= |
| | | golang.org/x/sync v0.1.0/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= |
| | | golang.org/x/sync v0.3.0 h1:ftCYgMx6zT/asHUrPw8BLLscYtGznsLAnjq5RH9P66E= |
| | |
| | | golang.org/x/sys v0.0.0-20210104204734-6f8348627aad/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= |
| | | golang.org/x/sys v0.0.0-20210119212857-b64e53b001e4/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= |
| | | golang.org/x/sys v0.0.0-20210225134936-a50acf3fe073/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= |
| | | golang.org/x/sys v0.0.0-20210330210617-4fbd30eecc44/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= |
| | | golang.org/x/sys v0.0.0-20210423082822-04245dca01da/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= |
| | | golang.org/x/sys v0.0.0-20210423185535-09eb48e85fd7/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= |
| | | golang.org/x/sys v0.0.0-20210510120138-977fb7262007/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= |
| | | golang.org/x/sys v0.0.0-20210615035016-665e8c7367d1/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= |
| | | golang.org/x/sys v0.0.0-20210616045830-e2b7044e8c71/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= |
| | | golang.org/x/sys v0.0.0-20220520151302-bc2c85ada10a/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= |
| | |
| | | golang.org/x/tools v0.0.0-20210105154028-b0ab187a4818/go.mod h1:emZCQorbCU4vsT4fOWvOPXz4eW1wZW4PmDk9uLelYpA= |
| | | golang.org/x/tools v0.0.0-20210108195828-e2f9c7f1fc8e/go.mod h1:emZCQorbCU4vsT4fOWvOPXz4eW1wZW4PmDk9uLelYpA= |
| | | golang.org/x/tools v0.1.0/go.mod h1:xkSsbof2nBLbhDlRMhhhyNLN/zl3eTqcnHD5viDpcZ0= |
| | | golang.org/x/tools v0.1.5/go.mod h1:o0xws9oXOQQZyjljx8fwUC0k7L1pTE6eaCbjGeHmOkk= |
| | | golang.org/x/tools v0.1.12/go.mod h1:hNGJHUnrk76NpqgfD5Aqm5Crs+Hm0VOH/i9J2+nxYbc= |
| | | golang.org/x/tools v0.6.0/go.mod h1:Xwgl3UAJ/d3gWutnCtw505GrjyAbvKui8lOU390QaIU= |
| | | golang.org/x/tools v0.9.1 h1:8WMNJAz3zrtPmnYC7ISf5dEn3MT0gY7jBJfw27yrrLo= |
| | |
| | | gorm.io/driver/postgres v1.5.2/go.mod h1:fmpX0m2I1PKuR7mKZiEluwrP3hbs+ps7JIGMUBpCgl8= |
| | | gorm.io/driver/sqlserver v1.5.1 h1:wpyW/pR26U94uaujltiFGXY7fd2Jw5hC9PB1ZF/Y5s4= |
| | | gorm.io/driver/sqlserver v1.5.1/go.mod h1:AYHzzte2msKTmYBYsSIq8ZUsznLJwBdkB2wpI+kt0nM= |
| | | gorm.io/gorm v1.23.6/go.mod h1:l2lP/RyAtc1ynaTjFksBde/O8v9oOGIApu2/xRitmZk= |
| | | gorm.io/gorm v1.25.1/go.mod h1:L4uxeKpfBml98NYqVqwAdmV1a2nBtAec/cf3fpucW/k= |
| | | gorm.io/gorm v1.25.2 h1:gs1o6Vsa+oVKG/a9ElL3XgyGfghFfkKA2SInQaCyMho= |
| | | gorm.io/gorm v1.25.2/go.mod h1:L4uxeKpfBml98NYqVqwAdmV1a2nBtAec/cf3fpucW/k= |
| | |
| | | modernc.org/memory v1.6.0/go.mod h1:PkUhL0Mugw21sHPeskwZW4D6VscE/GQJOnIpCnW6pSU= |
| | | modernc.org/sqlite v1.23.0 h1:MWTFBI5H1WLnXpNBh/BTruBVqzzoh28DA0iOnlkkRaM= |
| | | modernc.org/sqlite v1.23.0/go.mod h1:OrDj17Mggn6MhE+iPbBNf7RGKODDE9NFT0f3EwDzJqk= |
| | | moul.io/zapgorm2 v1.3.0 h1:+CzUTMIcnafd0d/BvBce8T4uPn6DQnpIrz64cyixlkk= |
| | | moul.io/zapgorm2 v1.3.0/go.mod h1:nPVy6U9goFKHR4s+zfSo1xVFaoU7Qgd5DoCdOfzoCqs= |
| | | rsc.io/binaryregexp v0.2.0/go.mod h1:qTv7/COck+e2FymRvadv62gMdZztPaShugOCi3I+8D8= |
| | | rsc.io/pdf v0.1.1/go.mod h1:n8OzWcQ6Sp37PL01nO98y4iUCRdTGarVfzxY20ICaU4= |
| | | rsc.io/quote/v3 v3.1.0/go.mod h1:yEA65RcK8LyAZtP9Kv3t0HmxON59tX3rD+tICJqUlj0= |
| | |
| | | test.SupplierType{}, |
| | | test.Supplier{}, |
| | | test.Contract{}, |
| | | test.Product{}, |
| | | test.Member{}, |
| | | test.SupplierMaterial{}, |
| | | purchase.Purchase{}, |
| | | purchase.PurchaseProducts{}, |
| | | ) |
| | |
| | | package internal |
| | | |
| | | import ( |
| | | "gorm.io/gorm/schema" |
| | | "log" |
| | | "os" |
| | | "time" |
| | | |
| | | "gorm.io/gorm" |
| | | "gorm.io/gorm/logger" |
| | | "gorm.io/gorm/schema" |
| | | "moul.io/zapgorm2" |
| | | "srm/global" |
| | | ) |
| | | |
| | |
| | | }, |
| | | DisableForeignKeyConstraintWhenMigrating: true, |
| | | } |
| | | _default := logger.New(log.New(os.Stdout, "\r\n", log.LstdFlags), logger.Config{ |
| | | SlowThreshold: 200 * time.Millisecond, |
| | | LogLevel: logger.Warn, |
| | | Colorful: true, |
| | | }) |
| | | var logMode DBBASE |
| | | switch global.GVA_CONFIG.System.DbType { |
| | | case "mysql": |
| | | logMode = &global.GVA_CONFIG.Mysql |
| | | case "pgsql": |
| | | logMode = &global.GVA_CONFIG.Pgsql |
| | | case "oracle": |
| | | logMode = &global.GVA_CONFIG.Oracle |
| | | default: |
| | | logMode = &global.GVA_CONFIG.Mysql |
| | | } |
| | | |
| | | switch logMode.GetLogMode() { |
| | | case "silent", "Silent": |
| | | config.Logger = _default.LogMode(logger.Silent) |
| | | case "error", "Error": |
| | | config.Logger = _default.LogMode(logger.Error) |
| | | case "warn", "Warn": |
| | | config.Logger = _default.LogMode(logger.Warn) |
| | | case "info", "Info": |
| | | config.Logger = _default.LogMode(logger.Info) |
| | | default: |
| | | config.Logger = _default.LogMode(logger.Info) |
| | | } |
| | | dbLogger := zapgorm2.New(global.GVA_LOG).LogMode(logger.Info) |
| | | config.Logger = dbLogger |
| | | return config |
| | | } |
| | |
| | | test.InitProductServiceConn() |
| | | qualityinspect.InitConn() |
| | | purchase_wms.InitPurchaseConn() |
| | | test.InitProductServiceConn() |
| | | } |
| | | |
| | | func closeGrpcClient() { |
| | | test.CloseProductServiceConn() |
| | | qualityinspect.CloseConn() |
| | | purchase_wms.ClosePurchaseConn() |
| | | test.CloseProductServiceConn() |
| | | } |
| | |
| | | |
| | | type PurchaseProducts struct { |
| | | global.GVA_MODEL |
| | | PurchaseId int `json:"purchaseId" gorm:"type:int(11);not null;default 0;comment:采购单id"` // 采购单id |
| | | ProductId int `json:"productId" gorm:"type:int(11);not null;default 0;comment:产品id"` // 产品id |
| | | Product test.Product `json:"-" gorm:"foreignKey:ProductId"` |
| | | Amount decimal.Decimal `json:"amount" form:"amount" gorm:"type:decimal(12,2);not null;default 0;comment:采购数量"` // 采购数量 |
| | | Price decimal.Decimal `json:"price" form:"price" gorm:"type:decimal(12,2);not null;default 0.00;comment:采购单价"` // 采购单价 |
| | | Total decimal.Decimal `json:"total" form:"total" gorm:"type:decimal(12,2);not null;default 0.00;comment:采购总价"` // 采购总价 |
| | | Remark string `json:"remark" form:"remark" gorm:"type:varchar(1000);not null; default '';comment:描述"` //描述 |
| | | PurchaseId int `json:"purchaseId" form:"purchaseType" gorm:"type:int(11);not null;default 0;comment:采购类型id"` // 采购id |
| | | ProductId string `json:"productId" form:"productId" gorm:"type:varchar(255);not null;default '';comment:产品id"` // 产品id |
| | | Product test.SupplierMaterial `json:"-" gorm:"foreignKey:ProductId"` |
| | | Amount decimal.Decimal `json:"amount" form:"amount" gorm:"type:decimal(12,2);not null;default 0;comment:采购数量"` // 采购数量 |
| | | Price decimal.Decimal `json:"price" form:"price" gorm:"type:decimal(12,2);not null;default 0.00;comment:采购单价"` // 采购单价 |
| | | Total decimal.Decimal `json:"total" form:"total" gorm:"type:decimal(12,2);not null;default 0.00;comment:采购总价"` // 采购总价 |
| | | Remark string `json:"remark" form:"remark" gorm:"type:varchar(1000);not null; default '';comment:描述"` //描述 |
| | | } |
| | | |
| | | func (PurchaseProducts) TableName() string { |
New file |
| | |
| | | package test |
| | | |
| | | import ( |
| | | "github.com/shopspring/decimal" |
| | | ) |
| | | |
| | | // Material 结构体 |
| | | type Material struct { |
| | | ID string |
| | | Name string `gorm:"type:varchar(191);not null;comment:物料名称" json:"name"` |
| | | MaterialType MaterialType `gorm:"index;type:int(11);comment:物料类型(数字)" json:"materialType"` |
| | | Model MaterialMode `gorm:"type:varchar(191);not null;comment:物料类型(字符串)" json:"model"` |
| | | Specs string `gorm:"type:varchar(191);comment:物料规格" json:"specs"` |
| | | Type string `gorm:"type:varchar(191);comment:物料型号" json:"type"` |
| | | MinInventory decimal.Decimal `gorm:"type:decimal(35,18);comment:最小库存" json:"minInventory"` |
| | | MaxInventory decimal.Decimal `gorm:"type:decimal(35,18);comment:最大库存" json:"maxInventory"` |
| | | Amount decimal.Decimal `gorm:"type:decimal(35,18);comment:数量" json:"amount"` |
| | | LockAmount decimal.Decimal `gorm:"type:decimal(35,18);default:0;comment:锁定数量" json:"lockAmount"` |
| | | Unit string `gorm:"type:varchar(100);comment:单位" json:"unit"` |
| | | TemplateID string `gorm:"type:varchar(191);comment:模板ID" json:"-"` |
| | | Status MaterialStatus `gorm:"type:int(11);comment:状态" json:"status"` |
| | | Supplier string `gorm:"type:varchar(191);comment:供应商" json:"supplier"` |
| | | PurchasePrice decimal.Decimal `gorm:"type:decimal(35,18);comment:采购价格" json:"purchasePrice"` |
| | | PurchaseAheadDay int `gorm:"type:int(11);comment:采购提前期(天)" json:"purchaseAheadDay"` |
| | | ProduceAheadDay int `gorm:"type:int(11);comment:制造提前期(天)" json:"produceAheadDay"` |
| | | MinPurchaseAmount decimal.Decimal `gorm:"type:decimal(35,18);comment:最小采购量" json:"minPurchaseAmount"` |
| | | PurchaseType PurchaseType `gorm:"type:int(11);comment:采购类型" json:"purchaseType"` |
| | | SalePrice decimal.Decimal `gorm:"type:decimal(35,18);comment:销售单价" json:"salePrice"` |
| | | CategoryName string `gorm:"type:varchar(255);comment:产品类别名称" json:"categoryName"` //产品类别名称 |
| | | } |
| | | |
| | | // PurchaseType 采购类型 |
| | | type PurchaseType int |
| | | |
| | | const ( |
| | | PurchaseTypeOutSource PurchaseType = iota + 1 // 采购 |
| | | PurchaseTypeSelf // 自制 |
| | | PurchaseTypeEntrust // 委外 |
| | | ) |
| | | |
| | | type MaterialStatus int |
| | | |
| | | const ( |
| | | MaterialStatusCreate MaterialStatus = iota // 新建 |
| | | MaterialStatusActive // 启用 |
| | | MaterialStatusInactive = -1 // 停用 |
| | | ) |
| | | |
| | | // MaterialMode 物料类型(字符串) |
| | | type MaterialMode string |
| | | |
| | | const ( |
| | | MaterialModeRaw MaterialMode = "原材料" |
| | | MaterialModeSemi MaterialMode = "半成品" |
| | | MaterialModeFinished MaterialMode = "成品" |
| | | MaterialModeAuxiliary MaterialMode = "辅料" //辅料 |
| | | MaterialModeConsumables MaterialMode = "耗材" //耗材 |
| | | MaterialModeOther MaterialMode = "其他" //其他 |
| | | ) |
| | | |
| | | func (t MaterialMode) Valid() bool { |
| | | if t != MaterialModeRaw && |
| | | t != MaterialModeSemi && |
| | | t != MaterialModeAuxiliary && |
| | | t != MaterialModeConsumables && |
| | | t != MaterialModeOther && |
| | | t != MaterialModeFinished { |
| | | return false |
| | | } |
| | | return true |
| | | } |
| | | |
| | | func (t MaterialMode) Type() MaterialType { |
| | | switch t { |
| | | case MaterialModeRaw: |
| | | return MaterialTypeRaw |
| | | case MaterialModeSemi: |
| | | return MaterialTypeSemi |
| | | case MaterialModeFinished: |
| | | return MaterialTypeFinished |
| | | } |
| | | return MaterialType(0) |
| | | } |
| | | |
| | | // MaterialType 物料类型(数字) |
| | | type MaterialType int |
| | | |
| | | const ( |
| | | MaterialTypeRaw = iota + 1 // 原材料 |
| | | MaterialTypeSemi // 半成品 |
| | | MaterialTypeFinished // 成品 |
| | | MaterialTypeAuxiliary //辅料 |
| | | MaterialTypeConsumables //耗材 |
| | | MaterialTypeOther //其他 |
| | | ) |
| | | |
| | | func (t MaterialType) Valid() bool { |
| | | if t < MaterialTypeRaw || |
| | | t > MaterialTypeFinished { |
| | | return false |
| | | } |
| | | return true |
| | | } |
| | | |
| | | // TableName Product 表名 |
| | | func (Material) TableName() string { |
| | | return "material" |
| | | } |
| | |
| | | package test |
| | | |
| | | import "srm/global" |
| | | import ( |
| | | "srm/global" |
| | | ) |
| | | |
| | | // Product 结构体 |
| | | type Product struct { |
| | | // SupplierMaterial 结构体 |
| | | type SupplierMaterial struct { |
| | | global.GVA_MODEL |
| | | Name string `json:"name" form:"name" gorm:"column:name;comment:名称;size:255;"` |
| | | Number string `json:"number" form:"number" gorm:"column:number;comment:编码;size:255;"` |
| | | Name string `gorm:"type:varchar(191);not null;comment:物料名称" json:"name"` |
| | | Number string `json:"number" form:"number" gorm:"column:number;comment:物料编码;size:255;"` |
| | | SupplierId uint `json:"supplierId" form:"supplierId" gorm:"column:supplier_id;comment:供应商id;size:255;"` |
| | | Supplier Supplier `json:"supplier" gorm:"foreignKey:SupplierId;comment:供应商"` |
| | | Supplier Supplier `json:"supplier" form:"supplier" gorm:"foreignKey:SupplierId;comment:供应商"` |
| | | Unit string `json:"unit" form:"unit" gorm:"column:unit;comment:计量单位;size:255;"` |
| | | PurchasePrice float64 `json:"purchasePrice" form:"purchasePrice" gorm:"column:purchase_price;comment:采购价格;"` |
| | | DeliveryTime int `json:"deliveryTime" form:"deliveryTime" gorm:"column:delivery_time;comment:;size:11;"` |
| | | ShippingDuration int `json:"shippingDuration" form:"shippingDuration" gorm:"column:shipping_duration;comment:物流时长;size:11;"` |
| | | DeliveryTime int `json:"deliveryTime" form:"deliveryTime" gorm:"column:delivery_time;comment:;size:11;"` //供货时长 |
| | | ShippingDuration int `json:"shippingDuration" form:"shippingDuration" gorm:"column:shipping_duration;comment:物流时长;size:11;"` //物流时长 |
| | | Specifications string `json:"specifications" form:"specifications" gorm:"column:specifications;comment:规格;size:255;"` |
| | | ModelNumber string `json:"modelNumber" form:"modelNumber" gorm:"column:model_number;comment:型号;size:255;"` |
| | | ProductType string `json:"productType" form:"productType" gorm:"column:product_type;comment:产品类别;size:255;"` |
| | | MinimumStock int `json:"minimumStock" form:"minimumStock" gorm:"column:minimum_stock;comment:最低库存;"` |
| | | MaximumStock int `json:"maximumStock" form:"maximumStock" gorm:"column:maximum_stock;comment:最高库存;"` |
| | | Remark string `json:"remark" form:"remark" gorm:"column:remark;comment:备注;size:255;"` |
| | | SupplierName string `json:"supplierName" gorm:"-"` |
| | | MinimumStock int64 `json:"minimumStock" form:"minimumStock" gorm:"column:minimum_stock;comment:最低库存;"` |
| | | MaximumStock int64 `json:"maximumStock" form:"maximumStock" gorm:"column:maximum_stock;comment:最高库存;"` |
| | | CategoryName string `gorm:"type:varchar(255);comment:产品类别名称" json:"categoryName"` //产品类别名称 |
| | | } |
| | | |
| | | // TableName Product 表名 |
| | | func (Product) TableName() string { |
| | | return "srm_product" |
| | | func (SupplierMaterial) TableName() string { |
| | | return "srm_supplier_material" |
| | | } |
| | |
| | | |
| | | import ( |
| | | "srm/model/common/request" |
| | | "srm/model/test" |
| | | "time" |
| | | ) |
| | | |
| | | type ProductSearch struct { |
| | | test.Product |
| | | SupplierNumber string `json:"supplierNumber" form:"supplierNumber"` |
| | | StartCreatedAt *time.Time `json:"startCreatedAt" form:"startCreatedAt"` |
| | | EndCreatedAt *time.Time `json:"endCreatedAt" form:"endCreatedAt"` |
| | | Product |
| | | request.PageInfo |
| | | } |
| | | |
| | | type ProductCreate struct { |
| | | List []*test.Product `json:"list"` |
| | | List []*Product `json:"list"` |
| | | } |
| | | |
| | | type Product struct { |
| | | Name string `json:"name" form:"name" gorm:"column:name;comment:名称;size:255;"` |
| | | Number string `json:"number" form:"number" gorm:"column:number;comment:编码;size:255;"` |
| | | SupplierId uint `json:"supplierId" form:"supplierId" gorm:"column:supplier_id;comment:供应商id;size:255;"` |
| | | Supplier string `json:"supplier" form:"supplier" gorm:"foreignKey:SupplierId;references:ID;comment:供应商"` |
| | | Unit string `json:"unit" form:"unit" gorm:"column:unit;comment:计量单位;size:255;"` |
| | | PurchasePrice float64 `json:"purchasePrice" form:"purchasePrice" gorm:"column:purchase_price;comment:采购价格;"` |
| | | DeliveryTime int `json:"deliveryTime" form:"deliveryTime" gorm:"column:delivery_time;comment:;size:11;"` |
| | | ShippingDuration int `json:"shippingDuration" form:"shippingDuration" gorm:"column:shipping_duration;comment:物流时长;size:11;"` |
| | | Specifications string `json:"specifications" form:"specifications" gorm:"column:specifications;comment:规格;size:255;"` |
| | | ModelNumber string `json:"modelNumber" form:"modelNumber" gorm:"column:model_number;comment:型号;size:255;"` |
| | | CategoryName string `json:"categoryName" form:"categoryName" gorm:"column:category_name;comment:产品类别;size:255;"` |
| | | SupplierName string `json:"supplierName" gorm:"-"` |
| | | SupplierNumber string `json:"supplierNumber" form:"supplierNumber"` |
| | | } |
New file |
| | |
| | | package productresponse |
| | | |
| | | type Product struct { |
| | | Name string `json:"name" form:"name" gorm:"column:name;comment:名称;size:255;"` |
| | | Number string `json:"number" form:"number" gorm:"column:number;comment:编码;size:255;"` |
| | | SupplierId uint `json:"supplierId" form:"supplierId" gorm:"column:supplier_id;comment:供应商id;size:255;"` |
| | | Unit string `json:"unit" form:"unit" gorm:"column:unit;comment:计量单位;size:255;"` |
| | | PurchasePrice float64 `json:"purchasePrice" form:"purchasePrice" gorm:"column:purchase_price;comment:采购价格;"` |
| | | DeliveryTime int `json:"deliveryTime" form:"deliveryTime" gorm:"column:delivery_time;comment:;size:11;"` |
| | | ShippingDuration int `json:"shippingDuration" form:"shippingDuration" gorm:"column:shipping_duration;comment:物流时长;size:11;"` |
| | | Specifications string `json:"specifications" form:"specifications" gorm:"column:specifications;comment:规格;size:255;"` |
| | | ModelNumber string `json:"modelNumber" form:"modelNumber" gorm:"column:model_number;comment:型号;size:255;"` |
| | | ProductType string `json:"productType" form:"productType" gorm:"column:product_type;comment:产品类别;size:255;"` |
| | | MinimumStock int64 `json:"minimumStock" form:"minimumStock" gorm:"column:minimum_stock;comment:最低库存;"` |
| | | MaximumStock int64 `json:"maximumStock" form:"maximumStock" gorm:"column:maximum_stock;comment:最高库存;"` |
| | | Remark string `json:"remark" form:"remark" gorm:"column:remark;comment:备注;size:255;"` |
| | | SupplierName string `json:"supplierName" gorm:"-"` |
| | | CategoryName string `gorm:"type:varchar(255);comment:产品类别名称" json:"categoryName"` //产品类别名称 |
| | | } |
| | | |
| | | type Material struct { |
| | | Name string `json:"name" form:"name" gorm:"column:name;comment:名称;size:255;"` |
| | | Number string `json:"number" form:"number" gorm:"column:number;comment:编码;size:255;"` |
| | | Unit string `json:"unit" form:"unit" gorm:"column:unit;comment:计量单位;size:255;"` |
| | | Specifications string `json:"specifications" form:"specifications" gorm:"column:specifications;comment:规格;size:255;"` |
| | | ModelNumber string `json:"modelNumber" form:"modelNumber" gorm:"column:model_number;comment:型号;size:255;"` |
| | | MinimumStock int64 `json:"minimumStock" form:"minimumStock" gorm:"column:minimum_stock;comment:最低库存;"` |
| | | MaximumStock int64 `json:"maximumStock" form:"maximumStock" gorm:"column:maximum_stock;comment:最高库存;"` |
| | | Remark string `json:"remark" form:"remark" gorm:"column:remark;comment:备注;size:255;"` |
| | | CategoryName string `gorm:"type:varchar(255);comment:产品类别名称" json:"categoryName"` //产品类别名称 |
| | | } |
| | |
| | | var purchaseList = make([]*purchase.Purchase, 0) |
| | | if info.Keyword != "" { |
| | | db.Distinct("srm_purchase.id").Joins("left join srm_purchase_products on srm_purchase_products.purchase_id = srm_purchase.id"). |
| | | Joins("left join srm_product on srm_product.Id = srm_purchase_products.product_id"). |
| | | Joins("left join material on material.id = srm_purchase_products.product_id"). |
| | | Joins("left join srm_supplier on srm_supplier.Id = srm_purchase.supplier_id"). |
| | | Where("srm_purchase.name like ?", "%"+info.Keyword+"%"). |
| | | Or("srm_product.name like ?", "%"+info.Keyword+"%"). |
| | | Or("material.name like ?", "%"+info.Keyword+"%"). |
| | | Or("srm_supplier.name like ?", "%"+info.Keyword+"%") |
| | | err = db.Limit(limit).Offset(offset).Find(&ids).Error |
| | | if err != nil { |
| | |
| | | } |
| | | productIds := make([]uint, 0, len(productList)) |
| | | for _, product := range productList { |
| | | productIds = append(productIds, uint(product.ProductId)) |
| | | productIds = append(productIds, product.ID) |
| | | } |
| | | productService := &test.ProductService{} |
| | | _, productMap, err := productService.GetProducts(productIds) |
| | |
| | | } |
| | | inspectOrders := make([]*qualityinspect.QualityInspect, 0, len(productList)) |
| | | for _, productItem := range productList { |
| | | product := productMap[uint(productItem.ProductId)] |
| | | product := productMap[productItem.ID] |
| | | if product == nil { |
| | | continue |
| | | } |
| | |
| | | |
| | | // CreateProduct 创建Product记录 |
| | | // Author [piexlmax](https://github.com/piexlmax) |
| | | func (pService *ProductService) CreateProduct(p []*test.Product) (err error) { |
| | | err = global.GVA_DB.Create(p).Error |
| | | func (pService *ProductService) CreateProduct(pList []*testReq.Product) (err error) { |
| | | |
| | | products := make([]*test.SupplierMaterial, 0, len(pList)) |
| | | |
| | | for _, p := range pList { |
| | | products = append(products, &test.SupplierMaterial{ |
| | | Name: p.Name, |
| | | Number: p.Number, |
| | | SupplierId: p.SupplierId, |
| | | Unit: p.Unit, |
| | | PurchasePrice: p.PurchasePrice, |
| | | DeliveryTime: p.DeliveryTime, |
| | | ShippingDuration: p.ShippingDuration, |
| | | Specifications: p.Specifications, |
| | | CategoryName: p.CategoryName, |
| | | }) |
| | | } |
| | | |
| | | err = global.GVA_DB.Create(products).Error |
| | | return err |
| | | } |
| | | |
| | | // DeleteProduct 删除Product记录 |
| | | // Author [piexlmax](https://github.com/piexlmax) |
| | | func (pService *ProductService) DeleteProduct(p test.Product) (err error) { |
| | | err = global.GVA_DB.Delete(&p).Error |
| | | func (pService *ProductService) DeleteProduct(id int) (err error) { |
| | | err = global.GVA_DB.Delete(&test.SupplierMaterial{}, "id = ?", id).Error |
| | | return err |
| | | } |
| | | |
| | | // DeleteProductByIds 批量删除Product记录 |
| | | // Author [piexlmax](https://github.com/piexlmax) |
| | | func (pService *ProductService) DeleteProductByIds(ids request.IdsReq) (err error) { |
| | | err = global.GVA_DB.Delete(&[]test.Product{}, "id in ?", ids.Ids).Error |
| | | err = global.GVA_DB.Delete(&[]test.SupplierMaterial{}, "id in ?", ids.Ids).Error |
| | | return err |
| | | } |
| | | |
| | | // UpdateProduct 更新Product记录 |
| | | // Author [piexlmax](https://github.com/piexlmax) |
| | | func (pService *ProductService) UpdateProduct(p test.Product) (err error) { |
| | | func (pService *ProductService) UpdateProduct(p test.SupplierMaterial) (err error) { |
| | | err = global.GVA_DB.Updates(&p).Error |
| | | return err |
| | | } |
| | | |
| | | // GetProduct 根据id获取Product记录 |
| | | // Author [piexlmax](https://github.com/piexlmax) |
| | | func (pService *ProductService) GetProduct(id uint) (p test.Product, err error) { |
| | | func (pService *ProductService) GetProduct(id int) (p test.SupplierMaterial, err error) { |
| | | err = global.GVA_DB.Where("id = ?", id).First(&p).Error |
| | | return |
| | | } |
| | | |
| | | // GetProductInfoList 分页获取Product记录 |
| | | // Author [piexlmax](https://github.com/piexlmax) |
| | | func (pService *ProductService) GetProductInfoList(info testReq.ProductSearch) (list []test.Product, total int64, err error) { |
| | | func (pService *ProductService) GetProductInfoList(info testReq.ProductSearch) (list []test.SupplierMaterial, total int64, err error) { |
| | | limit := info.PageSize |
| | | offset := info.PageSize * (info.Page - 1) |
| | | // 创建db |
| | | db := global.GVA_DB.Model(&test.Product{}) |
| | | var ps []test.Product |
| | | // 如果有条件搜索 下方会自动创建搜索语句 |
| | | db := global.GVA_DB.Model(&test.SupplierMaterial{}) |
| | | var ps []test.SupplierMaterial |
| | | //搜索框合一添加查询条件 |
| | | if info.Keyword != "" { |
| | | db = db.Where("srm_product.name LIKE ?", "%"+info.Keyword+"%").Joins("srm_supplier").Or("srm_supplier.name LIKE ?", "%"+info.Keyword+"%") |
| | | } |
| | | if info.StartCreatedAt != nil && info.EndCreatedAt != nil { |
| | | db = db.Where("created_at BETWEEN ? AND ?", info.StartCreatedAt, info.EndCreatedAt) |
| | | db = db.Where("`srm_supplier_material`.name LIKE ?", "%"+info.Keyword+"%").Joins("Supplier").Or("Supplier.name LIKE ?", "%"+info.Keyword+"%") |
| | | } |
| | | if info.Name != "" { |
| | | db = db.Where("name LIKE ?", "%"+info.Name+"%") |
| | |
| | | if info.Number != "" { |
| | | db = db.Where("number LIKE ?", "%"+info.Number+"%") |
| | | } |
| | | if info.Unit != "" { |
| | | db = db.Where("unit LIKE ?", "%"+info.Unit+"%") |
| | | } |
| | | |
| | | if info.SupplierId != 0 { |
| | | db = db.Where("supplier_id = ?", info.SupplierId) |
| | | } |
| | | |
| | | if info.MaximumStock != 0 { |
| | | db = db.Where("maximum_stock = ?", info.MaximumStock) |
| | | } |
| | | |
| | | if info.MinimumStock != 0 { |
| | | db = db.Where("minimum_stock = ?", info.MinimumStock) |
| | | } |
| | | |
| | | if info.PurchasePrice != 0 { |
| | | db = db.Where("purchase_price = ?", info.PurchasePrice) |
| | | } |
| | | |
| | | if info.Specifications != "" { |
| | | db = db.Where("specifications LIKE ?", "%"+info.Specifications+"%") |
| | | } |
| | | |
| | | if info.ModelNumber != "" { |
| | | db = db.Where("model_number LIKE ?", "%"+info.ModelNumber+"%") |
| | | } |
| | | |
| | | if info.ProductType != "" { |
| | | db = db.Where("product_type LIKE ?", "%"+info.ProductType+"%") |
| | | } |
| | | |
| | | if info.SupplierNumber != "" { |
| | | db = db.Joins("srm_supplier").Where("srm_supplier.number LIKE ?", "%"+info.SupplierNumber+"%") |
| | | } |
| | | |
| | | if info.DeliveryTime != 0 { |
| | | db = db.Where("delivery_time = ?", info.DeliveryTime) |
| | | } |
| | | |
| | | if info.ShippingDuration != 0 { |
| | | db = db.Where("shipping_duration = ?", info.ShippingDuration) |
| | | } |
| | | |
| | | err = db.Count(&total).Error |
| | |
| | | } |
| | | |
| | | // GetProducts 根据ids获取Product记录 |
| | | func (pService *ProductService) GetProducts(ids []uint) (p []*test.Product, m map[uint]*test.Product, err error) { |
| | | func (pService *ProductService) GetProducts(ids []uint) (p []*test.SupplierMaterial, m map[uint]*test.SupplierMaterial, err error) { |
| | | err = global.GVA_DB.Where("id in ?", ids).Find(&p).Error |
| | | if err != nil { |
| | | return |
| | | } |
| | | m = make(map[uint]*test.Product, len(p)) |
| | | m = make(map[uint]*test.SupplierMaterial, len(p)) |
| | | for _, product := range p { |
| | | m[product.ID] = product |
| | | } |
| | | return |
| | | } |
| | | |
| | | // GetMaterials 获取物料 |
| | | func (pService *ProductService) GetMaterials(info testReq.ProductSearch) (list []test.Material, total int64, err error) { |
| | | limit := info.PageSize |
| | | offset := info.PageSize * (info.Page - 1) |
| | | // 创建db |
| | | db := global.GVA_DB.Model(&test.Material{}) |
| | | var ps []test.Material |
| | | if info.Keyword != "" { |
| | | db = db.Where("name LIKE ? or number LIKE ?", "%"+info.Name+"%", "%"+info.Number+"%") |
| | | } |
| | | |
| | | db = db.Where("purchase_type = ?", test.PurchaseTypeOutSource) |
| | | |
| | | err = db.Count(&total).Error |
| | | if err != nil { |
| | | return |
| | | } |
| | | |
| | | err = db.Limit(limit).Offset(offset).Find(&ps).Error |
| | | return ps, total, err |
| | | } |