mirror of
https://gitlab.com/mbugroup/lti-api.git
synced 2026-05-20 13:31:56 +00:00
feat(BE-74): add production standart to project_flock and implement rbac finance and standart production
This commit is contained in:
+1
-1
@@ -40,7 +40,7 @@ func (u *ProductionStandardController) GetAll(c *fiber.Ctx) error {
|
||||
}
|
||||
|
||||
return c.Status(fiber.StatusOK).
|
||||
JSON(response.SuccessWithPaginate[dto.ProductionStandardListDTO]{
|
||||
JSON(response.SuccessWithPaginate[dto.ProductionStandardRelationDTO]{
|
||||
Code: fiber.StatusOK,
|
||||
Status: "success",
|
||||
Message: "Get all productionStandards successfully",
|
||||
|
||||
@@ -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),
|
||||
}
|
||||
}
|
||||
|
||||
@@ -15,9 +15,9 @@ func ProductionStandardRoutes(v1 fiber.Router, u user.UserService, s productionS
|
||||
route := v1.Group("/production-standards")
|
||||
route.Use(m.Auth(u))
|
||||
|
||||
route.Get("/", ctrl.GetAll)
|
||||
route.Post("/", ctrl.CreateOne)
|
||||
route.Get("/:id", ctrl.GetOne)
|
||||
route.Patch("/:id", ctrl.UpdateOne)
|
||||
route.Delete("/:id", ctrl.DeleteOne)
|
||||
route.Get("/", m.RequirePermissions(m.P_Production_Standart_GetAll), ctrl.GetAll)
|
||||
route.Post("/", m.RequirePermissions(m.P_Production_Standart_CreateOne), ctrl.CreateOne)
|
||||
route.Get("/:id", m.RequirePermissions(m.P_Production_Standart_GetOne), ctrl.GetOne)
|
||||
route.Patch("/:id", m.RequirePermissions(m.P_Production_Standart_UpdateOne), ctrl.UpdateOne)
|
||||
route.Delete("/:id", m.RequirePermissions(m.P_Production_Standart_DeleteOne), ctrl.DeleteOne)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user