Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

minor fix: change EmailAddress-> Email, PhoneNumber->Phone #4

Merged
merged 2 commits into from
Mar 24, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 4 additions & 8 deletions api/swagger/docs.go

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

9 changes: 3 additions & 6 deletions api/swagger/swagger.json
Original file line number Diff line number Diff line change
Expand Up @@ -1230,17 +1230,14 @@
},
"domain.CreateOrganizationRequest": {
"type": "object",
"required": [
"name"
],
"properties": {
"description": {
"type": "string"
},
"name": {
"type": "string"
},
"phoneNumber": {
"phone": {
"type": "string"
}
}
Expand Down Expand Up @@ -1300,7 +1297,7 @@
"name": {
"type": "string"
},
"phoneNumber": {
"phone": {
"type": "string"
},
"status": {
Expand Down Expand Up @@ -1375,7 +1372,7 @@
"description": {
"type": "string"
},
"emailAddress": {
"email": {
"type": "string"
},
"id": {
Expand Down
8 changes: 3 additions & 5 deletions api/swagger/swagger.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -177,10 +177,8 @@ definitions:
type: string
name:
type: string
phoneNumber:
phone:
type: string
required:
- name
type: object
domain.History:
properties:
Expand Down Expand Up @@ -218,7 +216,7 @@ definitions:
type: string
name:
type: string
phoneNumber:
phone:
type: string
status:
type: string
Expand Down Expand Up @@ -267,7 +265,7 @@ definitions:
type: string
description:
type: string
emailAddress:
email:
type: string
id:
type: string
Expand Down
6 changes: 3 additions & 3 deletions internal/repository/organization.go
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ type Organization struct {
ID string `gorm:"primarykey;type:varchar(36);not null"`
Name string
Description string
PhoneNumber string
Phone string
WorkflowId string
Status domain.OrganizationStatus
StatusDesc string
Expand Down Expand Up @@ -95,7 +95,7 @@ func (r *OrganizationRepository) Delete(organizationId string) (err error) {
func (r *OrganizationRepository) Update(organizationId string, in domain.UpdateOrganizationRequest) (err error) {
res := r.db.Model(&Organization{}).
Where("id = ?", organizationId).
Updates(map[string]interface{}{"Description": in.Description, "PhoneNumber": in.PhoneNumber})
Updates(map[string]interface{}{"Description": in.Description, "Phone": in.Phone})
if res.Error != nil {
return fmt.Errorf("could not delete organization for organizationId %s", organizationId)
}
Expand All @@ -118,7 +118,7 @@ func (r *OrganizationRepository) reflect(organization Organization) domain.Organ
ID: organization.ID,
Name: organization.Name,
Description: organization.Description,
PhoneNumber: organization.PhoneNumber,
Phone: organization.Phone,
Status: organization.Status.String(),
Creator: organization.Creator.String(),
CreatedAt: organization.CreatedAt,
Expand Down
16 changes: 8 additions & 8 deletions internal/repository/user.go
Original file line number Diff line number Diff line change
Expand Up @@ -48,12 +48,12 @@ func (r *UserRepository) DeleteWithUuid(uuid uuid.UUID) error {
func (r *UserRepository) UpdateWithUuid(uuid uuid.UUID, accountId string, name string, password string, email string, department string, description string) (domain.User, error) {
var user User
res := r.db.Model(&User{}).Where("id = ?", uuid).Updates(User{
AccountId: accountId,
Name: name,
Password: password,
EmailAddress: email,
Department: department,
Description: description,
AccountId: accountId,
Name: name,
Password: password,
Email: email,
Department: department,
Description: description,
})
if res.RowsAffected == 0 || res.Error != nil {
return domain.User{}, fmt.Errorf("Not found user. %s", res.Error)
Expand Down Expand Up @@ -125,7 +125,7 @@ type User struct {
OrganizationId string
Organization Organization `gorm:"foreignKey:OrganizationId;references:ID"`
Creator uuid.UUID
EmailAddress string
Email string
Department string
Description string
}
Expand Down Expand Up @@ -207,7 +207,7 @@ func (r *UserRepository) CreateWithUuid(uuid uuid.UUID, accountId string, name s
AccountId: accountId,
Password: password,
Name: name,
EmailAddress: email,
Email: email,
Department: department,
Description: description,
OrganizationId: orgainzationId,
Expand Down
8 changes: 4 additions & 4 deletions internal/usecase/user.go
Original file line number Diff line number Diff line change
Expand Up @@ -132,7 +132,7 @@ func (u *UserUsecase) CreateAdmin(orgainzationId string) (*domain.User, error) {
if err != nil {
return nil, err
}
resUser, err := u.repo.CreateWithUuid(userUuid, user.AccountId, user.Name, hashedPassword, user.EmailAddress,
resUser, err := u.repo.CreateWithUuid(userUuid, user.AccountId, user.Name, hashedPassword, user.Email,
user.Department, user.Description, user.Organization.ID, roleUuid)
if err != nil {
return nil, err
Expand Down Expand Up @@ -185,7 +185,7 @@ func (u *UserUsecase) UpdatePasswordByAccountId(ctx context.Context, accountId s
return errors.Wrap(err, "hashing password failed")
}

_, err = u.repo.UpdateWithUuid(uuid, user.AccountId, user.Name, hashedPassword, user.EmailAddress,
_, err = u.repo.UpdateWithUuid(uuid, user.AccountId, user.Name, hashedPassword, user.Email,
user.Department, user.Description)
if err != nil {
return errors.Wrap(err, "updating user in repository failed")
Expand Down Expand Up @@ -252,7 +252,7 @@ func (u *UserUsecase) UpdateByAccountId(ctx context.Context, accountId string, u

originPassword := (*users)[0].Password

*user, err = u.repo.UpdateWithUuid(uuid, user.AccountId, user.Name, originPassword, user.EmailAddress,
*user, err = u.repo.UpdateWithUuid(uuid, user.AccountId, user.Name, originPassword, user.Email,
user.Department, user.Description)
if err != nil {
return nil, errors.Wrap(err, "updating user in repository failed")
Expand Down Expand Up @@ -364,7 +364,7 @@ func (u *UserUsecase) Create(ctx context.Context, user *domain.User) (*domain.Us
return nil, err
}

resUser, err := u.repo.CreateWithUuid(userUuid, user.AccountId, user.Name, hashedPassword, user.EmailAddress,
resUser, err := u.repo.CreateWithUuid(userUuid, user.AccountId, user.Name, hashedPassword, user.Email,
user.Department, user.Description, user.Organization.ID, roleUuid)
if err != nil {
return nil, err
Expand Down
8 changes: 4 additions & 4 deletions pkg/domain/organization.go
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ type Organization = struct {
ID string `json:"id"`
Name string `json:"name"`
Description string `json:"description"`
PhoneNumber string `json:"phoneNumber"`
Phone string `json:"phone"`
Status string `json:"status"`
StatusDescription string `json:"statusDescription"`
Creator string `json:"creator"`
Expand All @@ -52,12 +52,12 @@ type Organization = struct {
}

type CreateOrganizationRequest struct {
Name string `json:"name" validate:"required"`
Name string `json:"name"`
Description string `json:"description"`
PhoneNumber string `json:"phoneNumber"`
Phone string `json:"phone"`
}

type UpdateOrganizationRequest struct {
Description string `json:"description"`
PhoneNumber string `json:"phoneNumber"`
Phone string `json:"phone"`
}
38 changes: 19 additions & 19 deletions pkg/domain/user.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,9 +17,9 @@ type User = struct {
CreatedAt time.Time `json:"createdAt"`
UpdatedAt time.Time `json:"updatedAt"`

EmailAddress string `json:"emailAddress"`
Department string `json:"department"`
Description string `json:"description"`
Email string `json:"email"`
Department string `json:"department"`
Description string `json:"description"`
}

type Role = struct {
Expand Down Expand Up @@ -67,13 +67,13 @@ type FindPasswordRequest struct {
}

type CreateUserRequest struct {
AccountId string `json:"accountId"`
Password string `json:"password"`
Name string `json:"name"`
EmailAddress string `json:"emailAddress"`
Department string `json:"department"`
Role string `json:"role"`
Description string `json:"description"`
AccountId string `json:"accountId"`
Password string `json:"password"`
Name string `json:"name"`
Email string `json:"email"`
Department string `json:"department"`
Role string `json:"role"`
Description string `json:"description"`
}

func (r *CreateUserRequest) ToUser() *User {
Expand All @@ -89,20 +89,20 @@ func (r *CreateUserRequest) ToUser() *User {
Creator: "",
CreatedAt: time.Time{},
UpdatedAt: time.Time{},
EmailAddress: r.EmailAddress,
Email: r.Email,
Department: r.Department,
Description: r.Description,
}
}

type UpdateUserRequest struct {
AccountId string `json:"accountId"`
Password string `json:"password"`
Name string `json:"name"`
EmailAddress string `json:"emailAddress"`
Department string `json:"department"`
Role string `json:"role"`
Description string `json:"description"`
AccountId string `json:"accountId"`
Password string `json:"password"`
Name string `json:"name"`
Email string `json:"email"`
Department string `json:"department"`
Role string `json:"role"`
Description string `json:"description"`
}

func (r *UpdateUserRequest) ToUser() *User {
Expand All @@ -118,7 +118,7 @@ func (r *UpdateUserRequest) ToUser() *User {
Creator: "",
CreatedAt: time.Time{},
UpdatedAt: time.Time{},
EmailAddress: r.EmailAddress,
Email: r.Email,
Department: r.Department,
Description: r.Description,
}
Expand Down