mirror of
https://gitlab.com/mbugroup/lti-api.git
synced 2026-05-23 23:05:44 +00:00
add query param location id
This commit is contained in:
+1
@@ -32,6 +32,7 @@ func (u *ProjectFlockKandangController) GetAll(c *fiber.Ctx) error {
|
|||||||
KandangId: uint(c.QueryInt("kandang_id", 0)),
|
KandangId: uint(c.QueryInt("kandang_id", 0)),
|
||||||
Category: c.Query("category", ""),
|
Category: c.Query("category", ""),
|
||||||
AreaId: uint(c.QueryInt("area_id", 0)),
|
AreaId: uint(c.QueryInt("area_id", 0)),
|
||||||
|
LocationId: uint(c.QueryInt("location_id", 0)),
|
||||||
SortBy: c.Query("sort_by", ""),
|
SortBy: c.Query("sort_by", ""),
|
||||||
SortOrder: c.Query("sort_order", ""),
|
SortOrder: c.Query("sort_order", ""),
|
||||||
StepName: c.Query("step_name", ""),
|
StepName: c.Query("step_name", ""),
|
||||||
|
|||||||
+1
@@ -19,6 +19,7 @@ type Query struct {
|
|||||||
KandangId uint `query:"kandang_id" validate:"omitempty"`
|
KandangId uint `query:"kandang_id" validate:"omitempty"`
|
||||||
Category string `query:"category" validate:"omitempty,oneof=Growing Laying"`
|
Category string `query:"category" validate:"omitempty,oneof=Growing Laying"`
|
||||||
AreaId uint `query:"area_id" validate:"omitempty"`
|
AreaId uint `query:"area_id" validate:"omitempty"`
|
||||||
|
LocationId uint `query:"location_id" validate:"omitempty,number,gt=0"`
|
||||||
SortBy string `query:"sort_by" validate:"omitempty,oneof=created_at period"`
|
SortBy string `query:"sort_by" validate:"omitempty,oneof=created_at period"`
|
||||||
SortOrder string `query:"sort_order" validate:"omitempty,oneof=ASC DESC"`
|
SortOrder string `query:"sort_order" validate:"omitempty,oneof=ASC DESC"`
|
||||||
StepName string `query:"step_name" validate:"omitempty,max=50"`
|
StepName string `query:"step_name" validate:"omitempty,max=50"`
|
||||||
|
|||||||
+12
@@ -178,6 +178,10 @@ func (r *projectFlockKandangRepositoryImpl) GetAllWithFilters(ctx context.Contex
|
|||||||
if query.AreaId > 0 {
|
if query.AreaId > 0 {
|
||||||
q = q.Where("\"project_flocks\".\"area_id\" = ?", query.AreaId)
|
q = q.Where("\"project_flocks\".\"area_id\" = ?", query.AreaId)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if query.LocationId > 0 {
|
||||||
|
q = q.Where("\"kandangs\".\"location_id\" = ?", query.LocationId)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if err := q.Model(&entity.ProjectFlockKandang{}).Count(&total).Error; err != nil {
|
if err := q.Model(&entity.ProjectFlockKandang{}).Count(&total).Error; err != nil {
|
||||||
@@ -276,6 +280,10 @@ func (r *projectFlockKandangRepositoryImpl) GetAllWithFiltersScoped(ctx context.
|
|||||||
if query.AreaId > 0 {
|
if query.AreaId > 0 {
|
||||||
q = q.Where("\"project_flocks\".\"area_id\" = ?", query.AreaId)
|
q = q.Where("\"project_flocks\".\"area_id\" = ?", query.AreaId)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if query.LocationId > 0 {
|
||||||
|
q = q.Where("\"kandangs\".\"location_id\" = ?", query.LocationId)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if err := q.Model(&entity.ProjectFlockKandang{}).Count(&total).Error; err != nil {
|
if err := q.Model(&entity.ProjectFlockKandang{}).Count(&total).Error; err != nil {
|
||||||
@@ -362,6 +370,10 @@ func (r *projectFlockKandangRepositoryImpl) GetAllNameWithPeriodeScoped(ctx cont
|
|||||||
if params.AreaId > 0 {
|
if params.AreaId > 0 {
|
||||||
q = q.Where("\"project_flocks\".\"area_id\" = ?", params.AreaId)
|
q = q.Where("\"project_flocks\".\"area_id\" = ?", params.AreaId)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if params.LocationId > 0 {
|
||||||
|
q = q.Where("\"kandangs\".\"location_id\" = ?", params.LocationId)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if err := q.Count(&total).Error; err != nil {
|
if err := q.Count(&total).Error; err != nil {
|
||||||
|
|||||||
Reference in New Issue
Block a user