mirror of https://github.com/rocboss/paopao-ce
commit
96a9d9bc22
@ -0,0 +1,29 @@
|
|||||||
|
// Copyright 2023 ROC. All rights reserved.
|
||||||
|
// Use of this source code is governed by a MIT style
|
||||||
|
// license that can be found in the LICENSE file.
|
||||||
|
|
||||||
|
package conf
|
||||||
|
|
||||||
|
import (
|
||||||
|
"context"
|
||||||
|
"sync"
|
||||||
|
|
||||||
|
"github.com/jackc/pgx/v5"
|
||||||
|
"github.com/sirupsen/logrus"
|
||||||
|
)
|
||||||
|
|
||||||
|
var (
|
||||||
|
_pgxDB *pgx.Conn
|
||||||
|
_oncePgx sync.Once
|
||||||
|
)
|
||||||
|
|
||||||
|
func MustPgxDB() *pgx.Conn {
|
||||||
|
_oncePgx.Do(func() {
|
||||||
|
conn, err := pgx.Connect(context.Background(), PostgresSetting.Dsn())
|
||||||
|
if err != nil {
|
||||||
|
logrus.Fatalf("pgx.Connect occurs error: %s", err)
|
||||||
|
}
|
||||||
|
_pgxDB = conn
|
||||||
|
})
|
||||||
|
return _pgxDB
|
||||||
|
}
|
@ -0,0 +1,55 @@
|
|||||||
|
// Copyright 2023 ROC. All rights reserved.
|
||||||
|
// Use of this source code is governed by a MIT style
|
||||||
|
// license that can be found in the LICENSE file.
|
||||||
|
|
||||||
|
package slonik
|
||||||
|
|
||||||
|
import (
|
||||||
|
"github.com/jackc/pgx/v5"
|
||||||
|
"github.com/rocboss/paopao-ce/internal/core"
|
||||||
|
"github.com/rocboss/paopao-ce/pkg/debug"
|
||||||
|
)
|
||||||
|
|
||||||
|
var (
|
||||||
|
_ core.AuthorizationManageService = (*authorizationManageSrv)(nil)
|
||||||
|
)
|
||||||
|
|
||||||
|
type authorizationManageSrv struct {
|
||||||
|
*pgxSrv
|
||||||
|
}
|
||||||
|
|
||||||
|
func (s *authorizationManageSrv) IsAllow(user *core.User, action *core.Action) bool {
|
||||||
|
// TODO
|
||||||
|
debug.NotImplemented()
|
||||||
|
return false
|
||||||
|
}
|
||||||
|
|
||||||
|
func (s *authorizationManageSrv) MyFriendSet(userId int64) core.FriendSet {
|
||||||
|
// TODO
|
||||||
|
debug.NotImplemented()
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
|
||||||
|
func (s *authorizationManageSrv) BeFriendFilter(userId int64) core.FriendFilter {
|
||||||
|
// TODO
|
||||||
|
debug.NotImplemented()
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
|
||||||
|
func (s *authorizationManageSrv) BeFriendIds(userId int64) ([]int64, error) {
|
||||||
|
// TODO
|
||||||
|
debug.NotImplemented()
|
||||||
|
return nil, nil
|
||||||
|
}
|
||||||
|
|
||||||
|
func (s *authorizationManageSrv) isFriend(userId int64, friendId int64) bool {
|
||||||
|
// TODO
|
||||||
|
debug.NotImplemented()
|
||||||
|
return false
|
||||||
|
}
|
||||||
|
|
||||||
|
func newAuthorizationManageService(db *pgx.Conn) core.AuthorizationManageService {
|
||||||
|
return &authorizationManageSrv{
|
||||||
|
pgxSrv: newPgxSrv(db),
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,102 @@
|
|||||||
|
// Copyright 2023 ROC. All rights reserved.
|
||||||
|
// Use of this source code is governed by a MIT style
|
||||||
|
// license that can be found in the LICENSE file.
|
||||||
|
|
||||||
|
package slonik
|
||||||
|
|
||||||
|
import (
|
||||||
|
"github.com/jackc/pgx/v5"
|
||||||
|
"github.com/rocboss/paopao-ce/internal/core"
|
||||||
|
"github.com/rocboss/paopao-ce/pkg/debug"
|
||||||
|
)
|
||||||
|
|
||||||
|
var (
|
||||||
|
_ core.CommentService = (*commentSrv)(nil)
|
||||||
|
_ core.CommentManageService = (*commentManageSrv)(nil)
|
||||||
|
)
|
||||||
|
|
||||||
|
type commentSrv struct {
|
||||||
|
*pgxSrv
|
||||||
|
}
|
||||||
|
|
||||||
|
type commentManageSrv struct {
|
||||||
|
*pgxSrv
|
||||||
|
}
|
||||||
|
|
||||||
|
func (s *commentSrv) GetComments(conditions *core.ConditionsT, offset, limit int) ([]*core.Comment, error) {
|
||||||
|
// TODO
|
||||||
|
debug.NotImplemented()
|
||||||
|
return nil, nil
|
||||||
|
}
|
||||||
|
|
||||||
|
func (s *commentSrv) GetCommentByID(id int64) (*core.Comment, error) {
|
||||||
|
// TODO
|
||||||
|
debug.NotImplemented()
|
||||||
|
return nil, nil
|
||||||
|
}
|
||||||
|
|
||||||
|
func (s *commentSrv) GetCommentReplyByID(id int64) (*core.CommentReply, error) {
|
||||||
|
// TODO
|
||||||
|
debug.NotImplemented()
|
||||||
|
return nil, nil
|
||||||
|
}
|
||||||
|
|
||||||
|
func (s *commentSrv) GetCommentCount(conditions *core.ConditionsT) (int64, error) {
|
||||||
|
// TODO
|
||||||
|
debug.NotImplemented()
|
||||||
|
return 0, nil
|
||||||
|
}
|
||||||
|
|
||||||
|
func (s *commentSrv) GetCommentContentsByIDs(ids []int64) ([]*core.CommentContent, error) {
|
||||||
|
// TODO
|
||||||
|
debug.NotImplemented()
|
||||||
|
return nil, nil
|
||||||
|
}
|
||||||
|
|
||||||
|
func (s *commentSrv) GetCommentRepliesByID(ids []int64) ([]*core.CommentReplyFormated, error) {
|
||||||
|
// TODO
|
||||||
|
debug.NotImplemented()
|
||||||
|
return nil, nil
|
||||||
|
}
|
||||||
|
|
||||||
|
func (s *commentManageSrv) DeleteComment(comment *core.Comment) error {
|
||||||
|
// TODO
|
||||||
|
debug.NotImplemented()
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
|
||||||
|
func (s *commentManageSrv) CreateComment(comment *core.Comment) (*core.Comment, error) {
|
||||||
|
// TODO
|
||||||
|
debug.NotImplemented()
|
||||||
|
return nil, nil
|
||||||
|
}
|
||||||
|
|
||||||
|
func (s *commentManageSrv) CreateCommentReply(reply *core.CommentReply) (*core.CommentReply, error) {
|
||||||
|
// TODO
|
||||||
|
debug.NotImplemented()
|
||||||
|
return nil, nil
|
||||||
|
}
|
||||||
|
|
||||||
|
func (s *commentManageSrv) DeleteCommentReply(reply *core.CommentReply) error {
|
||||||
|
// TODO
|
||||||
|
debug.NotImplemented()
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
|
||||||
|
func (s *commentManageSrv) CreateCommentContent(content *core.CommentContent) (*core.CommentContent, error) {
|
||||||
|
// TODO
|
||||||
|
debug.NotImplemented()
|
||||||
|
return nil, nil
|
||||||
|
}
|
||||||
|
|
||||||
|
func newCommentService(db *pgx.Conn) core.CommentService {
|
||||||
|
return &commentSrv{
|
||||||
|
pgxSrv: newPgxSrv(db),
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
func newCommentManageService(db *pgx.Conn) core.CommentManageService {
|
||||||
|
return &commentManageSrv{
|
||||||
|
pgxSrv: newPgxSrv(db),
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,61 @@
|
|||||||
|
// Copyright 2023 ROC. All rights reserved.
|
||||||
|
// Use of this source code is governed by a MIT style
|
||||||
|
// license that can be found in the LICENSE file.
|
||||||
|
|
||||||
|
package slonik
|
||||||
|
|
||||||
|
import (
|
||||||
|
"github.com/jackc/pgx/v5"
|
||||||
|
"github.com/rocboss/paopao-ce/internal/core"
|
||||||
|
"github.com/rocboss/paopao-ce/pkg/debug"
|
||||||
|
)
|
||||||
|
|
||||||
|
var (
|
||||||
|
_ core.ContactManageService = (*contactManageSrv)(nil)
|
||||||
|
)
|
||||||
|
|
||||||
|
type contactManageSrv struct {
|
||||||
|
*pgxSrv
|
||||||
|
}
|
||||||
|
|
||||||
|
func (s *contactManageSrv) RequestingFriend(userId int64, friendId int64, greetings string) (err error) {
|
||||||
|
// TODO
|
||||||
|
debug.NotImplemented()
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
|
||||||
|
func (s *contactManageSrv) AddFriend(userId int64, friendId int64) (err error) {
|
||||||
|
// TODO
|
||||||
|
debug.NotImplemented()
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
|
||||||
|
func (s *contactManageSrv) RejectFriend(userId int64, friendId int64) (err error) {
|
||||||
|
// TODO
|
||||||
|
debug.NotImplemented()
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
|
||||||
|
func (s *contactManageSrv) DeleteFriend(userId int64, friendId int64) (err error) {
|
||||||
|
// TODO
|
||||||
|
debug.NotImplemented()
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
|
||||||
|
func (s *contactManageSrv) GetContacts(userId int64, offset int, limit int) (*core.ContactList, error) {
|
||||||
|
// TODO
|
||||||
|
debug.NotImplemented()
|
||||||
|
return nil, nil
|
||||||
|
}
|
||||||
|
|
||||||
|
func (s *contactManageSrv) IsFriend(userId int64, friendId int64) bool {
|
||||||
|
// TODO
|
||||||
|
debug.NotImplemented()
|
||||||
|
return false
|
||||||
|
}
|
||||||
|
|
||||||
|
func newContactManageService(db *pgx.Conn) core.ContactManageService {
|
||||||
|
return &contactManageSrv{
|
||||||
|
pgxSrv: newPgxSrv(db),
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,15 @@
|
|||||||
|
// Copyright 2023 ROC. All rights reserved.
|
||||||
|
// Use of this source code is governed by a MIT style
|
||||||
|
// license that can be found in the LICENSE file.
|
||||||
|
|
||||||
|
//go:build migration
|
||||||
|
// +build migration
|
||||||
|
|
||||||
|
package slonik
|
||||||
|
|
||||||
|
import (
|
||||||
|
"embed"
|
||||||
|
)
|
||||||
|
|
||||||
|
//go:embed sqlc/postgres/schema
|
||||||
|
var Files embed.FS
|
@ -0,0 +1,61 @@
|
|||||||
|
// Copyright 2023 ROC. All rights reserved.
|
||||||
|
// Use of this source code is governed by a MIT style
|
||||||
|
// license that can be found in the LICENSE file.
|
||||||
|
|
||||||
|
package slonik
|
||||||
|
|
||||||
|
import (
|
||||||
|
"github.com/jackc/pgx/v5"
|
||||||
|
"github.com/rocboss/paopao-ce/internal/core"
|
||||||
|
"github.com/rocboss/paopao-ce/pkg/debug"
|
||||||
|
)
|
||||||
|
|
||||||
|
var (
|
||||||
|
_ core.MessageService = (*messageSrv)(nil)
|
||||||
|
)
|
||||||
|
|
||||||
|
type messageSrv struct {
|
||||||
|
*pgxSrv
|
||||||
|
}
|
||||||
|
|
||||||
|
func (s *messageSrv) CreateMessage(msg *core.Message) (*core.Message, error) {
|
||||||
|
// TODO
|
||||||
|
debug.NotImplemented()
|
||||||
|
return nil, nil
|
||||||
|
}
|
||||||
|
|
||||||
|
func (s *messageSrv) GetUnreadCount(userID int64) (int64, error) {
|
||||||
|
// TODO
|
||||||
|
debug.NotImplemented()
|
||||||
|
return 0, nil
|
||||||
|
}
|
||||||
|
|
||||||
|
func (s *messageSrv) GetMessageByID(id int64) (*core.Message, error) {
|
||||||
|
// TODO
|
||||||
|
debug.NotImplemented()
|
||||||
|
return nil, nil
|
||||||
|
}
|
||||||
|
|
||||||
|
func (s *messageSrv) ReadMessage(message *core.Message) error {
|
||||||
|
// TODO
|
||||||
|
debug.NotImplemented()
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
|
||||||
|
func (s *messageSrv) GetMessages(conditions *core.ConditionsT, offset, limit int) ([]*core.MessageFormated, error) {
|
||||||
|
// TODO
|
||||||
|
debug.NotImplemented()
|
||||||
|
return nil, nil
|
||||||
|
}
|
||||||
|
|
||||||
|
func (s *messageSrv) GetMessageCount(conditions *core.ConditionsT) (int64, error) {
|
||||||
|
// TODO
|
||||||
|
debug.NotImplemented()
|
||||||
|
return 0, nil
|
||||||
|
}
|
||||||
|
|
||||||
|
func newMessageService(db *pgx.Conn) core.MessageService {
|
||||||
|
return &messageSrv{
|
||||||
|
pgxSrv: newPgxSrv(db),
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,104 @@
|
|||||||
|
// Copyright 2023 ROC. All rights reserved.
|
||||||
|
// Use of this source code is governed by a MIT style
|
||||||
|
// license that can be found in the LICENSE file.
|
||||||
|
|
||||||
|
package slonik
|
||||||
|
|
||||||
|
import (
|
||||||
|
"context"
|
||||||
|
"sync"
|
||||||
|
|
||||||
|
"github.com/jackc/pgx/v5"
|
||||||
|
"github.com/rocboss/paopao-ce/internal/conf"
|
||||||
|
dbr "github.com/rocboss/paopao-ce/internal/dao/slonik/sqlc/postgres"
|
||||||
|
)
|
||||||
|
|
||||||
|
var (
|
||||||
|
_pgxDB *pgx.Conn
|
||||||
|
_oncePgx sync.Once
|
||||||
|
)
|
||||||
|
|
||||||
|
type pgxSrv struct {
|
||||||
|
db *pgx.Conn
|
||||||
|
q dbr.Querier
|
||||||
|
}
|
||||||
|
|
||||||
|
func (s *pgxSrv) begin(ctx context.Context) (pgx.Tx, dbr.Querier, error) {
|
||||||
|
tx, err := s.db.Begin(ctx)
|
||||||
|
if err != nil {
|
||||||
|
return nil, nil, err
|
||||||
|
}
|
||||||
|
return tx, dbr.New(tx), nil
|
||||||
|
}
|
||||||
|
|
||||||
|
func (s *pgxSrv) beingTx(ctx context.Context, txOptions pgx.TxOptions) (pgx.Tx, dbr.Querier, error) {
|
||||||
|
tx, err := s.db.BeginTx(ctx, txOptions)
|
||||||
|
if err != nil {
|
||||||
|
return nil, nil, err
|
||||||
|
}
|
||||||
|
return tx, dbr.New(tx), nil
|
||||||
|
}
|
||||||
|
|
||||||
|
func (s *pgxSrv) with(handle func(c context.Context, q dbr.Querier) error) error {
|
||||||
|
ctx := context.Background()
|
||||||
|
tx, err := s.db.Begin(ctx)
|
||||||
|
if err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
defer tx.Rollback(ctx)
|
||||||
|
if err = handle(ctx, dbr.New(tx)); err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
return tx.Commit(ctx)
|
||||||
|
}
|
||||||
|
|
||||||
|
func (s *pgxSrv) withTx(txOptions pgx.TxOptions, handle func(ctx context.Context, q dbr.Querier) error) error {
|
||||||
|
ctx := context.Background()
|
||||||
|
tx, err := s.db.BeginTx(ctx, txOptions)
|
||||||
|
if err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
defer tx.Rollback(ctx)
|
||||||
|
if err = handle(ctx, dbr.New(tx)); err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
return tx.Commit(ctx)
|
||||||
|
}
|
||||||
|
|
||||||
|
func (s *pgxSrv) withCtx(ctx context.Context, handle func(dbr.Querier) error) error {
|
||||||
|
tx, err := s.db.Begin(ctx)
|
||||||
|
if err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
defer tx.Rollback(ctx)
|
||||||
|
if err = handle(dbr.New(tx)); err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
return tx.Commit(ctx)
|
||||||
|
}
|
||||||
|
|
||||||
|
func (s *pgxSrv) withTxCtx(ctx context.Context, txOptions pgx.TxOptions, handle func(dbr.Querier) error) error {
|
||||||
|
tx, err := s.db.BeginTx(ctx, txOptions)
|
||||||
|
if err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
defer tx.Rollback(ctx)
|
||||||
|
if err = handle(dbr.New(tx)); err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
return tx.Commit(ctx)
|
||||||
|
}
|
||||||
|
|
||||||
|
func newPgxSrv(db *pgx.Conn) *pgxSrv {
|
||||||
|
return &pgxSrv{
|
||||||
|
db: db,
|
||||||
|
q: dbr.New(db),
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
func pgxDB() *pgx.Conn {
|
||||||
|
_oncePgx.Do(func() {
|
||||||
|
_pgxDB = conf.MustPgxDB()
|
||||||
|
})
|
||||||
|
return _pgxDB
|
||||||
|
}
|
@ -0,0 +1,46 @@
|
|||||||
|
// Copyright 2023 ROC. All rights reserved.
|
||||||
|
// Use of this source code is governed by a MIT style
|
||||||
|
// license that can be found in the LICENSE file.
|
||||||
|
|
||||||
|
package slonik
|
||||||
|
|
||||||
|
import (
|
||||||
|
"github.com/jackc/pgx/v5"
|
||||||
|
"github.com/rocboss/paopao-ce/internal/core"
|
||||||
|
"github.com/rocboss/paopao-ce/pkg/debug"
|
||||||
|
)
|
||||||
|
|
||||||
|
var (
|
||||||
|
_ core.SecurityService = (*securitySrv)(nil)
|
||||||
|
)
|
||||||
|
|
||||||
|
type securitySrv struct {
|
||||||
|
*pgxSrv
|
||||||
|
}
|
||||||
|
|
||||||
|
// GetLatestPhoneCaptcha 获取最新短信验证码
|
||||||
|
func (s *securitySrv) GetLatestPhoneCaptcha(phone string) (*core.Captcha, error) {
|
||||||
|
// TODO
|
||||||
|
debug.NotImplemented()
|
||||||
|
return nil, nil
|
||||||
|
}
|
||||||
|
|
||||||
|
// UsePhoneCaptcha 更新短信验证码
|
||||||
|
func (s *securitySrv) UsePhoneCaptcha(captcha *core.Captcha) error {
|
||||||
|
// TODO
|
||||||
|
debug.NotImplemented()
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
|
||||||
|
// SendPhoneCaptcha 发送短信验证码
|
||||||
|
func (s *securitySrv) SendPhoneCaptcha(phone string) error {
|
||||||
|
// TODO
|
||||||
|
debug.NotImplemented()
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
|
||||||
|
func newSecurityService(db *pgx.Conn, phoneVerify core.PhoneVerifyService) core.SecurityService {
|
||||||
|
return &securitySrv{
|
||||||
|
pgxSrv: newPgxSrv(db),
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,15 @@
|
|||||||
|
// Copyright 2023 ROC. All rights reserved.
|
||||||
|
// Use of this source code is governed by a MIT style
|
||||||
|
// license that can be found in the LICENSE file.
|
||||||
|
package main
|
||||||
|
|
||||||
|
import (
|
||||||
|
"os"
|
||||||
|
|
||||||
|
sqlc "github.com/kyleconroy/sqlc/pkg/cli"
|
||||||
|
)
|
||||||
|
|
||||||
|
//go:generate go run $GOFILE generate -x
|
||||||
|
func main() {
|
||||||
|
os.Exit(sqlc.Run(os.Args[1:]))
|
||||||
|
}
|
@ -0,0 +1,32 @@
|
|||||||
|
// Code generated by sqlc. DO NOT EDIT.
|
||||||
|
// versions:
|
||||||
|
// sqlc v1.17.2
|
||||||
|
|
||||||
|
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,
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,239 @@
|
|||||||
|
// Code generated by sqlc. DO NOT EDIT.
|
||||||
|
// versions:
|
||||||
|
// sqlc v1.17.2
|
||||||
|
|
||||||
|
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
|
||||||
|
}
|
||||||
|
|
||||||
|
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
|
||||||
|
}
|
||||||
|
|
||||||
|
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 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
|
||||||
|
}
|
||||||
|
|
||||||
|
type PPostAttachmentBill struct {
|
||||||
|
ID int64
|
||||||
|
PostID int64
|
||||||
|
UserID int64
|
||||||
|
PaidAmount int64
|
||||||
|
CreatedOn int64
|
||||||
|
ModifiedOn int64
|
||||||
|
DeletedOn int64
|
||||||
|
IsDel int16
|
||||||
|
}
|
||||||
|
|
||||||
|
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 PUser struct {
|
||||||
|
ID int64
|
||||||
|
Nickname string
|
||||||
|
Username string
|
||||||
|
Phone string
|
||||||
|
// MD5密码
|
||||||
|
Password string
|
||||||
|
Salt string
|
||||||
|
// 状态, 1正常, 2停用
|
||||||
|
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
|
||||||
|
}
|
@ -0,0 +1,21 @@
|
|||||||
|
// Code generated by sqlc. DO NOT EDIT.
|
||||||
|
// versions:
|
||||||
|
// sqlc v1.17.2
|
||||||
|
|
||||||
|
package dbr
|
||||||
|
|
||||||
|
import (
|
||||||
|
"context"
|
||||||
|
)
|
||||||
|
|
||||||
|
type Querier interface {
|
||||||
|
DecrTagsById(ctx context.Context, arg *DecrTagsByIdParams) error
|
||||||
|
HotTags(ctx context.Context, arg *HotTagsParams) ([]*HotTagsRow, error)
|
||||||
|
IncrTags(ctx context.Context, arg *IncrTagsParams) ([]*IncrTagsRow, error)
|
||||||
|
InsertTags(ctx context.Context, arg *InsertTagsParams) (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,54 @@
|
|||||||
|
-- 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;
|
||||||
|
|
||||||
|
-- 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;
|
||||||
|
|
||||||
|
-- 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;
|
||||||
|
|
||||||
|
-- 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;
|
||||||
|
|
||||||
|
-- name: InsertTags :one
|
||||||
|
INSERT INTO p_tag (user_id, tag, created_on, modified_on, quote_num)
|
||||||
|
VALUES ($1, $2, $3, $3, 1)
|
||||||
|
RETURNING id;
|
||||||
|
|
||||||
|
-- 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(@ids::BIGINT[]) AND is_del = false AND quote_num >= 1
|
||||||
|
);
|
||||||
|
|
||||||
|
-- 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(@tags::VARCHAR[])
|
||||||
|
)
|
||||||
|
RETURNING id, user_id, tag, quote_num;
|
@ -0,0 +1,17 @@
|
|||||||
|
DROP TABLE IF EXISTS p_attachment;
|
||||||
|
DROP TABLE IF EXISTS p_captcha;
|
||||||
|
DROP TABLE IF EXISTS p_comment;
|
||||||
|
DROP TABLE IF EXISTS p_comment_content;
|
||||||
|
DROP TABLE IF EXISTS p_comment_reply;
|
||||||
|
DROP TABLE IF EXISTS p_message;
|
||||||
|
DROP TABLE IF EXISTS p_post;
|
||||||
|
DROP TABLE IF EXISTS p_post_attachment_bill;
|
||||||
|
DROP TABLE IF EXISTS p_post_collection;
|
||||||
|
DROP TABLE IF EXISTS p_post_content;
|
||||||
|
DROP TABLE IF EXISTS p_post_star;
|
||||||
|
DROP TABLE IF EXISTS p_tag;
|
||||||
|
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;
|
||||||
|
|
@ -0,0 +1 @@
|
|||||||
|
ALTER TABLE p_post DROP COLUMN visibility;
|
@ -0,0 +1 @@
|
|||||||
|
ALTER TABLE p_post ADD COLUMN visibility SMALLINT NOT NULL DEFAULT 0; -- 可见性 0公开 1私密 2好友可见
|
@ -0,0 +1,2 @@
|
|||||||
|
DROP TABLE IF EXISTS p_contact;
|
||||||
|
DROP TABLE IF EXISTS p_contact_group;
|
@ -0,0 +1,27 @@
|
|||||||
|
CREATE TABLE p_contact (
|
||||||
|
id BIGSERIAL PRIMARY KEY,
|
||||||
|
user_id BIGINT NOT NULL,
|
||||||
|
friend_id BIGINT NOT NULL,
|
||||||
|
group_id BIGINT NOT NULL DEFAULT 0, -- 好友分组ID:默认为0无分组
|
||||||
|
remark VARCHAR(32) NOT NULL DEFAULT '', -- 好友备注
|
||||||
|
status SMALLINT NOT NULL DEFAULT 0, -- 好友状态: 1请求好友, 2已好友, 3拒绝好友, 4已删好友
|
||||||
|
is_top SMALLINT NOT NULL DEFAULT 0, -- 是否置顶, 0否, 1是
|
||||||
|
is_black SMALLINT NOT NULL DEFAULT 0, -- 是否为黑名单, 0否, 1是
|
||||||
|
is_del SMALLINT NOT NULL DEFAULT 0, -- 否删除好友, 0否, 1是
|
||||||
|
notice_enable 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 UNIQUE INDEX idx_contact_user_friend ON p_contact USING btree (user_id,friend_id);
|
||||||
|
CREATE INDEX idx_contact_user_friend_status ON p_contact USING btree (user_id, friend_id, status);
|
||||||
|
|
||||||
|
CREATE TABLE p_contact_group (
|
||||||
|
id BIGSERIAL PRIMARY KEY,
|
||||||
|
user_id int NOT NULL DEFAULT 0,
|
||||||
|
name VARCHAR(32) NOT NULL DEFAULT '', -- 分组名称
|
||||||
|
is_del SMALLINT NOT NULL DEFAULT 1, -- 是否删除, 0否, 1是
|
||||||
|
created_on BIGINT NOT NULL DEFAULT 0,
|
||||||
|
modified_on BIGINT NOT NULL DEFAULT 0,
|
||||||
|
deleted_on BIGINT NOT NULL DEFAULT 0
|
||||||
|
);
|
@ -0,0 +1,290 @@
|
|||||||
|
// Code generated by sqlc. DO NOT EDIT.
|
||||||
|
// versions:
|
||||||
|
// sqlc v1.17.2
|
||||||
|
// source: topic.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
|
||||||
|
}
|
@ -0,0 +1,14 @@
|
|||||||
|
version: '2'
|
||||||
|
sql:
|
||||||
|
- schema: postgres/schema
|
||||||
|
queries: postgres/query
|
||||||
|
engine: postgresql
|
||||||
|
gen:
|
||||||
|
go:
|
||||||
|
package: dbr
|
||||||
|
out: postgres
|
||||||
|
sql_package: 'pgx/v5'
|
||||||
|
emit_prepared_queries: true
|
||||||
|
emit_interface: true
|
||||||
|
emit_result_struct_pointers: true
|
||||||
|
emit_params_struct_pointers: true
|
@ -0,0 +1,170 @@
|
|||||||
|
// Copyright 2023 ROC. All rights reserved.
|
||||||
|
// Use of this source code is governed by a MIT style
|
||||||
|
// license that can be found in the LICENSE file.
|
||||||
|
|
||||||
|
package slonik
|
||||||
|
|
||||||
|
import (
|
||||||
|
"context"
|
||||||
|
"strings"
|
||||||
|
"time"
|
||||||
|
|
||||||
|
"github.com/jackc/pgx/v5"
|
||||||
|
"github.com/rocboss/paopao-ce/internal/core"
|
||||||
|
"github.com/rocboss/paopao-ce/internal/core/cs"
|
||||||
|
dbr "github.com/rocboss/paopao-ce/internal/dao/slonik/sqlc/postgres"
|
||||||
|
)
|
||||||
|
|
||||||
|
var (
|
||||||
|
_ core.TopicService = (*topicSrv)(nil)
|
||||||
|
)
|
||||||
|
|
||||||
|
type topicSrv struct {
|
||||||
|
*pgxSrv
|
||||||
|
}
|
||||||
|
|
||||||
|
// UpsertTags update/insert tags info.
|
||||||
|
// Assume tags slice is distinct elements.
|
||||||
|
func (s *topicSrv) UpsertTags(userId int64, tags []string) (res cs.TagInfoList, err error) {
|
||||||
|
err = s.with(func(c context.Context, q dbr.Querier) error {
|
||||||
|
now := time.Now().Unix()
|
||||||
|
upTags, err := q.IncrTags(c, &dbr.IncrTagsParams{
|
||||||
|
Tags: tags,
|
||||||
|
ModifiedOn: now,
|
||||||
|
})
|
||||||
|
if err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
if len(upTags) > 0 {
|
||||||
|
for _, t := range upTags {
|
||||||
|
for i := 0; i < len(tags); {
|
||||||
|
if tags[i] == t.Tag {
|
||||||
|
latestIdx := len(tags) - 1
|
||||||
|
tags[i] = tags[latestIdx]
|
||||||
|
tags = tags[:latestIdx]
|
||||||
|
break
|
||||||
|
}
|
||||||
|
}
|
||||||
|
res = append(res, &cs.TagInfo{
|
||||||
|
ID: t.ID,
|
||||||
|
UserID: t.UserID,
|
||||||
|
Tag: t.Tag,
|
||||||
|
QuoteNum: t.QuoteNum,
|
||||||
|
})
|
||||||
|
}
|
||||||
|
}
|
||||||
|
for _, tag := range tags {
|
||||||
|
id, err := q.InsertTags(c, &dbr.InsertTagsParams{
|
||||||
|
UserID: userId,
|
||||||
|
Tag: tag,
|
||||||
|
CreatedOn: now,
|
||||||
|
})
|
||||||
|
if err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
res = append(res, &cs.TagInfo{
|
||||||
|
ID: id,
|
||||||
|
UserID: userId,
|
||||||
|
Tag: tag,
|
||||||
|
QuoteNum: 1,
|
||||||
|
})
|
||||||
|
}
|
||||||
|
return nil
|
||||||
|
})
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
func (s *topicSrv) DecrTagsById(ids []int64) error {
|
||||||
|
return s.q.DecrTagsById(context.Background(), &dbr.DecrTagsByIdParams{
|
||||||
|
Ids: ids,
|
||||||
|
ModifiedOn: time.Now().Unix(),
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
|
func (s *topicSrv) ListTags(typ cs.TagType, limit int, offset int) (res cs.TagList, _ error) {
|
||||||
|
ctx := context.Background()
|
||||||
|
switch typ {
|
||||||
|
case cs.TagTypeHot:
|
||||||
|
tags, err := s.q.HotTags(ctx, &dbr.HotTagsParams{Limit: int32(limit), Offset: int32(offset)})
|
||||||
|
if err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
for _, tag := range tags {
|
||||||
|
res = append(res, &cs.TagItem{
|
||||||
|
ID: tag.ID,
|
||||||
|
UserID: tag.UserID,
|
||||||
|
Tag: tag.Tag,
|
||||||
|
QuoteNum: tag.QuoteNum,
|
||||||
|
User: &cs.UserInfo{
|
||||||
|
ID: tag.UserID,
|
||||||
|
Nickname: tag.Nickname,
|
||||||
|
Username: tag.Username,
|
||||||
|
Status: int(tag.Status),
|
||||||
|
Avatar: tag.Avatar,
|
||||||
|
IsAdmin: tag.IsAdmin,
|
||||||
|
},
|
||||||
|
})
|
||||||
|
}
|
||||||
|
case cs.TagTypeNew:
|
||||||
|
tags, err := s.q.NewestTags(ctx, &dbr.NewestTagsParams{Limit: int32(limit), Offset: int32(offset)})
|
||||||
|
if err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
for _, tag := range tags {
|
||||||
|
res = append(res, &cs.TagItem{
|
||||||
|
ID: tag.ID,
|
||||||
|
UserID: tag.UserID,
|
||||||
|
Tag: tag.Tag,
|
||||||
|
QuoteNum: tag.QuoteNum,
|
||||||
|
User: &cs.UserInfo{
|
||||||
|
ID: tag.UserID,
|
||||||
|
Nickname: tag.Nickname,
|
||||||
|
Username: tag.Username,
|
||||||
|
Status: int(tag.Status),
|
||||||
|
Avatar: tag.Avatar,
|
||||||
|
IsAdmin: tag.IsAdmin,
|
||||||
|
},
|
||||||
|
})
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
func (s *topicSrv) TagsByKeyword(keyword string) (res cs.TagInfoList, _ error) {
|
||||||
|
ctx := context.Background()
|
||||||
|
keyword = "%" + strings.Trim(keyword, " ") + "%"
|
||||||
|
if keyword == "%%" {
|
||||||
|
tags, err := s.q.TagsByKeywordA(ctx)
|
||||||
|
if err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
for _, tag := range tags {
|
||||||
|
res = append(res, &cs.TagInfo{
|
||||||
|
ID: tag.ID,
|
||||||
|
UserID: tag.UserID,
|
||||||
|
Tag: tag.Tag,
|
||||||
|
QuoteNum: tag.QuoteNum,
|
||||||
|
})
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
tags, err := s.q.TagsByKeywordB(ctx, keyword)
|
||||||
|
if err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
for _, tag := range tags {
|
||||||
|
res = append(res, &cs.TagInfo{
|
||||||
|
ID: tag.ID,
|
||||||
|
UserID: tag.UserID,
|
||||||
|
Tag: tag.Tag,
|
||||||
|
QuoteNum: tag.QuoteNum,
|
||||||
|
})
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
func newTopicService(db *pgx.Conn) core.TopicService {
|
||||||
|
return &topicSrv{
|
||||||
|
pgxSrv: newPgxSrv(db),
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,331 @@
|
|||||||
|
// Copyright 2023 ROC. All rights reserved.
|
||||||
|
// Use of this source code is governed by a MIT style
|
||||||
|
// license that can be found in the LICENSE file.
|
||||||
|
|
||||||
|
package slonik
|
||||||
|
|
||||||
|
import (
|
||||||
|
"github.com/jackc/pgx/v5"
|
||||||
|
"github.com/rocboss/paopao-ce/internal/core"
|
||||||
|
"github.com/rocboss/paopao-ce/internal/core/cs"
|
||||||
|
"github.com/rocboss/paopao-ce/pkg/debug"
|
||||||
|
"gorm.io/gorm"
|
||||||
|
)
|
||||||
|
|
||||||
|
var (
|
||||||
|
_ core.TweetService = (*tweetSrv)(nil)
|
||||||
|
_ core.TweetManageService = (*tweetManageSrv)(nil)
|
||||||
|
_ core.TweetHelpService = (*tweetHelpSrv)(nil)
|
||||||
|
)
|
||||||
|
|
||||||
|
type tweetSrv struct {
|
||||||
|
*pgxSrv
|
||||||
|
}
|
||||||
|
|
||||||
|
type tweetManageSrv struct {
|
||||||
|
*pgxSrv
|
||||||
|
}
|
||||||
|
|
||||||
|
type tweetHelpSrv struct {
|
||||||
|
*pgxSrv
|
||||||
|
}
|
||||||
|
|
||||||
|
// MergePosts post数据整合
|
||||||
|
func (s *tweetHelpSrv) MergePosts(posts []*core.Post) ([]*core.PostFormated, error) {
|
||||||
|
// TODO
|
||||||
|
debug.NotImplemented()
|
||||||
|
return nil, nil
|
||||||
|
}
|
||||||
|
|
||||||
|
// RevampPosts post数据整形修复
|
||||||
|
func (s *tweetHelpSrv) RevampPosts(posts []*core.PostFormated) ([]*core.PostFormated, error) {
|
||||||
|
// TODO
|
||||||
|
debug.NotImplemented()
|
||||||
|
return nil, nil
|
||||||
|
}
|
||||||
|
|
||||||
|
func (s *tweetHelpSrv) RevampTweets(tweets cs.TweetList) (cs.TweetList, error) {
|
||||||
|
// TODO
|
||||||
|
return nil, debug.ErrNotImplemented
|
||||||
|
}
|
||||||
|
|
||||||
|
func (s *tweetHelpSrv) MergeTweets(tweets cs.TweetInfo) (cs.TweetList, error) {
|
||||||
|
// TODO
|
||||||
|
return nil, debug.ErrNotImplemented
|
||||||
|
}
|
||||||
|
|
||||||
|
func (s *tweetHelpSrv) getPostContentsByIDs(ids []int64) ([]*core.PostContent, error) {
|
||||||
|
// TODO
|
||||||
|
debug.NotImplemented()
|
||||||
|
return nil, nil
|
||||||
|
}
|
||||||
|
|
||||||
|
func (s *tweetHelpSrv) getUsersByIDs(ids []int64) ([]*core.User, error) {
|
||||||
|
// TODO
|
||||||
|
debug.NotImplemented()
|
||||||
|
return nil, nil
|
||||||
|
}
|
||||||
|
|
||||||
|
func (s *tweetManageSrv) CreatePostCollection(postID, userID int64) (*core.PostCollection, error) {
|
||||||
|
// TODO
|
||||||
|
debug.NotImplemented()
|
||||||
|
return nil, nil
|
||||||
|
}
|
||||||
|
|
||||||
|
func (s *tweetManageSrv) DeletePostCollection(p *core.PostCollection) error {
|
||||||
|
// TODO
|
||||||
|
debug.NotImplemented()
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
|
||||||
|
func (s *tweetManageSrv) CreatePostContent(content *core.PostContent) (*core.PostContent, error) {
|
||||||
|
// TODO
|
||||||
|
debug.NotImplemented()
|
||||||
|
return nil, nil
|
||||||
|
}
|
||||||
|
|
||||||
|
func (s *tweetManageSrv) CreatePost(post *core.Post) (*core.Post, error) {
|
||||||
|
// TODO
|
||||||
|
debug.NotImplemented()
|
||||||
|
return nil, nil
|
||||||
|
}
|
||||||
|
|
||||||
|
func (s *tweetManageSrv) DeletePost(post *core.Post) ([]string, error) {
|
||||||
|
// TODO
|
||||||
|
debug.NotImplemented()
|
||||||
|
return nil, nil
|
||||||
|
}
|
||||||
|
|
||||||
|
func (s *tweetManageSrv) deleteCommentByPostId(db *gorm.DB, postId int64) ([]string, error) {
|
||||||
|
// TODO
|
||||||
|
debug.NotImplemented()
|
||||||
|
return nil, nil
|
||||||
|
}
|
||||||
|
|
||||||
|
func (s *tweetManageSrv) LockPost(post *core.Post) error {
|
||||||
|
// TODO
|
||||||
|
debug.NotImplemented()
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
|
||||||
|
func (s *tweetManageSrv) StickPost(post *core.Post) error {
|
||||||
|
// TODO
|
||||||
|
debug.NotImplemented()
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
|
||||||
|
func (s *tweetManageSrv) VisiblePost(post *core.Post, visibility core.PostVisibleT) error {
|
||||||
|
// TODO
|
||||||
|
debug.NotImplemented()
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
|
||||||
|
func (s *tweetManageSrv) UpdatePost(post *core.Post) error {
|
||||||
|
// TODO
|
||||||
|
debug.NotImplemented()
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
|
||||||
|
func (s *tweetManageSrv) CreatePostStar(postID, userID int64) (*core.PostStar, error) {
|
||||||
|
// TODO
|
||||||
|
debug.NotImplemented()
|
||||||
|
return nil, nil
|
||||||
|
}
|
||||||
|
|
||||||
|
func (s *tweetManageSrv) DeletePostStar(p *core.PostStar) error {
|
||||||
|
// TODO
|
||||||
|
debug.NotImplemented()
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
|
||||||
|
func (s *tweetManageSrv) CreateAttachment(obj *cs.Attachment) (int64, error) {
|
||||||
|
// TODO
|
||||||
|
return 0, debug.ErrNotImplemented
|
||||||
|
}
|
||||||
|
|
||||||
|
func (s *tweetManageSrv) CreateTweet(userId int64, req *cs.NewTweetReq) (*cs.TweetItem, error) {
|
||||||
|
// TODO
|
||||||
|
return nil, debug.ErrNotImplemented
|
||||||
|
}
|
||||||
|
|
||||||
|
func (s *tweetManageSrv) DeleteTweet(userId int64, tweetId int64) ([]string, error) {
|
||||||
|
// TODO
|
||||||
|
return nil, debug.ErrNotImplemented
|
||||||
|
}
|
||||||
|
|
||||||
|
func (s *tweetManageSrv) LockTweet(userId int64, tweetId int64) error {
|
||||||
|
// TODO
|
||||||
|
return debug.ErrNotImplemented
|
||||||
|
}
|
||||||
|
|
||||||
|
func (s *tweetManageSrv) StickTweet(userId int64, tweetId int64) error {
|
||||||
|
// TODO
|
||||||
|
return debug.ErrNotImplemented
|
||||||
|
}
|
||||||
|
|
||||||
|
func (s *tweetManageSrv) VisibleTweet(userId int64, visibility cs.TweetVisibleType) error {
|
||||||
|
// TODO
|
||||||
|
return debug.ErrNotImplemented
|
||||||
|
}
|
||||||
|
|
||||||
|
func (s *tweetManageSrv) CreateReaction(userId int64, tweetId int64) error {
|
||||||
|
// TODO
|
||||||
|
return debug.ErrNotImplemented
|
||||||
|
}
|
||||||
|
|
||||||
|
func (s *tweetManageSrv) DeleteReaction(userId int64, reactionId int64) error {
|
||||||
|
// TODO
|
||||||
|
return debug.ErrNotImplemented
|
||||||
|
}
|
||||||
|
|
||||||
|
func (s *tweetManageSrv) CreateFavorite(userId int64, tweetId int64) error {
|
||||||
|
// TODO
|
||||||
|
return debug.ErrNotImplemented
|
||||||
|
}
|
||||||
|
|
||||||
|
func (s *tweetManageSrv) DeleteFavorite(userId int64, favoriteId int64) error {
|
||||||
|
// TODO
|
||||||
|
return debug.ErrNotImplemented
|
||||||
|
}
|
||||||
|
|
||||||
|
func (s *tweetSrv) GetPostByID(id int64) (*core.Post, error) {
|
||||||
|
// TODO
|
||||||
|
debug.NotImplemented()
|
||||||
|
return nil, nil
|
||||||
|
}
|
||||||
|
|
||||||
|
func (s *tweetSrv) GetPosts(conditions *core.ConditionsT, limit int, offset int) ([]*core.Post, error) {
|
||||||
|
// TODO
|
||||||
|
debug.NotImplemented()
|
||||||
|
return nil, nil
|
||||||
|
}
|
||||||
|
|
||||||
|
func (s *tweetSrv) GetPostCount(conditions *core.ConditionsT) (int64, error) {
|
||||||
|
// TODO
|
||||||
|
debug.NotImplemented()
|
||||||
|
return 0, nil
|
||||||
|
}
|
||||||
|
|
||||||
|
func (s *tweetSrv) GetUserPostStar(postID, userID int64) (*core.PostStar, error) {
|
||||||
|
// TODO
|
||||||
|
debug.NotImplemented()
|
||||||
|
return nil, nil
|
||||||
|
}
|
||||||
|
|
||||||
|
func (s *tweetSrv) GetUserPostStars(userID int64, limit int, offset int) ([]*core.PostStar, error) {
|
||||||
|
// TODO
|
||||||
|
debug.NotImplemented()
|
||||||
|
return nil, nil
|
||||||
|
}
|
||||||
|
|
||||||
|
func (s *tweetSrv) GetUserPostStarCount(userID int64) (int64, error) {
|
||||||
|
// TODO
|
||||||
|
debug.NotImplemented()
|
||||||
|
return 0, nil
|
||||||
|
}
|
||||||
|
|
||||||
|
func (s *tweetSrv) GetUserPostCollection(postID, userID int64) (*core.PostCollection, error) {
|
||||||
|
// TODO
|
||||||
|
debug.NotImplemented()
|
||||||
|
return nil, nil
|
||||||
|
}
|
||||||
|
|
||||||
|
func (s *tweetSrv) GetUserPostCollections(userID int64, limit int, offset int) ([]*core.PostCollection, error) {
|
||||||
|
// TODO
|
||||||
|
debug.NotImplemented()
|
||||||
|
return nil, nil
|
||||||
|
}
|
||||||
|
|
||||||
|
func (s *tweetSrv) GetUserPostCollectionCount(userID int64) (int64, error) {
|
||||||
|
// TODO
|
||||||
|
debug.NotImplemented()
|
||||||
|
return 0, nil
|
||||||
|
}
|
||||||
|
|
||||||
|
func (s *tweetSrv) GetUserWalletBills(userID int64, limit int, offset int) ([]*core.WalletStatement, error) {
|
||||||
|
// TODO
|
||||||
|
debug.NotImplemented()
|
||||||
|
return nil, nil
|
||||||
|
}
|
||||||
|
|
||||||
|
func (s *tweetSrv) GetUserWalletBillCount(userID int64) (int64, error) {
|
||||||
|
// TODO
|
||||||
|
debug.NotImplemented()
|
||||||
|
return 0, nil
|
||||||
|
}
|
||||||
|
|
||||||
|
func (s *tweetSrv) GetPostAttatchmentBill(postID, userID int64) (*core.PostAttachmentBill, error) {
|
||||||
|
// TODO
|
||||||
|
debug.NotImplemented()
|
||||||
|
return nil, nil
|
||||||
|
}
|
||||||
|
|
||||||
|
func (s *tweetSrv) GetPostContentsByIDs(ids []int64) ([]*core.PostContent, error) {
|
||||||
|
// TODO
|
||||||
|
debug.NotImplemented()
|
||||||
|
return nil, nil
|
||||||
|
}
|
||||||
|
|
||||||
|
func (s *tweetSrv) GetPostContentByID(id int64) (*core.PostContent, error) {
|
||||||
|
// TODO
|
||||||
|
debug.NotImplemented()
|
||||||
|
return nil, nil
|
||||||
|
}
|
||||||
|
|
||||||
|
func (s *tweetSrv) TweetInfoById(id int64) (*cs.TweetInfo, error) {
|
||||||
|
// TODO
|
||||||
|
return nil, debug.ErrNotImplemented
|
||||||
|
}
|
||||||
|
|
||||||
|
func (s *tweetSrv) TweetItemById(id int64) (*cs.TweetItem, error) {
|
||||||
|
// TODO
|
||||||
|
return nil, debug.ErrNotImplemented
|
||||||
|
}
|
||||||
|
|
||||||
|
func (s *tweetSrv) UserTweets(visitorId, userId int64) (cs.TweetList, error) {
|
||||||
|
// TODO
|
||||||
|
return nil, debug.ErrNotImplemented
|
||||||
|
}
|
||||||
|
|
||||||
|
func (s *tweetSrv) ReactionByTweetId(userId int64, tweetId int64) (*cs.ReactionItem, error) {
|
||||||
|
// TODO
|
||||||
|
return nil, debug.ErrNotImplemented
|
||||||
|
}
|
||||||
|
|
||||||
|
func (s *tweetSrv) UserReactions(userId int64, limit int, offset int) (cs.ReactionList, error) {
|
||||||
|
// TODO
|
||||||
|
return nil, debug.ErrNotImplemented
|
||||||
|
}
|
||||||
|
|
||||||
|
func (s *tweetSrv) FavoriteByTweetId(userId int64, tweetId int64) (*cs.FavoriteItem, error) {
|
||||||
|
// TODO
|
||||||
|
return nil, debug.ErrNotImplemented
|
||||||
|
}
|
||||||
|
|
||||||
|
func (s *tweetSrv) UserFavorites(userId int64, limit int, offset int) (cs.FavoriteList, error) {
|
||||||
|
// TODO
|
||||||
|
return nil, debug.ErrNotImplemented
|
||||||
|
}
|
||||||
|
|
||||||
|
func (s *tweetSrv) AttachmentByTweetId(userId int64, tweetId int64) (*cs.AttachmentBill, error) {
|
||||||
|
// TODO
|
||||||
|
return nil, debug.ErrNotImplemented
|
||||||
|
}
|
||||||
|
|
||||||
|
func newTweetService(db *pgx.Conn) core.TweetService {
|
||||||
|
return &tweetSrv{
|
||||||
|
pgxSrv: newPgxSrv(db),
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
func newTweetManageService(db *pgx.Conn, cacheIndex core.CacheIndexService) core.TweetManageService {
|
||||||
|
return &tweetManageSrv{
|
||||||
|
pgxSrv: newPgxSrv(db),
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
func newTweetHelpService(db *pgx.Conn) core.TweetHelpService {
|
||||||
|
return &tweetHelpSrv{
|
||||||
|
pgxSrv: newPgxSrv(db),
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,67 @@
|
|||||||
|
// Copyright 2023 ROC. All rights reserved.
|
||||||
|
// Use of this source code is governed by a MIT style
|
||||||
|
// license that can be found in the LICENSE file.
|
||||||
|
|
||||||
|
package slonik
|
||||||
|
|
||||||
|
import (
|
||||||
|
"github.com/jackc/pgx/v5"
|
||||||
|
"github.com/rocboss/paopao-ce/internal/core"
|
||||||
|
"github.com/rocboss/paopao-ce/pkg/debug"
|
||||||
|
)
|
||||||
|
|
||||||
|
var (
|
||||||
|
_ core.UserManageService = (*userManageSrv)(nil)
|
||||||
|
)
|
||||||
|
|
||||||
|
type userManageSrv struct {
|
||||||
|
*pgxSrv
|
||||||
|
}
|
||||||
|
|
||||||
|
func (s *userManageSrv) GetUserByID(id int64) (*core.User, error) {
|
||||||
|
// TODO
|
||||||
|
debug.NotImplemented()
|
||||||
|
return nil, nil
|
||||||
|
}
|
||||||
|
|
||||||
|
func (s *userManageSrv) GetUserByUsername(username string) (*core.User, error) {
|
||||||
|
// TODO
|
||||||
|
debug.NotImplemented()
|
||||||
|
return nil, nil
|
||||||
|
}
|
||||||
|
|
||||||
|
func (s *userManageSrv) GetUserByPhone(phone string) (*core.User, error) {
|
||||||
|
// TODO
|
||||||
|
debug.NotImplemented()
|
||||||
|
return nil, nil
|
||||||
|
}
|
||||||
|
|
||||||
|
func (s *userManageSrv) GetUsersByIDs(ids []int64) ([]*core.User, error) {
|
||||||
|
// TODO
|
||||||
|
debug.NotImplemented()
|
||||||
|
return nil, nil
|
||||||
|
}
|
||||||
|
|
||||||
|
func (s *userManageSrv) GetUsersByKeyword(keyword string) ([]*core.User, error) {
|
||||||
|
// TODO
|
||||||
|
debug.NotImplemented()
|
||||||
|
return nil, nil
|
||||||
|
}
|
||||||
|
|
||||||
|
func (s *userManageSrv) CreateUser(user *core.User) (*core.User, error) {
|
||||||
|
// TODO
|
||||||
|
debug.NotImplemented()
|
||||||
|
return nil, nil
|
||||||
|
}
|
||||||
|
|
||||||
|
func (s *userManageSrv) UpdateUser(user *core.User) error {
|
||||||
|
// TODO
|
||||||
|
debug.NotImplemented()
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
|
||||||
|
func newUserManageService(db *pgx.Conn) core.UserManageService {
|
||||||
|
return &userManageSrv{
|
||||||
|
pgxSrv: newPgxSrv(db),
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,60 @@
|
|||||||
|
// Copyright 2023 ROC. All rights reserved.
|
||||||
|
// Use of this source code is governed by a MIT style
|
||||||
|
// license that can be found in the LICENSE file.
|
||||||
|
|
||||||
|
package slonik
|
||||||
|
|
||||||
|
import (
|
||||||
|
"github.com/jackc/pgx/v5"
|
||||||
|
"github.com/rocboss/paopao-ce/internal/core"
|
||||||
|
"github.com/rocboss/paopao-ce/pkg/debug"
|
||||||
|
)
|
||||||
|
|
||||||
|
var (
|
||||||
|
_ core.WalletService = (*walletSrv)(nil)
|
||||||
|
)
|
||||||
|
|
||||||
|
type walletSrv struct {
|
||||||
|
*pgxSrv
|
||||||
|
}
|
||||||
|
|
||||||
|
func (s *walletSrv) GetRechargeByID(id int64) (*core.WalletRecharge, error) {
|
||||||
|
// TODO
|
||||||
|
debug.NotImplemented()
|
||||||
|
return nil, nil
|
||||||
|
}
|
||||||
|
func (s *walletSrv) CreateRecharge(userId, amount int64) (*core.WalletRecharge, error) {
|
||||||
|
// TODO
|
||||||
|
debug.NotImplemented()
|
||||||
|
return nil, nil
|
||||||
|
}
|
||||||
|
|
||||||
|
func (s *walletSrv) GetUserWalletBills(userID int64, offset, limit int) ([]*core.WalletStatement, error) {
|
||||||
|
// TODO
|
||||||
|
debug.NotImplemented()
|
||||||
|
return nil, nil
|
||||||
|
}
|
||||||
|
|
||||||
|
func (s *walletSrv) GetUserWalletBillCount(userID int64) (int64, error) {
|
||||||
|
// TODO
|
||||||
|
debug.NotImplemented()
|
||||||
|
return 0, nil
|
||||||
|
}
|
||||||
|
|
||||||
|
func (s *walletSrv) HandleRechargeSuccess(recharge *core.WalletRecharge, tradeNo string) error {
|
||||||
|
// TODO
|
||||||
|
debug.NotImplemented()
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
|
||||||
|
func (s *walletSrv) HandlePostAttachmentBought(post *core.Post, user *core.User) error {
|
||||||
|
// TODO
|
||||||
|
debug.NotImplemented()
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
|
||||||
|
func newWalletService(db *pgx.Conn) core.WalletService {
|
||||||
|
return &walletSrv{
|
||||||
|
pgxSrv: newPgxSrv(db),
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,18 @@
|
|||||||
|
// Copyright 2023 ROC. All rights reserved.
|
||||||
|
// Use of this source code is governed by a MIT style
|
||||||
|
// license that can be found in the LICENSE file.
|
||||||
|
|
||||||
|
package types
|
||||||
|
|
||||||
|
import (
|
||||||
|
"github.com/jackc/pgx/v5/pgtype"
|
||||||
|
)
|
||||||
|
|
||||||
|
// PgxArray returns an object usable by pg drivers for passing a []T slice
|
||||||
|
// into a database as type T[].
|
||||||
|
func PgxArray[T any](elements []T) pgtype.Array[T] {
|
||||||
|
return pgtype.Array[T]{
|
||||||
|
Elements: elements,
|
||||||
|
Dims: []pgtype.ArrayDimension{{Length: int32(len(elements)), LowerBound: 1}},
|
||||||
|
}
|
||||||
|
}
|
Loading…
Reference in new issue