Merge branch 'dev' of ssh://meowgit.nekoea.red:22222/nihonium/nyanimedb into dev
This commit is contained in:
commit
7956a8a961
12 changed files with 113 additions and 35 deletions
|
|
@ -395,6 +395,9 @@ paths:
|
||||||
rate:
|
rate:
|
||||||
type: integer
|
type: integer
|
||||||
format: int32
|
format: int32
|
||||||
|
ftime:
|
||||||
|
type: string
|
||||||
|
format: date-time
|
||||||
required:
|
required:
|
||||||
- title_id
|
- title_id
|
||||||
- status
|
- status
|
||||||
|
|
@ -478,6 +481,9 @@ paths:
|
||||||
rate:
|
rate:
|
||||||
type: integer
|
type: integer
|
||||||
format: int32
|
format: int32
|
||||||
|
ftime:
|
||||||
|
type: string
|
||||||
|
format: date-time
|
||||||
responses:
|
responses:
|
||||||
'200':
|
'200':
|
||||||
description: Title successfully updated
|
description: Title successfully updated
|
||||||
|
|
|
||||||
|
|
@ -262,6 +262,7 @@ type GetUserTitlesParams struct {
|
||||||
|
|
||||||
// AddUserTitleJSONBody defines parameters for AddUserTitle.
|
// AddUserTitleJSONBody defines parameters for AddUserTitle.
|
||||||
type AddUserTitleJSONBody struct {
|
type AddUserTitleJSONBody struct {
|
||||||
|
Ftime *time.Time `json:"ftime,omitempty"`
|
||||||
Rate *int32 `json:"rate,omitempty"`
|
Rate *int32 `json:"rate,omitempty"`
|
||||||
|
|
||||||
// Status User's title status
|
// Status User's title status
|
||||||
|
|
@ -271,6 +272,7 @@ type AddUserTitleJSONBody struct {
|
||||||
|
|
||||||
// UpdateUserTitleJSONBody defines parameters for UpdateUserTitle.
|
// UpdateUserTitleJSONBody defines parameters for UpdateUserTitle.
|
||||||
type UpdateUserTitleJSONBody struct {
|
type UpdateUserTitleJSONBody struct {
|
||||||
|
Ftime *time.Time `json:"ftime,omitempty"`
|
||||||
Rate *int32 `json:"rate,omitempty"`
|
Rate *int32 `json:"rate,omitempty"`
|
||||||
|
|
||||||
// Status User's title status
|
// Status User's title status
|
||||||
|
|
|
||||||
|
|
@ -61,6 +61,9 @@ patch:
|
||||||
rate:
|
rate:
|
||||||
type: integer
|
type: integer
|
||||||
format: int32
|
format: int32
|
||||||
|
ftime:
|
||||||
|
type: string
|
||||||
|
format: date-time
|
||||||
responses:
|
responses:
|
||||||
'200':
|
'200':
|
||||||
description: Title successfully updated
|
description: Title successfully updated
|
||||||
|
|
|
||||||
|
|
@ -122,6 +122,9 @@ post:
|
||||||
rate:
|
rate:
|
||||||
type: integer
|
type: integer
|
||||||
format: int32
|
format: int32
|
||||||
|
ftime:
|
||||||
|
type: string
|
||||||
|
format: date-time
|
||||||
responses:
|
responses:
|
||||||
'200':
|
'200':
|
||||||
description: Title successfully added to user
|
description: Title successfully added to user
|
||||||
|
|
|
||||||
|
|
@ -69,6 +69,16 @@ func sqlDate2oapi(p_date pgtype.Timestamptz) *time.Time {
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func oapiDate2sql(t *time.Time) pgtype.Timestamptz {
|
||||||
|
if t == nil {
|
||||||
|
return pgtype.Timestamptz{Valid: false}
|
||||||
|
}
|
||||||
|
return pgtype.Timestamptz{
|
||||||
|
Time: *t,
|
||||||
|
Valid: true,
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// func UserTitleStatus2Sqlc(s *[]oapi.UserTitleStatus) (*SqlcUserStatus, error) {
|
// func UserTitleStatus2Sqlc(s *[]oapi.UserTitleStatus) (*SqlcUserStatus, error) {
|
||||||
// var sqlc_status SqlcUserStatus
|
// var sqlc_status SqlcUserStatus
|
||||||
// if s == nil {
|
// if s == nil {
|
||||||
|
|
@ -365,6 +375,7 @@ func (s Server) AddUserTitle(ctx context.Context, request oapi.AddUserTitleReque
|
||||||
TitleID: request.Body.TitleId,
|
TitleID: request.Body.TitleId,
|
||||||
Status: *status,
|
Status: *status,
|
||||||
Rate: request.Body.Rate,
|
Rate: request.Body.Rate,
|
||||||
|
Ftime: oapiDate2sql(request.Body.Ftime),
|
||||||
}
|
}
|
||||||
|
|
||||||
user_title, err := s.db.InsertUserTitle(ctx, params)
|
user_title, err := s.db.InsertUserTitle(ctx, params)
|
||||||
|
|
@ -428,6 +439,7 @@ func (s Server) UpdateUserTitle(ctx context.Context, request oapi.UpdateUserTitl
|
||||||
Rate: request.Body.Rate,
|
Rate: request.Body.Rate,
|
||||||
UserID: request.UserId,
|
UserID: request.UserId,
|
||||||
TitleID: request.TitleId,
|
TitleID: request.TitleId,
|
||||||
|
Ftime: oapiDate2sql(request.Body.Ftime),
|
||||||
}
|
}
|
||||||
|
|
||||||
user_title, err := s.db.UpdateUserTitle(ctx, params)
|
user_title, err := s.db.UpdateUserTitle(ctx, params)
|
||||||
|
|
|
||||||
|
|
@ -400,13 +400,14 @@ FROM reviews
|
||||||
WHERE review_id = sqlc.arg('review_id')::bigint;
|
WHERE review_id = sqlc.arg('review_id')::bigint;
|
||||||
|
|
||||||
-- name: InsertUserTitle :one
|
-- name: InsertUserTitle :one
|
||||||
INSERT INTO usertitles (user_id, title_id, status, rate, review_id)
|
INSERT INTO usertitles (user_id, title_id, status, rate, review_id, ctime)
|
||||||
VALUES (
|
VALUES (
|
||||||
sqlc.arg('user_id')::bigint,
|
sqlc.arg('user_id')::bigint,
|
||||||
sqlc.arg('title_id')::bigint,
|
sqlc.arg('title_id')::bigint,
|
||||||
sqlc.arg('status')::usertitle_status_t,
|
sqlc.arg('status')::usertitle_status_t,
|
||||||
sqlc.narg('rate')::int,
|
sqlc.narg('rate')::int,
|
||||||
sqlc.narg('review_id')::bigint
|
sqlc.narg('review_id')::bigint,
|
||||||
|
sqlc.narg('ftime')::timestamptz
|
||||||
)
|
)
|
||||||
RETURNING user_id, title_id, status, rate, review_id, ctime;
|
RETURNING user_id, title_id, status, rate, review_id, ctime;
|
||||||
|
|
||||||
|
|
@ -415,7 +416,8 @@ RETURNING user_id, title_id, status, rate, review_id, ctime;
|
||||||
UPDATE usertitles
|
UPDATE usertitles
|
||||||
SET
|
SET
|
||||||
status = COALESCE(sqlc.narg('status')::usertitle_status_t, status),
|
status = COALESCE(sqlc.narg('status')::usertitle_status_t, status),
|
||||||
rate = COALESCE(sqlc.narg('rate')::int, rate)
|
rate = COALESCE(sqlc.narg('rate')::int, rate),
|
||||||
|
ctime = COALESCE(sqlc.narg('ftime')::timestamptz, ctime)
|
||||||
WHERE
|
WHERE
|
||||||
user_id = sqlc.arg('user_id')
|
user_id = sqlc.arg('user_id')
|
||||||
AND title_id = sqlc.arg('title_id')
|
AND title_id = sqlc.arg('title_id')
|
||||||
|
|
|
||||||
|
|
@ -13,4 +13,4 @@ import type { ClientOptions as ClientOptions2 } from './types.gen';
|
||||||
*/
|
*/
|
||||||
export type CreateClientConfig<T extends ClientOptions = ClientOptions2> = (override?: Config<ClientOptions & T>) => Config<Required<ClientOptions> & T>;
|
export type CreateClientConfig<T extends ClientOptions = ClientOptions2> = (override?: Config<ClientOptions & T>) => Config<Required<ClientOptions> & T>;
|
||||||
|
|
||||||
export const client = createClient(createConfig<ClientOptions2>({ baseUrl: 'http://10.1.0.65:8081/api/v1' }));
|
export const client = createClient(createConfig<ClientOptions2>({ baseUrl: '/api/v1' }));
|
||||||
|
|
|
||||||
|
|
@ -2,7 +2,7 @@
|
||||||
|
|
||||||
import type { Client, Options as Options2, TDataShape } from './client';
|
import type { Client, Options as Options2, TDataShape } from './client';
|
||||||
import { client } from './client.gen';
|
import { client } from './client.gen';
|
||||||
import type { AddUserTitleData, AddUserTitleErrors, AddUserTitleResponses, DeleteUserTitleData, DeleteUserTitleErrors, DeleteUserTitleResponses, GetTitleData, GetTitleErrors, GetTitleResponses, GetTitlesData, GetTitlesErrors, GetTitlesResponses, GetUsersIdData, GetUsersIdErrors, GetUsersIdResponses, GetUserTitleData, GetUserTitleErrors, GetUserTitleResponses, GetUserTitlesData, GetUserTitlesErrors, GetUserTitlesResponses, UpdateUserData, UpdateUserErrors, UpdateUserResponses, UpdateUserTitleData, UpdateUserTitleErrors, UpdateUserTitleResponses } from './types.gen';
|
import type { AddUserTitleData, AddUserTitleErrors, AddUserTitleResponses, DeleteUserTitleData, DeleteUserTitleErrors, DeleteUserTitleResponses, GetTitleData, GetTitleErrors, GetTitleResponses, GetTitlesData, GetTitlesErrors, GetTitlesResponses, GetUsersData, GetUsersErrors, GetUsersIdData, GetUsersIdErrors, GetUsersIdResponses, GetUsersResponses, GetUserTitleData, GetUserTitleErrors, GetUserTitleResponses, GetUserTitlesData, GetUserTitlesErrors, GetUserTitlesResponses, UpdateUserData, UpdateUserErrors, UpdateUserResponses, UpdateUserTitleData, UpdateUserTitleErrors, UpdateUserTitleResponses } from './types.gen';
|
||||||
|
|
||||||
export type Options<TData extends TDataShape = TDataShape, ThrowOnError extends boolean = boolean> = Options2<TData, ThrowOnError> & {
|
export type Options<TData extends TDataShape = TDataShape, ThrowOnError extends boolean = boolean> = Options2<TData, ThrowOnError> & {
|
||||||
/**
|
/**
|
||||||
|
|
@ -32,6 +32,11 @@ export const getTitles = <ThrowOnError extends boolean = false>(options?: Option
|
||||||
*/
|
*/
|
||||||
export const getTitle = <ThrowOnError extends boolean = false>(options: Options<GetTitleData, ThrowOnError>) => (options.client ?? client).get<GetTitleResponses, GetTitleErrors, ThrowOnError>({ url: '/titles/{title_id}', ...options });
|
export const getTitle = <ThrowOnError extends boolean = false>(options: Options<GetTitleData, ThrowOnError>) => (options.client ?? client).get<GetTitleResponses, GetTitleErrors, ThrowOnError>({ url: '/titles/{title_id}', ...options });
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Search user by nickname or dispname (both in one param), response is always sorted by id
|
||||||
|
*/
|
||||||
|
export const getUsers = <ThrowOnError extends boolean = false>(options?: Options<GetUsersData, ThrowOnError>) => (options?.client ?? client).get<GetUsersResponses, GetUsersErrors, ThrowOnError>({ url: '/users/', ...options });
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Get user info
|
* Get user info
|
||||||
*/
|
*/
|
||||||
|
|
|
||||||
|
|
@ -60,6 +60,12 @@ export type Title = {
|
||||||
title_names: {
|
title_names: {
|
||||||
[key: string]: Array<string>;
|
[key: string]: Array<string>;
|
||||||
};
|
};
|
||||||
|
/**
|
||||||
|
* Localized description. Key = language (ISO 639-1), value = description.
|
||||||
|
*/
|
||||||
|
title_desc?: {
|
||||||
|
[key: string]: string;
|
||||||
|
};
|
||||||
studio?: Studio;
|
studio?: Studio;
|
||||||
tags: Tags;
|
tags: Tags;
|
||||||
poster?: Image;
|
poster?: Image;
|
||||||
|
|
@ -231,6 +237,50 @@ export type GetTitleResponses = {
|
||||||
|
|
||||||
export type GetTitleResponse = GetTitleResponses[keyof GetTitleResponses];
|
export type GetTitleResponse = GetTitleResponses[keyof GetTitleResponses];
|
||||||
|
|
||||||
|
export type GetUsersData = {
|
||||||
|
body?: never;
|
||||||
|
path?: never;
|
||||||
|
query?: {
|
||||||
|
word?: string;
|
||||||
|
limit?: number;
|
||||||
|
/**
|
||||||
|
* pass cursor naked
|
||||||
|
*/
|
||||||
|
cursor_id?: number;
|
||||||
|
};
|
||||||
|
url: '/users/';
|
||||||
|
};
|
||||||
|
|
||||||
|
export type GetUsersErrors = {
|
||||||
|
/**
|
||||||
|
* Request params are not correct
|
||||||
|
*/
|
||||||
|
400: unknown;
|
||||||
|
/**
|
||||||
|
* Unknown server error
|
||||||
|
*/
|
||||||
|
500: unknown;
|
||||||
|
};
|
||||||
|
|
||||||
|
export type GetUsersResponses = {
|
||||||
|
/**
|
||||||
|
* List of users with cursor
|
||||||
|
*/
|
||||||
|
200: {
|
||||||
|
/**
|
||||||
|
* List of users
|
||||||
|
*/
|
||||||
|
data: Array<User>;
|
||||||
|
cursor: number;
|
||||||
|
};
|
||||||
|
/**
|
||||||
|
* No users found
|
||||||
|
*/
|
||||||
|
204: void;
|
||||||
|
};
|
||||||
|
|
||||||
|
export type GetUsersResponse = GetUsersResponses[keyof GetUsersResponses];
|
||||||
|
|
||||||
export type GetUsersIdData = {
|
export type GetUsersIdData = {
|
||||||
body?: never;
|
body?: never;
|
||||||
path: {
|
path: {
|
||||||
|
|
|
||||||
0
modules/frontend/src/pages/UsersPage/UsersPage.tsx
Normal file
0
modules/frontend/src/pages/UsersPage/UsersPage.tsx
Normal file
|
|
@ -170,16 +170,3 @@ CREATE TRIGGER trg_notify_new_signal
|
||||||
AFTER INSERT ON signals
|
AFTER INSERT ON signals
|
||||||
FOR EACH ROW
|
FOR EACH ROW
|
||||||
EXECUTE FUNCTION notify_new_signal();
|
EXECUTE FUNCTION notify_new_signal();
|
||||||
|
|
||||||
CREATE OR REPLACE FUNCTION set_ctime()
|
|
||||||
RETURNS TRIGGER AS $$
|
|
||||||
BEGIN
|
|
||||||
NEW.ctime = now();
|
|
||||||
RETURN NEW;
|
|
||||||
END;
|
|
||||||
$$ LANGUAGE plpgsql;
|
|
||||||
|
|
||||||
CREATE TRIGGER set_ctime_on_update
|
|
||||||
BEFORE UPDATE ON usertitles
|
|
||||||
FOR EACH ROW
|
|
||||||
EXECUTE FUNCTION set_ctime();
|
|
||||||
|
|
@ -9,6 +9,8 @@ import (
|
||||||
"context"
|
"context"
|
||||||
"encoding/json"
|
"encoding/json"
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
|
"github.com/jackc/pgx/v5/pgtype"
|
||||||
)
|
)
|
||||||
|
|
||||||
const createImage = `-- name: CreateImage :one
|
const createImage = `-- name: CreateImage :one
|
||||||
|
|
@ -436,13 +438,14 @@ func (q *Queries) InsertTitleTags(ctx context.Context, arg InsertTitleTagsParams
|
||||||
}
|
}
|
||||||
|
|
||||||
const insertUserTitle = `-- name: InsertUserTitle :one
|
const insertUserTitle = `-- name: InsertUserTitle :one
|
||||||
INSERT INTO usertitles (user_id, title_id, status, rate, review_id)
|
INSERT INTO usertitles (user_id, title_id, status, rate, review_id, ctime)
|
||||||
VALUES (
|
VALUES (
|
||||||
$1::bigint,
|
$1::bigint,
|
||||||
$2::bigint,
|
$2::bigint,
|
||||||
$3::usertitle_status_t,
|
$3::usertitle_status_t,
|
||||||
$4::int,
|
$4::int,
|
||||||
$5::bigint
|
$5::bigint,
|
||||||
|
$6::timestamptz
|
||||||
)
|
)
|
||||||
RETURNING user_id, title_id, status, rate, review_id, ctime
|
RETURNING user_id, title_id, status, rate, review_id, ctime
|
||||||
`
|
`
|
||||||
|
|
@ -453,6 +456,7 @@ type InsertUserTitleParams struct {
|
||||||
Status UsertitleStatusT `json:"status"`
|
Status UsertitleStatusT `json:"status"`
|
||||||
Rate *int32 `json:"rate"`
|
Rate *int32 `json:"rate"`
|
||||||
ReviewID *int64 `json:"review_id"`
|
ReviewID *int64 `json:"review_id"`
|
||||||
|
Ftime pgtype.Timestamptz `json:"ftime"`
|
||||||
}
|
}
|
||||||
|
|
||||||
func (q *Queries) InsertUserTitle(ctx context.Context, arg InsertUserTitleParams) (Usertitle, error) {
|
func (q *Queries) InsertUserTitle(ctx context.Context, arg InsertUserTitleParams) (Usertitle, error) {
|
||||||
|
|
@ -462,6 +466,7 @@ func (q *Queries) InsertUserTitle(ctx context.Context, arg InsertUserTitleParams
|
||||||
arg.Status,
|
arg.Status,
|
||||||
arg.Rate,
|
arg.Rate,
|
||||||
arg.ReviewID,
|
arg.ReviewID,
|
||||||
|
arg.Ftime,
|
||||||
)
|
)
|
||||||
var i Usertitle
|
var i Usertitle
|
||||||
err := row.Scan(
|
err := row.Scan(
|
||||||
|
|
@ -1059,16 +1064,18 @@ const updateUserTitle = `-- name: UpdateUserTitle :one
|
||||||
UPDATE usertitles
|
UPDATE usertitles
|
||||||
SET
|
SET
|
||||||
status = COALESCE($1::usertitle_status_t, status),
|
status = COALESCE($1::usertitle_status_t, status),
|
||||||
rate = COALESCE($2::int, rate)
|
rate = COALESCE($2::int, rate),
|
||||||
|
ctime = COALESCE($3::timestamptz, ctime)
|
||||||
WHERE
|
WHERE
|
||||||
user_id = $3
|
user_id = $4
|
||||||
AND title_id = $4
|
AND title_id = $5
|
||||||
RETURNING user_id, title_id, status, rate, review_id, ctime
|
RETURNING user_id, title_id, status, rate, review_id, ctime
|
||||||
`
|
`
|
||||||
|
|
||||||
type UpdateUserTitleParams struct {
|
type UpdateUserTitleParams struct {
|
||||||
Status *UsertitleStatusT `json:"status"`
|
Status *UsertitleStatusT `json:"status"`
|
||||||
Rate *int32 `json:"rate"`
|
Rate *int32 `json:"rate"`
|
||||||
|
Ftime pgtype.Timestamptz `json:"ftime"`
|
||||||
UserID int64 `json:"user_id"`
|
UserID int64 `json:"user_id"`
|
||||||
TitleID int64 `json:"title_id"`
|
TitleID int64 `json:"title_id"`
|
||||||
}
|
}
|
||||||
|
|
@ -1078,6 +1085,7 @@ func (q *Queries) UpdateUserTitle(ctx context.Context, arg UpdateUserTitleParams
|
||||||
row := q.db.QueryRow(ctx, updateUserTitle,
|
row := q.db.QueryRow(ctx, updateUserTitle,
|
||||||
arg.Status,
|
arg.Status,
|
||||||
arg.Rate,
|
arg.Rate,
|
||||||
|
arg.Ftime,
|
||||||
arg.UserID,
|
arg.UserID,
|
||||||
arg.TitleID,
|
arg.TitleID,
|
||||||
)
|
)
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue