Skip to content

Commit

Permalink
✨ model change related to #67
Browse files Browse the repository at this point in the history
  • Loading branch information
Shion1305 committed Feb 25, 2024
1 parent 919ad53 commit 289899c
Show file tree
Hide file tree
Showing 7 changed files with 34 additions and 59 deletions.
5 changes: 2 additions & 3 deletions svc/pkg/domain/model/form/form.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@ import (
"sort"
"time"
"ynufes-mypage-backend/svc/pkg/domain/model/id"
"ynufes-mypage-backend/svc/pkg/domain/model/user"
)

type (
Expand All @@ -14,7 +13,7 @@ type (
Title string
Summary string
Description string
Roles []user.RoleID
Roles []id.RoleID
Deadline time.Time
IsOpen bool
Sections SectionsOrder
Expand All @@ -27,7 +26,7 @@ func NewForm(
eventID id.EventID,
title, summary, description string,
sectionOrders map[id.SectionID]float64,
roles []user.RoleID,
roles []id.RoleID,
deadline time.Time,
isOpen bool,
) *Form {
Expand Down
1 change: 1 addition & 0 deletions svc/pkg/domain/model/id/id.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ type (
SectionID util.ID
QuestionID util.ID
OrgIDs []OrgID
RoleID util.ID
)

func (i OrgIDs) HasOrgID(oid OrgID) bool {
Expand Down
8 changes: 8 additions & 0 deletions svc/pkg/domain/model/role/role.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
package role

import "ynufes-mypage-backend/svc/pkg/domain/model/id"

type Role struct {
ID id.RoleID
Name string
}
8 changes: 8 additions & 0 deletions svc/pkg/domain/model/staff/staff.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
package staff

import "ynufes-mypage-backend/svc/pkg/domain/model/id"

type Staff struct {
id.UserID
IsAdmin bool
}
39 changes: 0 additions & 39 deletions svc/pkg/domain/model/user/agent.go

This file was deleted.

3 changes: 1 addition & 2 deletions svc/pkg/infra/entity/form/aggregate.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@ import (
"ynufes-mypage-backend/pkg/identity"
"ynufes-mypage-backend/svc/pkg/domain/model/form"
"ynufes-mypage-backend/svc/pkg/domain/model/id"
"ynufes-mypage-backend/svc/pkg/domain/model/user"
"ynufes-mypage-backend/svc/pkg/exception"
)

Expand Down Expand Up @@ -57,7 +56,7 @@ func (f Form) ToModel() (*form.Form, error) {
return nil, err
}

roles := make([]user.RoleID, 0, len(f.Roles))
roles := make([]id.RoleID, 0, len(f.Roles))
for k, v := range f.Roles {
if !v {
continue
Expand Down
29 changes: 14 additions & 15 deletions svc/pkg/infra/reader/form_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@ import (
"ynufes-mypage-backend/svc/pkg/domain/model/event"
"ynufes-mypage-backend/svc/pkg/domain/model/form"
"ynufes-mypage-backend/svc/pkg/domain/model/id"
"ynufes-mypage-backend/svc/pkg/domain/model/user"
"ynufes-mypage-backend/svc/pkg/infra/writer"
)

Expand All @@ -33,9 +32,9 @@ func TestForm_GetByID(t *testing.T) {
Title: "FormTitle1",
Summary: "FormSummary1",
Description: "FormDescription1",
Roles: []user.RoleID{
user.RoleID(identity.IssueID()),
user.RoleID(identity.IssueID()),
Roles: []id.RoleID{
id.RoleID(identity.IssueID()),
id.RoleID(identity.IssueID()),
},
Deadline: time.UnixMilli(deadline),
IsOpen: false,
Expand Down Expand Up @@ -82,9 +81,9 @@ func TestForm_ListByEventID(t *testing.T) {
Title: "FormTitle1",
Summary: "FormSummary1",
Description: "FormDescription1",
Roles: []user.RoleID{
user.RoleID(identity.IssueID()),
user.RoleID(identity.IssueID()),
Roles: []id.RoleID{
id.RoleID(identity.IssueID()),
id.RoleID(identity.IssueID()),
},
Deadline: time.UnixMilli(deadline1),
IsOpen: false,
Expand All @@ -102,9 +101,9 @@ func TestForm_ListByEventID(t *testing.T) {
Title: "FormTitle2",
Summary: "FormSummary2",
Description: "FormDescription2",
Roles: []user.RoleID{
user.RoleID(identity.IssueID()),
user.RoleID(identity.IssueID()),
Roles: []id.RoleID{
id.RoleID(identity.IssueID()),
id.RoleID(identity.IssueID()),
},
Deadline: time.UnixMilli(deadline2),
IsOpen: false,
Expand All @@ -122,9 +121,9 @@ func TestForm_ListByEventID(t *testing.T) {
Title: "FormTitle3",
Summary: "FormSummary3",
Description: "FormDescription3",
Roles: []user.RoleID{
user.RoleID(identity.IssueID()),
user.RoleID(identity.IssueID()),
Roles: []id.RoleID{
id.RoleID(identity.IssueID()),
id.RoleID(identity.IssueID()),
},
Deadline: time.UnixMilli(deadline3),
IsOpen: false,
Expand Down Expand Up @@ -174,9 +173,9 @@ func checkFormEqual(t *testing.T, f1, f2 form.Form) {
}
}

func checkRolesEqual(t *testing.T, r1, r2 []user.RoleID) {
func checkRolesEqual(t *testing.T, r1, r2 []id.RoleID) {
assert.Equal(t, len(r1), len(r2))
roles := make(map[user.RoleID]struct{}, len(r1))
roles := make(map[id.RoleID]struct{}, len(r1))
for _, v := range r1 {
roles[v] = struct{}{}
}
Expand Down

0 comments on commit 289899c

Please sign in to comment.