mirror of
https://gitlab.com/mbugroup/lti-api.git
synced 2026-05-22 22:35:43 +00:00
add restrict delete master data kandang group
This commit is contained in:
@@ -226,6 +226,16 @@ func (s kandangGroupService) DeleteOne(c *fiber.Ctx, id uint) error {
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
hasDailyChecklistRelation, err := s.Repository.HasDailyChecklistRelation(c.Context(), id)
|
||||
if err != nil {
|
||||
s.Log.Errorf("Failed to check daily checklist relation for kandang group %d: %+v", id, err)
|
||||
return fiber.NewError(fiber.StatusInternalServerError, "Failed to check kandang group relation")
|
||||
}
|
||||
if hasDailyChecklistRelation {
|
||||
return fiber.NewError(fiber.StatusConflict, "Kandang group tidak boleh dihapus karena masih memiliki relasi daily checklist")
|
||||
}
|
||||
|
||||
if len(kandangGroup.Kandangs) > 0 {
|
||||
return fiber.NewError(fiber.StatusConflict, "Kandang group tidak boleh dihapus karena masih memiliki relasi kandang")
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user