|
|
package allied_creation_manufacture
|
|
|
|
|
|
import (
|
|
|
"fmt"
|
|
|
"time"
|
|
|
|
|
|
"gitlab.fjmaimaimai.com/allied-creation/allied-creation-gateway/pkg/constant"
|
|
|
"gitlab.fjmaimaimai.com/allied-creation/allied-creation-gateway/pkg/domain"
|
|
|
"gitlab.fjmaimaimai.com/allied-creation/allied-creation-gateway/pkg/infrastructure/service_gateway"
|
|
|
)
|
|
|
|
|
|
//HttpLibAlliedCreationManufacture 生产制造模块
|
|
|
type HttpLibAlliedCreationManufacture struct {
|
|
|
service_gateway.BaseServiceGateway
|
|
|
baseUrL string
|
|
|
}
|
|
|
|
|
|
func NewHttpLibAlliedCreationManufacture(operator domain.Operator) *HttpLibAlliedCreationManufacture {
|
|
|
return &HttpLibAlliedCreationManufacture{
|
|
|
BaseServiceGateway: service_gateway.BaseServiceGateway{
|
|
|
ConnectTimeout: 100 * time.Second,
|
|
|
ReadWriteTimeout: 100 * time.Second,
|
|
|
CompanyId: operator.CompanyId,
|
|
|
OrgId: operator.OrgId,
|
|
|
UserId: operator.UserId,
|
|
|
UserBaseId: operator.UserBaseId,
|
|
|
},
|
|
|
baseUrL: constant.ALLIED_CREATION_MANUFACTURE_HOST,
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
func (gateway HttpLibAlliedCreationManufacture) BaseUrl() string {
|
|
|
return gateway.baseUrL
|
|
|
}
|
|
|
|
|
|
//BatchAddProduct 批量添加产品
|
|
|
func (gateway HttpLibAlliedCreationManufacture) BatchAddProduct(param BatchAddProductRequest) (*BatchAddProductResponse, error) {
|
|
|
url := fmt.Sprintf("%s%s", gateway.BaseUrl(), "/products/batch-add")
|
|
|
method := "post"
|
|
|
var data BatchAddProductResponse
|
|
|
err := gateway.FastDoRequest(url, method, param, &data)
|
|
|
return &data, err
|
|
|
}
|
|
|
|
|
|
type BatchAddProductRequest struct {
|
|
|
List []*domain.ImportProductItem `json:"list"`
|
|
|
}
|
|
|
type BatchAddProductResponse []interface{}
|
|
|
|
|
|
//BatchAddProduct 批量添加产品
|
|
|
func (gateway HttpLibAlliedCreationManufacture) SearchProduct(param SearchProductRequest) (*SearchProductResponse, error) {
|
|
|
url := fmt.Sprintf("%s%s", gateway.BaseUrl(), "/products/search")
|
|
|
method := "post"
|
|
|
var data SearchProductResponse
|
|
|
err := gateway.FastDoRequest(url, method, param, &data)
|
|
|
return &data, err
|
|
|
}
|
|
|
|
|
|
type (
|
|
|
SearchProductRequest struct {
|
|
|
// 页码
|
|
|
PageNumber int `cname:"页码" json:"pageNumber,omitempty"`
|
|
|
// 页数
|
|
|
PageSize int `cname:"页数" json:"pageSize,omitempty"`
|
|
|
// 产品名称
|
|
|
ProductName string `json:"productName,omitempty"`
|
|
|
// 产品类别
|
|
|
ProductCategory string `cname:"产品类别" json:"productCategory"`
|
|
|
}
|
|
|
SearchProductResponse struct {
|
|
|
Grid struct {
|
|
|
List []SearchProductItem `json:"list"`
|
|
|
Total int `json:"total"`
|
|
|
} `json:"grid"`
|
|
|
}
|
|
|
SearchProductItem struct {
|
|
|
ProductID int `json:"productId"`
|
|
|
ProductCode string `json:"productCode"`
|
|
|
ProductName string `json:"productName"`
|
|
|
ProductCategory string `json:"productCategory"`
|
|
|
Unit string `json:"unit"`
|
|
|
UnitWeight float64 `json:"unitWeight"`
|
|
|
}
|
|
|
) |
...
|
...
|
|