Skip to content

Commit

Permalink
Merge branch 'main' into feature/docker-development
Browse files Browse the repository at this point in the history
  • Loading branch information
Julian702 authored Feb 13, 2024
2 parents 62f8507 + 696a685 commit 2771200
Show file tree
Hide file tree
Showing 43 changed files with 723 additions and 634 deletions.
2 changes: 2 additions & 0 deletions backend/api-documentation/decks/new deck.bru
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,8 @@ auth:bearer {

body:json {
{
"deckType": "PRIVATE",
"deckDescription": "description",
"deckName": "test deck"
}
}
Expand Down
14 changes: 8 additions & 6 deletions backend/pkg/converter/fiberSerializerTypes.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,12 +21,14 @@ type FiberGroup struct {
}

type FiberDeck struct {
DeckID string `json:"deckID"`
DeckName string `json:"deckName"`
DeckType string `json:"deckType"`
GroupID string `json:"groupID"`
IsActive bool `json:"isActive"`
IsFavorite bool `json:"isFavorite"`
DeckID string `json:"deckID"`
DeckName string `json:"deckName"`
DeckDescription string `json:"deckDescription"`
DeckType string `json:"deckType"`
DeckRole string `json:"deckRole"`
GroupID string `json:"groupID"`
IsActive bool `json:"isActive"`
IsFavorite bool `json:"isFavorite"`
}

type FiberGroupMemberAdmission struct {
Expand Down
41 changes: 23 additions & 18 deletions backend/pkg/converter/typeConverter.go
Original file line number Diff line number Diff line change
Expand Up @@ -174,35 +174,40 @@ func ProtoGroupWithRoleToFiberGroupConverter(group *pbCommon.Group) FiberGroup {

func ProtoDeckToFiberDeckConverter(deck *pbCommon.Deck) FiberDeck {
return FiberDeck{
DeckID: deck.DeckID,
DeckName: deck.DeckName,
DeckType: deck.DeckType.String(),
GroupID: deck.GroupID,
IsActive: deck.IsActive,
IsFavorite: deck.IsFavorite,
DeckID: deck.DeckID,
DeckName: deck.DeckName,
DeckDescription: deck.DeckDescription,
DeckType: deck.DeckType.String(),
GroupID: deck.GroupID,
IsActive: deck.IsActive,
IsFavorite: deck.IsFavorite,
DeckRole: deck.DeckRole.String(),
}
}

func ProtoDeckRespToFiberDeckConverter(deck *pbCommon.Deck) FiberDeck {
return FiberDeck{
DeckID: deck.DeckID,
DeckName: deck.DeckName,
DeckType: deck.DeckType.String(),
GroupID: deck.GroupID,
IsActive: deck.IsActive,
IsFavorite: deck.IsFavorite,
DeckID: deck.DeckID,
DeckName: deck.DeckName,
DeckDescription: deck.DeckDescription,
DeckType: deck.DeckType.String(),
GroupID: deck.GroupID,
IsActive: deck.IsActive,
IsFavorite: deck.IsFavorite,
DeckRole: deck.DeckRole.String(),
}
}

func StoreDeckToProtoDeckConverter(deck model.Deck) *pbCommon.Deck {
dt, _ := MigrateModelDeckTypeToProtoDeckType(deck.DeckType)
return &pbCommon.Deck{
DeckID: deck.ID,
DeckName: deck.Name,
DeckType: dt,
GroupID: deck.GroupID,
IsFavorite: deck.IsFavorite,
IsActive: deck.IsActive,
DeckID: deck.ID,
DeckName: deck.Name,
DeckDescription: deck.Description,
DeckType: dt,
GroupID: deck.GroupID,
IsFavorite: deck.IsFavorite,
IsActive: deck.IsActive,
}
}

Expand Down
4 changes: 4 additions & 0 deletions backend/pkg/helper/errors.go
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,10 @@ func NewMicroCantLeaveAsLastAdminErr(id ClientID) error {
return microErrors.BadRequest(string(id), "You can't leave when you are the last admin")
}

func NewMicroCantInviteToHomegroupErr(id ClientID) error {
return microErrors.BadRequest(string(id), "You can't invite users to your homegroup")
}

func NewMicroUserAdmissionInProgressErr(id ClientID) error {
return microErrors.BadRequest(string(id), "user already invited")
}
Expand Down
19 changes: 10 additions & 9 deletions backend/pkg/model/deck.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,15 +15,16 @@ const (
)

type Deck struct {
ID string `gorm:"primaryKey"`
Name string `gorm:"not null"`
DeckType DeckType `gorm:"not null"`
CreatedAt time.Time
GroupID string `gorm:"not null"`
Group Group
Cards []Card `gorm:"constraint:OnUpdate:CASCADE,OnDelete:CASCADE;"`
IsFavorite bool `gorm:"-"`
IsActive bool `gorm:"-"`
ID string `gorm:"primaryKey"`
Name string `gorm:"not null"`
Description string
DeckType DeckType `gorm:"not null"`
CreatedAt time.Time
GroupID string `gorm:"not null"`
Group Group
Cards []Card `gorm:"constraint:OnUpdate:CASCADE,OnDelete:CASCADE;"`
IsFavorite bool `gorm:"-"`
IsActive bool `gorm:"-"`
}

func (d *Deck) BeforeCreate(db *gorm.DB) (err error) {
Expand Down
168 changes: 95 additions & 73 deletions backend/pkg/proto/common.pb.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

13 changes: 8 additions & 5 deletions backend/pkg/proto/common.proto
Original file line number Diff line number Diff line change
Expand Up @@ -111,12 +111,15 @@ enum DeckType {
message Deck {
string deckID = 1;
string deckName = 2;
DeckType deckType = 3;
int64 createdAt = 4;
string groupID = 5;
bool isActive = 6;
bool isFavorite = 7;
string deckDescription = 3;
GroupRole deckRole = 4;
DeckType deckType = 5;
int64 createdAt = 6;
string groupID = 7;
bool isActive = 8;
bool isFavorite = 9;
}

message DeckRequest {
string userID = 1;
Deck deck = 2;
Expand Down
Loading

0 comments on commit 2771200

Please sign in to comment.