FIX(BE): category dto do not show

This commit is contained in:
ragilap
2025-10-21 15:51:19 +07:00
parent 0dedd1149e
commit 445789edfe
4 changed files with 20 additions and 59 deletions
@@ -219,8 +219,8 @@ func (s *projectflockService) CreateOne(c *fiber.Ctx, req *validation.Create) (*
return nil, err
}
category, ok := utils.NormalizeProjectFlockCategory(req.Category)
if !ok {
cat := strings.ToUpper(req.Category)
if !utils.IsValidProjectFlockCategory(cat) {
return nil, fiber.NewError(fiber.StatusBadRequest, "Invalid category")
}
@@ -257,7 +257,7 @@ func (s *projectflockService) CreateOne(c *fiber.Ctx, req *validation.Create) (*
createBody := &entity.ProjectFlock{
FlockId: req.FlockId,
AreaId: req.AreaId,
Category: string(category),
Category: cat,
FcrId: req.FcrId,
LocationId: req.LocationId,
CreatedBy: 1,
@@ -342,11 +342,12 @@ func (s projectflockService) UpdateOne(c *fiber.Ctx, req *validation.Update, id
})
}
if req.Category != nil {
if normalized, ok := utils.NormalizeProjectFlockCategory(*req.Category); ok {
updateBody["category"] = string(normalized)
} else {
cat := strings.ToUpper(*req.Category)
if !utils.IsValidProjectFlockCategory(cat) {
return nil, fiber.NewError(fiber.StatusBadRequest, "Invalid category")
}
updateBody["category"] = cat
}
if req.FcrId != nil {
updateBody["fcr_id"] = *req.FcrId