infra, item remove parent_id, infra_id
This commit is contained in:
@@ -13,7 +13,7 @@ type CreateDto struct {
|
||||
Name string `json:"name" validate:"maxLength=50"`
|
||||
InfraGroup_Code ero.InfraGroupCode `json:"infraGroup_code" validate:"maxLength=15"`
|
||||
Parent_Code *string `json:"parent_code"`
|
||||
Item_Id *uint `json:"-"`
|
||||
Item_Code *string `json:"-"`
|
||||
Unit_Code *string `json:"unit_code"`
|
||||
Specialist_Code *string `json:"specialist_code"`
|
||||
Subspecialist_Code *string `json:"subspecialist_code"`
|
||||
@@ -78,11 +78,11 @@ func (d Infra) ToResponse() ResponseDto {
|
||||
Name: d.Name,
|
||||
InfraGroup_Code: d.InfraGroup_Code,
|
||||
Parent_Code: d.Parent_Code,
|
||||
Parent: d.Parent,
|
||||
Childrens: d.Childrens,
|
||||
Item_Code: d.Item_Code,
|
||||
Item: d.Item,
|
||||
Rooms: d.Rooms,
|
||||
// Parent: d.Parent,
|
||||
Childrens: d.Childrens,
|
||||
Item_Code: d.Item_Code,
|
||||
Item: d.Item,
|
||||
Rooms: d.Rooms,
|
||||
}
|
||||
resp.SmallMain = d.SmallMain
|
||||
return resp
|
||||
|
||||
@@ -11,15 +11,13 @@ import (
|
||||
|
||||
type Infra struct {
|
||||
ecore.SmallMain // adjust this according to the needs
|
||||
Code string `json:"code" gorm:"uniqueIndex;size:10"`
|
||||
Code string `json:"code" gorm:"uniqueIndex;size:10;not null"`
|
||||
Name string `json:"name" gorm:"size:50"`
|
||||
InfraGroup_Code ero.InfraGroupCode `json:"infraGroup_code" gorm:"size:15"`
|
||||
Parent_Id *uint16 `json:"parent_id"`
|
||||
Parent_Code *string `json:"parent_code" gorm:"size:10"`
|
||||
Parent *Infra `json:"parent" gorm:"foreignKey:Parent_Id;references:Id"`
|
||||
Childrens []Infra `json:"childrens" gorm:"foreignKey:Parent_Id"` // may need references to self
|
||||
Item_Id *uint `json:"item_id"`
|
||||
Parent *Infra `json:"parent" gorm:"foreignKey:Parent_Code;references:Code"`
|
||||
Childrens []Infra `json:"childrens" gorm:"foreignKey:Parent_Code;references:Code"`
|
||||
Item_Code *string `json:"item_code" gorm:"size:50"`
|
||||
Item *ei.Item `json:"item,omitempty" gorm:"foreignKey:Item_Id;references:Id"`
|
||||
Item *ei.Item `json:"item,omitempty" gorm:"foreignKey:Item_Code;references:Code"`
|
||||
Rooms []erb.Basic `json:"rooms" gorm:"foreignKey:Infra_Code;references:Code"`
|
||||
}
|
||||
|
||||
@@ -14,7 +14,6 @@ type Item struct {
|
||||
ItemGroup_Code ero.ItemGroupCode `json:"itemGroup_code" gorm:"size:15"`
|
||||
Uom_Code *string `json:"uom_code" gorm:"size:10"`
|
||||
Uom *eu.Uom `json:"uom,omitempty" gorm:"foreignKey:Uom_Code;references:Code"`
|
||||
Infra_Id *uint16 `json:"infra_id"`
|
||||
Infra_Code *string `json:"infra_code" gorm:"size:10"`
|
||||
Stock *int `json:"stock"`
|
||||
}
|
||||
|
||||
@@ -30,7 +30,7 @@ func setData[T *e.CreateDto | *e.UpdateDto](input T, data *e.Infra) {
|
||||
data.Name = inputSrc.Name
|
||||
data.InfraGroup_Code = inputSrc.InfraGroup_Code
|
||||
data.Parent_Code = inputSrc.Parent_Code
|
||||
data.Item_Id = inputSrc.Item_Id
|
||||
data.Item_Code = inputSrc.Item_Code
|
||||
}
|
||||
|
||||
func createItem(input *e.CreateDto, event *pl.Event, tx *gorm.DB) error {
|
||||
@@ -49,7 +49,7 @@ func createItem(input *e.CreateDto, event *pl.Event, tx *gorm.DB) error {
|
||||
return err
|
||||
}
|
||||
|
||||
input.Item_Id = &item.Id
|
||||
input.Item_Code = &item.Code
|
||||
return nil
|
||||
}
|
||||
|
||||
|
||||
@@ -126,7 +126,7 @@ func UpdateData(input e.UpdateDto, data *e.Infra, event *pl.Event, dbx ...*gorm.
|
||||
} else {
|
||||
tx = dg.I
|
||||
}
|
||||
data.Parent = nil
|
||||
// data.Parent = nil
|
||||
data.Childrens = nil
|
||||
data.Item = nil
|
||||
data.Rooms = nil
|
||||
|
||||
Reference in New Issue
Block a user