mirror of
https://gitlab.com/mbugroup/lti-api.git
synced 2026-05-20 13:31:56 +00:00
[FEAT/BE] fix status closed project flock, closing perhitungan sapronak
This commit is contained in:
@@ -42,6 +42,7 @@ type KandangWithProjectFlockIdDTO struct {
|
||||
kandangDTO.KandangRelationDTO
|
||||
ProjectFlockKandangId uint `json:"project_flock_kandang_id"`
|
||||
Period int `json:"period"`
|
||||
ClosedAt *time.Time `json:"closed_at,omitempty"`
|
||||
}
|
||||
|
||||
type ProjectFlockDetailDTO struct {
|
||||
@@ -74,20 +75,28 @@ func ToProjectFlockListDTOWithPeriod(e entity.ProjectFlock, period int) ProjectF
|
||||
for i, kandang := range e.Kandangs {
|
||||
|
||||
var (
|
||||
pfkId uint
|
||||
period int
|
||||
pfkId uint
|
||||
period int
|
||||
closedAt *time.Time
|
||||
)
|
||||
for _, kh := range e.KandangHistory {
|
||||
if kh.KandangId == kandang.Id {
|
||||
pfkId = kh.Id
|
||||
period = kh.Period
|
||||
closedAt = kh.ClosedAt
|
||||
break
|
||||
}
|
||||
}
|
||||
mapped := kandangDTO.ToKandangRelationDTO(kandang)
|
||||
if closedAt != nil {
|
||||
// Jangan ubah tabel kandang, hanya override status di response.
|
||||
mapped.Status = string(utils.KandangStatusNonActive)
|
||||
}
|
||||
kandangSummaries[i] = KandangWithProjectFlockIdDTO{
|
||||
KandangRelationDTO: kandangDTO.ToKandangRelationDTO(kandang),
|
||||
KandangRelationDTO: mapped,
|
||||
ProjectFlockKandangId: pfkId,
|
||||
Period: period,
|
||||
ClosedAt: closedAt,
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user