mirror of
https://gitlab.com/mbugroup/lti-api.git
synced 2026-05-24 23:35:43 +00:00
fix(BE-273): add object nonstock and supplier in response get one and fix name base to relation in dto
This commit is contained in:
@@ -15,30 +15,30 @@ import (
|
||||
|
||||
// === DTO Structs ===
|
||||
|
||||
type RecordingBaseDTO struct {
|
||||
Id uint `json:"id"`
|
||||
ProjectFlockKandangId uint `json:"project_flock_kandang_id"`
|
||||
RecordDatetime time.Time `json:"record_datetime"`
|
||||
Day int `json:"day"`
|
||||
ProjectFlockCategory string `json:"project_flock_category"`
|
||||
TotalDepletionQty float64 `json:"total_depletion_qty"`
|
||||
CumDepletionRate float64 `json:"cum_depletion_rate"`
|
||||
DailyGain float64 `json:"daily_gain"`
|
||||
AvgDailyGain float64 `json:"avg_daily_gain"`
|
||||
CumIntake int `json:"cum_intake"`
|
||||
FcrValue float64 `json:"fcr_value"`
|
||||
TotalChickQty float64 `json:"total_chick_qty"`
|
||||
Approval approvalDTO.ApprovalBaseDTO `json:"approval"`
|
||||
EggGradingStatus *string `json:"egg_grading_status"`
|
||||
EggGradingPendingQty *int `json:"egg_grading_pending_qty"`
|
||||
EggGradingCompletedQty *int `json:"egg_grading_completed_qty"`
|
||||
type RecordingRelationDTO struct {
|
||||
Id uint `json:"id"`
|
||||
ProjectFlockKandangId uint `json:"project_flock_kandang_id"`
|
||||
RecordDatetime time.Time `json:"record_datetime"`
|
||||
Day int `json:"day"`
|
||||
ProjectFlockCategory string `json:"project_flock_category"`
|
||||
TotalDepletionQty float64 `json:"total_depletion_qty"`
|
||||
CumDepletionRate float64 `json:"cum_depletion_rate"`
|
||||
DailyGain float64 `json:"daily_gain"`
|
||||
AvgDailyGain float64 `json:"avg_daily_gain"`
|
||||
CumIntake int `json:"cum_intake"`
|
||||
FcrValue float64 `json:"fcr_value"`
|
||||
TotalChickQty float64 `json:"total_chick_qty"`
|
||||
Approval approvalDTO.ApprovalRelationDTO `json:"approval"`
|
||||
EggGradingStatus *string `json:"egg_grading_status"`
|
||||
EggGradingPendingQty *int `json:"egg_grading_pending_qty"`
|
||||
EggGradingCompletedQty *int `json:"egg_grading_completed_qty"`
|
||||
}
|
||||
|
||||
type RecordingListDTO struct {
|
||||
RecordingBaseDTO
|
||||
CreatedUser *userDTO.UserBaseDTO `json:"created_user"`
|
||||
CreatedAt time.Time `json:"created_at"`
|
||||
UpdatedAt time.Time `json:"updated_at"`
|
||||
RecordingRelationDTO
|
||||
CreatedUser *userDTO.UserRelationDTO `json:"created_user"`
|
||||
CreatedAt time.Time `json:"created_at"`
|
||||
UpdatedAt time.Time `json:"updated_at"`
|
||||
}
|
||||
|
||||
type RecordingDetailDTO struct {
|
||||
@@ -91,7 +91,7 @@ type RecordingEggGradingDTO struct {
|
||||
|
||||
// === Mapper Functions ===
|
||||
|
||||
func ToRecordingBaseDTO(e entity.Recording) RecordingBaseDTO {
|
||||
func ToRecordingRelationDTO(e entity.Recording) RecordingRelationDTO {
|
||||
var (
|
||||
projectFlockCategory string
|
||||
day int
|
||||
@@ -142,7 +142,7 @@ func ToRecordingBaseDTO(e entity.Recording) RecordingBaseDTO {
|
||||
|
||||
gradingStatus, gradingPending, gradingCompleted := computeEggGradingStatus(e)
|
||||
|
||||
return RecordingBaseDTO{
|
||||
return RecordingRelationDTO{
|
||||
Id: e.Id,
|
||||
ProjectFlockKandangId: e.ProjectFlockKandangId,
|
||||
RecordDatetime: e.RecordDatetime,
|
||||
@@ -163,17 +163,17 @@ func ToRecordingBaseDTO(e entity.Recording) RecordingBaseDTO {
|
||||
}
|
||||
|
||||
func ToRecordingListDTO(e entity.Recording) RecordingListDTO {
|
||||
var createdUser *userDTO.UserBaseDTO
|
||||
var createdUser *userDTO.UserRelationDTO
|
||||
if e.CreatedUser != nil && e.CreatedUser.Id != 0 {
|
||||
mapped := userDTO.ToUserBaseDTO(*e.CreatedUser)
|
||||
mapped := userDTO.ToUserRelationDTO(*e.CreatedUser)
|
||||
createdUser = &mapped
|
||||
}
|
||||
|
||||
return RecordingListDTO{
|
||||
RecordingBaseDTO: ToRecordingBaseDTO(e),
|
||||
CreatedAt: e.CreatedAt,
|
||||
UpdatedAt: e.UpdatedAt,
|
||||
CreatedUser: createdUser,
|
||||
RecordingRelationDTO: ToRecordingRelationDTO(e),
|
||||
CreatedAt: e.CreatedAt,
|
||||
UpdatedAt: e.UpdatedAt,
|
||||
CreatedUser: createdUser,
|
||||
}
|
||||
}
|
||||
|
||||
@@ -344,8 +344,8 @@ func filterGoodEggs(eggs []entity.RecordingEgg) []entity.RecordingEgg {
|
||||
return result
|
||||
}
|
||||
|
||||
func defaultRecordingLatestApproval(e entity.Recording) approvalDTO.ApprovalBaseDTO {
|
||||
result := approvalDTO.ApprovalBaseDTO{}
|
||||
func defaultRecordingLatestApproval(e entity.Recording) approvalDTO.ApprovalRelationDTO {
|
||||
result := approvalDTO.ApprovalRelationDTO{}
|
||||
|
||||
step := utils.RecordingStepPengajuan
|
||||
result.StepNumber = uint16(step)
|
||||
@@ -356,9 +356,9 @@ func defaultRecordingLatestApproval(e entity.Recording) approvalDTO.ApprovalBase
|
||||
}
|
||||
|
||||
if e.CreatedUser != nil && e.CreatedUser.Id != 0 {
|
||||
result.ActionBy = userDTO.ToUserBaseDTO(*e.CreatedUser)
|
||||
result.ActionBy = userDTO.ToUserRelationDTO(*e.CreatedUser)
|
||||
} else if e.CreatedBy != 0 {
|
||||
result.ActionBy = userDTO.UserBaseDTO{
|
||||
result.ActionBy = userDTO.UserRelationDTO{
|
||||
Id: e.CreatedBy,
|
||||
IdUser: int64(e.CreatedBy),
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user