add divisi
This commit is contained in:
No files matched your search
@@ -11,6 +11,8 @@ import (
|
||||
|
||||
e "simrs-vx/internal/domain/main-entities/unit"
|
||||
elog "simrs-vx/internal/domain/sync-entities/log"
|
||||
|
||||
d "github.com/karincake/dodol"
|
||||
)
|
||||
|
||||
func Create(input *e.CreateDto) error {
|
||||
@@ -34,15 +36,18 @@ func Create(input *e.CreateDto) error {
|
||||
}
|
||||
defer resp.Body.Close()
|
||||
|
||||
if resp.StatusCode != http.StatusOK {
|
||||
return fmt.Errorf(resp.Status)
|
||||
}
|
||||
|
||||
_, err = io.ReadAll(resp.Body)
|
||||
bodyBytes, err := io.ReadAll(resp.Body)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
if resp.StatusCode != http.StatusOK {
|
||||
errors := d.FieldError{}
|
||||
_ = json.Unmarshal(bodyBytes, &errors)
|
||||
|
||||
return fmt.Errorf(errors.Message)
|
||||
}
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
@@ -68,15 +73,18 @@ func CreateLog(input *elog.SimxLogDto) error {
|
||||
}
|
||||
defer resp.Body.Close()
|
||||
|
||||
if resp.StatusCode != http.StatusOK {
|
||||
return fmt.Errorf(resp.Status)
|
||||
}
|
||||
|
||||
_, err = io.ReadAll(resp.Body)
|
||||
bodyBytes, err := io.ReadAll(resp.Body)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
if resp.StatusCode != http.StatusOK {
|
||||
errors := d.FieldError{}
|
||||
_ = json.Unmarshal(bodyBytes, &errors)
|
||||
|
||||
return fmt.Errorf(errors.Message)
|
||||
}
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
@@ -102,15 +110,18 @@ func Update(input *e.UpdateDto) error {
|
||||
}
|
||||
defer resp.Body.Close()
|
||||
|
||||
if resp.StatusCode != http.StatusOK {
|
||||
return fmt.Errorf(resp.Status)
|
||||
}
|
||||
|
||||
_, err = io.ReadAll(resp.Body)
|
||||
bodyBytes, err := io.ReadAll(resp.Body)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
if resp.StatusCode != http.StatusOK {
|
||||
errors := d.FieldError{}
|
||||
_ = json.Unmarshal(bodyBytes, &errors)
|
||||
|
||||
return fmt.Errorf(errors.Message)
|
||||
}
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
@@ -136,15 +147,18 @@ func Delete(input *e.DeleteDto) error {
|
||||
}
|
||||
defer resp.Body.Close()
|
||||
|
||||
if resp.StatusCode != http.StatusOK {
|
||||
return fmt.Errorf(resp.Status)
|
||||
}
|
||||
|
||||
_, err = io.ReadAll(resp.Body)
|
||||
bodyBytes, err := io.ReadAll(resp.Body)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
if resp.StatusCode != http.StatusOK {
|
||||
errors := d.FieldError{}
|
||||
_ = json.Unmarshal(bodyBytes, &errors)
|
||||
|
||||
return fmt.Errorf(errors.Message)
|
||||
}
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user