mirror of
https://gitlab.com/mbugroup/lti-api.git
synced 2026-05-25 07:45:44 +00:00
feat[BE-127]: Createing transfer laying create one, approvals, get one, get all, update, delete, but Still unfinished
This commit is contained in:
+37
-2
@@ -30,6 +30,10 @@ func (u *TransferLayingController) GetAll(c *fiber.Ctx) error {
|
||||
TargetProjectFlockId: uint(c.QueryInt("target_project_flock_id", 0)),
|
||||
TransferDateFrom: c.Query("transfer_date_from", ""),
|
||||
TransferDateTo: c.Query("transfer_date_to", ""),
|
||||
ApprovalStatus: c.Query("approval_status", ""),
|
||||
TransferNumber: c.Query("transfer_number", ""),
|
||||
Sort: c.Query("sort", "created_at"),
|
||||
Order: c.Query("order", "desc"),
|
||||
}
|
||||
|
||||
if query.Page < 1 || query.Limit < 1 {
|
||||
@@ -64,7 +68,7 @@ func (u *TransferLayingController) GetOne(c *fiber.Ctx) error {
|
||||
return fiber.NewError(fiber.StatusBadRequest, "Invalid Id")
|
||||
}
|
||||
|
||||
result, err := u.TransferLayingService.GetOne(c, uint(id))
|
||||
result, approval, err := u.TransferLayingService.GetOneWithApproval(c, uint(id))
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
@@ -74,7 +78,7 @@ func (u *TransferLayingController) GetOne(c *fiber.Ctx) error {
|
||||
Code: fiber.StatusOK,
|
||||
Status: "success",
|
||||
Message: "Get transferLaying successfully",
|
||||
Data: dto.ToTransferLayingListDTO(*result),
|
||||
Data: dto.ToTransferLayingDetailDTOWithSingleApproval(*result, approval),
|
||||
})
|
||||
}
|
||||
|
||||
@@ -145,3 +149,34 @@ func (u *TransferLayingController) DeleteOne(c *fiber.Ctx) error {
|
||||
Message: "Delete transferLaying successfully",
|
||||
})
|
||||
}
|
||||
|
||||
func (u *TransferLayingController) Approval(c *fiber.Ctx) error {
|
||||
req := new(validation.Approve)
|
||||
if err := c.BodyParser(req); err != nil {
|
||||
return fiber.NewError(fiber.StatusBadRequest, "Invalid request body")
|
||||
}
|
||||
|
||||
results, err := u.TransferLayingService.Approval(c, req)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
var (
|
||||
data interface{}
|
||||
message = "Submit transfer laying approval successfully"
|
||||
)
|
||||
if len(results) == 1 {
|
||||
data = dto.ToTransferLayingListDTO(results[0])
|
||||
} else {
|
||||
message = "Submit transfer laying approvals successfully"
|
||||
data = dto.ToTransferLayingListDTOs(results)
|
||||
}
|
||||
|
||||
return c.Status(fiber.StatusOK).
|
||||
JSON(response.Success{
|
||||
Code: fiber.StatusOK,
|
||||
Status: "success",
|
||||
Message: message,
|
||||
Data: data,
|
||||
})
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user