product_material.go 1.7 KB
package domain

import "time"

// 生产物料
type ProductMaterial struct {
	// 物料ID
	ProductMaterialId int `json:"productMaterialId"`
	// 企业id
	CompanyId int `json:"companyId"`
	// 组织ID
	OrgId int `json:"orgId"`
	// 物料分组ID
	ProductMaterialGroupId int `json:"productMaterialGroupId"`
	// 物料编码
	MaterialNumber string `json:"materialNumber"`
	// 物料名称
	MaterialName string `json:"materialName"`
	// 物料属性
	MaterialAttribute *MaterialAttribute `json:"materialAttribute"`
	// 物料类别
	MaterialCategory *MaterialCategory `json:"materialCategory"`
	// 物料扩展
	ProductMaterialExt *MaterialExt `json:"productMaterialExt"`
	// 创建时间
	CreatedAt time.Time `json:"createdAt"`
	// 更新时间
	UpdatedAt time.Time `json:"updatedAt"`
	// 删除时间
	DeletedAt time.Time `json:"deletedAt"`
	// 扩展
	Ext *Ext `json:"ext"`
}

type ProductMaterialRepository interface {
	Save(productMaterial *ProductMaterial) (*ProductMaterial, error)
	Remove(productMaterial *ProductMaterial) (*ProductMaterial, error)
	FindOne(queryOptions map[string]interface{}) (*ProductMaterial, error)
	Find(queryOptions map[string]interface{}) (int64, []*ProductMaterial, error)
}

func (productMaterial *ProductMaterial) Identify() interface{} {
	if productMaterial.ProductMaterialId == 0 {
		return nil
	}
	return productMaterial.ProductMaterialId
}

func (productMaterial *ProductMaterial) Update(data map[string]interface{}) error {
	return nil
}

type ProductMaterials []*ProductMaterial

func (productMaterials ProductMaterials) ToMapById() map[int]*ProductMaterial {
	var mapProductMaterial = make(map[int]*ProductMaterial, 0)
	for _, v := range productMaterials {
		mapProductMaterial[v.ProductMaterialId] = v
	}
	return mapProductMaterial
}