Merge branch 'r/paopao-ce-pro' into r/paopao-ce-xtra

r/paopao-ce-xtra
Michael Li 1 year ago
commit 74e7484ce1
No known key found for this signature in database

@ -25,7 +25,7 @@ require (
github.com/golang-jwt/jwt/v5 v5.0.0
github.com/golang-migrate/migrate/v4 v4.15.2
github.com/huaweicloud/huaweicloud-sdk-go-obs v3.23.4+incompatible
github.com/jackc/pgx/v5 v5.4.2
github.com/jackc/pgx/v5 v5.4.3
github.com/json-iterator/go v1.1.12
github.com/meilisearch/meilisearch-go v0.25.0
github.com/minio/minio-go/v7 v7.0.62

@ -813,8 +813,8 @@ github.com/jackc/pgx/v4 v4.5.0/go.mod h1:EpAKPLdnTorwmPUUsqrPxy5fphV18j9q3wrfRXg
github.com/jackc/pgx/v4 v4.6.1-0.20200510190926-94ba730bb1e9/go.mod h1:t3/cdRQl6fOLDxqtlyhe9UWgfIi9R8+8v8GKV5TRA/o=
github.com/jackc/pgx/v4 v4.6.1-0.20200606145419-4e5062306904/go.mod h1:ZDaNWkt9sW1JMiNn0kdYBaLelIhw7Pg4qd+Vk6tw7Hg=
github.com/jackc/pgx/v4 v4.10.1/go.mod h1:QlrWebbs3kqEZPHCTGyxecvzG6tvIsYu+A5b1raylkA=
github.com/jackc/pgx/v5 v5.4.2 h1:u1gmGDwbdRUZiwisBm/Ky2M14uQyUP65bG8+20nnyrg=
github.com/jackc/pgx/v5 v5.4.2/go.mod h1:q6iHT8uDNXWiFNOlRqJzBTaSH3+2xCXkokxHZC5qWFY=
github.com/jackc/pgx/v5 v5.4.3 h1:cxFyXhxlvAifxnkKKdlxv8XqUf59tDlYjnV5YYfsJJY=
github.com/jackc/pgx/v5 v5.4.3/go.mod h1:Ig06C2Vu0t5qXC60W8sqIthScaEnFvojjj9dSljmHRA=
github.com/jackc/puddle v0.0.0-20190413234325-e4ced69a3a2b/go.mod h1:m4B5Dj62Y0fbyuIc15OsIqK0+JU8nkqQjsgx7dvjSWk=
github.com/jackc/puddle v0.0.0-20190608224051-11cab39313c9/go.mod h1:m4B5Dj62Y0fbyuIc15OsIqK0+JU8nkqQjsgx7dvjSWk=
github.com/jackc/puddle v1.1.0/go.mod h1:m4B5Dj62Y0fbyuIc15OsIqK0+JU8nkqQjsgx7dvjSWk=

@ -0,0 +1,78 @@
// 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
}

@ -0,0 +1,116 @@
// 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
}

@ -0,0 +1,35 @@
// 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
}

@ -0,0 +1,29 @@
// 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
}

@ -0,0 +1,25 @@
// 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
}

@ -35,15 +35,17 @@ type PCaptcha struct {
}
type PComment struct {
ID int64
PostID int64
UserID int64
Ip string
IpLoc string
CreatedOn int64
ModifiedOn int64
DeletedOn int64
IsDel int16
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 {
@ -60,17 +62,19 @@ type PCommentContent struct {
}
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
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 {
@ -99,6 +103,16 @@ type PContactGroup struct {
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
@ -149,6 +163,51 @@ type PPostAttachmentBill struct {
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
@ -209,19 +268,30 @@ type PTopicUser struct {
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
// MD5密码
Password string
Salt string
// 状态, 1正常, 2停用
Status int16
Avatar string
// 用户余额(分)
ID int64
Nickname string
Username string
Phone string
Password string
Salt string
Status int16
Avatar string
Balance int64
IsAdmin bool
CreatedOn int64

@ -6,13 +6,62 @@ 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)

@ -0,0 +1,12 @@
--------------------------------------------------------------------------------
-- authorization_manage sql dml
--------------------------------------------------------------------------------
-- name: BeFriendIds :many
SELECT user_id FROM p_contact WHERE friend_id=$1 AND status=2 AND is_del=0;
-- name: MyFriendSet :many
SELECT friend_id FROM p_contact WHERE user_id=$1 AND status=2 AND is_del=0;
-- name: IsFriend :one
SELECT status FROM p_contact WHERE user_id=$1 AND friend_id=$2 AND is_del=0;

@ -0,0 +1,16 @@
--------------------------------------------------------------------------------
-- comment sql dml
--------------------------------------------------------------------------------
-- name: GetNewestComments :many
SELECT * FROM p_comment WHERE post_id=$1 AND is_del=0 ORDER BY id DESC LIMIT $2 OFFSET $3;
-- name: GetDefaultComments :many
SELECT * FROM p_comment WHERE post_id=$1 AND is_del=0 ORDER BY id ASC LIMIT $2 OFFSET $3;
--------------------------------------------------------------------------------
-- comment_manage sql dml
--------------------------------------------------------------------------------
-- name: DeleteComment :exec
UPDATE p_comment SET deleted_on=$1, is_del=1 WHERE id=$2 AND is_del=0;

@ -0,0 +1,6 @@
--------------------------------------------------------------------------------
-- contact_manager sql dml
--------------------------------------------------------------------------------
-- name: CreateContact :exec
INSERT INTO p_contact (user_id, friend_id, status, created_on) VALUES ($1, $2, $3, $4);

@ -0,0 +1,6 @@
--------------------------------------------------------------------------------
-- following_manager sql dml
--------------------------------------------------------------------------------
-- name: CreateFollowing :exec
INSERT INTO p_following (user_id, follow_id, created_on) VALUES ($1, $2, $3);

@ -0,0 +1,6 @@
--------------------------------------------------------------------------------
-- message sql dml
--------------------------------------------------------------------------------
-- name: GetUnreadCount :one
SELECT count(*) FROM p_message WHERE receiver_user_id=$1 AND is_read=0 AND is_del=0;

@ -0,0 +1,6 @@
--------------------------------------------------------------------------------
-- security sql dml
--------------------------------------------------------------------------------
-- name: GetLatestPhoneCaptcha :one
SELECT * FROM p_captcha WHERE phone=$1 AND is_del=0;

@ -0,0 +1,10 @@
--------------------------------------------------------------------------------
-- ship_index sql dml
--------------------------------------------------------------------------------
-- name: IndexByAdmin :many
SELECT *
FROM p_post
WHERE is_del=0
ORDER BY is_top DESC, latest_replied_on DESC
LIMIT $1 OFFSET $2;

@ -0,0 +1,6 @@
--------------------------------------------------------------------------------
-- tweet sql dml
--------------------------------------------------------------------------------
-- name: GetPostById :one
SELECT * FROM p_post WHERE id=$1 AND is_del=0;

@ -0,0 +1,7 @@
--------------------------------------------------------------------------------
-- user_manage sql dml
--------------------------------------------------------------------------------
-- name: GetUserById :one
SELECT * FROM p_user WHERE id=$1 AND is_del=0;

@ -0,0 +1,10 @@
--------------------------------------------------------------------------------
-- wallet sql dml
--------------------------------------------------------------------------------
-- name: GetUserWalletBills :one
SELECT *
FROM p_wallet_statement
WHERE user_id=$1 AND is_del=0
ORDER BY id DESC
LIMIT $2 OFFSET $3;

@ -14,4 +14,3 @@ DROP TABLE IF EXISTS p_user;
DROP TABLE IF EXISTS p_wallet_recharge;
DROP TABLE IF EXISTS p_wallet_statement;
DROP SEQUENCE IF EXISTS post_id_seq;

@ -199,10 +199,6 @@ CREATE TABLE p_user (
deleted_on BIGINT NOT NULL DEFAULT 0,
is_del SMALLINT NOT NULL DEFAULT 0
);
COMMENT ON TABLE p_user IS '用户';
COMMENT ON COLUMN p_user.password IS 'MD5密码';
COMMENT ON COLUMN p_user.status IS '状态, 1正常, 2停用';
COMMENT ON COLUMN p_user.balance IS '用户余额(分)';
CREATE UNIQUE INDEX idx_user_username ON p_user USING btree (username);
CREATE INDEX idx_user_phone ON p_user USING btree (phone);

@ -0,0 +1,6 @@
ALTER TABLE p_comment DROP COLUMN thumbs_up_count;
ALTER TABLE p_comment DROP COLUMN thumbs_down_count;
ALTER TABLE p_comment_reply DROP COLUMN thumbs_up_count;
ALTER TABLE p_comment_reply DROP COLUMN thumbs_down_count;
DROP TABLE IF EXISTS p_tweet_comment_thumbs;

@ -0,0 +1,20 @@
ALTER TABLE p_comment ADD COLUMN thumbs_up_count INT NOT NULL DEFAULT 0;
ALTER TABLE p_comment ADD COLUMN thumbs_down_count INT NOT NULL DEFAULT 0;
ALTER TABLE p_comment_reply ADD COLUMN thumbs_up_count INT NOT NULL DEFAULT 0;
ALTER TABLE p_comment_reply ADD COLUMN thumbs_down_count INT NOT NULL DEFAULT 0;
CREATE TABLE p_tweet_comment_thumbs (
ID BIGSERIAL PRIMARY KEY,
user_id BIGINT NOT NULL,
tweet_id BIGINT NOT NULL,
comment_id BIGINT NOT NULL,
reply_id BIGINT,
comment_type SMALLINT NOT NULL DEFAULT 0,-- 评论类型 0为推文评论、1为评论回复
is_thumbs_up SMALLINT NOT NULL DEFAULT 0,-- 是否点赞 0 为否 1为是
is_thumbs_down SMALLINT NOT NULL DEFAULT 0,-- 是否点踩 0 为否 1为是
created_on BIGINT NOT NULL DEFAULT 0,
modified_on BIGINT NOT NULL DEFAULT 0,
deleted_on BIGINT NOT NULL DEFAULT 0,
is_del SMALLINT NOT NULL DEFAULT 0 -- 是否删除 0 为未删除、1 为已删除
);
CREATE INDEX idx_tweet_comment_thumbs_uid_tid ON p_tweet_comment_thumbs USING btree ( user_id, tweet_id );

@ -0,0 +1,3 @@
ALTER TABLE p_post_content ALTER COLUMN content SET DATA TYPE TEXT, ALTER COLUMN content SET NOT NULL, ALTER COLUMN content SET DEFAULT '';
ALTER TABLE p_comment_content ALTER COLUMN content SET DATA TYPE TEXT, ALTER COLUMN content SET NOT NULL, ALTER COLUMN content SET DEFAULT '';
ALTER TABLE p_comment_reply ALTER COLUMN content SET DATA TYPE TEXT, ALTER COLUMN content SET NOT NULL, ALTER COLUMN content SET DEFAULT '';

@ -0,0 +1,5 @@
DROP VIEW IF EXISTS p_post_by_media;
DROP VIEW IF EXISTS p_post_by_comment;

@ -0,0 +1,32 @@
CREATE VIEW p_post_by_media AS
SELECT post.*
FROM
( SELECT DISTINCT post_id FROM p_post_content WHERE ( TYPE = 3 OR TYPE = 4 OR TYPE = 7 OR TYPE = 8 ) AND is_del = 0 ) media
JOIN p_post post ON media.post_id = post.ID
WHERE
post.is_del = 0;
CREATE VIEW p_post_by_comment AS
SELECT P.*, C.user_id comment_user_id
FROM
(
SELECT
post_id,
user_id
FROM
p_comment
WHERE
is_del = 0 UNION
SELECT
post_id,
reply.user_id user_id
FROM
p_comment_reply reply
JOIN p_comment COMMENT ON reply.comment_id = COMMENT.ID
WHERE
reply.is_del = 0
AND COMMENT.is_del = 0
)
C JOIN p_post P ON C.post_id = P.ID
WHERE
P.is_del = 0;

@ -0,0 +1,10 @@
CREATE TABLE p_following (
id BIGSERIAL PRIMARY KEY,
user_id BIGINT NOT NULL,
follow_id BIGINT NOT NULL,
is_del SMALLINT NOT NULL DEFAULT 0, -- 是否删除, 0否, 1是
created_on BIGINT NOT NULL DEFAULT 0,
modified_on BIGINT NOT NULL DEFAULT 0,
deleted_on BIGINT NOT NULL DEFAULT 0
);
CREATE INDEX idx_following_user_follow ON p_following USING btree (user_id, follow_id);

@ -0,0 +1,37 @@
// 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
}

@ -0,0 +1,67 @@
// 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,7 +1,7 @@
// Code generated by sqlc. DO NOT EDIT.
// versions:
// sqlc v1.20.0
// source: topic.sql
// source: topics.sql
package dbr

@ -0,0 +1,45 @@
// 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
}

@ -0,0 +1,40 @@
// 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
}

@ -0,0 +1,46 @@
// 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
}

@ -1,3 +1,3 @@
ALTER TABLE p_post_content ALTER COLUMN content SET DATA TYPE TEXT NOT NULL DEFAULT '';
ALTER TABLE p_comment_content ALTER COLUMN content SET DATA TYPE TEXT NOT NULL DEFAULT '';
ALTER TABLE p_comment_reply ALTER COLUMN content SET DATA TYPE TEXT NOT NULL DEFAULT '';
ALTER TABLE p_post_content ALTER COLUMN content SET DATA TYPE TEXT, ALTER COLUMN content SET NOT NULL, ALTER COLUMN content SET DEFAULT '';
ALTER TABLE p_comment_content ALTER COLUMN content SET DATA TYPE TEXT, ALTER COLUMN content SET NOT NULL, ALTER COLUMN content SET DEFAULT '';
ALTER TABLE p_comment_reply ALTER COLUMN content SET DATA TYPE TEXT, ALTER COLUMN content SET NOT NULL, ALTER COLUMN content SET DEFAULT '';

Loading…
Cancel
Save