Remove redundant structs and methods:

UserSerializer, UsersSerializer, AuthResponse, UserResponse.
This commit is contained in:
smavros 2019-08-13 16:40:54 +02:00
parent 42f473cde0
commit 74b27f7525
3 changed files with 0 additions and 61 deletions

View file

@ -2,13 +2,6 @@ package common
import "github.com/jinzhu/gorm/dialects/postgres"
type UserResponse struct {
Username string `json:"username"`
Role string `json:"role"`
Mail string `json:"mail"`
ID uint `json:"id"`
}
type ScenarioResponse struct {
Name string `json:"name"`
ID uint `json:"id"`

View file

@ -4,53 +4,6 @@ import (
"github.com/gin-gonic/gin"
)
// User/s Serializers
type UsersSerializer struct {
Ctx *gin.Context
Users []User
}
func (self *UsersSerializer) Response(assoc bool) []UserResponse {
response := []UserResponse{}
for _, user := range self.Users {
serializer := UserSerializer{self.Ctx, user}
response = append(response, serializer.Response(assoc))
}
return response
}
type UserSerializer struct {
Ctx *gin.Context
User
}
func (self *UserSerializer) Response(assoc bool) UserResponse {
response := UserResponse{
Username: self.Username,
Role: self.Role,
Mail: self.Mail,
ID: self.ID,
}
// Associated models MUST NOT called with assoc=true otherwise we
// will have an infinite loop due to the circular dependencies
if assoc {
// TODO: maybe all those should be made in one transaction
//scenarios, _, _ := scenario.FindUserScenarios(&self.User)
//scenariosSerializer :=
// ScenariosSerializer{self.Ctx, scenarios}
// Add the associated models to the response
//response.Scenarios = scenariosSerializer.Response()
}
return response
}
// Scenario/s Serializers
type ScenariosSerializer struct {

View file

@ -21,13 +21,6 @@ type tokenClaims struct {
jwt.StandardClaims
}
type AuthResponse struct {
Success bool `json:"success"`
Message string `json:"message"`
Token string `json:"token"`
User common.UserResponse `json:"user"`
}
func VisitorAuthenticate(r *gin.RouterGroup) {
r.POST("", authenticate)
}