mirror of
https://gitlab.com/mbugroup/lti-api.git
synced 2026-05-24 07:15:43 +00:00
[FIX][BE]: LSS390
This commit is contained in:
@@ -1,6 +1,7 @@
|
||||
package dto
|
||||
|
||||
import (
|
||||
"strconv"
|
||||
"time"
|
||||
|
||||
entity "gitlab.com/mbugroup/lti-api.git/internal/entities"
|
||||
@@ -53,6 +54,7 @@ type ProjectFlockKandangListDTO struct {
|
||||
ProjectFlockKandangRelationDTO
|
||||
ProjectFlock *ProjectFlockDTO `json:"project_flock,omitempty"`
|
||||
Kandang *kandangDTO.KandangRelationDTO `json:"kandang,omitempty"`
|
||||
NameWithPeriod string `json:"name_with_period"`
|
||||
CreatedUser *userDTO.UserRelationDTO `json:"created_user,omitempty"`
|
||||
CreatedAt time.Time `json:"created_at"`
|
||||
Approval *approvalDTO.ApprovalRelationDTO `json:"approval,omitempty"`
|
||||
@@ -104,6 +106,7 @@ func ToProjectFlockKandangDetailDTOWithAvailableQty(e entity.ProjectFlockKandang
|
||||
ProjectFlockKandangRelationDTO: ToProjectFlockKandangRelationDTO(e),
|
||||
ProjectFlock: toProjectFlockDTO(projectFlockSummary),
|
||||
Kandang: toKandangRelation(e.Kandang),
|
||||
NameWithPeriod: toNameWithPeriod(e.Kandang, e.Period),
|
||||
CreatedAt: e.CreatedAt,
|
||||
CreatedUser: toCreatedUserDTO(e.ProjectFlock),
|
||||
Approval: toApprovalDTOSelector(e, func(x entity.ProjectFlockKandang) *entity.Approval { return x.LatestProjectFlockApproval }),
|
||||
@@ -126,6 +129,16 @@ func toKandangRelation(kandang entity.Kandang) *kandangDTO.KandangRelationDTO {
|
||||
return &mapped
|
||||
}
|
||||
|
||||
func toNameWithPeriod(kandang entity.Kandang, period int) string {
|
||||
if kandang.Name == "" {
|
||||
return ""
|
||||
}
|
||||
if period == 0 {
|
||||
return kandang.Name
|
||||
}
|
||||
return kandang.Name + " Period " + strconv.Itoa(period)
|
||||
}
|
||||
|
||||
func toApprovalDTOSelector(
|
||||
e entity.ProjectFlockKandang, selector func(entity.ProjectFlockKandang) *entity.Approval) *approvalDTO.ApprovalRelationDTO {
|
||||
approval := selector(e)
|
||||
@@ -147,6 +160,7 @@ func ToProjectFlockKandangListDTO(e entity.ProjectFlockKandang) ProjectFlockKand
|
||||
ProjectFlockKandangRelationDTO: ToProjectFlockKandangRelationDTO(e),
|
||||
ProjectFlock: toProjectFlockDTO(projectFlockSummary),
|
||||
Kandang: toKandangRelation(e.Kandang),
|
||||
NameWithPeriod: toNameWithPeriod(e.Kandang, e.Period),
|
||||
CreatedAt: e.CreatedAt,
|
||||
CreatedUser: toCreatedUserDTO(e.ProjectFlock),
|
||||
Approval: toApprovalDTOSelector(e, func(x entity.ProjectFlockKandang) *entity.Approval { return x.LatestProjectFlockApproval }),
|
||||
|
||||
Reference in New Issue
Block a user