fix: now post usertitle dont need title body
This commit is contained in:
parent
9139c77c5f
commit
65b76d58c3
4 changed files with 64 additions and 7 deletions
|
|
@ -326,7 +326,29 @@ paths:
|
||||||
content:
|
content:
|
||||||
application/json:
|
application/json:
|
||||||
schema:
|
schema:
|
||||||
$ref: '#/components/schemas/UserTitle'
|
type: object
|
||||||
|
required:
|
||||||
|
- user_id
|
||||||
|
- title_id
|
||||||
|
- status
|
||||||
|
properties:
|
||||||
|
user_id:
|
||||||
|
type: integer
|
||||||
|
format: int64
|
||||||
|
title_id:
|
||||||
|
type: integer
|
||||||
|
format: int64
|
||||||
|
status:
|
||||||
|
$ref: '#/components/schemas/UserTitleStatus'
|
||||||
|
rate:
|
||||||
|
type: integer
|
||||||
|
format: int32
|
||||||
|
review_id:
|
||||||
|
type: integer
|
||||||
|
format: int64
|
||||||
|
ctime:
|
||||||
|
type: string
|
||||||
|
format: date-time
|
||||||
responses:
|
responses:
|
||||||
'200':
|
'200':
|
||||||
description: Title successfully added to user
|
description: Title successfully added to user
|
||||||
|
|
|
||||||
|
|
@ -226,11 +226,23 @@ type GetUsersUserIdTitlesParams struct {
|
||||||
Fields *string `form:"fields,omitempty" json:"fields,omitempty"`
|
Fields *string `form:"fields,omitempty" json:"fields,omitempty"`
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// 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"`
|
||||||
|
|
||||||
|
// 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.
|
// UpdateUserJSONRequestBody defines body for UpdateUser for application/json ContentType.
|
||||||
type UpdateUserJSONRequestBody UpdateUserJSONBody
|
type UpdateUserJSONRequestBody UpdateUserJSONBody
|
||||||
|
|
||||||
// AddUserTitleJSONRequestBody defines body for AddUserTitle for application/json ContentType.
|
// AddUserTitleJSONRequestBody defines body for AddUserTitle for application/json ContentType.
|
||||||
type AddUserTitleJSONRequestBody = UserTitle
|
type AddUserTitleJSONRequestBody AddUserTitleJSONBody
|
||||||
|
|
||||||
// Getter for additional properties for Title. Returns the specified
|
// Getter for additional properties for Title. Returns the specified
|
||||||
// element and whether it was found
|
// element and whether it was found
|
||||||
|
|
|
||||||
|
|
@ -108,7 +108,30 @@ post:
|
||||||
content:
|
content:
|
||||||
application/json:
|
application/json:
|
||||||
schema:
|
schema:
|
||||||
$ref: '../schemas/UserTitle.yaml'
|
type: object
|
||||||
|
required:
|
||||||
|
- user_id
|
||||||
|
- title_id
|
||||||
|
- status
|
||||||
|
properties:
|
||||||
|
user_id:
|
||||||
|
type: integer
|
||||||
|
format: int64
|
||||||
|
title_id:
|
||||||
|
type: integer
|
||||||
|
format: int64
|
||||||
|
status:
|
||||||
|
$ref: ../schemas/enums/UserTitleStatus.yaml
|
||||||
|
rate:
|
||||||
|
type: integer
|
||||||
|
format: int32
|
||||||
|
review_id:
|
||||||
|
type: integer
|
||||||
|
format: int64
|
||||||
|
ctime:
|
||||||
|
type: string
|
||||||
|
format: date-time
|
||||||
|
|
||||||
responses:
|
responses:
|
||||||
'200':
|
'200':
|
||||||
description: Title successfully added to user
|
description: Title successfully added to user
|
||||||
|
|
|
||||||
|
|
@ -140,9 +140,9 @@ func UserTitleStatus2Sqlc(s *[]oapi.UserTitleStatus) ([]sqlc.UsertitleStatusT, e
|
||||||
}
|
}
|
||||||
|
|
||||||
func UserTitleStatus2Sqlc1(s *oapi.UserTitleStatus) (*sqlc.UsertitleStatusT, error) {
|
func UserTitleStatus2Sqlc1(s *oapi.UserTitleStatus) (*sqlc.UsertitleStatusT, error) {
|
||||||
var sqlc_status sqlc.UsertitleStatusT
|
var sqlc_status sqlc.UsertitleStatusT = sqlc.UsertitleStatusTFinished
|
||||||
if s == nil {
|
if s == nil {
|
||||||
return nil, nil
|
return &sqlc_status, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
switch *s {
|
switch *s {
|
||||||
|
|
@ -304,7 +304,7 @@ func (s Server) GetUsersUserIdTitles(ctx context.Context, request oapi.GetUsersU
|
||||||
tmp := fmt.Sprint(*t.Title.ReleaseYear)
|
tmp := fmt.Sprint(*t.Title.ReleaseYear)
|
||||||
new_cursor.Param = &tmp
|
new_cursor.Param = &tmp
|
||||||
case "rating":
|
case "rating":
|
||||||
tmp := strconv.FormatFloat(*t.Title.Rating, 'f', -1, 64)
|
tmp := strconv.FormatFloat(*t.Title.Rating, 'f', -1, 64) // падает
|
||||||
new_cursor.Param = &tmp
|
new_cursor.Param = &tmp
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -369,7 +369,7 @@ func (s Server) AddUserTitle(ctx context.Context, request oapi.AddUserTitleReque
|
||||||
|
|
||||||
params := sqlc.InsertUserTitleParams{
|
params := sqlc.InsertUserTitleParams{
|
||||||
UserID: request.UserId,
|
UserID: request.UserId,
|
||||||
TitleID: request.Body.Title.Id,
|
TitleID: request.Body.TitleId,
|
||||||
Status: *status,
|
Status: *status,
|
||||||
Rate: request.Body.Rate,
|
Rate: request.Body.Rate,
|
||||||
ReviewID: request.Body.ReviewId,
|
ReviewID: request.Body.ReviewId,
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue