feat: delete usertitle described
This commit is contained in:
parent
cb9fba6fbc
commit
e0a68d7d0f
6 changed files with 526 additions and 228 deletions
290
api/api.gen.go
290
api/api.gen.go
|
|
@ -16,12 +16,6 @@ import (
|
|||
openapi_types "github.com/oapi-codegen/runtime/types"
|
||||
)
|
||||
|
||||
// Defines values for ImageStorageType.
|
||||
const (
|
||||
Local ImageStorageType = "local"
|
||||
S3 ImageStorageType = "s3"
|
||||
)
|
||||
|
||||
// Defines values for ReleaseSeason.
|
||||
const (
|
||||
Fall ReleaseSeason = "fall"
|
||||
|
|
@ -30,6 +24,12 @@ const (
|
|||
Winter ReleaseSeason = "winter"
|
||||
)
|
||||
|
||||
// Defines values for StorageType.
|
||||
const (
|
||||
Local StorageType = "local"
|
||||
S3 StorageType = "s3"
|
||||
)
|
||||
|
||||
// Defines values for TitleSort.
|
||||
const (
|
||||
Id TitleSort = "id"
|
||||
|
|
@ -65,15 +65,15 @@ type Image struct {
|
|||
ImagePath *string `json:"image_path,omitempty"`
|
||||
|
||||
// StorageType Image storage type
|
||||
StorageType *ImageStorageType `json:"storage_type,omitempty"`
|
||||
StorageType *StorageType `json:"storage_type,omitempty"`
|
||||
}
|
||||
|
||||
// ImageStorageType Image storage type
|
||||
type ImageStorageType string
|
||||
|
||||
// ReleaseSeason Title release season
|
||||
type ReleaseSeason string
|
||||
|
||||
// StorageType Image storage type
|
||||
type StorageType string
|
||||
|
||||
// Studio defines model for Studio.
|
||||
type Studio struct {
|
||||
Description *string `json:"description,omitempty"`
|
||||
|
|
@ -156,6 +156,18 @@ type UserTitle struct {
|
|||
UserId int64 `json:"user_id"`
|
||||
}
|
||||
|
||||
// UserTitleMini defines model for UserTitleMini.
|
||||
type UserTitleMini struct {
|
||||
Ctime *time.Time `json:"ctime,omitempty"`
|
||||
Rate *int32 `json:"rate,omitempty"`
|
||||
ReviewId *int64 `json:"review_id,omitempty"`
|
||||
|
||||
// Status User's title status
|
||||
Status UserTitleStatus `json:"status"`
|
||||
TitleId int64 `json:"title_id"`
|
||||
UserId int64 `json:"user_id"`
|
||||
}
|
||||
|
||||
// UserTitleStatus User's title status
|
||||
type UserTitleStatus string
|
||||
|
||||
|
|
@ -225,21 +237,30 @@ type GetUsersUserIdTitlesParams struct {
|
|||
Fields *string `form:"fields,omitempty" json:"fields,omitempty"`
|
||||
}
|
||||
|
||||
// UpdateUserTitleJSONBody defines parameters for UpdateUserTitle.
|
||||
type UpdateUserTitleJSONBody struct {
|
||||
Rate *int32 `json:"rate,omitempty"`
|
||||
|
||||
// Status User's title status
|
||||
Status *UserTitleStatus `json:"status,omitempty"`
|
||||
TitleId int64 `json:"title_id"`
|
||||
}
|
||||
|
||||
// AddUserTitleJSONBody defines parameters for AddUserTitle.
|
||||
type AddUserTitleJSONBody struct {
|
||||
Ctime *time.Time `json:"ctime,omitempty"`
|
||||
Rate *int32 `json:"rate,omitempty"`
|
||||
ReviewId *int64 `json:"review_id,omitempty"`
|
||||
Rate *int32 `json:"rate,omitempty"`
|
||||
|
||||
// Status User's title status
|
||||
Status UserTitleStatus `json:"status"`
|
||||
TitleId int64 `json:"title_id"`
|
||||
UserId int64 `json:"user_id"`
|
||||
}
|
||||
|
||||
// UpdateUserJSONRequestBody defines body for UpdateUser for application/json ContentType.
|
||||
type UpdateUserJSONRequestBody UpdateUserJSONBody
|
||||
|
||||
// UpdateUserTitleJSONRequestBody defines body for UpdateUserTitle for application/json ContentType.
|
||||
type UpdateUserTitleJSONRequestBody UpdateUserTitleJSONBody
|
||||
|
||||
// AddUserTitleJSONRequestBody defines body for AddUserTitle for application/json ContentType.
|
||||
type AddUserTitleJSONRequestBody AddUserTitleJSONBody
|
||||
|
||||
|
|
@ -499,9 +520,15 @@ type ServerInterface interface {
|
|||
// Partially update a user account
|
||||
// (PATCH /users/{user_id})
|
||||
UpdateUser(c *gin.Context, userId int64)
|
||||
// Delete a usertitle
|
||||
// (DELETE /users/{user_id}/titles)
|
||||
DeleteUserTitle(c *gin.Context, userId int64)
|
||||
// Get user titles
|
||||
// (GET /users/{user_id}/titles)
|
||||
GetUsersUserIdTitles(c *gin.Context, userId string, params GetUsersUserIdTitlesParams)
|
||||
// Update a usertitle
|
||||
// (PATCH /users/{user_id}/titles)
|
||||
UpdateUserTitle(c *gin.Context, userId int64)
|
||||
// Add a title to a user
|
||||
// (POST /users/{user_id}/titles)
|
||||
AddUserTitle(c *gin.Context, userId int64)
|
||||
|
|
@ -716,6 +743,30 @@ func (siw *ServerInterfaceWrapper) UpdateUser(c *gin.Context) {
|
|||
siw.Handler.UpdateUser(c, userId)
|
||||
}
|
||||
|
||||
// DeleteUserTitle operation middleware
|
||||
func (siw *ServerInterfaceWrapper) DeleteUserTitle(c *gin.Context) {
|
||||
|
||||
var err error
|
||||
|
||||
// ------------- Path parameter "user_id" -------------
|
||||
var userId int64
|
||||
|
||||
err = runtime.BindStyledParameterWithOptions("simple", "user_id", c.Param("user_id"), &userId, runtime.BindStyledParameterOptions{Explode: false, Required: true})
|
||||
if err != nil {
|
||||
siw.ErrorHandler(c, fmt.Errorf("Invalid format for parameter user_id: %w", err), http.StatusBadRequest)
|
||||
return
|
||||
}
|
||||
|
||||
for _, middleware := range siw.HandlerMiddlewares {
|
||||
middleware(c)
|
||||
if c.IsAborted() {
|
||||
return
|
||||
}
|
||||
}
|
||||
|
||||
siw.Handler.DeleteUserTitle(c, userId)
|
||||
}
|
||||
|
||||
// GetUsersUserIdTitles operation middleware
|
||||
func (siw *ServerInterfaceWrapper) GetUsersUserIdTitles(c *gin.Context) {
|
||||
|
||||
|
|
@ -839,6 +890,30 @@ func (siw *ServerInterfaceWrapper) GetUsersUserIdTitles(c *gin.Context) {
|
|||
siw.Handler.GetUsersUserIdTitles(c, userId, params)
|
||||
}
|
||||
|
||||
// UpdateUserTitle operation middleware
|
||||
func (siw *ServerInterfaceWrapper) UpdateUserTitle(c *gin.Context) {
|
||||
|
||||
var err error
|
||||
|
||||
// ------------- Path parameter "user_id" -------------
|
||||
var userId int64
|
||||
|
||||
err = runtime.BindStyledParameterWithOptions("simple", "user_id", c.Param("user_id"), &userId, runtime.BindStyledParameterOptions{Explode: false, Required: true})
|
||||
if err != nil {
|
||||
siw.ErrorHandler(c, fmt.Errorf("Invalid format for parameter user_id: %w", err), http.StatusBadRequest)
|
||||
return
|
||||
}
|
||||
|
||||
for _, middleware := range siw.HandlerMiddlewares {
|
||||
middleware(c)
|
||||
if c.IsAborted() {
|
||||
return
|
||||
}
|
||||
}
|
||||
|
||||
siw.Handler.UpdateUserTitle(c, userId)
|
||||
}
|
||||
|
||||
// AddUserTitle operation middleware
|
||||
func (siw *ServerInterfaceWrapper) AddUserTitle(c *gin.Context) {
|
||||
|
||||
|
|
@ -894,7 +969,9 @@ func RegisterHandlersWithOptions(router gin.IRouter, si ServerInterface, options
|
|||
router.GET(options.BaseURL+"/titles/:title_id", wrapper.GetTitlesTitleId)
|
||||
router.GET(options.BaseURL+"/users/:user_id", wrapper.GetUsersUserId)
|
||||
router.PATCH(options.BaseURL+"/users/:user_id", wrapper.UpdateUser)
|
||||
router.DELETE(options.BaseURL+"/users/:user_id/titles", wrapper.DeleteUserTitle)
|
||||
router.GET(options.BaseURL+"/users/:user_id/titles", wrapper.GetUsersUserIdTitles)
|
||||
router.PATCH(options.BaseURL+"/users/:user_id/titles", wrapper.UpdateUserTitle)
|
||||
router.POST(options.BaseURL+"/users/:user_id/titles", wrapper.AddUserTitle)
|
||||
}
|
||||
|
||||
|
|
@ -1110,6 +1187,54 @@ func (response UpdateUser500Response) VisitUpdateUserResponse(w http.ResponseWri
|
|||
return nil
|
||||
}
|
||||
|
||||
type DeleteUserTitleRequestObject struct {
|
||||
UserId int64 `json:"user_id"`
|
||||
}
|
||||
|
||||
type DeleteUserTitleResponseObject interface {
|
||||
VisitDeleteUserTitleResponse(w http.ResponseWriter) error
|
||||
}
|
||||
|
||||
type DeleteUserTitle200Response struct {
|
||||
}
|
||||
|
||||
func (response DeleteUserTitle200Response) VisitDeleteUserTitleResponse(w http.ResponseWriter) error {
|
||||
w.WriteHeader(200)
|
||||
return nil
|
||||
}
|
||||
|
||||
type DeleteUserTitle401Response struct {
|
||||
}
|
||||
|
||||
func (response DeleteUserTitle401Response) VisitDeleteUserTitleResponse(w http.ResponseWriter) error {
|
||||
w.WriteHeader(401)
|
||||
return nil
|
||||
}
|
||||
|
||||
type DeleteUserTitle403Response struct {
|
||||
}
|
||||
|
||||
func (response DeleteUserTitle403Response) VisitDeleteUserTitleResponse(w http.ResponseWriter) error {
|
||||
w.WriteHeader(403)
|
||||
return nil
|
||||
}
|
||||
|
||||
type DeleteUserTitle404Response struct {
|
||||
}
|
||||
|
||||
func (response DeleteUserTitle404Response) VisitDeleteUserTitleResponse(w http.ResponseWriter) error {
|
||||
w.WriteHeader(404)
|
||||
return nil
|
||||
}
|
||||
|
||||
type DeleteUserTitle500Response struct {
|
||||
}
|
||||
|
||||
func (response DeleteUserTitle500Response) VisitDeleteUserTitleResponse(w http.ResponseWriter) error {
|
||||
w.WriteHeader(500)
|
||||
return nil
|
||||
}
|
||||
|
||||
type GetUsersUserIdTitlesRequestObject struct {
|
||||
UserId string `json:"user_id"`
|
||||
Params GetUsersUserIdTitlesParams
|
||||
|
|
@ -1163,6 +1288,64 @@ func (response GetUsersUserIdTitles500Response) VisitGetUsersUserIdTitlesRespons
|
|||
return nil
|
||||
}
|
||||
|
||||
type UpdateUserTitleRequestObject struct {
|
||||
UserId int64 `json:"user_id"`
|
||||
Body *UpdateUserTitleJSONRequestBody
|
||||
}
|
||||
|
||||
type UpdateUserTitleResponseObject interface {
|
||||
VisitUpdateUserTitleResponse(w http.ResponseWriter) error
|
||||
}
|
||||
|
||||
type UpdateUserTitle200JSONResponse UserTitleMini
|
||||
|
||||
func (response UpdateUserTitle200JSONResponse) VisitUpdateUserTitleResponse(w http.ResponseWriter) error {
|
||||
w.Header().Set("Content-Type", "application/json")
|
||||
w.WriteHeader(200)
|
||||
|
||||
return json.NewEncoder(w).Encode(response)
|
||||
}
|
||||
|
||||
type UpdateUserTitle400Response struct {
|
||||
}
|
||||
|
||||
func (response UpdateUserTitle400Response) VisitUpdateUserTitleResponse(w http.ResponseWriter) error {
|
||||
w.WriteHeader(400)
|
||||
return nil
|
||||
}
|
||||
|
||||
type UpdateUserTitle401Response struct {
|
||||
}
|
||||
|
||||
func (response UpdateUserTitle401Response) VisitUpdateUserTitleResponse(w http.ResponseWriter) error {
|
||||
w.WriteHeader(401)
|
||||
return nil
|
||||
}
|
||||
|
||||
type UpdateUserTitle403Response struct {
|
||||
}
|
||||
|
||||
func (response UpdateUserTitle403Response) VisitUpdateUserTitleResponse(w http.ResponseWriter) error {
|
||||
w.WriteHeader(403)
|
||||
return nil
|
||||
}
|
||||
|
||||
type UpdateUserTitle404Response struct {
|
||||
}
|
||||
|
||||
func (response UpdateUserTitle404Response) VisitUpdateUserTitleResponse(w http.ResponseWriter) error {
|
||||
w.WriteHeader(404)
|
||||
return nil
|
||||
}
|
||||
|
||||
type UpdateUserTitle500Response struct {
|
||||
}
|
||||
|
||||
func (response UpdateUserTitle500Response) VisitUpdateUserTitleResponse(w http.ResponseWriter) error {
|
||||
w.WriteHeader(500)
|
||||
return nil
|
||||
}
|
||||
|
||||
type AddUserTitleRequestObject struct {
|
||||
UserId int64 `json:"user_id"`
|
||||
Body *AddUserTitleJSONRequestBody
|
||||
|
|
@ -1172,16 +1355,7 @@ type AddUserTitleResponseObject interface {
|
|||
VisitAddUserTitleResponse(w http.ResponseWriter) error
|
||||
}
|
||||
|
||||
type AddUserTitle200JSONResponse struct {
|
||||
Ctime *time.Time `json:"ctime,omitempty"`
|
||||
Rate *int32 `json:"rate,omitempty"`
|
||||
ReviewId *int64 `json:"review_id,omitempty"`
|
||||
|
||||
// Status User's title status
|
||||
Status UserTitleStatus `json:"status"`
|
||||
TitleId int64 `json:"title_id"`
|
||||
UserId int64 `json:"user_id"`
|
||||
}
|
||||
type AddUserTitle200JSONResponse UserTitleMini
|
||||
|
||||
func (response AddUserTitle200JSONResponse) VisitAddUserTitleResponse(w http.ResponseWriter) error {
|
||||
w.Header().Set("Content-Type", "application/json")
|
||||
|
|
@ -1252,9 +1426,15 @@ type StrictServerInterface interface {
|
|||
// Partially update a user account
|
||||
// (PATCH /users/{user_id})
|
||||
UpdateUser(ctx context.Context, request UpdateUserRequestObject) (UpdateUserResponseObject, error)
|
||||
// Delete a usertitle
|
||||
// (DELETE /users/{user_id}/titles)
|
||||
DeleteUserTitle(ctx context.Context, request DeleteUserTitleRequestObject) (DeleteUserTitleResponseObject, error)
|
||||
// Get user titles
|
||||
// (GET /users/{user_id}/titles)
|
||||
GetUsersUserIdTitles(ctx context.Context, request GetUsersUserIdTitlesRequestObject) (GetUsersUserIdTitlesResponseObject, error)
|
||||
// Update a usertitle
|
||||
// (PATCH /users/{user_id}/titles)
|
||||
UpdateUserTitle(ctx context.Context, request UpdateUserTitleRequestObject) (UpdateUserTitleResponseObject, error)
|
||||
// Add a title to a user
|
||||
// (POST /users/{user_id}/titles)
|
||||
AddUserTitle(ctx context.Context, request AddUserTitleRequestObject) (AddUserTitleResponseObject, error)
|
||||
|
|
@ -1390,6 +1570,33 @@ func (sh *strictHandler) UpdateUser(ctx *gin.Context, userId int64) {
|
|||
}
|
||||
}
|
||||
|
||||
// DeleteUserTitle operation middleware
|
||||
func (sh *strictHandler) DeleteUserTitle(ctx *gin.Context, userId int64) {
|
||||
var request DeleteUserTitleRequestObject
|
||||
|
||||
request.UserId = userId
|
||||
|
||||
handler := func(ctx *gin.Context, request interface{}) (interface{}, error) {
|
||||
return sh.ssi.DeleteUserTitle(ctx, request.(DeleteUserTitleRequestObject))
|
||||
}
|
||||
for _, middleware := range sh.middlewares {
|
||||
handler = middleware(handler, "DeleteUserTitle")
|
||||
}
|
||||
|
||||
response, err := handler(ctx, request)
|
||||
|
||||
if err != nil {
|
||||
ctx.Error(err)
|
||||
ctx.Status(http.StatusInternalServerError)
|
||||
} else if validResponse, ok := response.(DeleteUserTitleResponseObject); ok {
|
||||
if err := validResponse.VisitDeleteUserTitleResponse(ctx.Writer); err != nil {
|
||||
ctx.Error(err)
|
||||
}
|
||||
} else if response != nil {
|
||||
ctx.Error(fmt.Errorf("unexpected response type: %T", response))
|
||||
}
|
||||
}
|
||||
|
||||
// GetUsersUserIdTitles operation middleware
|
||||
func (sh *strictHandler) GetUsersUserIdTitles(ctx *gin.Context, userId string, params GetUsersUserIdTitlesParams) {
|
||||
var request GetUsersUserIdTitlesRequestObject
|
||||
|
|
@ -1418,6 +1625,41 @@ func (sh *strictHandler) GetUsersUserIdTitles(ctx *gin.Context, userId string, p
|
|||
}
|
||||
}
|
||||
|
||||
// UpdateUserTitle operation middleware
|
||||
func (sh *strictHandler) UpdateUserTitle(ctx *gin.Context, userId int64) {
|
||||
var request UpdateUserTitleRequestObject
|
||||
|
||||
request.UserId = userId
|
||||
|
||||
var body UpdateUserTitleJSONRequestBody
|
||||
if err := ctx.ShouldBindJSON(&body); err != nil {
|
||||
ctx.Status(http.StatusBadRequest)
|
||||
ctx.Error(err)
|
||||
return
|
||||
}
|
||||
request.Body = &body
|
||||
|
||||
handler := func(ctx *gin.Context, request interface{}) (interface{}, error) {
|
||||
return sh.ssi.UpdateUserTitle(ctx, request.(UpdateUserTitleRequestObject))
|
||||
}
|
||||
for _, middleware := range sh.middlewares {
|
||||
handler = middleware(handler, "UpdateUserTitle")
|
||||
}
|
||||
|
||||
response, err := handler(ctx, request)
|
||||
|
||||
if err != nil {
|
||||
ctx.Error(err)
|
||||
ctx.Status(http.StatusInternalServerError)
|
||||
} else if validResponse, ok := response.(UpdateUserTitleResponseObject); ok {
|
||||
if err := validResponse.VisitUpdateUserTitleResponse(ctx.Writer); err != nil {
|
||||
ctx.Error(err)
|
||||
}
|
||||
} else if response != nil {
|
||||
ctx.Error(fmt.Errorf("unexpected response type: %T", response))
|
||||
}
|
||||
}
|
||||
|
||||
// AddUserTitle operation middleware
|
||||
func (sh *strictHandler) AddUserTitle(ctx *gin.Context, userId int64) {
|
||||
var request AddUserTitleRequestObject
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue