hackathon/api/v1/users.gunk

86 lines
1.8 KiB
Go

2021-12-19 15:30:21 +07:00
package codequest
import (
"github.com/gunk/opt/http"
"github.com/gunk/opt/openapiv2"
"github.com/gunk/opt/proto"
"time"
)
type UserService interface {
// +gunk http.Match{
// Method: "GET",
// Path: "/v1/users/me",
// }
2022-04-28 23:31:09 +07:00
Info(InfoRequest) Info
2021-12-19 15:30:21 +07:00
// +gunk http.Match{
// Method: "GET",
// Path: "/v1/admin/users/{Email}",
// }
UserByEmail(UserByEmailRequest) User
// +gunk http.Match{
// Method: "GET",
// Path: "/v1/admin/users",
// }
AllUsers(AllUsersRequest) AllUsersResponse
// +gunk http.Match{
2022-04-28 23:31:09 +07:00
// Method: "PATCH",
2021-12-19 15:30:21 +07:00
// Path: "/v1/users/me",
// Body: "Body",
// }
UpdateUser(UpdateUserRequest) User
// +gunk http.Match{
2022-04-28 23:31:09 +07:00
// Method: "PATCH",
// Path: "/v1/admin/users/{Body.Email}",
2021-12-19 15:30:21 +07:00
// Body: "Body",
// }
2022-04-28 23:31:09 +07:00
AdminUpdateUser(AdminUpdateUserRequest) User
2021-12-19 15:30:21 +07:00
// +gunk http.Match{
// Method: "DELETE",
// Path: "/v1/admin/users/{Email}",
// }
DeleteUser(DeleteUserRequest) User
}
2022-04-28 23:31:09 +07:00
type InfoRequest struct{}
2021-12-19 15:30:21 +07:00
type UpdateFields struct {
Name string `pb:"1" json:"name"`
2022-04-28 23:31:09 +07:00
GradeLevel int `pb:"3" json:"gradeLevel"`
2021-12-19 15:30:21 +07:00
Admin bool `pb:"4" json:"admin"`
}
2022-04-28 23:31:09 +07:00
type AdminUpdateFields struct {
Email string `pb:"1" json:"email"`
Name string `pb:"2" json:"name"`
GradeLevel int `pb:"3" json:"gradeLevel"`
Admin bool `pb:"4" json:"admin"`
}
2021-12-19 15:30:21 +07:00
type UpdateUserRequest struct {
2022-04-28 23:31:09 +07:00
Body UpdateFields `pb:"1" json:"Body"`
}
type AdminUpdateUserRequest struct {
Body AdminUpdateFields `pb:"1" json:"Body"`
2021-12-19 15:30:21 +07:00
}
type UserByEmailRequest struct {
Email string `pb:"1" json:"email"`
}
type DeleteUserRequest struct {
Email string `pb:"1" json:"email"`
}
2022-04-28 23:31:09 +07:00
type AllUsersRequest struct{}
2021-12-19 15:30:21 +07:00
type AllUsersResponse struct {
Users []User `pb:"1" json:"users"`
}