86 lines
1.8 KiB
Go
86 lines
1.8 KiB
Go
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",
|
|
// }
|
|
Info(InfoRequest) Info
|
|
|
|
// +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{
|
|
// Method: "PATCH",
|
|
// Path: "/v1/users/me",
|
|
// Body: "Body",
|
|
// }
|
|
UpdateUser(UpdateUserRequest) User
|
|
|
|
// +gunk http.Match{
|
|
// Method: "PATCH",
|
|
// Path: "/v1/admin/users/{Body.Email}",
|
|
// Body: "Body",
|
|
// }
|
|
AdminUpdateUser(AdminUpdateUserRequest) User
|
|
|
|
// +gunk http.Match{
|
|
// Method: "DELETE",
|
|
// Path: "/v1/admin/users/{Email}",
|
|
// }
|
|
DeleteUser(DeleteUserRequest) User
|
|
}
|
|
|
|
type InfoRequest struct{}
|
|
|
|
type UpdateFields struct {
|
|
Name string `pb:"1" json:"name"`
|
|
GradeLevel int `pb:"3" json:"gradeLevel"`
|
|
Admin bool `pb:"4" json:"admin"`
|
|
}
|
|
|
|
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"`
|
|
}
|
|
|
|
type UpdateUserRequest struct {
|
|
Body UpdateFields `pb:"1" json:"Body"`
|
|
}
|
|
|
|
type AdminUpdateUserRequest struct {
|
|
Body AdminUpdateFields `pb:"1" json:"Body"`
|
|
}
|
|
|
|
type UserByEmailRequest struct {
|
|
Email string `pb:"1" json:"email"`
|
|
}
|
|
|
|
type DeleteUserRequest struct {
|
|
Email string `pb:"1" json:"email"`
|
|
}
|
|
|
|
type AllUsersRequest struct{}
|
|
|
|
type AllUsersResponse struct {
|
|
Users []User `pb:"1" json:"users"`
|
|
}
|