grouptasks pagination
parent
d094dec64e
commit
c70b1c396a
|
@ -191,7 +191,7 @@ func GetEquipmentDocumentations(stockItemId string, query structs.PageQuery, c *
|
|||
return c.SendStatus(fiber.StatusInternalServerError)
|
||||
}
|
||||
} else {
|
||||
totalPages = utils.GetTotalPages(&documentations, stockItemId, "stock_item_id = ?", stockItemId)
|
||||
totalPages = utils.GetTotalPages(&documentations, "stock_item_id = ?", stockItemId)
|
||||
}
|
||||
|
||||
logger.AddSystemLog(structs.LogMessage{
|
||||
|
|
|
@ -110,7 +110,7 @@ type GroupTasksRequest struct {
|
|||
|
||||
// swagger:model GroupTasksResponse
|
||||
type GroupTasksResponse struct {
|
||||
CategoryGroups []CategoryGroup
|
||||
GroupTasks []GroupTasks
|
||||
GroupTasksSteps []GroupTaskSteps
|
||||
CategoryGroup CategoryGroup
|
||||
GroupTasks []GroupTasks
|
||||
TotalPages int
|
||||
}
|
||||
|
|
|
@ -37,7 +37,7 @@ const (
|
|||
ConnectionStateOnline = 1
|
||||
|
||||
EquipmentDocumentationsPaginationLimit = 3
|
||||
GroupTasksPaginationLimit = 10
|
||||
GroupTasksPaginationLimit = 5
|
||||
)
|
||||
|
||||
var (
|
||||
|
|
|
@ -115,8 +115,8 @@ func QueryParserHelper(c *fiber.Ctx, query interface{}) error {
|
|||
}
|
||||
|
||||
// GetTotalPages returns total pages for pagination
|
||||
// Example Where("stock_item_id = ?", stockItemId) -> whereQuery = "stock_item_id = ?" and whereQuery = stockItemId
|
||||
func GetTotalPages(any interface{}, stockItemId string, whereQuery interface{}, args ...interface{}) int {
|
||||
// Example whereQuery = "stock_item_id = ?" and args = stockItemId is Where("stock_item_id = ?", stockItemId)
|
||||
func GetTotalPages(any interface{}, whereQuery interface{}, args ...interface{}) int {
|
||||
var totalPages int64
|
||||
|
||||
database.DB.Model(any).
|
||||
|
|
|
@ -28,10 +28,18 @@ func GetGroupTasks(c *fiber.Ctx) error {
|
|||
log.Info().Msgf("params: %v", params)
|
||||
log.Info().Msgf("query: %v", query)
|
||||
|
||||
var categoryGroup structs.CategoryGroup
|
||||
|
||||
for _, cGroup := range cache.GetCategoryGroups() {
|
||||
if cGroup.Category == params.Category {
|
||||
categoryGroup = cGroup
|
||||
}
|
||||
}
|
||||
|
||||
return c.JSON(structs.GroupTasksResponse{
|
||||
CategoryGroups: cache.GetCategoryGroupsSorted(),
|
||||
GroupTasks: grouptasks.GetAllGroupTasks(params.Category, query),
|
||||
GroupTasksSteps: grouptasks.GetAllGroupTasksSteps(),
|
||||
CategoryGroup: categoryGroup,
|
||||
GroupTasks: grouptasks.GetAllGroupTasks(params.Category, query),
|
||||
TotalPages: utils.GetTotalPages([]structs.GroupTasks{}, "category = ?", params.Category),
|
||||
})
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue