unit_conversion.go 1.9 KB
package domain

import "time"

// 单位换算
type UnitConversion struct {
	// 单位换算ID
	UnitConversionId int `json:"unitConversionId,omitempty"`
	// 企业id
	CompanyId int `json:"companyId,omitempty"`
	// 组织ID
	OrgId int `json:"orgId,omitempty"`
	// 工作位置
	WorkStation *WorkStation `json:"workStation,omitempty"`
	// material
	Material *Material `json:"material,omitempty"`
	// 转换前单位数量
	FromUnitQuantity *UnitQuantity `json:"fromUnitQuantity,omitempty"`
	// 转换后单位数量
	ToUnitQuantity *UnitQuantity `json:"toUnitQuantity,omitempty"`
	// 智能称重标识 1:是 2:否
	IntelligentWeighingFlag int `json:"intelligentWeighingFlag,omitempty"`
	// 创建时间
	CreatedAt time.Time `json:"createdAt,omitempty"`
	// 更新时间
	UpdatedAt time.Time `json:"updatedAt,omitempty"`
	// 删除时间
	DeletedAt time.Time `json:"deletedAt,omitempty"`
	// 扩展数据
	Ext *Ext `json:"ext,omitempty"`
}

type UnitConversionRepository interface {
	Save(unitConversion *UnitConversion) (*UnitConversion, error)
	Remove(unitConversion *UnitConversion) (*UnitConversion, error)
	FindOne(queryOptions map[string]interface{}) (*UnitConversion, error)
	Find(queryOptions map[string]interface{}) (int64, []*UnitConversion, error)
}

func (unitConversion *UnitConversion) Identify() interface{} {
	if unitConversion.UnitConversionId == 0 {
		return nil
	}
	return unitConversion.UnitConversionId
}

func (unitConversion *UnitConversion) Update(data map[string]interface{}) error {
	//if materialName, ok := data["materialName"]; ok {
	//	unitConversion.Material.MaterialName = materialName.(string)
	//}
	//if materialCategory, ok := data["materialCategory"]; ok {
	//	unitConversion.Material.MaterialCategory = materialCategory.(string)
	//}
	//if intelligentWeighingFlag, ok := data["intelligentWeighingFlag"]; ok {
	//	unitConversion.IntelligentWeighingFlag = intelligentWeighingFlag.(bool)
	//}
	unitConversion.UpdatedAt = time.Now()
	return nil
}