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