mirror of
https://gitlab.com/mbugroup/lti-api.git
synced 2026-05-25 07:45:44 +00:00
adjust query daily checklist
This commit is contained in:
@@ -17,7 +17,7 @@ type DailyChecklist struct {
|
|||||||
CreatedAt time.Time `gorm:"autoCreateTime"`
|
CreatedAt time.Time `gorm:"autoCreateTime"`
|
||||||
UpdatedAt time.Time `gorm:"autoUpdateTime"`
|
UpdatedAt time.Time `gorm:"autoUpdateTime"`
|
||||||
|
|
||||||
Kandang Kandang `gorm:"foreignKey:KandangId;references:Id"`
|
Kandang KandangGroup `gorm:"foreignKey:KandangId;references:Id"`
|
||||||
Checklist *Checklist `gorm:"foreignKey:ChecklistId;references:Id"`
|
Checklist *Checklist `gorm:"foreignKey:ChecklistId;references:Id"`
|
||||||
Creator *User `gorm:"foreignKey:CreatedBy;references:Id"`
|
Creator *User `gorm:"foreignKey:CreatedBy;references:Id"`
|
||||||
Tasks []DailyChecklistTask `gorm:"foreignKey:DailyChecklistId;references:Id"`
|
Tasks []DailyChecklistTask `gorm:"foreignKey:DailyChecklistId;references:Id"`
|
||||||
|
|||||||
@@ -64,9 +64,11 @@ func (u *DailyChecklistController) GetAll(c *fiber.Ctx) error {
|
|||||||
status = *item.Status
|
status = *item.Status
|
||||||
}
|
}
|
||||||
|
|
||||||
var kandang *kandangDTO.KandangRelationDTO
|
// var kandang *kandangDTO.KandangRelationDTO
|
||||||
|
var kandang *kandangDTO.KandangGroupRelationDTO
|
||||||
if item.Kandang.Id != 0 {
|
if item.Kandang.Id != 0 {
|
||||||
mapped := kandangDTO.ToKandangRelationDTO(item.Kandang)
|
// mapped := kandangDTO.ToKandangRelationDTO(item.Kandang)x
|
||||||
|
mapped := kandangDTO.ToKandangGroupRelationDTO(item.Kandang)
|
||||||
kandang = &mapped
|
kandang = &mapped
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -19,19 +19,19 @@ type DailyChecklistRelationDTO struct {
|
|||||||
}
|
}
|
||||||
|
|
||||||
type DailyChecklistListDTO struct {
|
type DailyChecklistListDTO struct {
|
||||||
Id uint `json:"id"`
|
Id uint `json:"id"`
|
||||||
Name string `json:"name"`
|
Name string `json:"name"`
|
||||||
Status string `json:"status"`
|
Status string `json:"status"`
|
||||||
Category string `json:"category"`
|
Category string `json:"category"`
|
||||||
Date time.Time `json:"date"`
|
Date time.Time `json:"date"`
|
||||||
Kandang *kandangDTO.KandangRelationDTO `json:"kandang,omitempty"`
|
Kandang *kandangDTO.KandangGroupRelationDTO `json:"kandang,omitempty"`
|
||||||
CreatedUser *userDTO.UserRelationDTO `json:"created_user"`
|
CreatedUser *userDTO.UserRelationDTO `json:"created_user"`
|
||||||
CreatedAt time.Time `json:"created_at"`
|
CreatedAt time.Time `json:"created_at"`
|
||||||
UpdatedAt time.Time `json:"updated_at"`
|
UpdatedAt time.Time `json:"updated_at"`
|
||||||
TotalPhase int `json:"total_phase"`
|
TotalPhase int `json:"total_phase"`
|
||||||
TotalActivity int `json:"total_activity"`
|
TotalActivity int `json:"total_activity"`
|
||||||
Progress int `json:"progress"`
|
Progress int `json:"progress"`
|
||||||
RejectReason *string `json:"reject_reason"`
|
RejectReason *string `json:"reject_reason"`
|
||||||
}
|
}
|
||||||
|
|
||||||
type DailyChecklistDetailDTO struct {
|
type DailyChecklistDetailDTO struct {
|
||||||
@@ -156,9 +156,9 @@ func ToDailyChecklistListDTO(e entity.DailyChecklist) DailyChecklistListDTO {
|
|||||||
status = *e.Status
|
status = *e.Status
|
||||||
}
|
}
|
||||||
|
|
||||||
var kandang *kandangDTO.KandangRelationDTO
|
var kandang *kandangDTO.KandangGroupRelationDTO
|
||||||
if e.Kandang.Id != 0 {
|
if e.Kandang.Id != 0 {
|
||||||
mapped := kandangDTO.ToKandangRelationDTO(e.Kandang)
|
mapped := kandangDTO.ToKandangGroupRelationDTO(e.Kandang)
|
||||||
kandang = &mapped
|
kandang = &mapped
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -75,7 +75,7 @@ type DailyChecklistListItem struct {
|
|||||||
RejectReason *string
|
RejectReason *string
|
||||||
CreatedAt time.Time
|
CreatedAt time.Time
|
||||||
UpdatedAt time.Time
|
UpdatedAt time.Time
|
||||||
Kandang entity.Kandang
|
Kandang entity.KandangGroup
|
||||||
TotalPhase int
|
TotalPhase int
|
||||||
TotalActivity int
|
TotalActivity int
|
||||||
Progress int
|
Progress int
|
||||||
@@ -341,9 +341,9 @@ func (s dailyChecklistService) GetAll(c *fiber.Ctx, params *validation.Query) ([
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
kandangMap := make(map[uint]entity.Kandang)
|
kandangMap := make(map[uint]entity.KandangGroup)
|
||||||
if len(kandangIDs) > 0 {
|
if len(kandangIDs) > 0 {
|
||||||
var kandangs []entity.Kandang
|
var kandangs []entity.KandangGroup
|
||||||
if err := s.Repository.DB().WithContext(c.Context()).
|
if err := s.Repository.DB().WithContext(c.Context()).
|
||||||
Where("id IN ?", kandangIDs).
|
Where("id IN ?", kandangIDs).
|
||||||
Preload("Location").
|
Preload("Location").
|
||||||
|
|||||||
Reference in New Issue
Block a user