feat(BE-74): add production standart to project_flock and implement rbac finance and standart production

This commit is contained in:
ragilap
2025-12-29 23:15:34 +07:00
parent 68703d8752
commit 635049163e
20 changed files with 126 additions and 41 deletions
@@ -7,7 +7,7 @@ import (
// === DTO Structs ===
type ProductionStandardListDTO struct {
type ProductionStandardRelationDTO struct {
Id uint `json:"id"`
Name string `json:"name"`
ProjectCategory string `json:"project_category"`
@@ -15,7 +15,7 @@ type ProductionStandardListDTO struct {
}
type ProductionStandardDetailDTO struct {
ProductionStandardListDTO
ProductionStandardRelationDTO
Details []WeeklyProductionStandardDTO `json:"details"`
}
@@ -43,14 +43,14 @@ type WeeklyProductionStandardDTO struct {
// === Mapper Functions ===
func ToProductionStandardListDTO(e entity.ProductionStandard) ProductionStandardListDTO {
func ToProductionStandardListDTO(e entity.ProductionStandard) ProductionStandardRelationDTO {
var createdUser *userDTO.UserRelationDTO
if e.CreatedUser.Id != 0 {
mapped := userDTO.ToUserRelationDTO(e.CreatedUser)
createdUser = &mapped
}
return ProductionStandardListDTO{
return ProductionStandardRelationDTO{
Id: e.Id,
Name: e.Name,
ProjectCategory: e.ProjectCategory,
@@ -58,8 +58,16 @@ func ToProductionStandardListDTO(e entity.ProductionStandard) ProductionStandard
}
}
func ToProductionStandardListDTOs(e []entity.ProductionStandard) []ProductionStandardListDTO {
result := make([]ProductionStandardListDTO, len(e))
func ToProductionStandardRelationDTO(e entity.ProductionStandard) ProductionStandardRelationDTO {
return ProductionStandardRelationDTO{
Id: e.Id,
Name: e.Name,
ProjectCategory: e.ProjectCategory,
}
}
func ToProductionStandardListDTOs(e []entity.ProductionStandard) []ProductionStandardRelationDTO {
result := make([]ProductionStandardRelationDTO, len(e))
for i, r := range e {
result[i] = ToProductionStandardListDTO(r)
}
@@ -149,7 +157,7 @@ func ToProductionStandardDetailDTO(
productionStandardDetails []entity.ProductionStandardDetail,
) ProductionStandardDetailDTO {
return ProductionStandardDetailDTO{
ProductionStandardListDTO: ToProductionStandardListDTO(standard),
ProductionStandardRelationDTO: ToProductionStandardRelationDTO(standard),
Details: ToWeeklyProductionStandardDTOsWithDetails(growthDetails, productionStandardDetails),
}
}