specialist, subscpecialist, specialist-position, subspecialist-position ids into codes
This commit is contained in:
No files matched your search
@@ -290,7 +290,7 @@ func Delete(input e.DeleteDto) (*d.Data, error) {
|
||||
|
||||
func validateForeignKey(input e.CreateDto) error {
|
||||
// validate installation_id
|
||||
if _, err := us.ReadDetail(es.ReadDetailDto{Id: *input.Specialist_Id}); err != nil {
|
||||
if _, err := us.ReadDetail(es.ReadDetailDto{Code: input.Specialist_Code}); err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
|
||||
@@ -17,7 +17,7 @@ func setData[T *e.CreateDto | *e.UpdateDto](input T, data *e.SpecialistPosition)
|
||||
inputSrc = &inputTemp.CreateDto
|
||||
}
|
||||
|
||||
data.Specialist_Id = inputSrc.Specialist_Id
|
||||
data.Specialist_Code = inputSrc.Specialist_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)
|
||||
|
||||
@@ -166,7 +166,7 @@ func ReadDetail(input e.ReadDetailDto) (*d.Data, error) {
|
||||
}
|
||||
|
||||
func Update(input e.UpdateDto) (*d.Data, error) {
|
||||
rdDto := e.ReadDetailDto{Id: uint16(input.Id)}
|
||||
rdDto := e.ReadDetailDto{Code: &input.Code}
|
||||
var data *e.Specialist
|
||||
var err error
|
||||
|
||||
@@ -222,7 +222,7 @@ func Update(input e.UpdateDto) (*d.Data, error) {
|
||||
}
|
||||
|
||||
func Delete(input e.DeleteDto) (*d.Data, error) {
|
||||
rdDto := e.ReadDetailDto{Id: uint16(input.Id)}
|
||||
rdDto := e.ReadDetailDto{Code: input.Code}
|
||||
var data *e.Specialist
|
||||
var err error
|
||||
|
||||
|
||||
@@ -19,5 +19,5 @@ func setData[T *e.CreateDto | *e.UpdateDto](input T, data *e.Specialist) {
|
||||
|
||||
data.Code = inputSrc.Code
|
||||
data.Name = inputSrc.Name
|
||||
data.Unit_Id = inputSrc.Unit_Id
|
||||
data.Unit_Code = inputSrc.Unit_Code
|
||||
}
|
||||
@@ -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.SubspecialistPosition
|
||||
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.SubspecialistPosition
|
||||
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 := us.ReadDetail(es.ReadDetailDto{Id: *input.Subspecialist_Id}); err != nil {
|
||||
if _, err := us.ReadDetail(es.ReadDetailDto{Code: input.Subspecialist_Code}); err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
|
||||
@@ -17,7 +17,7 @@ func setData[T *e.CreateDto | *e.UpdateDto](input T, data *e.SubspecialistPositi
|
||||
inputSrc = &inputTemp.CreateDto
|
||||
}
|
||||
|
||||
data.Subspecialist_Id = inputSrc.Subspecialist_Id
|
||||
data.Subspecialist_Code = inputSrc.Subspecialist_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{
|
||||
|
||||
@@ -166,7 +166,7 @@ func ReadDetail(input e.ReadDetailDto) (*d.Data, error) {
|
||||
}
|
||||
|
||||
func Update(input e.UpdateDto) (*d.Data, error) {
|
||||
rdDto := e.ReadDetailDto{Id: uint16(input.Id)}
|
||||
rdDto := e.ReadDetailDto{Code: &input.Code}
|
||||
var data *e.Subspecialist
|
||||
var err error
|
||||
|
||||
@@ -222,7 +222,7 @@ func Update(input e.UpdateDto) (*d.Data, error) {
|
||||
}
|
||||
|
||||
func Delete(input e.DeleteDto) (*d.Data, error) {
|
||||
rdDto := e.ReadDetailDto{Id: uint16(input.Id)}
|
||||
rdDto := e.ReadDetailDto{Code: input.Code}
|
||||
var data *e.Subspecialist
|
||||
var err error
|
||||
|
||||
|
||||
@@ -81,6 +81,13 @@ func ReadDetailData(input e.ReadDetailDto, event *pl.Event, dbx ...*gorm.DB) (*e
|
||||
tx = dg.I
|
||||
}
|
||||
|
||||
if input.Code != nil {
|
||||
tx = tx.Where("\"Code\" = ?", *input.Code)
|
||||
}
|
||||
if input.Id != nil {
|
||||
tx = tx.Where("\"Id\" = ?", input.Id)
|
||||
}
|
||||
|
||||
if err := tx.
|
||||
Scopes(gh.Preload(input.Includes)).
|
||||
First(&data, input.Id).Error; err != nil {
|
||||
|
||||
Reference in New Issue
Block a user