unit, unit-position,installation-position removes ids
This commit is contained in:
@@ -175,7 +175,7 @@ func ReadDetail(input e.ReadDetailDto) (*d.Data, error) {
|
||||
}
|
||||
|
||||
func Update(input e.UpdateDto) (*d.Data, error) {
|
||||
rdDto := e.ReadDetailDto{Id: input.Id}
|
||||
rdDto := e.ReadDetailDto{Code: &input.Code}
|
||||
var data *e.UnitPosition
|
||||
var err error
|
||||
|
||||
@@ -235,7 +235,7 @@ func Update(input e.UpdateDto) (*d.Data, error) {
|
||||
}
|
||||
|
||||
func Delete(input e.DeleteDto) (*d.Data, error) {
|
||||
rdDto := e.ReadDetailDto{Id: input.Id}
|
||||
rdDto := e.ReadDetailDto{Code: input.Code}
|
||||
var data *e.UnitPosition
|
||||
var err error
|
||||
|
||||
@@ -290,7 +290,7 @@ func Delete(input e.DeleteDto) (*d.Data, error) {
|
||||
|
||||
func validateForeignKey(input e.CreateDto) error {
|
||||
// validate installation_id
|
||||
if _, err := uu.ReadDetail(eu.ReadDetailDto{Id: *input.Unit_Id}); err != nil {
|
||||
if _, err := uu.ReadDetail(eu.ReadDetailDto{Code: &input.Code}); err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
|
||||
@@ -17,7 +17,7 @@ func setData[T *e.CreateDto | *e.UpdateDto](input T, data *e.UnitPosition) {
|
||||
inputSrc = &inputTemp.CreateDto
|
||||
}
|
||||
|
||||
data.Unit_Id = inputSrc.Unit_Id
|
||||
data.Unit_Code = inputSrc.Unit_Code
|
||||
data.Code = inputSrc.Code
|
||||
data.Name = inputSrc.Name
|
||||
data.HeadStatus = inputSrc.HeadStatus
|
||||
|
||||
@@ -83,7 +83,7 @@ func ReadDetailData(input e.ReadDetailDto, event *pl.Event, dbx ...*gorm.DB) (*e
|
||||
}
|
||||
|
||||
switch {
|
||||
case input.Id != 0:
|
||||
case input.Id != nil:
|
||||
getData = tx.First(&data, input.Id)
|
||||
case input.Code != nil && *input.Code != "":
|
||||
getData = tx.Where("code = ?", *input.Code).First(&data)
|
||||
|
||||
Reference in New Issue
Block a user