Skip to content

Commit

Permalink
Merge pull request #29 from Microkubes/ISSUE-276
Browse files Browse the repository at this point in the history
adds new properties to profile (company, company registration number,…
  • Loading branch information
blazhovsky authored Mar 10, 2020
2 parents f0c95e2 + 04fcc9e commit 8b7fedf
Show file tree
Hide file tree
Showing 11 changed files with 143 additions and 35 deletions.
6 changes: 6 additions & 0 deletions app/media_types.go

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

21 changes: 21 additions & 0 deletions app/user_types.go

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

6 changes: 6 additions & 0 deletions client/media_types.go

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

21 changes: 21 additions & 0 deletions client/user_types.go

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

27 changes: 18 additions & 9 deletions db/repository.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,10 +13,13 @@ import (

// User is an object which holds the UserID, FullName, Email and the date of creation
type User struct {
UserID string `json:"userId" bson:"userId"`
FullName string `json:"fullname,omitempty" bson:"fullName,omitempty"`
Email string `json:"email,omitempty" bson:"email,omitempty"`
CreatedOn int `json:"createdOn,omitempty" bson:"createdOn"`
UserID string `json:"userId" bson:"userId"`
FullName string `json:"fullname,omitempty" bson:"fullName,omitempty"`
Email string `json:"email,omitempty" bson:"email,omitempty"`
Company string `json:"company,omitempty" bson:"company,omitempty"`
CompanyRegistrationNumber string `json:"companyRegistrationNumber,omitempty" bson:"companyRegistrationNumber,omitempty"`
TaxNumber string `json:"taxNumber,omitempty" bson:"taxNumber,omitempty"`
CreatedOn int `json:"createdOn,omitempty" bson:"createdOn"`
}

// UserProfileRepository defines the interface for accessing the user profile data
Expand Down Expand Up @@ -61,7 +64,7 @@ func (r *BackendUserService) UpdateUserProfile(profile *app.UserProfilePayload,
fmt.Printf("Error: %s\n", err.Error())
if !backends.IsErrNotFound(err) {
return nil, err
}
}
}

var existing *app.UserProfile
Expand All @@ -70,17 +73,23 @@ func (r *BackendUserService) UpdateUserProfile(profile *app.UserProfilePayload,

if exitingIntf == nil {
existing = &app.UserProfile{
FullName: &profile.FullName,
Email: &profile.Email,
UserID: userID,
FullName: &profile.FullName,
Email: &profile.Email,
UserID: userID,
Company: profile.Company,
CompanyRegistrationNumber: profile.CompanyRegistrationNumber,
TaxNumber: profile.TaxNumber,
}
} else {
existing = exitingIntf.(*app.UserProfile)
existing.FullName = &profile.FullName
existing.Email = &profile.Email
existing.Company = profile.Company
existing.CompanyRegistrationNumber = profile.CompanyRegistrationNumber
existing.TaxNumber = profile.TaxNumber
filter = backends.NewFilter().Match("userId", userID)
}

_, err = r.userRepository.Save(existing, filter)

if err != nil {
Expand Down
9 changes: 9 additions & 0 deletions design/design.go
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,9 @@ var UserProfileMedia = MediaType("application/microkubes.user-profile+json", fun
Attribute("userId", String, "Unique user ID")
Attribute("fullName")
Attribute("email")
Attribute("company")
Attribute("companyRegistrationNumber")
Attribute("taxNumber")
Attribute("createdOn", Integer, "User profile created timestamp")
Required("userId", "createdOn")
})
Expand All @@ -83,6 +86,9 @@ var UserProfileMedia = MediaType("application/microkubes.user-profile+json", fun
Attribute("userId")
Attribute("fullName")
Attribute("email")
Attribute("company")
Attribute("companyRegistrationNumber")
Attribute("taxNumber")
Attribute("createdOn")
})
})
Expand All @@ -95,6 +101,9 @@ var UserProfilePayload = Type("UserProfilePayload", func() {
Attribute("email", String, "Email of user", func() {
Format("email")
})
Attribute("company", String, "Company name")
Attribute("companyRegistrationNumber", String, "Company registration number")
Attribute("taxNumber", String, "Tax number")

Required("fullName", "email")
})
Expand Down
4 changes: 2 additions & 2 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@ module github.com/Microkubes/microservice-user-profile
go 1.13

require (
github.com/Microkubes/backends v1.1.0
github.com/Microkubes/microservice-security v1.1.0
github.com/Microkubes/backends v1.1.1
github.com/Microkubes/microservice-security v1.1.1
github.com/Microkubes/microservice-tools v1.1.0
github.com/keitaroinc/goa v1.5.0
github.com/spf13/cobra v0.0.5
Expand Down
10 changes: 5 additions & 5 deletions go.sum
Original file line number Diff line number Diff line change
@@ -1,10 +1,9 @@
github.com/BurntSushi/toml v0.3.1/go.mod h1:xHWCNGjB5oqiDr8zfno3MHue2Ht5sIBksp03qcyfWMU=
github.com/DataDog/datadog-go v3.2.0+incompatible/go.mod h1:LButxg5PwREeZtORoXG3tL4fMGNddJ+vMq1mwgfaqoQ=
github.com/Microkubes/backends v1.1.0 h1:DBQx9rO4l32oWHWlYcvdhBcpaNpheI6TlA/JFYLImm4=
github.com/Microkubes/backends v1.1.0/go.mod h1:bgnvzTuYN8C4wCOFchZSIkDb8W/VDoFtve83UQOyTrw=
github.com/Microkubes/microservice-security v1.1.0 h1:iI5MPmx2KoZEJC6dlfs7509bzE3+LfG9CC/TCRFhkAI=
github.com/Microkubes/microservice-security v1.1.0/go.mod h1:qcBGphki1Z2HQ9LPmu7MRHnG9TqqanBJfx6uQ+/Y0V0=
github.com/Microkubes/microservice-tools v1.0.1/go.mod h1:jTxEBqKe41hggPi5e8qJOcw96rztD8jIXp0qf69LgzE=
github.com/Microkubes/backends v1.1.1 h1:/zOZwSGrPzaw4WuBVGYAY+YR5cYaeJrjfm+EZPR9PaA=
github.com/Microkubes/backends v1.1.1/go.mod h1:w2FSUGVYqtnD5cxPFYXJu65oYNSZOZNNBC9v2FRJjBA=
github.com/Microkubes/microservice-security v1.1.1 h1:qNvcoIdLz1RKOYerV6I/pTAnLmKRQ85FBoe77OC0lWE=
github.com/Microkubes/microservice-security v1.1.1/go.mod h1:FS0mUGDuKY6tlo+4cZ7xRKxtcm49m2si8/4ZdS8PjNQ=
github.com/Microkubes/microservice-tools v1.1.0 h1:0kyByC+JqVi/nDDp+eKYhDpgqdA1xvVP68wGIpcJDcQ=
github.com/Microkubes/microservice-tools v1.1.0/go.mod h1:9YPuF99237LdC2025udqFF82dzLl0jPvZEnXIAGJXBQ=
github.com/afex/hystrix-go v0.0.0-20180502004556-fa1af6a1f4f5 h1:rFw4nCn9iMW+Vajsk51NtYIcwSTkXr+JGrMd36kTDJw=
Expand Down Expand Up @@ -166,6 +165,7 @@ golang.org/x/sys v0.0.0-20190922100055-0a153f010e69 h1:rOhMmluY6kLMhdnrivzec6lLg
golang.org/x/sys v0.0.0-20190922100055-0a153f010e69/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
golang.org/x/text v0.3.0 h1:g61tztE5qeGQ89tm6NTjjM9VPIm088od1l6aSorWRWg=
golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ=
golang.org/x/tools v0.0.0-20190328211700-ab21143f2384 h1:TFlARGu6Czu1z7q93HTxcP1P+/ZFC/IKythI5RzrnRg=
golang.org/x/tools v0.0.0-20190328211700-ab21143f2384/go.mod h1:LCzVGOaR6xXOjkQ3onu1FJEFr0SW1gC7cKk1uF8kGRs=
golang.org/x/xerrors v0.0.0-20190717185122-a985d3407aa7 h1:9zdDQZ7Thm29KFXgAX/+yaf3eVbP7djjWp/dXAppNCc=
golang.org/x/xerrors v0.0.0-20190717185122-a985d3407aa7/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0=
Expand Down
Loading

0 comments on commit 8b7fedf

Please sign in to comment.