mirror of
https://gitlab.com/mbugroup/lti-api.git
synced 2026-05-20 13:31:56 +00:00
Feat(BE-36,37,38,39): finish master data management api
This commit is contained in:
@@ -108,7 +108,7 @@ func (s *kandangService) CreateOne(c *fiber.Ctx, req *validation.Create) (*entit
|
||||
return nil, err
|
||||
}
|
||||
|
||||
return s.Repository.GetByID(c.Context(), createBody.Id, s.withRelations)
|
||||
return s.GetOne(c, createBody.Id)
|
||||
}
|
||||
|
||||
func (s kandangService) UpdateOne(c *fiber.Ctx, req *validation.Update, id uint) (*entity.Kandang, error) {
|
||||
@@ -128,17 +128,18 @@ func (s kandangService) UpdateOne(c *fiber.Ctx, req *validation.Update, id uint)
|
||||
updateBody["name"] = *req.Name
|
||||
}
|
||||
|
||||
if err := common.EnsureRelations(c.Context(),
|
||||
common.RelationCheck{Name: "Location", ID: req.LocationId, Exists: s.Repository.LocationExists},
|
||||
common.RelationCheck{Name: "Pic", ID: req.PicId, Exists: s.Repository.PicExists},
|
||||
); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
if req.LocationId != nil {
|
||||
if err := common.EnsureRelations(c.Context(), common.RelationCheck{Name: "Location", ID: req.LocationId, Exists: s.Repository.LocationExists}); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
updateBody["location_id"] = *req.LocationId
|
||||
}
|
||||
|
||||
if req.PicId != nil {
|
||||
if err := common.EnsureRelations(c.Context(), common.RelationCheck{Name: "Pic", ID: req.PicId, Exists: s.Repository.PicExists}); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
updateBody["pic_id"] = *req.PicId
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user