mirror of https://github.com/rocboss/paopao-ce
parent
04c10a1718
commit
ac78970ce1
@ -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
|
||||||
|
}
|
@ -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;
|
@ -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 @@
|
|||||||
|
-- nothing
|
@ -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 @@
|
|||||||
|
DROP TABLE IF EXISTS p_following;
|
@ -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.
|
// Code generated by sqlc. DO NOT EDIT.
|
||||||
// versions:
|
// versions:
|
||||||
// sqlc v1.20.0
|
// sqlc v1.20.0
|
||||||
// source: topic.sql
|
// source: topics.sql
|
||||||
|
|
||||||
package dbr
|
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_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 NOT NULL 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 NOT NULL 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…
Reference in new issue