fix: change username to name and add profile pic to staff
This commit is contained in:
parent
c02d8cda69
commit
afe6f4e9a6
@ -5,10 +5,11 @@ import (
|
|||||||
)
|
)
|
||||||
|
|
||||||
type Staff struct {
|
type Staff struct {
|
||||||
ID string `gorm:"primaryKey" json:"id"`
|
ID string `gorm:"primaryKey" json:"id"`
|
||||||
Username string `gorm:"default:null;unique" json:"username"`
|
Name string `gorm:"default:null;unique" json:"name"`
|
||||||
Email string `gorm:"unique;not null" json:"email"`
|
ProfilePicture string `gorm:"default:null" json:"profile_picture"`
|
||||||
Password string `gorm:"not null" json:"password"`
|
Email string `gorm:"unique;not null" json:"email"`
|
||||||
CreatedAt time.Time `gorm:"default:CURRENT_TIMESTAMP" json:"created_at"`
|
Password string `gorm:"not null" json:"password"`
|
||||||
UpdatedAt time.Time `gorm:"default:CURRENT_TIMESTAMP" json:"updated_at"`
|
CreatedAt time.Time `gorm:"default:CURRENT_TIMESTAMP" json:"created_at"`
|
||||||
|
UpdatedAt time.Time `gorm:"default:CURRENT_TIMESTAMP" json:"updated_at"`
|
||||||
}
|
}
|
||||||
|
|||||||
@ -17,9 +17,10 @@ type LoginRepoResponse struct {
|
|||||||
}
|
}
|
||||||
|
|
||||||
type StaffProfile struct {
|
type StaffProfile struct {
|
||||||
ID string `json:"id"`
|
ID string `json:"id"`
|
||||||
Email string `json:"email"`
|
Email string `json:"email"`
|
||||||
Username string `json:"username"`
|
Name string `json:"name"`
|
||||||
|
ProfilePicture string `json:"profile_picture"`
|
||||||
}
|
}
|
||||||
|
|
||||||
type UserProfile struct {
|
type UserProfile struct {
|
||||||
|
|||||||
@ -16,20 +16,22 @@ type User struct {
|
|||||||
}
|
}
|
||||||
|
|
||||||
type RegisterStaffReq struct {
|
type RegisterStaffReq struct {
|
||||||
Email string `json:"email" validate:"required"`
|
Email string `json:"email" validate:"required"`
|
||||||
Password string `json:"password" validate:"required"`
|
Password string `json:"password" validate:"required"`
|
||||||
Username string `json:"username" validate:"required"`
|
Name string `json:"name" validate:"required"`
|
||||||
|
ProfilePicture string `json:"profile_picture"`
|
||||||
}
|
}
|
||||||
|
|
||||||
type UpdateStaffReq struct {
|
type UpdateStaffReq struct {
|
||||||
Email string `json:"email"`
|
Email string `json:"email"`
|
||||||
Password string `json:"password"`
|
Password string `json:"password"`
|
||||||
Username string `json:"username"`
|
Name string `json:"name"`
|
||||||
}
|
}
|
||||||
|
|
||||||
type Staff struct {
|
type Staff struct {
|
||||||
ID string `json:"id"`
|
ID string `json:"id"`
|
||||||
Email string `json:"email"`
|
Email string `json:"email"`
|
||||||
Password string `json:"password"`
|
Password string `json:"password"`
|
||||||
Username string `json:"username"`
|
Name string `json:"name"`
|
||||||
|
ProfilePicture string `json:"profile_picture"`
|
||||||
}
|
}
|
||||||
|
|||||||
@ -9,9 +9,10 @@ func (as *AuthSvc) GetStaffProfile(email string) (*authdomain.StaffProfile, erro
|
|||||||
}
|
}
|
||||||
|
|
||||||
profile := &authdomain.StaffProfile{
|
profile := &authdomain.StaffProfile{
|
||||||
ID: staff.ID,
|
ID: staff.ID,
|
||||||
Username: staff.Username,
|
Name: staff.Name,
|
||||||
Email: staff.Email,
|
Email: staff.Email,
|
||||||
|
ProfilePicture: staff.ProfilePicture,
|
||||||
}
|
}
|
||||||
|
|
||||||
return profile, nil
|
return profile, nil
|
||||||
|
|||||||
@ -20,10 +20,11 @@ func (a *AuthSvc) RegisterStaff(spec authdomain.RegisterStaffReq) (string, error
|
|||||||
}
|
}
|
||||||
|
|
||||||
staff := authdomain.Staff{
|
staff := authdomain.Staff{
|
||||||
ID: uuid.NewString(),
|
ID: uuid.NewString(),
|
||||||
Email: spec.Email,
|
Email: spec.Email,
|
||||||
Password: hashedPwd,
|
Password: hashedPwd,
|
||||||
Username: spec.Username,
|
Name: spec.Name,
|
||||||
|
ProfilePicture: spec.ProfilePicture,
|
||||||
}
|
}
|
||||||
|
|
||||||
_, err = a.staffRepo.Create(&staff)
|
_, err = a.staffRepo.Create(&staff)
|
||||||
|
|||||||
10
openapi.yml
10
openapi.yml
@ -25,7 +25,9 @@ paths:
|
|||||||
type: string
|
type: string
|
||||||
email:
|
email:
|
||||||
type: string
|
type: string
|
||||||
username:
|
name:
|
||||||
|
type: string
|
||||||
|
profile_picture:
|
||||||
type: string
|
type: string
|
||||||
"400":
|
"400":
|
||||||
description: Bad request
|
description: Bad request
|
||||||
@ -108,12 +110,14 @@ paths:
|
|||||||
format: email
|
format: email
|
||||||
password:
|
password:
|
||||||
type: string
|
type: string
|
||||||
username:
|
name:
|
||||||
|
type: string
|
||||||
|
profile_picture:
|
||||||
type: string
|
type: string
|
||||||
required:
|
required:
|
||||||
- email
|
- email
|
||||||
- password
|
- password
|
||||||
- username
|
- name
|
||||||
responses:
|
responses:
|
||||||
"201":
|
"201":
|
||||||
description: Staff member created
|
description: Staff member created
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user