mirror of https://github.com/rocboss/paopao-ce
You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
117 lines
2.8 KiB
117 lines
2.8 KiB
1 year ago
|
// Code generated by sqlc. DO NOT EDIT.
|
||
|
// versions:
|
||
|
// sqlc v1.20.0
|
||
|
// source: comments.sql
|
||
|
|
||
|
package pgc
|
||
|
|
||
|
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
|
||
|
}
|