add divisi

This commit is contained in:
vanilia
2025-11-17 16:17:26 +07:00
parent 18af731553
commit 8911bb678c
12 changed files with 431 additions and 327 deletions

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
}