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.InstallationPosition
|
||||
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.InstallationPosition
|
||||
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 := ui.ReadDetail(ei.ReadDetailDto{Id: *input.Installation_Id}); err != nil {
|
||||
if _, err := ui.ReadDetail(ei.ReadDetailDto{Code: input.Installation_Code}); err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
|
||||
@@ -17,7 +17,7 @@ func setData[T *e.CreateDto | *e.UpdateDto](input T, data *e.InstallationPositio
|
||||
inputSrc = &inputTemp.CreateDto
|
||||
}
|
||||
|
||||
data.Installation_Id = inputSrc.Installation_Id
|
||||
data.Installation_Code = inputSrc.Installation_Code
|
||||
data.Code = inputSrc.Code
|
||||
data.Name = inputSrc.Name
|
||||
data.HeadStatus = inputSrc.HeadStatus
|
||||
|
||||
@@ -83,10 +83,10 @@ 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)
|
||||
getData = tx.Where("\"Code\" = ?", *input.Code).First(&data)
|
||||
default:
|
||||
event.Status = "failed"
|
||||
event.ErrInfo = pl.ErrorInfo{
|
||||
|
||||
Reference in New Issue
Block a user