mirror of
https://gitlab.com/mbugroup/lti-api.git
synced 2026-05-20 13:31:56 +00:00
fix(BE): req body approval and fix projectflock.dto
This commit is contained in:
@@ -191,29 +191,33 @@ func (u *ProjectflockController) DeleteOne(c *fiber.Ctx) error {
|
||||
}
|
||||
|
||||
func (u *ProjectflockController) Approval(c *fiber.Ctx) error {
|
||||
param := c.Params("id")
|
||||
|
||||
id, err := strconv.Atoi(param)
|
||||
if err != nil {
|
||||
return fiber.NewError(fiber.StatusBadRequest, "Invalid Id")
|
||||
}
|
||||
|
||||
req := new(validation.Approve)
|
||||
if err := c.BodyParser(req); err != nil {
|
||||
return fiber.NewError(fiber.StatusBadRequest, "Invalid request body")
|
||||
}
|
||||
|
||||
result, err := u.ProjectflockService.Approval(c, uint(id), req)
|
||||
results, err := u.ProjectflockService.Approval(c, req)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
var (
|
||||
data interface{}
|
||||
message = "Submit projectflock approval successfully"
|
||||
)
|
||||
if len(results) == 1 {
|
||||
data = dto.ToProjectFlockListDTO(results[0])
|
||||
} else {
|
||||
message = "Submit projectflock approvals successfully"
|
||||
data = dto.ToProjectFlockListDTOs(results)
|
||||
}
|
||||
|
||||
return c.Status(fiber.StatusOK).
|
||||
JSON(response.Success{
|
||||
Code: fiber.StatusOK,
|
||||
Status: "success",
|
||||
Message: "Submit projectflock approval successfully",
|
||||
Data: dto.ToProjectFlockListDTO(*result),
|
||||
Message: message,
|
||||
Data: data,
|
||||
})
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user