mirror of https://github.com/rocboss/paopao-ce
parent
0141aff7e1
commit
ba66ad922f
@ -0,0 +1,226 @@
|
|||||||
|
// Code generated by sqlc. DO NOT EDIT.
|
||||||
|
// versions:
|
||||||
|
// sqlc v1.21.0
|
||||||
|
// source: metrics.sql
|
||||||
|
|
||||||
|
package pgc
|
||||||
|
|
||||||
|
import (
|
||||||
|
"context"
|
||||||
|
)
|
||||||
|
|
||||||
|
const addCommentMetric = `-- name: AddCommentMetric :one
|
||||||
|
INSERT INTO p_comment_metric (comment_id, created_on)
|
||||||
|
VALUES ($1, $2)
|
||||||
|
RETURNING id
|
||||||
|
`
|
||||||
|
|
||||||
|
type AddCommentMetricParams struct {
|
||||||
|
CommentID int64
|
||||||
|
CreatedOn int64
|
||||||
|
}
|
||||||
|
|
||||||
|
func (q *Queries) AddCommentMetric(ctx context.Context, arg *AddCommentMetricParams) (int64, error) {
|
||||||
|
row := q.db.QueryRow(ctx, addCommentMetric, arg.CommentID, arg.CreatedOn)
|
||||||
|
var id int64
|
||||||
|
err := row.Scan(&id)
|
||||||
|
return id, err
|
||||||
|
}
|
||||||
|
|
||||||
|
const addTweetMetric = `-- name: AddTweetMetric :one
|
||||||
|
INSERT INTO p_post_metric (post_id, created_on)
|
||||||
|
VALUES ($1, $2)
|
||||||
|
RETURNING id
|
||||||
|
`
|
||||||
|
|
||||||
|
type AddTweetMetricParams struct {
|
||||||
|
PostID int64
|
||||||
|
CreatedOn int64
|
||||||
|
}
|
||||||
|
|
||||||
|
func (q *Queries) AddTweetMetric(ctx context.Context, arg *AddTweetMetricParams) (int64, error) {
|
||||||
|
row := q.db.QueryRow(ctx, addTweetMetric, arg.PostID, arg.CreatedOn)
|
||||||
|
var id int64
|
||||||
|
err := row.Scan(&id)
|
||||||
|
return id, err
|
||||||
|
}
|
||||||
|
|
||||||
|
const addUserMetric = `-- name: AddUserMetric :one
|
||||||
|
INSERT INTO p_user_metric (user_id, created_on) VALUES ($1, $2) RETURNING id
|
||||||
|
`
|
||||||
|
|
||||||
|
type AddUserMetricParams struct {
|
||||||
|
UserID int64
|
||||||
|
CreatedOn int64
|
||||||
|
}
|
||||||
|
|
||||||
|
func (q *Queries) AddUserMetric(ctx context.Context, arg *AddUserMetricParams) (int64, error) {
|
||||||
|
row := q.db.QueryRow(ctx, addUserMetric, arg.UserID, arg.CreatedOn)
|
||||||
|
var id int64
|
||||||
|
err := row.Scan(&id)
|
||||||
|
return id, err
|
||||||
|
}
|
||||||
|
|
||||||
|
const commentMotivationFactor = `-- name: CommentMotivationFactor :one
|
||||||
|
SELECT motivation_factor FROM p_comment_metric WHERE comment_id=$1 AND is_del=0
|
||||||
|
`
|
||||||
|
|
||||||
|
func (q *Queries) CommentMotivationFactor(ctx context.Context, commentID int64) (int32, error) {
|
||||||
|
row := q.db.QueryRow(ctx, commentMotivationFactor, commentID)
|
||||||
|
var motivation_factor int32
|
||||||
|
err := row.Scan(&motivation_factor)
|
||||||
|
return motivation_factor, err
|
||||||
|
}
|
||||||
|
|
||||||
|
const deleteCommentMetric = `-- name: DeleteCommentMetric :exec
|
||||||
|
UPDATE p_comment_metric SET is_del=1, deleted_on=$1 WHERE comment_id=$2 AND is_del=0
|
||||||
|
`
|
||||||
|
|
||||||
|
type DeleteCommentMetricParams struct {
|
||||||
|
DeletedOn int64
|
||||||
|
CommentID int64
|
||||||
|
}
|
||||||
|
|
||||||
|
func (q *Queries) DeleteCommentMetric(ctx context.Context, arg *DeleteCommentMetricParams) error {
|
||||||
|
_, err := q.db.Exec(ctx, deleteCommentMetric, arg.DeletedOn, arg.CommentID)
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
|
||||||
|
const deleteTweetMetric = `-- name: DeleteTweetMetric :exec
|
||||||
|
UPDATE p_post_metric SET is_del=1, deleted_on=$1 WHERE post_id=$2 AND is_del=0
|
||||||
|
`
|
||||||
|
|
||||||
|
type DeleteTweetMetricParams struct {
|
||||||
|
DeletedOn int64
|
||||||
|
PostID int64
|
||||||
|
}
|
||||||
|
|
||||||
|
func (q *Queries) DeleteTweetMetric(ctx context.Context, arg *DeleteTweetMetricParams) error {
|
||||||
|
_, err := q.db.Exec(ctx, deleteTweetMetric, arg.DeletedOn, arg.PostID)
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
|
||||||
|
const deleteUserMetric = `-- name: DeleteUserMetric :exec
|
||||||
|
UPDATE p_user_metric SET is_del=1, deleted_on=$1 WHERE user_id=$2 AND is_del=0
|
||||||
|
`
|
||||||
|
|
||||||
|
type DeleteUserMetricParams struct {
|
||||||
|
DeletedOn int64
|
||||||
|
UserID int64
|
||||||
|
}
|
||||||
|
|
||||||
|
func (q *Queries) DeleteUserMetric(ctx context.Context, arg *DeleteUserMetricParams) error {
|
||||||
|
_, err := q.db.Exec(ctx, deleteUserMetric, arg.DeletedOn, arg.UserID)
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
|
||||||
|
const getUserTweetsCount = `-- name: GetUserTweetsCount :one
|
||||||
|
SELECT tweets_count FROM p_user_metric WHERE user_id=$1 AND is_del=0
|
||||||
|
`
|
||||||
|
|
||||||
|
func (q *Queries) GetUserTweetsCount(ctx context.Context, userID int64) (int32, error) {
|
||||||
|
row := q.db.QueryRow(ctx, getUserTweetsCount, userID)
|
||||||
|
var tweets_count int32
|
||||||
|
err := row.Scan(&tweets_count)
|
||||||
|
return tweets_count, err
|
||||||
|
}
|
||||||
|
|
||||||
|
const tweetMotivationFactor = `-- name: TweetMotivationFactor :one
|
||||||
|
SELECT motivation_factor FROM p_post_metric WHERE post_id=$1 AND is_del=0
|
||||||
|
`
|
||||||
|
|
||||||
|
func (q *Queries) TweetMotivationFactor(ctx context.Context, postID int64) (int32, error) {
|
||||||
|
row := q.db.QueryRow(ctx, tweetMotivationFactor, postID)
|
||||||
|
var motivation_factor int32
|
||||||
|
err := row.Scan(&motivation_factor)
|
||||||
|
return motivation_factor, err
|
||||||
|
}
|
||||||
|
|
||||||
|
const updateCommentMetric = `-- name: UpdateCommentMetric :exec
|
||||||
|
|
||||||
|
UPDATE p_comment_metric SET rank_score=$1, modified_on=$2 WHERE comment_id=$3 AND is_del=0
|
||||||
|
`
|
||||||
|
|
||||||
|
type UpdateCommentMetricParams struct {
|
||||||
|
RankScore int64
|
||||||
|
ModifiedOn int64
|
||||||
|
CommentID int64
|
||||||
|
}
|
||||||
|
|
||||||
|
// ------------------------------------------------------------------------------
|
||||||
|
// comment_metrics sql dml
|
||||||
|
// ------------------------------------------------------------------------------
|
||||||
|
func (q *Queries) UpdateCommentMetric(ctx context.Context, arg *UpdateCommentMetricParams) error {
|
||||||
|
_, err := q.db.Exec(ctx, updateCommentMetric, arg.RankScore, arg.ModifiedOn, arg.CommentID)
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
|
||||||
|
const updateTweetMetric = `-- name: UpdateTweetMetric :exec
|
||||||
|
|
||||||
|
UPDATE p_post_metric SET rank_score=$1, modified_on=$2 WHERE post_id=$3 AND is_del=0
|
||||||
|
`
|
||||||
|
|
||||||
|
type UpdateTweetMetricParams struct {
|
||||||
|
RankScore int64
|
||||||
|
ModifiedOn int64
|
||||||
|
PostID int64
|
||||||
|
}
|
||||||
|
|
||||||
|
// ------------------------------------------------------------------------------
|
||||||
|
// tweet_metrics sql dml
|
||||||
|
// ------------------------------------------------------------------------------
|
||||||
|
func (q *Queries) UpdateTweetMetric(ctx context.Context, arg *UpdateTweetMetricParams) error {
|
||||||
|
_, err := q.db.Exec(ctx, updateTweetMetric, arg.RankScore, arg.ModifiedOn, arg.PostID)
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
|
||||||
|
const updateUserMetric = `-- name: UpdateUserMetric :exec
|
||||||
|
|
||||||
|
UPDATE p_user_metric SET tweets_count=$1, modified_on=$2 WHERE user_id=$3 AND is_del=0
|
||||||
|
`
|
||||||
|
|
||||||
|
type UpdateUserMetricParams struct {
|
||||||
|
TweetsCount int32
|
||||||
|
ModifiedOn int64
|
||||||
|
UserID int64
|
||||||
|
}
|
||||||
|
|
||||||
|
// ------------------------------------------------------------------------------
|
||||||
|
// user_metrics sql dml
|
||||||
|
// ------------------------------------------------------------------------------
|
||||||
|
func (q *Queries) UpdateUserMetric(ctx context.Context, arg *UpdateUserMetricParams) error {
|
||||||
|
_, err := q.db.Exec(ctx, updateUserMetric, arg.TweetsCount, arg.ModifiedOn, arg.UserID)
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
|
||||||
|
const upsertCommentMetric = `-- name: UpsertCommentMetric :exec
|
||||||
|
INSERT INTO p_comment_metric (comment_id, rank_score, created_on)
|
||||||
|
VALUES ($1, $2, $3)
|
||||||
|
RETURNING id
|
||||||
|
`
|
||||||
|
|
||||||
|
type UpsertCommentMetricParams struct {
|
||||||
|
CommentID int64
|
||||||
|
RankScore int64
|
||||||
|
CreatedOn int64
|
||||||
|
}
|
||||||
|
|
||||||
|
func (q *Queries) UpsertCommentMetric(ctx context.Context, arg *UpsertCommentMetricParams) error {
|
||||||
|
_, err := q.db.Exec(ctx, upsertCommentMetric, arg.CommentID, arg.RankScore, arg.CreatedOn)
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
|
||||||
|
const upsertTweetMetric = `-- name: UpsertTweetMetric :exec
|
||||||
|
INSERT INTO p_post_metric (post_id, rank_score, created_on) VALUES ($1, $2, $3)
|
||||||
|
`
|
||||||
|
|
||||||
|
type UpsertTweetMetricParams struct {
|
||||||
|
PostID int64
|
||||||
|
RankScore int64
|
||||||
|
CreatedOn int64
|
||||||
|
}
|
||||||
|
|
||||||
|
func (q *Queries) UpsertTweetMetric(ctx context.Context, arg *UpsertTweetMetricParams) error {
|
||||||
|
_, err := q.db.Exec(ctx, upsertTweetMetric, arg.PostID, arg.RankScore, arg.CreatedOn)
|
||||||
|
return err
|
||||||
|
}
|
@ -0,0 +1,76 @@
|
|||||||
|
// Code generated by sqlc. DO NOT EDIT.
|
||||||
|
// versions:
|
||||||
|
// sqlc v1.21.0
|
||||||
|
// source: trends.sql
|
||||||
|
|
||||||
|
package pgc
|
||||||
|
|
||||||
|
import (
|
||||||
|
"context"
|
||||||
|
)
|
||||||
|
|
||||||
|
const countIndexTrends = `-- name: CountIndexTrends :one
|
||||||
|
SELECT count(*)
|
||||||
|
FROM p_contact c
|
||||||
|
JOIN p_user u
|
||||||
|
ON c.friend_id=u.id
|
||||||
|
JOIN p_user_metric m
|
||||||
|
ON c.friend_id=m.user_id
|
||||||
|
WHERE c.user_id=$1 AND c.is_del=0 AND u.is_del=0 AND m.is_del=0 AND m.tweets_count>0
|
||||||
|
`
|
||||||
|
|
||||||
|
func (q *Queries) CountIndexTrends(ctx context.Context, userID int64) (int64, error) {
|
||||||
|
row := q.db.QueryRow(ctx, countIndexTrends, userID)
|
||||||
|
var count int64
|
||||||
|
err := row.Scan(&count)
|
||||||
|
return count, err
|
||||||
|
}
|
||||||
|
|
||||||
|
const getIndexTrends = `-- name: GetIndexTrends :many
|
||||||
|
|
||||||
|
SELECT u.username username,
|
||||||
|
u.nickname nickname,
|
||||||
|
u.avatar avatar
|
||||||
|
FROM p_contact c
|
||||||
|
JOIN p_user u
|
||||||
|
ON c.friend_id=u.id
|
||||||
|
JOIN p_user_metric m
|
||||||
|
ON c.friend_id=m.user_id
|
||||||
|
WHERE c.user_id=$1 AND c.is_del=0 AND u.is_del=0 AND m.is_del=0 AND m.tweets_count>0
|
||||||
|
LIMIT $2 OFFSET $3
|
||||||
|
`
|
||||||
|
|
||||||
|
type GetIndexTrendsParams struct {
|
||||||
|
UserID int64
|
||||||
|
Limit int32
|
||||||
|
Offset int32
|
||||||
|
}
|
||||||
|
|
||||||
|
type GetIndexTrendsRow struct {
|
||||||
|
Username string
|
||||||
|
Nickname string
|
||||||
|
Avatar string
|
||||||
|
}
|
||||||
|
|
||||||
|
// ------------------------------------------------------------------------------
|
||||||
|
// trends_manager sql dml
|
||||||
|
// ------------------------------------------------------------------------------
|
||||||
|
func (q *Queries) GetIndexTrends(ctx context.Context, arg *GetIndexTrendsParams) ([]*GetIndexTrendsRow, error) {
|
||||||
|
rows, err := q.db.Query(ctx, getIndexTrends, arg.UserID, arg.Limit, arg.Offset)
|
||||||
|
if err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
defer rows.Close()
|
||||||
|
var items []*GetIndexTrendsRow
|
||||||
|
for rows.Next() {
|
||||||
|
var i GetIndexTrendsRow
|
||||||
|
if err := rows.Scan(&i.Username, &i.Nickname, &i.Avatar); err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
items = append(items, &i)
|
||||||
|
}
|
||||||
|
if err := rows.Err(); err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
return items, nil
|
||||||
|
}
|
File diff suppressed because it is too large
Load Diff
@ -1,78 +0,0 @@
|
|||||||
// Code generated by sqlc. DO NOT EDIT.
|
|
||||||
// versions:
|
|
||||||
// sqlc v1.20.0
|
|
||||||
// source: authrity.sql
|
|
||||||
|
|
||||||
package dbr
|
|
||||||
|
|
||||||
import (
|
|
||||||
"context"
|
|
||||||
)
|
|
||||||
|
|
||||||
const beFriendIds = `-- name: BeFriendIds :many
|
|
||||||
|
|
||||||
SELECT user_id FROM p_contact WHERE friend_id=$1 AND status=2 AND is_del=0
|
|
||||||
`
|
|
||||||
|
|
||||||
// ------------------------------------------------------------------------------
|
|
||||||
// authorization_manage sql dml
|
|
||||||
// ------------------------------------------------------------------------------
|
|
||||||
func (q *Queries) BeFriendIds(ctx context.Context, friendID int64) ([]int64, error) {
|
|
||||||
rows, err := q.db.Query(ctx, beFriendIds, friendID)
|
|
||||||
if err != nil {
|
|
||||||
return nil, err
|
|
||||||
}
|
|
||||||
defer rows.Close()
|
|
||||||
var items []int64
|
|
||||||
for rows.Next() {
|
|
||||||
var user_id int64
|
|
||||||
if err := rows.Scan(&user_id); err != nil {
|
|
||||||
return nil, err
|
|
||||||
}
|
|
||||||
items = append(items, user_id)
|
|
||||||
}
|
|
||||||
if err := rows.Err(); err != nil {
|
|
||||||
return nil, err
|
|
||||||
}
|
|
||||||
return items, nil
|
|
||||||
}
|
|
||||||
|
|
||||||
const isFriend = `-- name: IsFriend :one
|
|
||||||
SELECT status FROM p_contact WHERE user_id=$1 AND friend_id=$2 AND is_del=0
|
|
||||||
`
|
|
||||||
|
|
||||||
type IsFriendParams struct {
|
|
||||||
UserID int64
|
|
||||||
FriendID int64
|
|
||||||
}
|
|
||||||
|
|
||||||
func (q *Queries) IsFriend(ctx context.Context, arg *IsFriendParams) (int16, error) {
|
|
||||||
row := q.db.QueryRow(ctx, isFriend, arg.UserID, arg.FriendID)
|
|
||||||
var status int16
|
|
||||||
err := row.Scan(&status)
|
|
||||||
return status, err
|
|
||||||
}
|
|
||||||
|
|
||||||
const myFriendSet = `-- name: MyFriendSet :many
|
|
||||||
SELECT friend_id FROM p_contact WHERE user_id=$1 AND status=2 AND is_del=0
|
|
||||||
`
|
|
||||||
|
|
||||||
func (q *Queries) MyFriendSet(ctx context.Context, userID int64) ([]int64, error) {
|
|
||||||
rows, err := q.db.Query(ctx, myFriendSet, userID)
|
|
||||||
if err != nil {
|
|
||||||
return nil, err
|
|
||||||
}
|
|
||||||
defer rows.Close()
|
|
||||||
var items []int64
|
|
||||||
for rows.Next() {
|
|
||||||
var friend_id int64
|
|
||||||
if err := rows.Scan(&friend_id); err != nil {
|
|
||||||
return nil, err
|
|
||||||
}
|
|
||||||
items = append(items, friend_id)
|
|
||||||
}
|
|
||||||
if err := rows.Err(); err != nil {
|
|
||||||
return nil, err
|
|
||||||
}
|
|
||||||
return items, nil
|
|
||||||
}
|
|
@ -1,116 +0,0 @@
|
|||||||
// Code generated by sqlc. DO NOT EDIT.
|
|
||||||
// versions:
|
|
||||||
// sqlc v1.20.0
|
|
||||||
// source: comments.sql
|
|
||||||
|
|
||||||
package dbr
|
|
||||||
|
|
||||||
import (
|
|
||||||
"context"
|
|
||||||
)
|
|
||||||
|
|
||||||
const deleteComment = `-- name: DeleteComment :exec
|
|
||||||
|
|
||||||
UPDATE p_comment SET deleted_on=$1, is_del=1 WHERE id=$2 AND is_del=0
|
|
||||||
`
|
|
||||||
|
|
||||||
type DeleteCommentParams struct {
|
|
||||||
DeletedOn int64
|
|
||||||
ID int64
|
|
||||||
}
|
|
||||||
|
|
||||||
// ------------------------------------------------------------------------------
|
|
||||||
// comment_manage sql dml
|
|
||||||
// ------------------------------------------------------------------------------
|
|
||||||
func (q *Queries) DeleteComment(ctx context.Context, arg *DeleteCommentParams) error {
|
|
||||||
_, err := q.db.Exec(ctx, deleteComment, arg.DeletedOn, arg.ID)
|
|
||||||
return err
|
|
||||||
}
|
|
||||||
|
|
||||||
const getDefaultComments = `-- name: GetDefaultComments :many
|
|
||||||
SELECT id, post_id, user_id, ip, ip_loc, created_on, modified_on, deleted_on, is_del, thumbs_up_count, thumbs_down_count FROM p_comment WHERE post_id=$1 AND is_del=0 ORDER BY id ASC LIMIT $2 OFFSET $3
|
|
||||||
`
|
|
||||||
|
|
||||||
type GetDefaultCommentsParams struct {
|
|
||||||
PostID int64
|
|
||||||
Limit int32
|
|
||||||
Offset int32
|
|
||||||
}
|
|
||||||
|
|
||||||
func (q *Queries) GetDefaultComments(ctx context.Context, arg *GetDefaultCommentsParams) ([]*PComment, error) {
|
|
||||||
rows, err := q.db.Query(ctx, getDefaultComments, arg.PostID, arg.Limit, arg.Offset)
|
|
||||||
if err != nil {
|
|
||||||
return nil, err
|
|
||||||
}
|
|
||||||
defer rows.Close()
|
|
||||||
var items []*PComment
|
|
||||||
for rows.Next() {
|
|
||||||
var i PComment
|
|
||||||
if err := rows.Scan(
|
|
||||||
&i.ID,
|
|
||||||
&i.PostID,
|
|
||||||
&i.UserID,
|
|
||||||
&i.Ip,
|
|
||||||
&i.IpLoc,
|
|
||||||
&i.CreatedOn,
|
|
||||||
&i.ModifiedOn,
|
|
||||||
&i.DeletedOn,
|
|
||||||
&i.IsDel,
|
|
||||||
&i.ThumbsUpCount,
|
|
||||||
&i.ThumbsDownCount,
|
|
||||||
); err != nil {
|
|
||||||
return nil, err
|
|
||||||
}
|
|
||||||
items = append(items, &i)
|
|
||||||
}
|
|
||||||
if err := rows.Err(); err != nil {
|
|
||||||
return nil, err
|
|
||||||
}
|
|
||||||
return items, nil
|
|
||||||
}
|
|
||||||
|
|
||||||
const getNewestComments = `-- name: GetNewestComments :many
|
|
||||||
|
|
||||||
SELECT id, post_id, user_id, ip, ip_loc, created_on, modified_on, deleted_on, is_del, thumbs_up_count, thumbs_down_count FROM p_comment WHERE post_id=$1 AND is_del=0 ORDER BY id DESC LIMIT $2 OFFSET $3
|
|
||||||
`
|
|
||||||
|
|
||||||
type GetNewestCommentsParams struct {
|
|
||||||
PostID int64
|
|
||||||
Limit int32
|
|
||||||
Offset int32
|
|
||||||
}
|
|
||||||
|
|
||||||
// ------------------------------------------------------------------------------
|
|
||||||
// comment sql dml
|
|
||||||
// ------------------------------------------------------------------------------
|
|
||||||
func (q *Queries) GetNewestComments(ctx context.Context, arg *GetNewestCommentsParams) ([]*PComment, error) {
|
|
||||||
rows, err := q.db.Query(ctx, getNewestComments, arg.PostID, arg.Limit, arg.Offset)
|
|
||||||
if err != nil {
|
|
||||||
return nil, err
|
|
||||||
}
|
|
||||||
defer rows.Close()
|
|
||||||
var items []*PComment
|
|
||||||
for rows.Next() {
|
|
||||||
var i PComment
|
|
||||||
if err := rows.Scan(
|
|
||||||
&i.ID,
|
|
||||||
&i.PostID,
|
|
||||||
&i.UserID,
|
|
||||||
&i.Ip,
|
|
||||||
&i.IpLoc,
|
|
||||||
&i.CreatedOn,
|
|
||||||
&i.ModifiedOn,
|
|
||||||
&i.DeletedOn,
|
|
||||||
&i.IsDel,
|
|
||||||
&i.ThumbsUpCount,
|
|
||||||
&i.ThumbsDownCount,
|
|
||||||
); err != nil {
|
|
||||||
return nil, err
|
|
||||||
}
|
|
||||||
items = append(items, &i)
|
|
||||||
}
|
|
||||||
if err := rows.Err(); err != nil {
|
|
||||||
return nil, err
|
|
||||||
}
|
|
||||||
return items, nil
|
|
||||||
}
|
|
@ -1,35 +0,0 @@
|
|||||||
// Code generated by sqlc. DO NOT EDIT.
|
|
||||||
// versions:
|
|
||||||
// sqlc v1.20.0
|
|
||||||
// source: contacts.sql
|
|
||||||
|
|
||||||
package dbr
|
|
||||||
|
|
||||||
import (
|
|
||||||
"context"
|
|
||||||
)
|
|
||||||
|
|
||||||
const createContact = `-- name: CreateContact :exec
|
|
||||||
|
|
||||||
INSERT INTO p_contact (user_id, friend_id, status, created_on) VALUES ($1, $2, $3, $4)
|
|
||||||
`
|
|
||||||
|
|
||||||
type CreateContactParams struct {
|
|
||||||
UserID int64
|
|
||||||
FriendID int64
|
|
||||||
Status int16
|
|
||||||
CreatedOn int64
|
|
||||||
}
|
|
||||||
|
|
||||||
// ------------------------------------------------------------------------------
|
|
||||||
// contact_manager sql dml
|
|
||||||
// ------------------------------------------------------------------------------
|
|
||||||
func (q *Queries) CreateContact(ctx context.Context, arg *CreateContactParams) error {
|
|
||||||
_, err := q.db.Exec(ctx, createContact,
|
|
||||||
arg.UserID,
|
|
||||||
arg.FriendID,
|
|
||||||
arg.Status,
|
|
||||||
arg.CreatedOn,
|
|
||||||
)
|
|
||||||
return err
|
|
||||||
}
|
|
@ -1,32 +0,0 @@
|
|||||||
// Code generated by sqlc. DO NOT EDIT.
|
|
||||||
// versions:
|
|
||||||
// sqlc v1.20.0
|
|
||||||
|
|
||||||
package dbr
|
|
||||||
|
|
||||||
import (
|
|
||||||
"context"
|
|
||||||
|
|
||||||
"github.com/jackc/pgx/v5"
|
|
||||||
"github.com/jackc/pgx/v5/pgconn"
|
|
||||||
)
|
|
||||||
|
|
||||||
type DBTX interface {
|
|
||||||
Exec(context.Context, string, ...interface{}) (pgconn.CommandTag, error)
|
|
||||||
Query(context.Context, string, ...interface{}) (pgx.Rows, error)
|
|
||||||
QueryRow(context.Context, string, ...interface{}) pgx.Row
|
|
||||||
}
|
|
||||||
|
|
||||||
func New(db DBTX) *Queries {
|
|
||||||
return &Queries{db: db}
|
|
||||||
}
|
|
||||||
|
|
||||||
type Queries struct {
|
|
||||||
db DBTX
|
|
||||||
}
|
|
||||||
|
|
||||||
func (q *Queries) WithTx(tx pgx.Tx) *Queries {
|
|
||||||
return &Queries{
|
|
||||||
db: tx,
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,29 +0,0 @@
|
|||||||
// Code generated by sqlc. DO NOT EDIT.
|
|
||||||
// versions:
|
|
||||||
// sqlc v1.20.0
|
|
||||||
// source: following.sql
|
|
||||||
|
|
||||||
package dbr
|
|
||||||
|
|
||||||
import (
|
|
||||||
"context"
|
|
||||||
)
|
|
||||||
|
|
||||||
const createFollowing = `-- name: CreateFollowing :exec
|
|
||||||
|
|
||||||
INSERT INTO p_following (user_id, follow_id, created_on) VALUES ($1, $2, $3)
|
|
||||||
`
|
|
||||||
|
|
||||||
type CreateFollowingParams struct {
|
|
||||||
UserID int64
|
|
||||||
FollowID int64
|
|
||||||
CreatedOn int64
|
|
||||||
}
|
|
||||||
|
|
||||||
// ------------------------------------------------------------------------------
|
|
||||||
// following_manager sql dml
|
|
||||||
// ------------------------------------------------------------------------------
|
|
||||||
func (q *Queries) CreateFollowing(ctx context.Context, arg *CreateFollowingParams) error {
|
|
||||||
_, err := q.db.Exec(ctx, createFollowing, arg.UserID, arg.FollowID, arg.CreatedOn)
|
|
||||||
return err
|
|
||||||
}
|
|
@ -1,25 +0,0 @@
|
|||||||
// Code generated by sqlc. DO NOT EDIT.
|
|
||||||
// versions:
|
|
||||||
// sqlc v1.20.0
|
|
||||||
// source: messages.sql
|
|
||||||
|
|
||||||
package dbr
|
|
||||||
|
|
||||||
import (
|
|
||||||
"context"
|
|
||||||
)
|
|
||||||
|
|
||||||
const getUnreadCount = `-- name: GetUnreadCount :one
|
|
||||||
|
|
||||||
SELECT count(*) FROM p_message WHERE receiver_user_id=$1 AND is_read=0 AND is_del=0
|
|
||||||
`
|
|
||||||
|
|
||||||
// ------------------------------------------------------------------------------
|
|
||||||
// message sql dml
|
|
||||||
// ------------------------------------------------------------------------------
|
|
||||||
func (q *Queries) GetUnreadCount(ctx context.Context, receiverUserID int64) (int64, error) {
|
|
||||||
row := q.db.QueryRow(ctx, getUnreadCount, receiverUserID)
|
|
||||||
var count int64
|
|
||||||
err := row.Scan(&count)
|
|
||||||
return count, err
|
|
||||||
}
|
|
@ -1,326 +0,0 @@
|
|||||||
// Code generated by sqlc. DO NOT EDIT.
|
|
||||||
// versions:
|
|
||||||
// sqlc v1.20.0
|
|
||||||
|
|
||||||
package dbr
|
|
||||||
|
|
||||||
import (
|
|
||||||
"github.com/jackc/pgx/v5/pgtype"
|
|
||||||
)
|
|
||||||
|
|
||||||
type PAttachment struct {
|
|
||||||
ID int64
|
|
||||||
UserID int64
|
|
||||||
FileSize int64
|
|
||||||
ImgWidth int64
|
|
||||||
ImgHeight int64
|
|
||||||
Type int16
|
|
||||||
Content string
|
|
||||||
CreatedOn int64
|
|
||||||
ModifiedOn int64
|
|
||||||
DeletedOn int64
|
|
||||||
IsDel int16
|
|
||||||
}
|
|
||||||
|
|
||||||
type PCaptcha struct {
|
|
||||||
ID int64
|
|
||||||
Phone pgtype.Text
|
|
||||||
Captcha pgtype.Text
|
|
||||||
UseTimes int32
|
|
||||||
ExpiredOn int64
|
|
||||||
CreatedOn int64
|
|
||||||
ModifiedOn int64
|
|
||||||
DeletedOn int64
|
|
||||||
IsDel int16
|
|
||||||
}
|
|
||||||
|
|
||||||
type PComment struct {
|
|
||||||
ID int64
|
|
||||||
PostID int64
|
|
||||||
UserID int64
|
|
||||||
Ip string
|
|
||||||
IpLoc string
|
|
||||||
CreatedOn int64
|
|
||||||
ModifiedOn int64
|
|
||||||
DeletedOn int64
|
|
||||||
IsDel int16
|
|
||||||
ThumbsUpCount int32
|
|
||||||
ThumbsDownCount int32
|
|
||||||
}
|
|
||||||
|
|
||||||
type PCommentContent struct {
|
|
||||||
ID int64
|
|
||||||
CommentID int64
|
|
||||||
UserID int64
|
|
||||||
Content string
|
|
||||||
Type int16
|
|
||||||
Sort int64
|
|
||||||
CreatedOn int64
|
|
||||||
ModifiedOn int64
|
|
||||||
DeletedOn int64
|
|
||||||
IsDel int16
|
|
||||||
}
|
|
||||||
|
|
||||||
type PCommentReply struct {
|
|
||||||
ID int64
|
|
||||||
CommentID int64
|
|
||||||
UserID int64
|
|
||||||
AtUserID int64
|
|
||||||
Content string
|
|
||||||
Ip string
|
|
||||||
IpLoc string
|
|
||||||
CreatedOn int64
|
|
||||||
ModifiedOn int64
|
|
||||||
DeletedOn int64
|
|
||||||
IsDel int16
|
|
||||||
ThumbsUpCount int32
|
|
||||||
ThumbsDownCount int32
|
|
||||||
}
|
|
||||||
|
|
||||||
type PContact struct {
|
|
||||||
ID int64
|
|
||||||
UserID int64
|
|
||||||
FriendID int64
|
|
||||||
GroupID int64
|
|
||||||
Remark string
|
|
||||||
Status int16
|
|
||||||
IsTop int16
|
|
||||||
IsBlack int16
|
|
||||||
IsDel int16
|
|
||||||
NoticeEnable int16
|
|
||||||
CreatedOn int64
|
|
||||||
ModifiedOn int64
|
|
||||||
DeletedOn int64
|
|
||||||
}
|
|
||||||
|
|
||||||
type PContactGroup struct {
|
|
||||||
ID int64
|
|
||||||
UserID int32
|
|
||||||
Name string
|
|
||||||
IsDel int16
|
|
||||||
CreatedOn int64
|
|
||||||
ModifiedOn int64
|
|
||||||
DeletedOn int64
|
|
||||||
}
|
|
||||||
|
|
||||||
type PFollowing struct {
|
|
||||||
ID int64
|
|
||||||
UserID int64
|
|
||||||
FollowID int64
|
|
||||||
IsDel int16
|
|
||||||
CreatedOn int64
|
|
||||||
ModifiedOn int64
|
|
||||||
DeletedOn int64
|
|
||||||
}
|
|
||||||
|
|
||||||
type PMessage struct {
|
|
||||||
ID int64
|
|
||||||
SenderUserID int64
|
|
||||||
ReceiverUserID int64
|
|
||||||
Type int16
|
|
||||||
Brief string
|
|
||||||
Content string
|
|
||||||
PostID int64
|
|
||||||
CommentID int64
|
|
||||||
ReplyID int64
|
|
||||||
IsRead int16
|
|
||||||
CreatedOn int64
|
|
||||||
ModifiedOn int64
|
|
||||||
DeletedOn int64
|
|
||||||
IsDel int16
|
|
||||||
}
|
|
||||||
|
|
||||||
type PPost struct {
|
|
||||||
ID int64
|
|
||||||
UserID int64
|
|
||||||
CommentCount int64
|
|
||||||
CollectionCount int64
|
|
||||||
UpvoteCount int64
|
|
||||||
IsTop int16
|
|
||||||
IsEssence int16
|
|
||||||
IsLock int16
|
|
||||||
LatestRepliedOn int64
|
|
||||||
Tags string
|
|
||||||
AttachmentPrice int64
|
|
||||||
Ip string
|
|
||||||
IpLoc string
|
|
||||||
CreatedOn int64
|
|
||||||
ModifiedOn int64
|
|
||||||
DeletedOn int64
|
|
||||||
IsDel int16
|
|
||||||
Visibility int16
|
|
||||||
ShareCount int64
|
|
||||||
}
|
|
||||||
|
|
||||||
type PPostAttachmentBill struct {
|
|
||||||
ID int64
|
|
||||||
PostID int64
|
|
||||||
UserID int64
|
|
||||||
PaidAmount int64
|
|
||||||
CreatedOn int64
|
|
||||||
ModifiedOn int64
|
|
||||||
DeletedOn int64
|
|
||||||
IsDel int16
|
|
||||||
}
|
|
||||||
|
|
||||||
type PPostByComment struct {
|
|
||||||
ID int64
|
|
||||||
UserID int64
|
|
||||||
CommentCount int64
|
|
||||||
CollectionCount int64
|
|
||||||
UpvoteCount int64
|
|
||||||
IsTop int16
|
|
||||||
IsEssence int16
|
|
||||||
IsLock int16
|
|
||||||
LatestRepliedOn int64
|
|
||||||
Tags string
|
|
||||||
AttachmentPrice int64
|
|
||||||
Ip string
|
|
||||||
IpLoc string
|
|
||||||
CreatedOn int64
|
|
||||||
ModifiedOn int64
|
|
||||||
DeletedOn int64
|
|
||||||
IsDel int16
|
|
||||||
Visibility int16
|
|
||||||
ShareCount int64
|
|
||||||
CommentUserID int64
|
|
||||||
}
|
|
||||||
|
|
||||||
type PPostByMedium struct {
|
|
||||||
ID int64
|
|
||||||
UserID int64
|
|
||||||
CommentCount int64
|
|
||||||
CollectionCount int64
|
|
||||||
UpvoteCount int64
|
|
||||||
IsTop int16
|
|
||||||
IsEssence int16
|
|
||||||
IsLock int16
|
|
||||||
LatestRepliedOn int64
|
|
||||||
Tags string
|
|
||||||
AttachmentPrice int64
|
|
||||||
Ip string
|
|
||||||
IpLoc string
|
|
||||||
CreatedOn int64
|
|
||||||
ModifiedOn int64
|
|
||||||
DeletedOn int64
|
|
||||||
IsDel int16
|
|
||||||
Visibility int16
|
|
||||||
ShareCount int64
|
|
||||||
}
|
|
||||||
|
|
||||||
type PPostCollection struct {
|
|
||||||
ID int64
|
|
||||||
PostID int64
|
|
||||||
UserID int64
|
|
||||||
CreatedOn int64
|
|
||||||
ModifiedOn int64
|
|
||||||
DeletedOn int64
|
|
||||||
IsDel int16
|
|
||||||
}
|
|
||||||
|
|
||||||
type PPostContent struct {
|
|
||||||
ID int64
|
|
||||||
PostID int64
|
|
||||||
UserID int64
|
|
||||||
Content string
|
|
||||||
Type int16
|
|
||||||
Sort int16
|
|
||||||
CreatedOn int64
|
|
||||||
ModifiedOn int64
|
|
||||||
DeletedOn int64
|
|
||||||
IsDel int16
|
|
||||||
}
|
|
||||||
|
|
||||||
type PPostStar struct {
|
|
||||||
ID int64
|
|
||||||
PostID int64
|
|
||||||
UserID int64
|
|
||||||
CreatedOn int64
|
|
||||||
ModifiedOn int64
|
|
||||||
DeletedOn int64
|
|
||||||
IsDel int16
|
|
||||||
}
|
|
||||||
|
|
||||||
type PTag struct {
|
|
||||||
ID int64
|
|
||||||
UserID int64
|
|
||||||
Tag string
|
|
||||||
QuoteNum int64
|
|
||||||
CreatedOn int64
|
|
||||||
ModifiedOn int64
|
|
||||||
DeletedOn int64
|
|
||||||
IsDel int16
|
|
||||||
}
|
|
||||||
|
|
||||||
type PTopicUser struct {
|
|
||||||
ID int64
|
|
||||||
TopicID int64
|
|
||||||
UserID int64
|
|
||||||
AliasName pgtype.Text
|
|
||||||
Remark pgtype.Text
|
|
||||||
QuoteNum pgtype.Int8
|
|
||||||
IsTop int16
|
|
||||||
CreatedOn int64
|
|
||||||
ModifiedOn int64
|
|
||||||
DeletedOn int64
|
|
||||||
IsDel int16
|
|
||||||
ReserveA pgtype.Text
|
|
||||||
ReserveB pgtype.Text
|
|
||||||
}
|
|
||||||
|
|
||||||
type PTweetCommentThumb struct {
|
|
||||||
ID int64
|
|
||||||
UserID int64
|
|
||||||
TweetID int64
|
|
||||||
CommentID int64
|
|
||||||
ReplyID pgtype.Int8
|
|
||||||
CommentType int16
|
|
||||||
IsThumbsUp int16
|
|
||||||
IsThumbsDown int16
|
|
||||||
CreatedOn int64
|
|
||||||
ModifiedOn int64
|
|
||||||
DeletedOn int64
|
|
||||||
IsDel int16
|
|
||||||
}
|
|
||||||
|
|
||||||
type PUser struct {
|
|
||||||
ID int64
|
|
||||||
Nickname string
|
|
||||||
Username string
|
|
||||||
Phone string
|
|
||||||
Password string
|
|
||||||
Salt string
|
|
||||||
Status int16
|
|
||||||
Avatar string
|
|
||||||
Balance int64
|
|
||||||
IsAdmin bool
|
|
||||||
CreatedOn int64
|
|
||||||
ModifiedOn int64
|
|
||||||
DeletedOn int64
|
|
||||||
IsDel int16
|
|
||||||
}
|
|
||||||
|
|
||||||
type PWalletRecharge struct {
|
|
||||||
ID int64
|
|
||||||
UserID int64
|
|
||||||
Amount int64
|
|
||||||
TradeNo string
|
|
||||||
TradeStatus string
|
|
||||||
CreatedOn int64
|
|
||||||
ModifiedOn int64
|
|
||||||
DeletedOn int64
|
|
||||||
IsDel int16
|
|
||||||
}
|
|
||||||
|
|
||||||
type PWalletStatement struct {
|
|
||||||
ID int64
|
|
||||||
UserID int64
|
|
||||||
ChangeAmount int64
|
|
||||||
BalanceSnapshot int64
|
|
||||||
Reason string
|
|
||||||
PostID int64
|
|
||||||
CreatedOn int64
|
|
||||||
ModifiedOn int64
|
|
||||||
DeletedOn int64
|
|
||||||
IsDel int16
|
|
||||||
}
|
|
@ -1,70 +0,0 @@
|
|||||||
// Code generated by sqlc. DO NOT EDIT.
|
|
||||||
// versions:
|
|
||||||
// sqlc v1.20.0
|
|
||||||
|
|
||||||
package dbr
|
|
||||||
|
|
||||||
import (
|
|
||||||
"context"
|
|
||||||
|
|
||||||
"github.com/jackc/pgx/v5/pgtype"
|
|
||||||
)
|
|
||||||
|
|
||||||
type Querier interface {
|
|
||||||
//------------------------------------------------------------------------------
|
|
||||||
// authorization_manage sql dml
|
|
||||||
//------------------------------------------------------------------------------
|
|
||||||
BeFriendIds(ctx context.Context, friendID int64) ([]int64, error)
|
|
||||||
//------------------------------------------------------------------------------
|
|
||||||
// contact_manager sql dml
|
|
||||||
//------------------------------------------------------------------------------
|
|
||||||
CreateContact(ctx context.Context, arg *CreateContactParams) error
|
|
||||||
//------------------------------------------------------------------------------
|
|
||||||
// following_manager sql dml
|
|
||||||
//------------------------------------------------------------------------------
|
|
||||||
CreateFollowing(ctx context.Context, arg *CreateFollowingParams) error
|
|
||||||
DecrTagsById(ctx context.Context, arg *DecrTagsByIdParams) error
|
|
||||||
//------------------------------------------------------------------------------
|
|
||||||
// comment_manage sql dml
|
|
||||||
//------------------------------------------------------------------------------
|
|
||||||
DeleteComment(ctx context.Context, arg *DeleteCommentParams) error
|
|
||||||
GetDefaultComments(ctx context.Context, arg *GetDefaultCommentsParams) ([]*PComment, error)
|
|
||||||
//------------------------------------------------------------------------------
|
|
||||||
// security sql dml
|
|
||||||
//------------------------------------------------------------------------------
|
|
||||||
GetLatestPhoneCaptcha(ctx context.Context, phone pgtype.Text) (*PCaptcha, error)
|
|
||||||
//------------------------------------------------------------------------------
|
|
||||||
// comment sql dml
|
|
||||||
//------------------------------------------------------------------------------
|
|
||||||
GetNewestComments(ctx context.Context, arg *GetNewestCommentsParams) ([]*PComment, error)
|
|
||||||
//------------------------------------------------------------------------------
|
|
||||||
// tweet sql dml
|
|
||||||
//------------------------------------------------------------------------------
|
|
||||||
GetPostById(ctx context.Context, id int64) (*PPost, error)
|
|
||||||
//------------------------------------------------------------------------------
|
|
||||||
// message sql dml
|
|
||||||
//------------------------------------------------------------------------------
|
|
||||||
GetUnreadCount(ctx context.Context, receiverUserID int64) (int64, error)
|
|
||||||
//------------------------------------------------------------------------------
|
|
||||||
// user_manage sql dml
|
|
||||||
//------------------------------------------------------------------------------
|
|
||||||
GetUserById(ctx context.Context, id int64) (*PUser, error)
|
|
||||||
//------------------------------------------------------------------------------
|
|
||||||
// wallet sql dml
|
|
||||||
//------------------------------------------------------------------------------
|
|
||||||
GetUserWalletBills(ctx context.Context, arg *GetUserWalletBillsParams) (*PWalletStatement, error)
|
|
||||||
HotTags(ctx context.Context, arg *HotTagsParams) ([]*HotTagsRow, error)
|
|
||||||
IncrTags(ctx context.Context, arg *IncrTagsParams) ([]*IncrTagsRow, error)
|
|
||||||
//------------------------------------------------------------------------------
|
|
||||||
// ship_index sql dml
|
|
||||||
//------------------------------------------------------------------------------
|
|
||||||
IndexByAdmin(ctx context.Context, arg *IndexByAdminParams) ([]*PPost, error)
|
|
||||||
InsertTags(ctx context.Context, arg *InsertTagsParams) (int64, error)
|
|
||||||
IsFriend(ctx context.Context, arg *IsFriendParams) (int16, error)
|
|
||||||
MyFriendSet(ctx context.Context, userID int64) ([]int64, error)
|
|
||||||
NewestTags(ctx context.Context, arg *NewestTagsParams) ([]*NewestTagsRow, error)
|
|
||||||
TagsByKeywordA(ctx context.Context) ([]*TagsByKeywordARow, error)
|
|
||||||
TagsByKeywordB(ctx context.Context, tag string) ([]*TagsByKeywordBRow, error)
|
|
||||||
}
|
|
||||||
|
|
||||||
var _ Querier = (*Queries)(nil)
|
|
@ -0,0 +1,59 @@
|
|||||||
|
--------------------------------------------------------------------------------
|
||||||
|
-- tweet_metrics sql dml
|
||||||
|
--------------------------------------------------------------------------------
|
||||||
|
|
||||||
|
-- name: UpdateTweetMetric :exec
|
||||||
|
UPDATE p_post_metric SET rank_score=$1, modified_on=$2 WHERE post_id=$3 AND is_del=0;
|
||||||
|
|
||||||
|
-- name: TweetMotivationFactor :one
|
||||||
|
SELECT motivation_factor FROM p_post_metric WHERE post_id=$1 AND is_del=0;
|
||||||
|
|
||||||
|
-- name: AddTweetMetric :one
|
||||||
|
INSERT INTO p_post_metric (post_id, created_on)
|
||||||
|
VALUES ($1, $2)
|
||||||
|
RETURNING id;
|
||||||
|
|
||||||
|
-- name: UpsertTweetMetric :exec
|
||||||
|
INSERT INTO p_post_metric (post_id, rank_score, created_on) VALUES ($1, $2, $3);
|
||||||
|
|
||||||
|
-- name: DeleteTweetMetric :exec
|
||||||
|
UPDATE p_post_metric SET is_del=1, deleted_on=$1 WHERE post_id=$2 AND is_del=0;
|
||||||
|
|
||||||
|
--------------------------------------------------------------------------------
|
||||||
|
-- comment_metrics sql dml
|
||||||
|
--------------------------------------------------------------------------------
|
||||||
|
|
||||||
|
-- name: UpdateCommentMetric :exec
|
||||||
|
UPDATE p_comment_metric SET rank_score=$1, modified_on=$2 WHERE comment_id=$3 AND is_del=0;
|
||||||
|
|
||||||
|
-- name: CommentMotivationFactor :one
|
||||||
|
SELECT motivation_factor FROM p_comment_metric WHERE comment_id=$1 AND is_del=0;
|
||||||
|
|
||||||
|
-- name: AddCommentMetric :one
|
||||||
|
INSERT INTO p_comment_metric (comment_id, created_on)
|
||||||
|
VALUES ($1, $2)
|
||||||
|
RETURNING id;
|
||||||
|
|
||||||
|
-- name: UpsertCommentMetric :exec
|
||||||
|
INSERT INTO p_comment_metric (comment_id, rank_score, created_on)
|
||||||
|
VALUES ($1, $2, $3)
|
||||||
|
RETURNING id;
|
||||||
|
|
||||||
|
-- name: DeleteCommentMetric :exec
|
||||||
|
UPDATE p_comment_metric SET is_del=1, deleted_on=$1 WHERE comment_id=$2 AND is_del=0;
|
||||||
|
|
||||||
|
--------------------------------------------------------------------------------
|
||||||
|
-- user_metrics sql dml
|
||||||
|
--------------------------------------------------------------------------------
|
||||||
|
|
||||||
|
-- name: UpdateUserMetric :exec
|
||||||
|
UPDATE p_user_metric SET tweets_count=$1, modified_on=$2 WHERE user_id=$3 AND is_del=0;
|
||||||
|
|
||||||
|
-- name: GetUserTweetsCount :one
|
||||||
|
SELECT tweets_count FROM p_user_metric WHERE user_id=$1 AND is_del=0;
|
||||||
|
|
||||||
|
-- name: AddUserMetric :one
|
||||||
|
INSERT INTO p_user_metric (user_id, created_on) VALUES ($1, $2) RETURNING id;
|
||||||
|
|
||||||
|
-- name: DeleteUserMetric :exec
|
||||||
|
UPDATE p_user_metric SET is_del=1, deleted_on=$1 WHERE user_id=$2 AND is_del=0;
|
@ -0,0 +1,24 @@
|
|||||||
|
--------------------------------------------------------------------------------
|
||||||
|
-- trends_manager sql dml
|
||||||
|
--------------------------------------------------------------------------------
|
||||||
|
|
||||||
|
-- name: GetIndexTrends :many
|
||||||
|
SELECT u.username username,
|
||||||
|
u.nickname nickname,
|
||||||
|
u.avatar avatar
|
||||||
|
FROM p_contact c
|
||||||
|
JOIN p_user u
|
||||||
|
ON c.friend_id=u.id
|
||||||
|
JOIN p_user_metric m
|
||||||
|
ON c.friend_id=m.user_id
|
||||||
|
WHERE c.user_id=$1 AND c.is_del=0 AND u.is_del=0 AND m.is_del=0 AND m.tweets_count>0
|
||||||
|
LIMIT $2 OFFSET $3;
|
||||||
|
|
||||||
|
-- name: CountIndexTrends :one
|
||||||
|
SELECT count(*)
|
||||||
|
FROM p_contact c
|
||||||
|
JOIN p_user u
|
||||||
|
ON c.friend_id=u.id
|
||||||
|
JOIN p_user_metric m
|
||||||
|
ON c.friend_id=m.user_id
|
||||||
|
WHERE c.user_id=$1 AND c.is_del=0 AND u.is_del=0 AND m.is_del=0 AND m.tweets_count>0;
|
@ -0,0 +1,19 @@
|
|||||||
|
DROP TABLE IF EXISTS p_post_metric;
|
||||||
|
|
||||||
|
-- 原来的可见性: 0公开 1私密 2好友可见 3关注可见
|
||||||
|
-- 现在的可见性: 0私密 10充电可见 20订阅可见 30保留 40保留 50好友可见 60关注可见 70保留 80保留 90公开
|
||||||
|
UPDATE p_post a
|
||||||
|
SET visibility = (
|
||||||
|
SELECT
|
||||||
|
CASE visibility
|
||||||
|
WHEN 90 THEN 0
|
||||||
|
WHEN 0 THEN 1
|
||||||
|
WHEN 50 THEN 2
|
||||||
|
WHEN 60 THEN 3
|
||||||
|
ELSE 0
|
||||||
|
END
|
||||||
|
FROM
|
||||||
|
p_post b
|
||||||
|
WHERE
|
||||||
|
a.ID = b.ID
|
||||||
|
);
|
@ -0,0 +1,40 @@
|
|||||||
|
CREATE TABLE p_post_metric (
|
||||||
|
ID BIGSERIAL PRIMARY KEY,
|
||||||
|
post_id BIGINT NOT NULL,
|
||||||
|
rank_score BIGINT NOT NULL DEFAULT 0,
|
||||||
|
incentive_score INT NOT NULL DEFAULT 0,
|
||||||
|
decay_factor INT NOT NULL DEFAULT 0,
|
||||||
|
motivation_factor INT NOT NULL DEFAULT 0,
|
||||||
|
is_del SMALLINT NOT NULL DEFAULT 0,
|
||||||
|
created_on BIGINT NOT NULL DEFAULT 0,
|
||||||
|
modified_on BIGINT NOT NULL DEFAULT 0,
|
||||||
|
deleted_on BIGINT NOT NULL DEFAULT 0
|
||||||
|
);
|
||||||
|
CREATE INDEX idx_post_metric_post_id_rank_score ON p_post_metric USING btree ( post_id, rank_score );
|
||||||
|
|
||||||
|
INSERT INTO p_post_metric ( post_id, rank_score, created_on ) SELECT ID AS
|
||||||
|
post_id,
|
||||||
|
comment_count + upvote_count * 2 + collection_count * 4 AS rank_score,
|
||||||
|
created_on
|
||||||
|
FROM
|
||||||
|
p_post
|
||||||
|
WHERE
|
||||||
|
is_del = 0;
|
||||||
|
|
||||||
|
-- 原来的可见性: 0公开 1私密 2好友可见 3关注可见
|
||||||
|
-- 现在的可见性: 0私密 10充电可见 20订阅可见 30保留 40保留 50好友可见 60关注可见 70保留 80保留 90公开
|
||||||
|
UPDATE p_post a
|
||||||
|
SET visibility = (
|
||||||
|
SELECT
|
||||||
|
CASE visibility
|
||||||
|
WHEN 0 THEN 90
|
||||||
|
WHEN 1 THEN 0
|
||||||
|
WHEN 2 THEN 50
|
||||||
|
WHEN 3 THEN 60
|
||||||
|
ELSE 0
|
||||||
|
END
|
||||||
|
FROM
|
||||||
|
p_post b
|
||||||
|
WHERE
|
||||||
|
a.ID = b.ID
|
||||||
|
);
|
@ -0,0 +1 @@
|
|||||||
|
ALTER TABLE p_comment DROP COLUMN is_essence;
|
@ -0,0 +1 @@
|
|||||||
|
ALTER TABLE p_comment ADD COLUMN is_essence SMALLINT NOT NULL DEFAULT 0;
|
@ -0,0 +1,3 @@
|
|||||||
|
ALTER TABLE p_comment DROP COLUMN IF EXISTS reply_count;
|
||||||
|
DROP TABLE IF EXISTS p_comment_metric;
|
||||||
|
DROP TABLE IF EXISTS p_user_metric;
|
@ -0,0 +1,51 @@
|
|||||||
|
ALTER TABLE p_comment ADD COLUMN reply_count INT NOT NULL DEFAULT 0;
|
||||||
|
|
||||||
|
WITH comment_reply AS (
|
||||||
|
SELECT comment_id, count(*) AS count
|
||||||
|
FROM p_comment_reply
|
||||||
|
WHERE is_del=0
|
||||||
|
GROUP By comment_id
|
||||||
|
)
|
||||||
|
UPDATE p_comment comment
|
||||||
|
SET reply_count = reply.count
|
||||||
|
FROM comment_reply reply
|
||||||
|
WHERE comment.id = reply.comment_id;
|
||||||
|
|
||||||
|
CREATE TABLE p_comment_metric (
|
||||||
|
id BIGSERIAL PRIMARY KEY,
|
||||||
|
comment_id BIGINT NOT NULL,
|
||||||
|
rank_score BIGINT NOT NULL DEFAULT 0,
|
||||||
|
incentive_score INT NOT NULL DEFAULT 0,
|
||||||
|
decay_factor INT NOT NULL DEFAULT 0,
|
||||||
|
motivation_factor INT NOT NULL DEFAULT 0,
|
||||||
|
is_del SMALLINT NOT NULL DEFAULT 0,
|
||||||
|
created_on BIGINT NOT NULL DEFAULT 0,
|
||||||
|
modified_on BIGINT NOT NULL DEFAULT 0,
|
||||||
|
deleted_on BIGINT NOT NULL DEFAULT 0
|
||||||
|
);
|
||||||
|
CREATE INDEX idx_comment_metric_comment_id_rank_score ON p_comment_metric USING btree (comment_id, rank_score);
|
||||||
|
|
||||||
|
INSERT INTO p_comment_metric (comment_id, rank_score, created_on)
|
||||||
|
SELECT id AS comment_id,
|
||||||
|
reply_count*2 + thumbs_up_count*4 - thumbs_down_count AS rank_score,
|
||||||
|
created_on
|
||||||
|
FROM p_comment
|
||||||
|
WHERE is_del=0;
|
||||||
|
|
||||||
|
CREATE TABLE p_user_metric (
|
||||||
|
id BIGSERIAL PRIMARY KEY,
|
||||||
|
user_id BIGINT NOT NULL,
|
||||||
|
tweets_count INT NOT NULL DEFAULT 0,
|
||||||
|
latest_trends_on BIGINT NOT NULL DEFAULT 0,
|
||||||
|
is_del SMALLINT NOT NULL DEFAULT 0,
|
||||||
|
created_on BIGINT NOT NULL DEFAULT 0,
|
||||||
|
modified_on BIGINT NOT NULL DEFAULT 0,
|
||||||
|
deleted_on BIGINT NOT NULL DEFAULT 0
|
||||||
|
);
|
||||||
|
CREATE INDEX idx_user_metric_user_id_tweets_count_trends ON p_user_metric USING btree (user_id, tweets_count, latest_trends_on);
|
||||||
|
|
||||||
|
INSERT INTO p_user_metric (user_id, tweets_count)
|
||||||
|
SELECT user_id, count(*) AS tweets_count
|
||||||
|
FROM p_post
|
||||||
|
WHERE is_del=0
|
||||||
|
GROUP BY user_id;
|
@ -1,37 +0,0 @@
|
|||||||
// Code generated by sqlc. DO NOT EDIT.
|
|
||||||
// versions:
|
|
||||||
// sqlc v1.20.0
|
|
||||||
// source: security.sql
|
|
||||||
|
|
||||||
package dbr
|
|
||||||
|
|
||||||
import (
|
|
||||||
"context"
|
|
||||||
|
|
||||||
"github.com/jackc/pgx/v5/pgtype"
|
|
||||||
)
|
|
||||||
|
|
||||||
const getLatestPhoneCaptcha = `-- name: GetLatestPhoneCaptcha :one
|
|
||||||
|
|
||||||
SELECT id, phone, captcha, use_times, expired_on, created_on, modified_on, deleted_on, is_del FROM p_captcha WHERE phone=$1 AND is_del=0
|
|
||||||
`
|
|
||||||
|
|
||||||
// ------------------------------------------------------------------------------
|
|
||||||
// security sql dml
|
|
||||||
// ------------------------------------------------------------------------------
|
|
||||||
func (q *Queries) GetLatestPhoneCaptcha(ctx context.Context, phone pgtype.Text) (*PCaptcha, error) {
|
|
||||||
row := q.db.QueryRow(ctx, getLatestPhoneCaptcha, phone)
|
|
||||||
var i PCaptcha
|
|
||||||
err := row.Scan(
|
|
||||||
&i.ID,
|
|
||||||
&i.Phone,
|
|
||||||
&i.Captcha,
|
|
||||||
&i.UseTimes,
|
|
||||||
&i.ExpiredOn,
|
|
||||||
&i.CreatedOn,
|
|
||||||
&i.ModifiedOn,
|
|
||||||
&i.DeletedOn,
|
|
||||||
&i.IsDel,
|
|
||||||
)
|
|
||||||
return &i, err
|
|
||||||
}
|
|
@ -1,67 +0,0 @@
|
|||||||
// Code generated by sqlc. DO NOT EDIT.
|
|
||||||
// versions:
|
|
||||||
// sqlc v1.20.0
|
|
||||||
// source: timeline.sql
|
|
||||||
|
|
||||||
package dbr
|
|
||||||
|
|
||||||
import (
|
|
||||||
"context"
|
|
||||||
)
|
|
||||||
|
|
||||||
const indexByAdmin = `-- name: IndexByAdmin :many
|
|
||||||
|
|
||||||
SELECT id, user_id, comment_count, collection_count, upvote_count, is_top, is_essence, is_lock, latest_replied_on, tags, attachment_price, ip, ip_loc, created_on, modified_on, deleted_on, is_del, visibility, share_count
|
|
||||||
FROM p_post
|
|
||||||
WHERE is_del=0
|
|
||||||
ORDER BY is_top DESC, latest_replied_on DESC
|
|
||||||
LIMIT $1 OFFSET $2
|
|
||||||
`
|
|
||||||
|
|
||||||
type IndexByAdminParams struct {
|
|
||||||
Limit int32
|
|
||||||
Offset int32
|
|
||||||
}
|
|
||||||
|
|
||||||
// ------------------------------------------------------------------------------
|
|
||||||
// ship_index sql dml
|
|
||||||
// ------------------------------------------------------------------------------
|
|
||||||
func (q *Queries) IndexByAdmin(ctx context.Context, arg *IndexByAdminParams) ([]*PPost, error) {
|
|
||||||
rows, err := q.db.Query(ctx, indexByAdmin, arg.Limit, arg.Offset)
|
|
||||||
if err != nil {
|
|
||||||
return nil, err
|
|
||||||
}
|
|
||||||
defer rows.Close()
|
|
||||||
var items []*PPost
|
|
||||||
for rows.Next() {
|
|
||||||
var i PPost
|
|
||||||
if err := rows.Scan(
|
|
||||||
&i.ID,
|
|
||||||
&i.UserID,
|
|
||||||
&i.CommentCount,
|
|
||||||
&i.CollectionCount,
|
|
||||||
&i.UpvoteCount,
|
|
||||||
&i.IsTop,
|
|
||||||
&i.IsEssence,
|
|
||||||
&i.IsLock,
|
|
||||||
&i.LatestRepliedOn,
|
|
||||||
&i.Tags,
|
|
||||||
&i.AttachmentPrice,
|
|
||||||
&i.Ip,
|
|
||||||
&i.IpLoc,
|
|
||||||
&i.CreatedOn,
|
|
||||||
&i.ModifiedOn,
|
|
||||||
&i.DeletedOn,
|
|
||||||
&i.IsDel,
|
|
||||||
&i.Visibility,
|
|
||||||
&i.ShareCount,
|
|
||||||
); err != nil {
|
|
||||||
return nil, err
|
|
||||||
}
|
|
||||||
items = append(items, &i)
|
|
||||||
}
|
|
||||||
if err := rows.Err(); err != nil {
|
|
||||||
return nil, err
|
|
||||||
}
|
|
||||||
return items, nil
|
|
||||||
}
|
|
@ -1,290 +0,0 @@
|
|||||||
// Code generated by sqlc. DO NOT EDIT.
|
|
||||||
// versions:
|
|
||||||
// sqlc v1.20.0
|
|
||||||
// source: topics.sql
|
|
||||||
|
|
||||||
package dbr
|
|
||||||
|
|
||||||
import (
|
|
||||||
"context"
|
|
||||||
)
|
|
||||||
|
|
||||||
const decrTagsById = `-- name: DecrTagsById :exec
|
|
||||||
UPDATE p_tag
|
|
||||||
SET quote_num = quote_num-1,
|
|
||||||
modified_on=$1
|
|
||||||
WHERE id IN (
|
|
||||||
SELECT id
|
|
||||||
FROM p_tag
|
|
||||||
WHERE id = ANY($2::BIGINT[]) AND is_del = false AND quote_num >= 1
|
|
||||||
)
|
|
||||||
`
|
|
||||||
|
|
||||||
type DecrTagsByIdParams struct {
|
|
||||||
ModifiedOn int64
|
|
||||||
Ids []int64
|
|
||||||
}
|
|
||||||
|
|
||||||
func (q *Queries) DecrTagsById(ctx context.Context, arg *DecrTagsByIdParams) error {
|
|
||||||
_, err := q.db.Exec(ctx, decrTagsById, arg.ModifiedOn, arg.Ids)
|
|
||||||
return err
|
|
||||||
}
|
|
||||||
|
|
||||||
const hotTags = `-- name: HotTags :many
|
|
||||||
SELECT t.id, t.tag, t.quote_num, u.id user_id, u.nickname, u.username, u.status, u.avatar, u.is_admin
|
|
||||||
FROM p_tag t JOIN p_user u ON t.user_id = u.id
|
|
||||||
WHERE t.is_del = false AND t.quote_num > 0
|
|
||||||
ORDER BY quote_num DESC
|
|
||||||
OFFSET $1 LIMIT $2
|
|
||||||
`
|
|
||||||
|
|
||||||
type HotTagsParams struct {
|
|
||||||
Offset int32
|
|
||||||
Limit int32
|
|
||||||
}
|
|
||||||
|
|
||||||
type HotTagsRow struct {
|
|
||||||
ID int64
|
|
||||||
Tag string
|
|
||||||
QuoteNum int64
|
|
||||||
UserID int64
|
|
||||||
Nickname string
|
|
||||||
Username string
|
|
||||||
Status int16
|
|
||||||
Avatar string
|
|
||||||
IsAdmin bool
|
|
||||||
}
|
|
||||||
|
|
||||||
func (q *Queries) HotTags(ctx context.Context, arg *HotTagsParams) ([]*HotTagsRow, error) {
|
|
||||||
rows, err := q.db.Query(ctx, hotTags, arg.Offset, arg.Limit)
|
|
||||||
if err != nil {
|
|
||||||
return nil, err
|
|
||||||
}
|
|
||||||
defer rows.Close()
|
|
||||||
var items []*HotTagsRow
|
|
||||||
for rows.Next() {
|
|
||||||
var i HotTagsRow
|
|
||||||
if err := rows.Scan(
|
|
||||||
&i.ID,
|
|
||||||
&i.Tag,
|
|
||||||
&i.QuoteNum,
|
|
||||||
&i.UserID,
|
|
||||||
&i.Nickname,
|
|
||||||
&i.Username,
|
|
||||||
&i.Status,
|
|
||||||
&i.Avatar,
|
|
||||||
&i.IsAdmin,
|
|
||||||
); err != nil {
|
|
||||||
return nil, err
|
|
||||||
}
|
|
||||||
items = append(items, &i)
|
|
||||||
}
|
|
||||||
if err := rows.Err(); err != nil {
|
|
||||||
return nil, err
|
|
||||||
}
|
|
||||||
return items, nil
|
|
||||||
}
|
|
||||||
|
|
||||||
const incrTags = `-- name: IncrTags :many
|
|
||||||
UPDATE p_tag
|
|
||||||
SET quote_num = quote_num+1,
|
|
||||||
modified_on = $1,
|
|
||||||
id_del = false
|
|
||||||
WHERE id IN (
|
|
||||||
SELECT id
|
|
||||||
FROM p_tag
|
|
||||||
WHERE tag = ANY($2::VARCHAR[])
|
|
||||||
)
|
|
||||||
RETURNING id, user_id, tag, quote_num
|
|
||||||
`
|
|
||||||
|
|
||||||
type IncrTagsParams struct {
|
|
||||||
ModifiedOn int64
|
|
||||||
Tags []string
|
|
||||||
}
|
|
||||||
|
|
||||||
type IncrTagsRow struct {
|
|
||||||
ID int64
|
|
||||||
UserID int64
|
|
||||||
Tag string
|
|
||||||
QuoteNum int64
|
|
||||||
}
|
|
||||||
|
|
||||||
func (q *Queries) IncrTags(ctx context.Context, arg *IncrTagsParams) ([]*IncrTagsRow, error) {
|
|
||||||
rows, err := q.db.Query(ctx, incrTags, arg.ModifiedOn, arg.Tags)
|
|
||||||
if err != nil {
|
|
||||||
return nil, err
|
|
||||||
}
|
|
||||||
defer rows.Close()
|
|
||||||
var items []*IncrTagsRow
|
|
||||||
for rows.Next() {
|
|
||||||
var i IncrTagsRow
|
|
||||||
if err := rows.Scan(
|
|
||||||
&i.ID,
|
|
||||||
&i.UserID,
|
|
||||||
&i.Tag,
|
|
||||||
&i.QuoteNum,
|
|
||||||
); err != nil {
|
|
||||||
return nil, err
|
|
||||||
}
|
|
||||||
items = append(items, &i)
|
|
||||||
}
|
|
||||||
if err := rows.Err(); err != nil {
|
|
||||||
return nil, err
|
|
||||||
}
|
|
||||||
return items, nil
|
|
||||||
}
|
|
||||||
|
|
||||||
const insertTags = `-- name: InsertTags :one
|
|
||||||
INSERT INTO p_tag (user_id, tag, created_on, modified_on, quote_num)
|
|
||||||
VALUES ($1, $2, $3, $3, 1)
|
|
||||||
RETURNING id
|
|
||||||
`
|
|
||||||
|
|
||||||
type InsertTagsParams struct {
|
|
||||||
UserID int64
|
|
||||||
Tag string
|
|
||||||
CreatedOn int64
|
|
||||||
}
|
|
||||||
|
|
||||||
func (q *Queries) InsertTags(ctx context.Context, arg *InsertTagsParams) (int64, error) {
|
|
||||||
row := q.db.QueryRow(ctx, insertTags, arg.UserID, arg.Tag, arg.CreatedOn)
|
|
||||||
var id int64
|
|
||||||
err := row.Scan(&id)
|
|
||||||
return id, err
|
|
||||||
}
|
|
||||||
|
|
||||||
const newestTags = `-- name: NewestTags :many
|
|
||||||
SELECT t.id, t.tag, t.quote_num, u.id user_id, u.nickname, u.username, u.status, u.avatar, u.is_admin
|
|
||||||
FROM p_tag t JOIN p_user u ON t.user_id = u.id
|
|
||||||
WHERE t.is_del = false AND t.quote_num > 0
|
|
||||||
ORDER BY t.id DESC
|
|
||||||
OFFSET $1 LIMIT $2
|
|
||||||
`
|
|
||||||
|
|
||||||
type NewestTagsParams struct {
|
|
||||||
Offset int32
|
|
||||||
Limit int32
|
|
||||||
}
|
|
||||||
|
|
||||||
type NewestTagsRow struct {
|
|
||||||
ID int64
|
|
||||||
Tag string
|
|
||||||
QuoteNum int64
|
|
||||||
UserID int64
|
|
||||||
Nickname string
|
|
||||||
Username string
|
|
||||||
Status int16
|
|
||||||
Avatar string
|
|
||||||
IsAdmin bool
|
|
||||||
}
|
|
||||||
|
|
||||||
func (q *Queries) NewestTags(ctx context.Context, arg *NewestTagsParams) ([]*NewestTagsRow, error) {
|
|
||||||
rows, err := q.db.Query(ctx, newestTags, arg.Offset, arg.Limit)
|
|
||||||
if err != nil {
|
|
||||||
return nil, err
|
|
||||||
}
|
|
||||||
defer rows.Close()
|
|
||||||
var items []*NewestTagsRow
|
|
||||||
for rows.Next() {
|
|
||||||
var i NewestTagsRow
|
|
||||||
if err := rows.Scan(
|
|
||||||
&i.ID,
|
|
||||||
&i.Tag,
|
|
||||||
&i.QuoteNum,
|
|
||||||
&i.UserID,
|
|
||||||
&i.Nickname,
|
|
||||||
&i.Username,
|
|
||||||
&i.Status,
|
|
||||||
&i.Avatar,
|
|
||||||
&i.IsAdmin,
|
|
||||||
); err != nil {
|
|
||||||
return nil, err
|
|
||||||
}
|
|
||||||
items = append(items, &i)
|
|
||||||
}
|
|
||||||
if err := rows.Err(); err != nil {
|
|
||||||
return nil, err
|
|
||||||
}
|
|
||||||
return items, nil
|
|
||||||
}
|
|
||||||
|
|
||||||
const tagsByKeywordA = `-- name: TagsByKeywordA :many
|
|
||||||
SELECT id, user_id, tag, quote_num
|
|
||||||
FROM p_tag
|
|
||||||
WHERE is_del AND quote_num > 0
|
|
||||||
ORDER BY quote_num DESC
|
|
||||||
OFFSET 0 LIMIT 6
|
|
||||||
`
|
|
||||||
|
|
||||||
type TagsByKeywordARow struct {
|
|
||||||
ID int64
|
|
||||||
UserID int64
|
|
||||||
Tag string
|
|
||||||
QuoteNum int64
|
|
||||||
}
|
|
||||||
|
|
||||||
func (q *Queries) TagsByKeywordA(ctx context.Context) ([]*TagsByKeywordARow, error) {
|
|
||||||
rows, err := q.db.Query(ctx, tagsByKeywordA)
|
|
||||||
if err != nil {
|
|
||||||
return nil, err
|
|
||||||
}
|
|
||||||
defer rows.Close()
|
|
||||||
var items []*TagsByKeywordARow
|
|
||||||
for rows.Next() {
|
|
||||||
var i TagsByKeywordARow
|
|
||||||
if err := rows.Scan(
|
|
||||||
&i.ID,
|
|
||||||
&i.UserID,
|
|
||||||
&i.Tag,
|
|
||||||
&i.QuoteNum,
|
|
||||||
); err != nil {
|
|
||||||
return nil, err
|
|
||||||
}
|
|
||||||
items = append(items, &i)
|
|
||||||
}
|
|
||||||
if err := rows.Err(); err != nil {
|
|
||||||
return nil, err
|
|
||||||
}
|
|
||||||
return items, nil
|
|
||||||
}
|
|
||||||
|
|
||||||
const tagsByKeywordB = `-- name: TagsByKeywordB :many
|
|
||||||
SELECT id, user_id, tag, quote_num
|
|
||||||
FROM p_tag
|
|
||||||
WHERE is_del = false AND tag LIKE $1
|
|
||||||
ORDER BY quote_num DESC
|
|
||||||
OFFSET 0 LIMIT 6
|
|
||||||
`
|
|
||||||
|
|
||||||
type TagsByKeywordBRow struct {
|
|
||||||
ID int64
|
|
||||||
UserID int64
|
|
||||||
Tag string
|
|
||||||
QuoteNum int64
|
|
||||||
}
|
|
||||||
|
|
||||||
func (q *Queries) TagsByKeywordB(ctx context.Context, tag string) ([]*TagsByKeywordBRow, error) {
|
|
||||||
rows, err := q.db.Query(ctx, tagsByKeywordB, tag)
|
|
||||||
if err != nil {
|
|
||||||
return nil, err
|
|
||||||
}
|
|
||||||
defer rows.Close()
|
|
||||||
var items []*TagsByKeywordBRow
|
|
||||||
for rows.Next() {
|
|
||||||
var i TagsByKeywordBRow
|
|
||||||
if err := rows.Scan(
|
|
||||||
&i.ID,
|
|
||||||
&i.UserID,
|
|
||||||
&i.Tag,
|
|
||||||
&i.QuoteNum,
|
|
||||||
); err != nil {
|
|
||||||
return nil, err
|
|
||||||
}
|
|
||||||
items = append(items, &i)
|
|
||||||
}
|
|
||||||
if err := rows.Err(); err != nil {
|
|
||||||
return nil, err
|
|
||||||
}
|
|
||||||
return items, nil
|
|
||||||
}
|
|
@ -1,45 +0,0 @@
|
|||||||
// Code generated by sqlc. DO NOT EDIT.
|
|
||||||
// versions:
|
|
||||||
// sqlc v1.20.0
|
|
||||||
// source: tweets.sql
|
|
||||||
|
|
||||||
package dbr
|
|
||||||
|
|
||||||
import (
|
|
||||||
"context"
|
|
||||||
)
|
|
||||||
|
|
||||||
const getPostById = `-- name: GetPostById :one
|
|
||||||
|
|
||||||
SELECT id, user_id, comment_count, collection_count, upvote_count, is_top, is_essence, is_lock, latest_replied_on, tags, attachment_price, ip, ip_loc, created_on, modified_on, deleted_on, is_del, visibility, share_count FROM p_post WHERE id=$1 AND is_del=0
|
|
||||||
`
|
|
||||||
|
|
||||||
// ------------------------------------------------------------------------------
|
|
||||||
// tweet sql dml
|
|
||||||
// ------------------------------------------------------------------------------
|
|
||||||
func (q *Queries) GetPostById(ctx context.Context, id int64) (*PPost, error) {
|
|
||||||
row := q.db.QueryRow(ctx, getPostById, id)
|
|
||||||
var i PPost
|
|
||||||
err := row.Scan(
|
|
||||||
&i.ID,
|
|
||||||
&i.UserID,
|
|
||||||
&i.CommentCount,
|
|
||||||
&i.CollectionCount,
|
|
||||||
&i.UpvoteCount,
|
|
||||||
&i.IsTop,
|
|
||||||
&i.IsEssence,
|
|
||||||
&i.IsLock,
|
|
||||||
&i.LatestRepliedOn,
|
|
||||||
&i.Tags,
|
|
||||||
&i.AttachmentPrice,
|
|
||||||
&i.Ip,
|
|
||||||
&i.IpLoc,
|
|
||||||
&i.CreatedOn,
|
|
||||||
&i.ModifiedOn,
|
|
||||||
&i.DeletedOn,
|
|
||||||
&i.IsDel,
|
|
||||||
&i.Visibility,
|
|
||||||
&i.ShareCount,
|
|
||||||
)
|
|
||||||
return &i, err
|
|
||||||
}
|
|
@ -1,40 +0,0 @@
|
|||||||
// Code generated by sqlc. DO NOT EDIT.
|
|
||||||
// versions:
|
|
||||||
// sqlc v1.20.0
|
|
||||||
// source: user.sql
|
|
||||||
|
|
||||||
package dbr
|
|
||||||
|
|
||||||
import (
|
|
||||||
"context"
|
|
||||||
)
|
|
||||||
|
|
||||||
const getUserById = `-- name: GetUserById :one
|
|
||||||
|
|
||||||
SELECT id, nickname, username, phone, password, salt, status, avatar, balance, is_admin, created_on, modified_on, deleted_on, is_del FROM p_user WHERE id=$1 AND is_del=0
|
|
||||||
`
|
|
||||||
|
|
||||||
// ------------------------------------------------------------------------------
|
|
||||||
// user_manage sql dml
|
|
||||||
// ------------------------------------------------------------------------------
|
|
||||||
func (q *Queries) GetUserById(ctx context.Context, id int64) (*PUser, error) {
|
|
||||||
row := q.db.QueryRow(ctx, getUserById, id)
|
|
||||||
var i PUser
|
|
||||||
err := row.Scan(
|
|
||||||
&i.ID,
|
|
||||||
&i.Nickname,
|
|
||||||
&i.Username,
|
|
||||||
&i.Phone,
|
|
||||||
&i.Password,
|
|
||||||
&i.Salt,
|
|
||||||
&i.Status,
|
|
||||||
&i.Avatar,
|
|
||||||
&i.Balance,
|
|
||||||
&i.IsAdmin,
|
|
||||||
&i.CreatedOn,
|
|
||||||
&i.ModifiedOn,
|
|
||||||
&i.DeletedOn,
|
|
||||||
&i.IsDel,
|
|
||||||
)
|
|
||||||
return &i, err
|
|
||||||
}
|
|
@ -1,46 +0,0 @@
|
|||||||
// Code generated by sqlc. DO NOT EDIT.
|
|
||||||
// versions:
|
|
||||||
// sqlc v1.20.0
|
|
||||||
// source: wallet.sql
|
|
||||||
|
|
||||||
package dbr
|
|
||||||
|
|
||||||
import (
|
|
||||||
"context"
|
|
||||||
)
|
|
||||||
|
|
||||||
const getUserWalletBills = `-- name: GetUserWalletBills :one
|
|
||||||
|
|
||||||
SELECT id, user_id, change_amount, balance_snapshot, reason, post_id, created_on, modified_on, deleted_on, is_del
|
|
||||||
FROM p_wallet_statement
|
|
||||||
WHERE user_id=$1 AND is_del=0
|
|
||||||
ORDER BY id DESC
|
|
||||||
LIMIT $2 OFFSET $3
|
|
||||||
`
|
|
||||||
|
|
||||||
type GetUserWalletBillsParams struct {
|
|
||||||
UserID int64
|
|
||||||
Limit int32
|
|
||||||
Offset int32
|
|
||||||
}
|
|
||||||
|
|
||||||
// ------------------------------------------------------------------------------
|
|
||||||
// wallet sql dml
|
|
||||||
// ------------------------------------------------------------------------------
|
|
||||||
func (q *Queries) GetUserWalletBills(ctx context.Context, arg *GetUserWalletBillsParams) (*PWalletStatement, error) {
|
|
||||||
row := q.db.QueryRow(ctx, getUserWalletBills, arg.UserID, arg.Limit, arg.Offset)
|
|
||||||
var i PWalletStatement
|
|
||||||
err := row.Scan(
|
|
||||||
&i.ID,
|
|
||||||
&i.UserID,
|
|
||||||
&i.ChangeAmount,
|
|
||||||
&i.BalanceSnapshot,
|
|
||||||
&i.Reason,
|
|
||||||
&i.PostID,
|
|
||||||
&i.CreatedOn,
|
|
||||||
&i.ModifiedOn,
|
|
||||||
&i.DeletedOn,
|
|
||||||
&i.IsDel,
|
|
||||||
)
|
|
||||||
return &i, err
|
|
||||||
}
|
|
Loading…
Reference in new issue