Skip to content

Commit

Permalink
feat(organization): expose user deleted_at
Browse files Browse the repository at this point in the history
  • Loading branch information
balzdur committed Mar 7, 2024
1 parent 6d9b988 commit 032aea6
Show file tree
Hide file tree
Showing 3 changed files with 26 additions and 22 deletions.
4 changes: 1 addition & 3 deletions dto/organization_dto.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,7 @@ func AdaptOrganizationDto(org models.Organization) APIOrganization {
}

type CreateOrganizationBodyDto struct {
Name string `json:"name"`
DatabaseName string `json:"databaseName"`
Name string `json:"name"`
}

type CreateOrganizationInputDto struct {
Expand All @@ -27,7 +26,6 @@ type CreateOrganizationInputDto struct {

type UpdateOrganizationBodyDto struct {
Name *string `json:"name,omitempty"`
DatabaseName *string `json:"databaseName,omitempty"`
ExportScheduledExecutionS3 *string `json:"export_scheduled_execution_s3,omitempty"`
}

Expand Down
20 changes: 13 additions & 7 deletions dto/user_dto.go
Original file line number Diff line number Diff line change
@@ -1,14 +1,19 @@
package dto

import "github.com/checkmarble/marble-backend/models"
import (
"time"

"github.com/checkmarble/marble-backend/models"
)

type User struct {
UserId string `json:"user_id"`
Email string `json:"email"`
Role string `json:"role"`
OrganizationId string `json:"organization_id"`
FirstName string `json:"first_name"`
LastName string `json:"last_name"`
UserId string `json:"user_id"`
Email string `json:"email"`
Role string `json:"role"`
OrganizationId string `json:"organization_id"`
FirstName string `json:"first_name"`
LastName string `json:"last_name"`
DeletedAt *time.Time `json:"deleted_at,omitempty"`
}

func AdaptUserDto(user models.User) User {
Expand All @@ -19,6 +24,7 @@ func AdaptUserDto(user models.User) User {
OrganizationId: user.OrganizationId,
FirstName: user.FirstName,
LastName: user.LastName,
DeletedAt: user.DeletedAt,
}
}

Expand Down
24 changes: 12 additions & 12 deletions repositories/dbmodels/db_user.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,22 +21,22 @@ const TABLE_USERS = "users"
var UserFields = utils.ColumnList[DBUserResult]()

func AdaptUser(db DBUserResult) (models.User, error) {
var organizationId, firstName, lastName string
user := models.User{
UserId: models.UserId(db.Id),
Email: db.Email,
Role: models.Role(db.Role),
}
if db.OrganizationId != nil {
organizationId = *db.OrganizationId
user.OrganizationId = *db.OrganizationId
}
if db.FirstName.Valid {
firstName = db.FirstName.String
user.FirstName = db.FirstName.String
}
if db.LastName.Valid {
lastName = db.LastName.String
user.LastName = db.LastName.String
}
if db.DeletedAt.Valid {
user.DeletedAt = &db.DeletedAt.Time
}
return models.User{
UserId: models.UserId(db.Id),
Email: db.Email,
Role: models.Role(db.Role),
OrganizationId: organizationId,
FirstName: firstName,
LastName: lastName,
}, nil
return user, nil
}

0 comments on commit 032aea6

Please sign in to comment.