mirror of
https://gitlab.com/mbugroup/lti-api.git
synced 2026-05-20 13:31:56 +00:00
Merge branch 'feat/kandang-groups' into 'development'
[FIX][BE]: adjust api delete group kandang See merge request mbugroup/lti-api!367
This commit is contained in:
@@ -222,9 +222,13 @@ func (s kandangGroupService) UpdateOne(c *fiber.Ctx, req *validation.Update, id
|
|||||||
}
|
}
|
||||||
|
|
||||||
func (s kandangGroupService) DeleteOne(c *fiber.Ctx, id uint) error {
|
func (s kandangGroupService) DeleteOne(c *fiber.Ctx, id uint) error {
|
||||||
if _, err := s.GetOne(c, id); err != nil {
|
kandangGroup, err := s.GetOne(c, id)
|
||||||
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
if len(kandangGroup.Kandangs) > 0 {
|
||||||
|
return fiber.NewError(fiber.StatusConflict, "Kandang group tidak boleh dihapus karena masih memiliki relasi kandang")
|
||||||
|
}
|
||||||
|
|
||||||
if err := s.Repository.DeleteOne(c.Context(), id); err != nil {
|
if err := s.Repository.DeleteOne(c.Context(), id); err != nil {
|
||||||
if errors.Is(err, gorm.ErrRecordNotFound) {
|
if errors.Is(err, gorm.ErrRecordNotFound) {
|
||||||
|
|||||||
Reference in New Issue
Block a user