Private
Public Access
commit parcial de implementacion de builder
Signed-off-by: fede <federico.nicolas.polidoro@gmail.com>
This commit is contained in:
1 parent
f2cf7927eb
commit
4704777050
53 files changed
+1054
-863
No files matched your search
@@ -2,9 +2,11 @@ package grupo
|
||||
|
||||
import (
|
||||
"net/http"
|
||||
"strconv"
|
||||
|
||||
dto_directors "repuestera_back/dto/Builders/Directors"
|
||||
models_seguridad "repuestera_back/models/seguridad"
|
||||
r "repuestera_back/repositorios"
|
||||
"strconv"
|
||||
|
||||
"github.com/gin-gonic/gin"
|
||||
)
|
||||
@@ -25,6 +27,16 @@ func ActualizarGrupo(c *gin.Context) {
|
||||
c.JSON(http.StatusBadRequest, gin.H{"error": err.Error()})
|
||||
return
|
||||
}
|
||||
r.ObtenerRepositorios(c).Grupo.Actualizar(grupo, input)
|
||||
c.JSON(http.StatusOK, grupo)
|
||||
if err := r.ObtenerRepositorios(c).Grupo.Actualizar(grupo, input); err != nil {
|
||||
c.JSON(http.StatusInternalServerError, gin.H{"error": err.Error()})
|
||||
return
|
||||
}
|
||||
|
||||
respuesta, err := dto_directors.NewGrupoDirector().DesdeGrupo(grupo)
|
||||
if err != nil {
|
||||
c.JSON(http.StatusInternalServerError, gin.H{"error": err.Error()})
|
||||
return
|
||||
}
|
||||
|
||||
c.JSON(http.StatusOK, respuesta)
|
||||
}
|
||||
@@ -2,6 +2,8 @@ package grupo
|
||||
|
||||
import (
|
||||
"net/http"
|
||||
|
||||
dto_directors "repuestera_back/dto/Builders/Directors"
|
||||
models_seguridad "repuestera_back/models/seguridad"
|
||||
r "repuestera_back/repositorios"
|
||||
|
||||
@@ -18,5 +20,12 @@ func CrearGrupo(c *gin.Context) {
|
||||
c.JSON(http.StatusInternalServerError, gin.H{"error": err.Error()})
|
||||
return
|
||||
}
|
||||
c.JSON(http.StatusCreated, grupo)
|
||||
|
||||
respuesta, err := dto_directors.NewGrupoDirector().DesdeGrupo(&grupo)
|
||||
if err != nil {
|
||||
c.JSON(http.StatusInternalServerError, gin.H{"error": err.Error()})
|
||||
return
|
||||
}
|
||||
|
||||
c.JSON(http.StatusCreated, respuesta)
|
||||
}
|
||||
@@ -2,7 +2,7 @@ package grupo
|
||||
|
||||
import (
|
||||
"net/http"
|
||||
dto_builders "repuestera_back/dto/Builders"
|
||||
dto_directors "repuestera_back/dto/Builders/Directors"
|
||||
r "repuestera_back/repositorios"
|
||||
"strconv"
|
||||
|
||||
@@ -21,9 +21,11 @@ func ObtenerGrupo(c *gin.Context) {
|
||||
return
|
||||
}
|
||||
|
||||
dto := dto_builders.
|
||||
NewGrupoSimpleBuilder(grupo).
|
||||
Build()
|
||||
respuesta, err := dto_directors.NewGrupoSimpleDirector().DesdeGrupo(grupo)
|
||||
if err != nil {
|
||||
c.JSON(http.StatusInternalServerError, gin.H{"error": err.Error()})
|
||||
return
|
||||
}
|
||||
|
||||
c.JSON(http.StatusOK, dto)
|
||||
c.JSON(http.StatusOK, respuesta)
|
||||
}
|
||||
@@ -2,6 +2,8 @@ package grupo
|
||||
|
||||
import (
|
||||
"net/http"
|
||||
|
||||
dto_directors "repuestera_back/dto/Builders/Directors"
|
||||
r "repuestera_back/repositorios"
|
||||
|
||||
"github.com/gin-gonic/gin"
|
||||
@@ -13,5 +15,12 @@ func ObtenerGrupos(c *gin.Context) {
|
||||
c.JSON(http.StatusInternalServerError, gin.H{"error": err.Error()})
|
||||
return
|
||||
}
|
||||
c.JSON(http.StatusOK, grupos)
|
||||
|
||||
respuesta, err := dto_directors.NewGrupoDirector().Listar(grupos)
|
||||
if err != nil {
|
||||
c.JSON(http.StatusInternalServerError, gin.H{"error": err.Error()})
|
||||
return
|
||||
}
|
||||
|
||||
c.JSON(http.StatusOK, respuesta)
|
||||
}
|
||||
@@ -2,9 +2,11 @@ package grupo
|
||||
|
||||
import (
|
||||
"net/http"
|
||||
r "repuestera_back/repositorios"
|
||||
"strconv"
|
||||
|
||||
dto_directors "repuestera_back/dto/Builders/Directors"
|
||||
r "repuestera_back/repositorios"
|
||||
|
||||
"github.com/gin-gonic/gin"
|
||||
)
|
||||
|
||||
@@ -13,7 +15,7 @@ func ObtenerGruposDeUsuario(c *gin.Context) {
|
||||
|
||||
usuarioID, err := strconv.ParseUint(usuarioIDStr, 10, 64)
|
||||
if err != nil {
|
||||
c.JSON(400, gin.H{"error": "id invalido"})
|
||||
c.JSON(http.StatusBadRequest, gin.H{"error": "id invalido"})
|
||||
return
|
||||
}
|
||||
|
||||
@@ -22,5 +24,12 @@ func ObtenerGruposDeUsuario(c *gin.Context) {
|
||||
c.JSON(http.StatusInternalServerError, gin.H{"error": "no se ha podido obtener los grupos del usuario"})
|
||||
return
|
||||
}
|
||||
c.JSON(http.StatusOK, grupos)
|
||||
|
||||
respuesta, err := dto_directors.NewGrupoDirector().Listar(grupos)
|
||||
if err != nil {
|
||||
c.JSON(http.StatusInternalServerError, gin.H{"error": err.Error()})
|
||||
return
|
||||
}
|
||||
|
||||
c.JSON(http.StatusOK, respuesta)
|
||||
}
|
||||
@@ -2,8 +2,9 @@ package grupo
|
||||
|
||||
import (
|
||||
"net/http"
|
||||
"repuestera_back/dto"
|
||||
dto_builders "repuestera_back/dto/Builders"
|
||||
|
||||
dto_directors "repuestera_back/dto/Builders/Directors"
|
||||
models_seguridad "repuestera_back/models/seguridad"
|
||||
r "repuestera_back/repositorios"
|
||||
|
||||
"github.com/gin-gonic/gin"
|
||||
@@ -40,20 +41,28 @@ func ObtenerGruposYPermisosPorEmail(c *gin.Context) {
|
||||
c.JSON(http.StatusInternalServerError, gin.H{"error": err.Error()})
|
||||
return
|
||||
}
|
||||
grupos := make([]dto.GrupoSimpleDTO, 0, len(usuario.Grupos))
|
||||
|
||||
grupos := make([]*models_seguridad.Grupo, 0, len(usuario.Grupos))
|
||||
for i := range usuario.Grupos {
|
||||
grupoCompleto, err := r.ObtenerRepositorios(c).Grupo.ObtenerPorIDConRelaciones(usuario.Grupos[i].ID, true)
|
||||
if err != nil {
|
||||
c.JSON(http.StatusInternalServerError, gin.H{"error": err.Error()})
|
||||
return
|
||||
}
|
||||
g := dto_builders.NewGrupoSimpleBuilder(grupoCompleto).Build()
|
||||
g.ID = grupoCompleto.ID
|
||||
grupos = append(grupos, g)
|
||||
grupos = append(grupos, grupoCompleto)
|
||||
}
|
||||
|
||||
c.JSON(http.StatusOK, dto.GruposYPermisosResponse{
|
||||
Email: usuario.Email,
|
||||
Groups: grupos,
|
||||
})
|
||||
respuesta, err := dto_directors.NewGrupoSimpleDirector().Listar(grupos)
|
||||
if err != nil {
|
||||
c.JSON(http.StatusInternalServerError, gin.H{"error": err.Error()})
|
||||
return
|
||||
}
|
||||
|
||||
envelope, err := dto_directors.NewGrupoDirector().GruposYPermisos(usuario.Email, respuesta)
|
||||
if err != nil {
|
||||
c.JSON(http.StatusInternalServerError, gin.H{"error": err.Error()})
|
||||
return
|
||||
}
|
||||
|
||||
c.JSON(http.StatusOK, envelope)
|
||||
}
|
||||
Reference in new issue
Block a user