mirror of https://github.com/rocboss/paopao-ce
parent
74ce4e5b10
commit
41f3cedc8d
@ -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,58 @@
|
|||||||
|
// 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"
|
||||||
|
dbr "github.com/rocboss/paopao-ce/internal/dao/slonik/ce/postgres"
|
||||||
|
"github.com/rocboss/paopao-ce/pkg/debug"
|
||||||
|
)
|
||||||
|
|
||||||
|
var (
|
||||||
|
_ core.AuthorizationManageService = (*authorizationManageServant)(nil)
|
||||||
|
)
|
||||||
|
|
||||||
|
type authorizationManageServant struct {
|
||||||
|
db *pgx.Conn
|
||||||
|
q dbr.Querier
|
||||||
|
}
|
||||||
|
|
||||||
|
func (s *authorizationManageServant) IsAllow(user *core.User, action *core.Action) bool {
|
||||||
|
// TODO
|
||||||
|
debug.NotImplemented()
|
||||||
|
return false
|
||||||
|
}
|
||||||
|
|
||||||
|
func (s *authorizationManageServant) MyFriendSet(userId int64) core.FriendSet {
|
||||||
|
// TODO
|
||||||
|
debug.NotImplemented()
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
|
||||||
|
func (s *authorizationManageServant) BeFriendFilter(userId int64) core.FriendFilter {
|
||||||
|
// TODO
|
||||||
|
debug.NotImplemented()
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
|
||||||
|
func (s *authorizationManageServant) BeFriendIds(userId int64) ([]int64, error) {
|
||||||
|
// TODO
|
||||||
|
debug.NotImplemented()
|
||||||
|
return nil, nil
|
||||||
|
}
|
||||||
|
|
||||||
|
func (s *authorizationManageServant) isFriend(userId int64, friendId int64) bool {
|
||||||
|
// TODO
|
||||||
|
debug.NotImplemented()
|
||||||
|
return false
|
||||||
|
}
|
||||||
|
|
||||||
|
func newAuthorizationManageService(db *pgx.Conn) core.AuthorizationManageService {
|
||||||
|
return &authorizationManageServant{
|
||||||
|
db: db,
|
||||||
|
q: dbr.New(db),
|
||||||
|
}
|
||||||
|
}
|
@ -1,3 +1,7 @@
|
|||||||
|
// 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 ce
|
package ce
|
||||||
|
|
||||||
//go:generate sqlc generate -x
|
//go:generate sqlc generate -x
|
||||||
|
@ -1,88 +0,0 @@
|
|||||||
// Code generated by sqlc. DO NOT EDIT.
|
|
||||||
// versions:
|
|
||||||
// sqlc v1.16.0
|
|
||||||
// source: city.sql
|
|
||||||
|
|
||||||
package dbr
|
|
||||||
|
|
||||||
import (
|
|
||||||
"context"
|
|
||||||
)
|
|
||||||
|
|
||||||
const createCity = `-- name: CreateCity :exec
|
|
||||||
INSERT INTO city (
|
|
||||||
name,
|
|
||||||
slug
|
|
||||||
) VALUES (
|
|
||||||
?,
|
|
||||||
?
|
|
||||||
)
|
|
||||||
`
|
|
||||||
|
|
||||||
type CreateCityParams struct {
|
|
||||||
Name string
|
|
||||||
Slug string
|
|
||||||
}
|
|
||||||
|
|
||||||
func (q *Queries) CreateCity(ctx context.Context, arg CreateCityParams) error {
|
|
||||||
_, err := q.exec(ctx, q.createCityStmt, createCity, arg.Name, arg.Slug)
|
|
||||||
return err
|
|
||||||
}
|
|
||||||
|
|
||||||
const getCity = `-- name: GetCity :one
|
|
||||||
SELECT slug, name
|
|
||||||
FROM city
|
|
||||||
WHERE slug = ?
|
|
||||||
`
|
|
||||||
|
|
||||||
func (q *Queries) GetCity(ctx context.Context, slug string) (City, error) {
|
|
||||||
row := q.queryRow(ctx, q.getCityStmt, getCity, slug)
|
|
||||||
var i City
|
|
||||||
err := row.Scan(&i.Slug, &i.Name)
|
|
||||||
return i, err
|
|
||||||
}
|
|
||||||
|
|
||||||
const listCities = `-- name: ListCities :many
|
|
||||||
SELECT slug, name
|
|
||||||
FROM city
|
|
||||||
ORDER BY name
|
|
||||||
`
|
|
||||||
|
|
||||||
func (q *Queries) ListCities(ctx context.Context) ([]City, error) {
|
|
||||||
rows, err := q.query(ctx, q.listCitiesStmt, listCities)
|
|
||||||
if err != nil {
|
|
||||||
return nil, err
|
|
||||||
}
|
|
||||||
defer rows.Close()
|
|
||||||
var items []City
|
|
||||||
for rows.Next() {
|
|
||||||
var i City
|
|
||||||
if err := rows.Scan(&i.Slug, &i.Name); err != nil {
|
|
||||||
return nil, err
|
|
||||||
}
|
|
||||||
items = append(items, i)
|
|
||||||
}
|
|
||||||
if err := rows.Close(); err != nil {
|
|
||||||
return nil, err
|
|
||||||
}
|
|
||||||
if err := rows.Err(); err != nil {
|
|
||||||
return nil, err
|
|
||||||
}
|
|
||||||
return items, nil
|
|
||||||
}
|
|
||||||
|
|
||||||
const updateCityName = `-- name: UpdateCityName :exec
|
|
||||||
UPDATE city
|
|
||||||
SET name = ?
|
|
||||||
WHERE slug = ?
|
|
||||||
`
|
|
||||||
|
|
||||||
type UpdateCityNameParams struct {
|
|
||||||
Name string
|
|
||||||
Slug string
|
|
||||||
}
|
|
||||||
|
|
||||||
func (q *Queries) UpdateCityName(ctx context.Context, arg UpdateCityNameParams) error {
|
|
||||||
_, err := q.exec(ctx, q.updateCityNameStmt, updateCityName, arg.Name, arg.Slug)
|
|
||||||
return err
|
|
||||||
}
|
|
@ -1,178 +0,0 @@
|
|||||||
// Code generated by sqlc. DO NOT EDIT.
|
|
||||||
// versions:
|
|
||||||
// sqlc v1.16.0
|
|
||||||
|
|
||||||
package dbr
|
|
||||||
|
|
||||||
import (
|
|
||||||
"context"
|
|
||||||
"database/sql"
|
|
||||||
"fmt"
|
|
||||||
)
|
|
||||||
|
|
||||||
type DBTX interface {
|
|
||||||
ExecContext(context.Context, string, ...interface{}) (sql.Result, error)
|
|
||||||
PrepareContext(context.Context, string) (*sql.Stmt, error)
|
|
||||||
QueryContext(context.Context, string, ...interface{}) (*sql.Rows, error)
|
|
||||||
QueryRowContext(context.Context, string, ...interface{}) *sql.Row
|
|
||||||
}
|
|
||||||
|
|
||||||
func New(db DBTX) *Queries {
|
|
||||||
return &Queries{db: db}
|
|
||||||
}
|
|
||||||
|
|
||||||
func Prepare(ctx context.Context, db DBTX) (*Queries, error) {
|
|
||||||
q := Queries{db: db}
|
|
||||||
var err error
|
|
||||||
if q.createCityStmt, err = db.PrepareContext(ctx, createCity); err != nil {
|
|
||||||
return nil, fmt.Errorf("error preparing query CreateCity: %w", err)
|
|
||||||
}
|
|
||||||
if q.createVenueStmt, err = db.PrepareContext(ctx, createVenue); err != nil {
|
|
||||||
return nil, fmt.Errorf("error preparing query CreateVenue: %w", err)
|
|
||||||
}
|
|
||||||
if q.deleteVenueStmt, err = db.PrepareContext(ctx, deleteVenue); err != nil {
|
|
||||||
return nil, fmt.Errorf("error preparing query DeleteVenue: %w", err)
|
|
||||||
}
|
|
||||||
if q.getCityStmt, err = db.PrepareContext(ctx, getCity); err != nil {
|
|
||||||
return nil, fmt.Errorf("error preparing query GetCity: %w", err)
|
|
||||||
}
|
|
||||||
if q.getVenueStmt, err = db.PrepareContext(ctx, getVenue); err != nil {
|
|
||||||
return nil, fmt.Errorf("error preparing query GetVenue: %w", err)
|
|
||||||
}
|
|
||||||
if q.listCitiesStmt, err = db.PrepareContext(ctx, listCities); err != nil {
|
|
||||||
return nil, fmt.Errorf("error preparing query ListCities: %w", err)
|
|
||||||
}
|
|
||||||
if q.listVenuesStmt, err = db.PrepareContext(ctx, listVenues); err != nil {
|
|
||||||
return nil, fmt.Errorf("error preparing query ListVenues: %w", err)
|
|
||||||
}
|
|
||||||
if q.updateCityNameStmt, err = db.PrepareContext(ctx, updateCityName); err != nil {
|
|
||||||
return nil, fmt.Errorf("error preparing query UpdateCityName: %w", err)
|
|
||||||
}
|
|
||||||
if q.updateVenueNameStmt, err = db.PrepareContext(ctx, updateVenueName); err != nil {
|
|
||||||
return nil, fmt.Errorf("error preparing query UpdateVenueName: %w", err)
|
|
||||||
}
|
|
||||||
if q.venueCountByCityStmt, err = db.PrepareContext(ctx, venueCountByCity); err != nil {
|
|
||||||
return nil, fmt.Errorf("error preparing query VenueCountByCity: %w", err)
|
|
||||||
}
|
|
||||||
return &q, nil
|
|
||||||
}
|
|
||||||
|
|
||||||
func (q *Queries) Close() error {
|
|
||||||
var err error
|
|
||||||
if q.createCityStmt != nil {
|
|
||||||
if cerr := q.createCityStmt.Close(); cerr != nil {
|
|
||||||
err = fmt.Errorf("error closing createCityStmt: %w", cerr)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if q.createVenueStmt != nil {
|
|
||||||
if cerr := q.createVenueStmt.Close(); cerr != nil {
|
|
||||||
err = fmt.Errorf("error closing createVenueStmt: %w", cerr)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if q.deleteVenueStmt != nil {
|
|
||||||
if cerr := q.deleteVenueStmt.Close(); cerr != nil {
|
|
||||||
err = fmt.Errorf("error closing deleteVenueStmt: %w", cerr)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if q.getCityStmt != nil {
|
|
||||||
if cerr := q.getCityStmt.Close(); cerr != nil {
|
|
||||||
err = fmt.Errorf("error closing getCityStmt: %w", cerr)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if q.getVenueStmt != nil {
|
|
||||||
if cerr := q.getVenueStmt.Close(); cerr != nil {
|
|
||||||
err = fmt.Errorf("error closing getVenueStmt: %w", cerr)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if q.listCitiesStmt != nil {
|
|
||||||
if cerr := q.listCitiesStmt.Close(); cerr != nil {
|
|
||||||
err = fmt.Errorf("error closing listCitiesStmt: %w", cerr)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if q.listVenuesStmt != nil {
|
|
||||||
if cerr := q.listVenuesStmt.Close(); cerr != nil {
|
|
||||||
err = fmt.Errorf("error closing listVenuesStmt: %w", cerr)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if q.updateCityNameStmt != nil {
|
|
||||||
if cerr := q.updateCityNameStmt.Close(); cerr != nil {
|
|
||||||
err = fmt.Errorf("error closing updateCityNameStmt: %w", cerr)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if q.updateVenueNameStmt != nil {
|
|
||||||
if cerr := q.updateVenueNameStmt.Close(); cerr != nil {
|
|
||||||
err = fmt.Errorf("error closing updateVenueNameStmt: %w", cerr)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if q.venueCountByCityStmt != nil {
|
|
||||||
if cerr := q.venueCountByCityStmt.Close(); cerr != nil {
|
|
||||||
err = fmt.Errorf("error closing venueCountByCityStmt: %w", cerr)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return err
|
|
||||||
}
|
|
||||||
|
|
||||||
func (q *Queries) exec(ctx context.Context, stmt *sql.Stmt, query string, args ...interface{}) (sql.Result, error) {
|
|
||||||
switch {
|
|
||||||
case stmt != nil && q.tx != nil:
|
|
||||||
return q.tx.StmtContext(ctx, stmt).ExecContext(ctx, args...)
|
|
||||||
case stmt != nil:
|
|
||||||
return stmt.ExecContext(ctx, args...)
|
|
||||||
default:
|
|
||||||
return q.db.ExecContext(ctx, query, args...)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
func (q *Queries) query(ctx context.Context, stmt *sql.Stmt, query string, args ...interface{}) (*sql.Rows, error) {
|
|
||||||
switch {
|
|
||||||
case stmt != nil && q.tx != nil:
|
|
||||||
return q.tx.StmtContext(ctx, stmt).QueryContext(ctx, args...)
|
|
||||||
case stmt != nil:
|
|
||||||
return stmt.QueryContext(ctx, args...)
|
|
||||||
default:
|
|
||||||
return q.db.QueryContext(ctx, query, args...)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
func (q *Queries) queryRow(ctx context.Context, stmt *sql.Stmt, query string, args ...interface{}) *sql.Row {
|
|
||||||
switch {
|
|
||||||
case stmt != nil && q.tx != nil:
|
|
||||||
return q.tx.StmtContext(ctx, stmt).QueryRowContext(ctx, args...)
|
|
||||||
case stmt != nil:
|
|
||||||
return stmt.QueryRowContext(ctx, args...)
|
|
||||||
default:
|
|
||||||
return q.db.QueryRowContext(ctx, query, args...)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
type Queries struct {
|
|
||||||
db DBTX
|
|
||||||
tx *sql.Tx
|
|
||||||
createCityStmt *sql.Stmt
|
|
||||||
createVenueStmt *sql.Stmt
|
|
||||||
deleteVenueStmt *sql.Stmt
|
|
||||||
getCityStmt *sql.Stmt
|
|
||||||
getVenueStmt *sql.Stmt
|
|
||||||
listCitiesStmt *sql.Stmt
|
|
||||||
listVenuesStmt *sql.Stmt
|
|
||||||
updateCityNameStmt *sql.Stmt
|
|
||||||
updateVenueNameStmt *sql.Stmt
|
|
||||||
venueCountByCityStmt *sql.Stmt
|
|
||||||
}
|
|
||||||
|
|
||||||
func (q *Queries) WithTx(tx *sql.Tx) *Queries {
|
|
||||||
return &Queries{
|
|
||||||
db: tx,
|
|
||||||
tx: tx,
|
|
||||||
createCityStmt: q.createCityStmt,
|
|
||||||
createVenueStmt: q.createVenueStmt,
|
|
||||||
deleteVenueStmt: q.deleteVenueStmt,
|
|
||||||
getCityStmt: q.getCityStmt,
|
|
||||||
getVenueStmt: q.getVenueStmt,
|
|
||||||
listCitiesStmt: q.listCitiesStmt,
|
|
||||||
listVenuesStmt: q.listVenuesStmt,
|
|
||||||
updateCityNameStmt: q.updateCityNameStmt,
|
|
||||||
updateVenueNameStmt: q.updateVenueNameStmt,
|
|
||||||
venueCountByCityStmt: q.venueCountByCityStmt,
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,75 +0,0 @@
|
|||||||
// Code generated by sqlc. DO NOT EDIT.
|
|
||||||
// versions:
|
|
||||||
// sqlc v1.16.0
|
|
||||||
|
|
||||||
package dbr
|
|
||||||
|
|
||||||
import (
|
|
||||||
"database/sql"
|
|
||||||
"database/sql/driver"
|
|
||||||
"fmt"
|
|
||||||
"time"
|
|
||||||
)
|
|
||||||
|
|
||||||
type VenuesStatus string
|
|
||||||
|
|
||||||
const (
|
|
||||||
VenuesStatusOpen VenuesStatus = "open"
|
|
||||||
VenuesStatusClosed VenuesStatus = "closed"
|
|
||||||
)
|
|
||||||
|
|
||||||
func (e *VenuesStatus) Scan(src interface{}) error {
|
|
||||||
switch s := src.(type) {
|
|
||||||
case []byte:
|
|
||||||
*e = VenuesStatus(s)
|
|
||||||
case string:
|
|
||||||
*e = VenuesStatus(s)
|
|
||||||
default:
|
|
||||||
return fmt.Errorf("unsupported scan type for VenuesStatus: %T", src)
|
|
||||||
}
|
|
||||||
return nil
|
|
||||||
}
|
|
||||||
|
|
||||||
type NullVenuesStatus struct {
|
|
||||||
VenuesStatus VenuesStatus
|
|
||||||
Valid bool // Valid is true if VenuesStatus is not NULL
|
|
||||||
}
|
|
||||||
|
|
||||||
// Scan implements the Scanner interface.
|
|
||||||
func (ns *NullVenuesStatus) Scan(value interface{}) error {
|
|
||||||
if value == nil {
|
|
||||||
ns.VenuesStatus, ns.Valid = "", false
|
|
||||||
return nil
|
|
||||||
}
|
|
||||||
ns.Valid = true
|
|
||||||
return ns.VenuesStatus.Scan(value)
|
|
||||||
}
|
|
||||||
|
|
||||||
// Value implements the driver Valuer interface.
|
|
||||||
func (ns NullVenuesStatus) Value() (driver.Value, error) {
|
|
||||||
if !ns.Valid {
|
|
||||||
return nil, nil
|
|
||||||
}
|
|
||||||
return string(ns.VenuesStatus), nil
|
|
||||||
}
|
|
||||||
|
|
||||||
type City struct {
|
|
||||||
Slug string
|
|
||||||
Name string
|
|
||||||
}
|
|
||||||
|
|
||||||
// Venues are places where muisc happens
|
|
||||||
type Venue struct {
|
|
||||||
ID int64
|
|
||||||
// Venues can be either open or closed
|
|
||||||
Status VenuesStatus
|
|
||||||
Statuses sql.NullString
|
|
||||||
// This value appears in public URLs
|
|
||||||
Slug string
|
|
||||||
Name string
|
|
||||||
City string
|
|
||||||
SpotifyPlaylist string
|
|
||||||
SongkickID sql.NullString
|
|
||||||
Tags sql.NullString
|
|
||||||
CreatedAt time.Time
|
|
||||||
}
|
|
@ -1,25 +0,0 @@
|
|||||||
// Code generated by sqlc. DO NOT EDIT.
|
|
||||||
// versions:
|
|
||||||
// sqlc v1.16.0
|
|
||||||
|
|
||||||
package dbr
|
|
||||||
|
|
||||||
import (
|
|
||||||
"context"
|
|
||||||
"database/sql"
|
|
||||||
)
|
|
||||||
|
|
||||||
type Querier interface {
|
|
||||||
CreateCity(ctx context.Context, arg CreateCityParams) error
|
|
||||||
CreateVenue(ctx context.Context, arg CreateVenueParams) (sql.Result, error)
|
|
||||||
DeleteVenue(ctx context.Context, arg DeleteVenueParams) error
|
|
||||||
GetCity(ctx context.Context, slug string) (City, error)
|
|
||||||
GetVenue(ctx context.Context, arg GetVenueParams) (Venue, error)
|
|
||||||
ListCities(ctx context.Context) ([]City, error)
|
|
||||||
ListVenues(ctx context.Context, city string) ([]Venue, error)
|
|
||||||
UpdateCityName(ctx context.Context, arg UpdateCityNameParams) error
|
|
||||||
UpdateVenueName(ctx context.Context, arg UpdateVenueNameParams) error
|
|
||||||
VenueCountByCity(ctx context.Context) ([]VenueCountByCityRow, error)
|
|
||||||
}
|
|
||||||
|
|
||||||
var _ Querier = (*Queries)(nil)
|
|
@ -1,23 +0,0 @@
|
|||||||
/* name: ListCities :many */
|
|
||||||
SELECT *
|
|
||||||
FROM city
|
|
||||||
ORDER BY name;
|
|
||||||
|
|
||||||
/* name: GetCity :one */
|
|
||||||
SELECT *
|
|
||||||
FROM city
|
|
||||||
WHERE slug = ?;
|
|
||||||
|
|
||||||
/* name: CreateCity :exec */
|
|
||||||
INSERT INTO city (
|
|
||||||
name,
|
|
||||||
slug
|
|
||||||
) VALUES (
|
|
||||||
?,
|
|
||||||
?
|
|
||||||
);
|
|
||||||
|
|
||||||
/* name: UpdateCityName :exec */
|
|
||||||
UPDATE city
|
|
||||||
SET name = ?
|
|
||||||
WHERE slug = ?;
|
|
@ -1,48 +0,0 @@
|
|||||||
/* name: ListVenues :many */
|
|
||||||
SELECT *
|
|
||||||
FROM venue
|
|
||||||
WHERE city = ?
|
|
||||||
ORDER BY name;
|
|
||||||
|
|
||||||
/* name: DeleteVenue :exec */
|
|
||||||
DELETE FROM venue
|
|
||||||
WHERE slug = ? AND slug = ?;
|
|
||||||
|
|
||||||
/* name: GetVenue :one */
|
|
||||||
SELECT *
|
|
||||||
FROM venue
|
|
||||||
WHERE slug = ? AND city = ?;
|
|
||||||
|
|
||||||
/* name: CreateVenue :execresult */
|
|
||||||
INSERT INTO venue (
|
|
||||||
slug,
|
|
||||||
name,
|
|
||||||
city,
|
|
||||||
created_at,
|
|
||||||
spotify_playlist,
|
|
||||||
status,
|
|
||||||
statuses,
|
|
||||||
tags
|
|
||||||
) VALUES (
|
|
||||||
?,
|
|
||||||
?,
|
|
||||||
?,
|
|
||||||
NOW(),
|
|
||||||
?,
|
|
||||||
?,
|
|
||||||
?,
|
|
||||||
?
|
|
||||||
);
|
|
||||||
|
|
||||||
/* name: UpdateVenueName :exec */
|
|
||||||
UPDATE venue
|
|
||||||
SET name = ?
|
|
||||||
WHERE slug = ?;
|
|
||||||
|
|
||||||
/* name: VenueCountByCity :many */
|
|
||||||
SELECT
|
|
||||||
city,
|
|
||||||
count(*)
|
|
||||||
FROM venue
|
|
||||||
GROUP BY 1
|
|
||||||
ORDER BY 1;
|
|
@ -1,4 +0,0 @@
|
|||||||
CREATE TABLE city (
|
|
||||||
slug varchar(255) PRIMARY KEY,
|
|
||||||
name text NOT NULL
|
|
||||||
)
|
|
@ -1,12 +0,0 @@
|
|||||||
CREATE TABLE venues (
|
|
||||||
id SERIAL primary key,
|
|
||||||
dropped text,
|
|
||||||
status ENUM('open', 'closed') not null COMMENT 'Venues can be either open or closed',
|
|
||||||
statuses text, -- status[],
|
|
||||||
slug text not null COMMENT 'This value appears in public URLs',
|
|
||||||
name varchar(255) not null,
|
|
||||||
city text not null references city(slug),
|
|
||||||
spotify_playlist varchar(255) not null,
|
|
||||||
songkick_id text,
|
|
||||||
tags text -- text[]
|
|
||||||
) COMMENT='Venues are places where muisc happens';
|
|
@ -1,3 +0,0 @@
|
|||||||
ALTER TABLE venues RENAME TO venue;
|
|
||||||
ALTER TABLE venue ADD COLUMN created_at TIMESTAMP NOT NULL DEFAULT NOW();
|
|
||||||
ALTER TABLE venue DROP COLUMN dropped;
|
|
@ -1,193 +0,0 @@
|
|||||||
// Code generated by sqlc. DO NOT EDIT.
|
|
||||||
// versions:
|
|
||||||
// sqlc v1.16.0
|
|
||||||
// source: venue.sql
|
|
||||||
|
|
||||||
package dbr
|
|
||||||
|
|
||||||
import (
|
|
||||||
"context"
|
|
||||||
"database/sql"
|
|
||||||
)
|
|
||||||
|
|
||||||
const createVenue = `-- name: CreateVenue :execresult
|
|
||||||
INSERT INTO venue (
|
|
||||||
slug,
|
|
||||||
name,
|
|
||||||
city,
|
|
||||||
created_at,
|
|
||||||
spotify_playlist,
|
|
||||||
status,
|
|
||||||
statuses,
|
|
||||||
tags
|
|
||||||
) VALUES (
|
|
||||||
?,
|
|
||||||
?,
|
|
||||||
?,
|
|
||||||
NOW(),
|
|
||||||
?,
|
|
||||||
?,
|
|
||||||
?,
|
|
||||||
?
|
|
||||||
)
|
|
||||||
`
|
|
||||||
|
|
||||||
type CreateVenueParams struct {
|
|
||||||
Slug string
|
|
||||||
Name string
|
|
||||||
City string
|
|
||||||
SpotifyPlaylist string
|
|
||||||
Status VenuesStatus
|
|
||||||
Statuses sql.NullString
|
|
||||||
Tags sql.NullString
|
|
||||||
}
|
|
||||||
|
|
||||||
func (q *Queries) CreateVenue(ctx context.Context, arg CreateVenueParams) (sql.Result, error) {
|
|
||||||
return q.exec(ctx, q.createVenueStmt, createVenue,
|
|
||||||
arg.Slug,
|
|
||||||
arg.Name,
|
|
||||||
arg.City,
|
|
||||||
arg.SpotifyPlaylist,
|
|
||||||
arg.Status,
|
|
||||||
arg.Statuses,
|
|
||||||
arg.Tags,
|
|
||||||
)
|
|
||||||
}
|
|
||||||
|
|
||||||
const deleteVenue = `-- name: DeleteVenue :exec
|
|
||||||
DELETE FROM venue
|
|
||||||
WHERE slug = ? AND slug = ?
|
|
||||||
`
|
|
||||||
|
|
||||||
type DeleteVenueParams struct {
|
|
||||||
Slug string
|
|
||||||
Slug_2 string
|
|
||||||
}
|
|
||||||
|
|
||||||
func (q *Queries) DeleteVenue(ctx context.Context, arg DeleteVenueParams) error {
|
|
||||||
_, err := q.exec(ctx, q.deleteVenueStmt, deleteVenue, arg.Slug, arg.Slug_2)
|
|
||||||
return err
|
|
||||||
}
|
|
||||||
|
|
||||||
const getVenue = `-- name: GetVenue :one
|
|
||||||
SELECT id, status, statuses, slug, name, city, spotify_playlist, songkick_id, tags, created_at
|
|
||||||
FROM venue
|
|
||||||
WHERE slug = ? AND city = ?
|
|
||||||
`
|
|
||||||
|
|
||||||
type GetVenueParams struct {
|
|
||||||
Slug string
|
|
||||||
City string
|
|
||||||
}
|
|
||||||
|
|
||||||
func (q *Queries) GetVenue(ctx context.Context, arg GetVenueParams) (Venue, error) {
|
|
||||||
row := q.queryRow(ctx, q.getVenueStmt, getVenue, arg.Slug, arg.City)
|
|
||||||
var i Venue
|
|
||||||
err := row.Scan(
|
|
||||||
&i.ID,
|
|
||||||
&i.Status,
|
|
||||||
&i.Statuses,
|
|
||||||
&i.Slug,
|
|
||||||
&i.Name,
|
|
||||||
&i.City,
|
|
||||||
&i.SpotifyPlaylist,
|
|
||||||
&i.SongkickID,
|
|
||||||
&i.Tags,
|
|
||||||
&i.CreatedAt,
|
|
||||||
)
|
|
||||||
return i, err
|
|
||||||
}
|
|
||||||
|
|
||||||
const listVenues = `-- name: ListVenues :many
|
|
||||||
SELECT id, status, statuses, slug, name, city, spotify_playlist, songkick_id, tags, created_at
|
|
||||||
FROM venue
|
|
||||||
WHERE city = ?
|
|
||||||
ORDER BY name
|
|
||||||
`
|
|
||||||
|
|
||||||
func (q *Queries) ListVenues(ctx context.Context, city string) ([]Venue, error) {
|
|
||||||
rows, err := q.query(ctx, q.listVenuesStmt, listVenues, city)
|
|
||||||
if err != nil {
|
|
||||||
return nil, err
|
|
||||||
}
|
|
||||||
defer rows.Close()
|
|
||||||
var items []Venue
|
|
||||||
for rows.Next() {
|
|
||||||
var i Venue
|
|
||||||
if err := rows.Scan(
|
|
||||||
&i.ID,
|
|
||||||
&i.Status,
|
|
||||||
&i.Statuses,
|
|
||||||
&i.Slug,
|
|
||||||
&i.Name,
|
|
||||||
&i.City,
|
|
||||||
&i.SpotifyPlaylist,
|
|
||||||
&i.SongkickID,
|
|
||||||
&i.Tags,
|
|
||||||
&i.CreatedAt,
|
|
||||||
); err != nil {
|
|
||||||
return nil, err
|
|
||||||
}
|
|
||||||
items = append(items, i)
|
|
||||||
}
|
|
||||||
if err := rows.Close(); err != nil {
|
|
||||||
return nil, err
|
|
||||||
}
|
|
||||||
if err := rows.Err(); err != nil {
|
|
||||||
return nil, err
|
|
||||||
}
|
|
||||||
return items, nil
|
|
||||||
}
|
|
||||||
|
|
||||||
const updateVenueName = `-- name: UpdateVenueName :exec
|
|
||||||
UPDATE venue
|
|
||||||
SET name = ?
|
|
||||||
WHERE slug = ?
|
|
||||||
`
|
|
||||||
|
|
||||||
type UpdateVenueNameParams struct {
|
|
||||||
Name string
|
|
||||||
Slug string
|
|
||||||
}
|
|
||||||
|
|
||||||
func (q *Queries) UpdateVenueName(ctx context.Context, arg UpdateVenueNameParams) error {
|
|
||||||
_, err := q.exec(ctx, q.updateVenueNameStmt, updateVenueName, arg.Name, arg.Slug)
|
|
||||||
return err
|
|
||||||
}
|
|
||||||
|
|
||||||
const venueCountByCity = `-- name: VenueCountByCity :many
|
|
||||||
SELECT
|
|
||||||
city,
|
|
||||||
count(*)
|
|
||||||
FROM venue
|
|
||||||
GROUP BY 1
|
|
||||||
ORDER BY 1
|
|
||||||
`
|
|
||||||
|
|
||||||
type VenueCountByCityRow struct {
|
|
||||||
City string
|
|
||||||
Count int64
|
|
||||||
}
|
|
||||||
|
|
||||||
func (q *Queries) VenueCountByCity(ctx context.Context) ([]VenueCountByCityRow, error) {
|
|
||||||
rows, err := q.query(ctx, q.venueCountByCityStmt, venueCountByCity)
|
|
||||||
if err != nil {
|
|
||||||
return nil, err
|
|
||||||
}
|
|
||||||
defer rows.Close()
|
|
||||||
var items []VenueCountByCityRow
|
|
||||||
for rows.Next() {
|
|
||||||
var i VenueCountByCityRow
|
|
||||||
if err := rows.Scan(&i.City, &i.Count); err != nil {
|
|
||||||
return nil, err
|
|
||||||
}
|
|
||||||
items = append(items, i)
|
|
||||||
}
|
|
||||||
if err := rows.Close(); err != nil {
|
|
||||||
return nil, err
|
|
||||||
}
|
|
||||||
if err := rows.Err(); err != nil {
|
|
||||||
return nil, err
|
|
||||||
}
|
|
||||||
return items, nil
|
|
||||||
}
|
|
@ -1,88 +0,0 @@
|
|||||||
// Code generated by sqlc. DO NOT EDIT.
|
|
||||||
// versions:
|
|
||||||
// sqlc v1.16.0
|
|
||||||
// source: city.sql
|
|
||||||
|
|
||||||
package dbr
|
|
||||||
|
|
||||||
import (
|
|
||||||
"context"
|
|
||||||
)
|
|
||||||
|
|
||||||
const createCity = `-- name: CreateCity :exec
|
|
||||||
INSERT INTO city (
|
|
||||||
name,
|
|
||||||
slug
|
|
||||||
) VALUES (
|
|
||||||
?,
|
|
||||||
?
|
|
||||||
)
|
|
||||||
`
|
|
||||||
|
|
||||||
type CreateCityParams struct {
|
|
||||||
Name string
|
|
||||||
Slug string
|
|
||||||
}
|
|
||||||
|
|
||||||
func (q *Queries) CreateCity(ctx context.Context, arg CreateCityParams) error {
|
|
||||||
_, err := q.exec(ctx, q.createCityStmt, createCity, arg.Name, arg.Slug)
|
|
||||||
return err
|
|
||||||
}
|
|
||||||
|
|
||||||
const getCity = `-- name: GetCity :one
|
|
||||||
SELECT slug, name
|
|
||||||
FROM city
|
|
||||||
WHERE slug = ?
|
|
||||||
`
|
|
||||||
|
|
||||||
func (q *Queries) GetCity(ctx context.Context, slug string) (City, error) {
|
|
||||||
row := q.queryRow(ctx, q.getCityStmt, getCity, slug)
|
|
||||||
var i City
|
|
||||||
err := row.Scan(&i.Slug, &i.Name)
|
|
||||||
return i, err
|
|
||||||
}
|
|
||||||
|
|
||||||
const listCities = `-- name: ListCities :many
|
|
||||||
SELECT slug, name
|
|
||||||
FROM city
|
|
||||||
ORDER BY name
|
|
||||||
`
|
|
||||||
|
|
||||||
func (q *Queries) ListCities(ctx context.Context) ([]City, error) {
|
|
||||||
rows, err := q.query(ctx, q.listCitiesStmt, listCities)
|
|
||||||
if err != nil {
|
|
||||||
return nil, err
|
|
||||||
}
|
|
||||||
defer rows.Close()
|
|
||||||
var items []City
|
|
||||||
for rows.Next() {
|
|
||||||
var i City
|
|
||||||
if err := rows.Scan(&i.Slug, &i.Name); err != nil {
|
|
||||||
return nil, err
|
|
||||||
}
|
|
||||||
items = append(items, i)
|
|
||||||
}
|
|
||||||
if err := rows.Close(); err != nil {
|
|
||||||
return nil, err
|
|
||||||
}
|
|
||||||
if err := rows.Err(); err != nil {
|
|
||||||
return nil, err
|
|
||||||
}
|
|
||||||
return items, nil
|
|
||||||
}
|
|
||||||
|
|
||||||
const updateCityName = `-- name: UpdateCityName :exec
|
|
||||||
UPDATE city
|
|
||||||
SET name = ?
|
|
||||||
WHERE slug = ?
|
|
||||||
`
|
|
||||||
|
|
||||||
type UpdateCityNameParams struct {
|
|
||||||
Name string
|
|
||||||
Slug string
|
|
||||||
}
|
|
||||||
|
|
||||||
func (q *Queries) UpdateCityName(ctx context.Context, arg UpdateCityNameParams) error {
|
|
||||||
_, err := q.exec(ctx, q.updateCityNameStmt, updateCityName, arg.Name, arg.Slug)
|
|
||||||
return err
|
|
||||||
}
|
|
@ -1,178 +0,0 @@
|
|||||||
// Code generated by sqlc. DO NOT EDIT.
|
|
||||||
// versions:
|
|
||||||
// sqlc v1.16.0
|
|
||||||
|
|
||||||
package dbr
|
|
||||||
|
|
||||||
import (
|
|
||||||
"context"
|
|
||||||
"database/sql"
|
|
||||||
"fmt"
|
|
||||||
)
|
|
||||||
|
|
||||||
type DBTX interface {
|
|
||||||
ExecContext(context.Context, string, ...interface{}) (sql.Result, error)
|
|
||||||
PrepareContext(context.Context, string) (*sql.Stmt, error)
|
|
||||||
QueryContext(context.Context, string, ...interface{}) (*sql.Rows, error)
|
|
||||||
QueryRowContext(context.Context, string, ...interface{}) *sql.Row
|
|
||||||
}
|
|
||||||
|
|
||||||
func New(db DBTX) *Queries {
|
|
||||||
return &Queries{db: db}
|
|
||||||
}
|
|
||||||
|
|
||||||
func Prepare(ctx context.Context, db DBTX) (*Queries, error) {
|
|
||||||
q := Queries{db: db}
|
|
||||||
var err error
|
|
||||||
if q.createCityStmt, err = db.PrepareContext(ctx, createCity); err != nil {
|
|
||||||
return nil, fmt.Errorf("error preparing query CreateCity: %w", err)
|
|
||||||
}
|
|
||||||
if q.createVenueStmt, err = db.PrepareContext(ctx, createVenue); err != nil {
|
|
||||||
return nil, fmt.Errorf("error preparing query CreateVenue: %w", err)
|
|
||||||
}
|
|
||||||
if q.deleteVenueStmt, err = db.PrepareContext(ctx, deleteVenue); err != nil {
|
|
||||||
return nil, fmt.Errorf("error preparing query DeleteVenue: %w", err)
|
|
||||||
}
|
|
||||||
if q.getCityStmt, err = db.PrepareContext(ctx, getCity); err != nil {
|
|
||||||
return nil, fmt.Errorf("error preparing query GetCity: %w", err)
|
|
||||||
}
|
|
||||||
if q.getVenueStmt, err = db.PrepareContext(ctx, getVenue); err != nil {
|
|
||||||
return nil, fmt.Errorf("error preparing query GetVenue: %w", err)
|
|
||||||
}
|
|
||||||
if q.listCitiesStmt, err = db.PrepareContext(ctx, listCities); err != nil {
|
|
||||||
return nil, fmt.Errorf("error preparing query ListCities: %w", err)
|
|
||||||
}
|
|
||||||
if q.listVenuesStmt, err = db.PrepareContext(ctx, listVenues); err != nil {
|
|
||||||
return nil, fmt.Errorf("error preparing query ListVenues: %w", err)
|
|
||||||
}
|
|
||||||
if q.updateCityNameStmt, err = db.PrepareContext(ctx, updateCityName); err != nil {
|
|
||||||
return nil, fmt.Errorf("error preparing query UpdateCityName: %w", err)
|
|
||||||
}
|
|
||||||
if q.updateVenueNameStmt, err = db.PrepareContext(ctx, updateVenueName); err != nil {
|
|
||||||
return nil, fmt.Errorf("error preparing query UpdateVenueName: %w", err)
|
|
||||||
}
|
|
||||||
if q.venueCountByCityStmt, err = db.PrepareContext(ctx, venueCountByCity); err != nil {
|
|
||||||
return nil, fmt.Errorf("error preparing query VenueCountByCity: %w", err)
|
|
||||||
}
|
|
||||||
return &q, nil
|
|
||||||
}
|
|
||||||
|
|
||||||
func (q *Queries) Close() error {
|
|
||||||
var err error
|
|
||||||
if q.createCityStmt != nil {
|
|
||||||
if cerr := q.createCityStmt.Close(); cerr != nil {
|
|
||||||
err = fmt.Errorf("error closing createCityStmt: %w", cerr)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if q.createVenueStmt != nil {
|
|
||||||
if cerr := q.createVenueStmt.Close(); cerr != nil {
|
|
||||||
err = fmt.Errorf("error closing createVenueStmt: %w", cerr)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if q.deleteVenueStmt != nil {
|
|
||||||
if cerr := q.deleteVenueStmt.Close(); cerr != nil {
|
|
||||||
err = fmt.Errorf("error closing deleteVenueStmt: %w", cerr)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if q.getCityStmt != nil {
|
|
||||||
if cerr := q.getCityStmt.Close(); cerr != nil {
|
|
||||||
err = fmt.Errorf("error closing getCityStmt: %w", cerr)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if q.getVenueStmt != nil {
|
|
||||||
if cerr := q.getVenueStmt.Close(); cerr != nil {
|
|
||||||
err = fmt.Errorf("error closing getVenueStmt: %w", cerr)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if q.listCitiesStmt != nil {
|
|
||||||
if cerr := q.listCitiesStmt.Close(); cerr != nil {
|
|
||||||
err = fmt.Errorf("error closing listCitiesStmt: %w", cerr)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if q.listVenuesStmt != nil {
|
|
||||||
if cerr := q.listVenuesStmt.Close(); cerr != nil {
|
|
||||||
err = fmt.Errorf("error closing listVenuesStmt: %w", cerr)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if q.updateCityNameStmt != nil {
|
|
||||||
if cerr := q.updateCityNameStmt.Close(); cerr != nil {
|
|
||||||
err = fmt.Errorf("error closing updateCityNameStmt: %w", cerr)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if q.updateVenueNameStmt != nil {
|
|
||||||
if cerr := q.updateVenueNameStmt.Close(); cerr != nil {
|
|
||||||
err = fmt.Errorf("error closing updateVenueNameStmt: %w", cerr)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if q.venueCountByCityStmt != nil {
|
|
||||||
if cerr := q.venueCountByCityStmt.Close(); cerr != nil {
|
|
||||||
err = fmt.Errorf("error closing venueCountByCityStmt: %w", cerr)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return err
|
|
||||||
}
|
|
||||||
|
|
||||||
func (q *Queries) exec(ctx context.Context, stmt *sql.Stmt, query string, args ...interface{}) (sql.Result, error) {
|
|
||||||
switch {
|
|
||||||
case stmt != nil && q.tx != nil:
|
|
||||||
return q.tx.StmtContext(ctx, stmt).ExecContext(ctx, args...)
|
|
||||||
case stmt != nil:
|
|
||||||
return stmt.ExecContext(ctx, args...)
|
|
||||||
default:
|
|
||||||
return q.db.ExecContext(ctx, query, args...)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
func (q *Queries) query(ctx context.Context, stmt *sql.Stmt, query string, args ...interface{}) (*sql.Rows, error) {
|
|
||||||
switch {
|
|
||||||
case stmt != nil && q.tx != nil:
|
|
||||||
return q.tx.StmtContext(ctx, stmt).QueryContext(ctx, args...)
|
|
||||||
case stmt != nil:
|
|
||||||
return stmt.QueryContext(ctx, args...)
|
|
||||||
default:
|
|
||||||
return q.db.QueryContext(ctx, query, args...)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
func (q *Queries) queryRow(ctx context.Context, stmt *sql.Stmt, query string, args ...interface{}) *sql.Row {
|
|
||||||
switch {
|
|
||||||
case stmt != nil && q.tx != nil:
|
|
||||||
return q.tx.StmtContext(ctx, stmt).QueryRowContext(ctx, args...)
|
|
||||||
case stmt != nil:
|
|
||||||
return stmt.QueryRowContext(ctx, args...)
|
|
||||||
default:
|
|
||||||
return q.db.QueryRowContext(ctx, query, args...)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
type Queries struct {
|
|
||||||
db DBTX
|
|
||||||
tx *sql.Tx
|
|
||||||
createCityStmt *sql.Stmt
|
|
||||||
createVenueStmt *sql.Stmt
|
|
||||||
deleteVenueStmt *sql.Stmt
|
|
||||||
getCityStmt *sql.Stmt
|
|
||||||
getVenueStmt *sql.Stmt
|
|
||||||
listCitiesStmt *sql.Stmt
|
|
||||||
listVenuesStmt *sql.Stmt
|
|
||||||
updateCityNameStmt *sql.Stmt
|
|
||||||
updateVenueNameStmt *sql.Stmt
|
|
||||||
venueCountByCityStmt *sql.Stmt
|
|
||||||
}
|
|
||||||
|
|
||||||
func (q *Queries) WithTx(tx *sql.Tx) *Queries {
|
|
||||||
return &Queries{
|
|
||||||
db: tx,
|
|
||||||
tx: tx,
|
|
||||||
createCityStmt: q.createCityStmt,
|
|
||||||
createVenueStmt: q.createVenueStmt,
|
|
||||||
deleteVenueStmt: q.deleteVenueStmt,
|
|
||||||
getCityStmt: q.getCityStmt,
|
|
||||||
getVenueStmt: q.getVenueStmt,
|
|
||||||
listCitiesStmt: q.listCitiesStmt,
|
|
||||||
listVenuesStmt: q.listVenuesStmt,
|
|
||||||
updateCityNameStmt: q.updateCityNameStmt,
|
|
||||||
updateVenueNameStmt: q.updateVenueNameStmt,
|
|
||||||
venueCountByCityStmt: q.venueCountByCityStmt,
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,28 +0,0 @@
|
|||||||
// Code generated by sqlc. DO NOT EDIT.
|
|
||||||
// versions:
|
|
||||||
// sqlc v1.16.0
|
|
||||||
|
|
||||||
package dbr
|
|
||||||
|
|
||||||
import (
|
|
||||||
"database/sql"
|
|
||||||
"time"
|
|
||||||
)
|
|
||||||
|
|
||||||
type City struct {
|
|
||||||
Slug string
|
|
||||||
Name string
|
|
||||||
}
|
|
||||||
|
|
||||||
type Venue struct {
|
|
||||||
ID int64
|
|
||||||
Status string
|
|
||||||
Statuses sql.NullString
|
|
||||||
Slug string
|
|
||||||
Name string
|
|
||||||
City string
|
|
||||||
SpotifyPlaylist string
|
|
||||||
SongkickID sql.NullString
|
|
||||||
Tags sql.NullString
|
|
||||||
CreatedAt time.Time
|
|
||||||
}
|
|
@ -1,25 +0,0 @@
|
|||||||
// Code generated by sqlc. DO NOT EDIT.
|
|
||||||
// versions:
|
|
||||||
// sqlc v1.16.0
|
|
||||||
|
|
||||||
package dbr
|
|
||||||
|
|
||||||
import (
|
|
||||||
"context"
|
|
||||||
"database/sql"
|
|
||||||
)
|
|
||||||
|
|
||||||
type Querier interface {
|
|
||||||
CreateCity(ctx context.Context, arg CreateCityParams) error
|
|
||||||
CreateVenue(ctx context.Context, arg CreateVenueParams) (sql.Result, error)
|
|
||||||
DeleteVenue(ctx context.Context, arg DeleteVenueParams) error
|
|
||||||
GetCity(ctx context.Context, slug string) (City, error)
|
|
||||||
GetVenue(ctx context.Context, arg GetVenueParams) (Venue, error)
|
|
||||||
ListCities(ctx context.Context) ([]City, error)
|
|
||||||
ListVenues(ctx context.Context, city string) ([]Venue, error)
|
|
||||||
UpdateCityName(ctx context.Context, arg UpdateCityNameParams) error
|
|
||||||
UpdateVenueName(ctx context.Context, arg UpdateVenueNameParams) error
|
|
||||||
VenueCountByCity(ctx context.Context) ([]VenueCountByCityRow, error)
|
|
||||||
}
|
|
||||||
|
|
||||||
var _ Querier = (*Queries)(nil)
|
|
@ -1,23 +0,0 @@
|
|||||||
/* name: ListCities :many */
|
|
||||||
SELECT *
|
|
||||||
FROM city
|
|
||||||
ORDER BY name;
|
|
||||||
|
|
||||||
/* name: GetCity :one */
|
|
||||||
SELECT *
|
|
||||||
FROM city
|
|
||||||
WHERE slug = ?;
|
|
||||||
|
|
||||||
/* name: CreateCity :exec */
|
|
||||||
INSERT INTO city (
|
|
||||||
name,
|
|
||||||
slug
|
|
||||||
) VALUES (
|
|
||||||
?,
|
|
||||||
?
|
|
||||||
);
|
|
||||||
|
|
||||||
/* name: UpdateCityName :exec */
|
|
||||||
UPDATE city
|
|
||||||
SET name = ?
|
|
||||||
WHERE slug = ?;
|
|
@ -1,48 +0,0 @@
|
|||||||
/* name: ListVenues :many */
|
|
||||||
SELECT *
|
|
||||||
FROM venue
|
|
||||||
WHERE city = ?
|
|
||||||
ORDER BY name;
|
|
||||||
|
|
||||||
/* name: DeleteVenue :exec */
|
|
||||||
DELETE FROM venue
|
|
||||||
WHERE slug = ? AND slug = ?;
|
|
||||||
|
|
||||||
/* name: GetVenue :one */
|
|
||||||
SELECT *
|
|
||||||
FROM venue
|
|
||||||
WHERE slug = ? AND city = ?;
|
|
||||||
|
|
||||||
/* name: CreateVenue :execresult */
|
|
||||||
INSERT INTO venue (
|
|
||||||
slug,
|
|
||||||
name,
|
|
||||||
city,
|
|
||||||
created_at,
|
|
||||||
spotify_playlist,
|
|
||||||
status,
|
|
||||||
statuses,
|
|
||||||
tags
|
|
||||||
) VALUES (
|
|
||||||
?,
|
|
||||||
?,
|
|
||||||
?,
|
|
||||||
CURRENT_TIMESTAMP,
|
|
||||||
?,
|
|
||||||
?,
|
|
||||||
?,
|
|
||||||
?
|
|
||||||
);
|
|
||||||
|
|
||||||
/* name: UpdateVenueName :exec */
|
|
||||||
UPDATE venue
|
|
||||||
SET name = ?
|
|
||||||
WHERE slug = ?;
|
|
||||||
|
|
||||||
/* name: VenueCountByCity :many */
|
|
||||||
SELECT
|
|
||||||
city,
|
|
||||||
count(*)
|
|
||||||
FROM venue
|
|
||||||
GROUP BY 1
|
|
||||||
ORDER BY 1;
|
|
@ -1,4 +0,0 @@
|
|||||||
CREATE TABLE city (
|
|
||||||
slug varchar(255) PRIMARY KEY,
|
|
||||||
name text NOT NULL
|
|
||||||
)
|
|
@ -1,13 +0,0 @@
|
|||||||
CREATE TABLE venues (
|
|
||||||
id integer primary key AUTOINCREMENT,
|
|
||||||
dropped text,
|
|
||||||
status text not null,
|
|
||||||
statuses text, -- status[]
|
|
||||||
slug text not null,
|
|
||||||
name varchar(255) not null,
|
|
||||||
city text not null references city(slug),
|
|
||||||
spotify_playlist varchar(255) not null,
|
|
||||||
songkick_id text,
|
|
||||||
tags text, -- tags[]
|
|
||||||
CHECK (status = 'open' OR status = 'closed')
|
|
||||||
);
|
|
@ -1,3 +0,0 @@
|
|||||||
ALTER TABLE venues RENAME TO venue;
|
|
||||||
ALTER TABLE venue ADD COLUMN created_at DATETIME NOT NULL DEFAULT CURRENT_TIMESTAMP;
|
|
||||||
ALTER TABLE venue DROP COLUMN dropped;
|
|
@ -1,193 +0,0 @@
|
|||||||
// Code generated by sqlc. DO NOT EDIT.
|
|
||||||
// versions:
|
|
||||||
// sqlc v1.16.0
|
|
||||||
// source: venue.sql
|
|
||||||
|
|
||||||
package dbr
|
|
||||||
|
|
||||||
import (
|
|
||||||
"context"
|
|
||||||
"database/sql"
|
|
||||||
)
|
|
||||||
|
|
||||||
const createVenue = `-- name: CreateVenue :execresult
|
|
||||||
INSERT INTO venue (
|
|
||||||
slug,
|
|
||||||
name,
|
|
||||||
city,
|
|
||||||
created_at,
|
|
||||||
spotify_playlist,
|
|
||||||
status,
|
|
||||||
statuses,
|
|
||||||
tags
|
|
||||||
) VALUES (
|
|
||||||
?,
|
|
||||||
?,
|
|
||||||
?,
|
|
||||||
CURRENT_TIMESTAMP,
|
|
||||||
?,
|
|
||||||
?,
|
|
||||||
?,
|
|
||||||
?
|
|
||||||
)
|
|
||||||
`
|
|
||||||
|
|
||||||
type CreateVenueParams struct {
|
|
||||||
Slug string
|
|
||||||
Name string
|
|
||||||
City string
|
|
||||||
SpotifyPlaylist string
|
|
||||||
Status string
|
|
||||||
Statuses sql.NullString
|
|
||||||
Tags sql.NullString
|
|
||||||
}
|
|
||||||
|
|
||||||
func (q *Queries) CreateVenue(ctx context.Context, arg CreateVenueParams) (sql.Result, error) {
|
|
||||||
return q.exec(ctx, q.createVenueStmt, createVenue,
|
|
||||||
arg.Slug,
|
|
||||||
arg.Name,
|
|
||||||
arg.City,
|
|
||||||
arg.SpotifyPlaylist,
|
|
||||||
arg.Status,
|
|
||||||
arg.Statuses,
|
|
||||||
arg.Tags,
|
|
||||||
)
|
|
||||||
}
|
|
||||||
|
|
||||||
const deleteVenue = `-- name: DeleteVenue :exec
|
|
||||||
DELETE FROM venue
|
|
||||||
WHERE slug = ? AND slug = ?
|
|
||||||
`
|
|
||||||
|
|
||||||
type DeleteVenueParams struct {
|
|
||||||
Slug string
|
|
||||||
Slug_2 string
|
|
||||||
}
|
|
||||||
|
|
||||||
func (q *Queries) DeleteVenue(ctx context.Context, arg DeleteVenueParams) error {
|
|
||||||
_, err := q.exec(ctx, q.deleteVenueStmt, deleteVenue, arg.Slug, arg.Slug_2)
|
|
||||||
return err
|
|
||||||
}
|
|
||||||
|
|
||||||
const getVenue = `-- name: GetVenue :one
|
|
||||||
SELECT id, status, statuses, slug, name, city, spotify_playlist, songkick_id, tags, created_at
|
|
||||||
FROM venue
|
|
||||||
WHERE slug = ? AND city = ?
|
|
||||||
`
|
|
||||||
|
|
||||||
type GetVenueParams struct {
|
|
||||||
Slug string
|
|
||||||
City string
|
|
||||||
}
|
|
||||||
|
|
||||||
func (q *Queries) GetVenue(ctx context.Context, arg GetVenueParams) (Venue, error) {
|
|
||||||
row := q.queryRow(ctx, q.getVenueStmt, getVenue, arg.Slug, arg.City)
|
|
||||||
var i Venue
|
|
||||||
err := row.Scan(
|
|
||||||
&i.ID,
|
|
||||||
&i.Status,
|
|
||||||
&i.Statuses,
|
|
||||||
&i.Slug,
|
|
||||||
&i.Name,
|
|
||||||
&i.City,
|
|
||||||
&i.SpotifyPlaylist,
|
|
||||||
&i.SongkickID,
|
|
||||||
&i.Tags,
|
|
||||||
&i.CreatedAt,
|
|
||||||
)
|
|
||||||
return i, err
|
|
||||||
}
|
|
||||||
|
|
||||||
const listVenues = `-- name: ListVenues :many
|
|
||||||
SELECT id, status, statuses, slug, name, city, spotify_playlist, songkick_id, tags, created_at
|
|
||||||
FROM venue
|
|
||||||
WHERE city = ?
|
|
||||||
ORDER BY name
|
|
||||||
`
|
|
||||||
|
|
||||||
func (q *Queries) ListVenues(ctx context.Context, city string) ([]Venue, error) {
|
|
||||||
rows, err := q.query(ctx, q.listVenuesStmt, listVenues, city)
|
|
||||||
if err != nil {
|
|
||||||
return nil, err
|
|
||||||
}
|
|
||||||
defer rows.Close()
|
|
||||||
var items []Venue
|
|
||||||
for rows.Next() {
|
|
||||||
var i Venue
|
|
||||||
if err := rows.Scan(
|
|
||||||
&i.ID,
|
|
||||||
&i.Status,
|
|
||||||
&i.Statuses,
|
|
||||||
&i.Slug,
|
|
||||||
&i.Name,
|
|
||||||
&i.City,
|
|
||||||
&i.SpotifyPlaylist,
|
|
||||||
&i.SongkickID,
|
|
||||||
&i.Tags,
|
|
||||||
&i.CreatedAt,
|
|
||||||
); err != nil {
|
|
||||||
return nil, err
|
|
||||||
}
|
|
||||||
items = append(items, i)
|
|
||||||
}
|
|
||||||
if err := rows.Close(); err != nil {
|
|
||||||
return nil, err
|
|
||||||
}
|
|
||||||
if err := rows.Err(); err != nil {
|
|
||||||
return nil, err
|
|
||||||
}
|
|
||||||
return items, nil
|
|
||||||
}
|
|
||||||
|
|
||||||
const updateVenueName = `-- name: UpdateVenueName :exec
|
|
||||||
UPDATE venue
|
|
||||||
SET name = ?
|
|
||||||
WHERE slug = ?
|
|
||||||
`
|
|
||||||
|
|
||||||
type UpdateVenueNameParams struct {
|
|
||||||
Name string
|
|
||||||
Slug string
|
|
||||||
}
|
|
||||||
|
|
||||||
func (q *Queries) UpdateVenueName(ctx context.Context, arg UpdateVenueNameParams) error {
|
|
||||||
_, err := q.exec(ctx, q.updateVenueNameStmt, updateVenueName, arg.Name, arg.Slug)
|
|
||||||
return err
|
|
||||||
}
|
|
||||||
|
|
||||||
const venueCountByCity = `-- name: VenueCountByCity :many
|
|
||||||
SELECT
|
|
||||||
city,
|
|
||||||
count(*)
|
|
||||||
FROM venue
|
|
||||||
GROUP BY 1
|
|
||||||
ORDER BY 1
|
|
||||||
`
|
|
||||||
|
|
||||||
type VenueCountByCityRow struct {
|
|
||||||
City string
|
|
||||||
Count int64
|
|
||||||
}
|
|
||||||
|
|
||||||
func (q *Queries) VenueCountByCity(ctx context.Context) ([]VenueCountByCityRow, error) {
|
|
||||||
rows, err := q.query(ctx, q.venueCountByCityStmt, venueCountByCity)
|
|
||||||
if err != nil {
|
|
||||||
return nil, err
|
|
||||||
}
|
|
||||||
defer rows.Close()
|
|
||||||
var items []VenueCountByCityRow
|
|
||||||
for rows.Next() {
|
|
||||||
var i VenueCountByCityRow
|
|
||||||
if err := rows.Scan(&i.City, &i.Count); err != nil {
|
|
||||||
return nil, err
|
|
||||||
}
|
|
||||||
items = append(items, i)
|
|
||||||
}
|
|
||||||
if err := rows.Close(); err != nil {
|
|
||||||
return nil, err
|
|
||||||
}
|
|
||||||
if err := rows.Err(); err != nil {
|
|
||||||
return nil, err
|
|
||||||
}
|
|
||||||
return items, nil
|
|
||||||
}
|
|
@ -0,0 +1,107 @@
|
|||||||
|
// 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"
|
||||||
|
dbr "github.com/rocboss/paopao-ce/internal/dao/slonik/ce/postgres"
|
||||||
|
"github.com/rocboss/paopao-ce/pkg/debug"
|
||||||
|
)
|
||||||
|
|
||||||
|
var (
|
||||||
|
_ core.CommentService = (*commentServant)(nil)
|
||||||
|
_ core.CommentManageService = (*commentManageServant)(nil)
|
||||||
|
)
|
||||||
|
|
||||||
|
type commentServant struct {
|
||||||
|
db *pgx.Conn
|
||||||
|
q dbr.Querier
|
||||||
|
}
|
||||||
|
|
||||||
|
type commentManageServant struct {
|
||||||
|
db *pgx.Conn
|
||||||
|
q dbr.Querier
|
||||||
|
}
|
||||||
|
|
||||||
|
func (s *commentServant) GetComments(conditions *core.ConditionsT, offset, limit int) ([]*core.Comment, error) {
|
||||||
|
// TODO
|
||||||
|
debug.NotImplemented()
|
||||||
|
return nil, nil
|
||||||
|
}
|
||||||
|
|
||||||
|
func (s *commentServant) GetCommentByID(id int64) (*core.Comment, error) {
|
||||||
|
// TODO
|
||||||
|
debug.NotImplemented()
|
||||||
|
return nil, nil
|
||||||
|
}
|
||||||
|
|
||||||
|
func (s *commentServant) GetCommentReplyByID(id int64) (*core.CommentReply, error) {
|
||||||
|
// TODO
|
||||||
|
debug.NotImplemented()
|
||||||
|
return nil, nil
|
||||||
|
}
|
||||||
|
|
||||||
|
func (s *commentServant) GetCommentCount(conditions *core.ConditionsT) (int64, error) {
|
||||||
|
// TODO
|
||||||
|
debug.NotImplemented()
|
||||||
|
return 0, nil
|
||||||
|
}
|
||||||
|
|
||||||
|
func (s *commentServant) GetCommentContentsByIDs(ids []int64) ([]*core.CommentContent, error) {
|
||||||
|
// TODO
|
||||||
|
debug.NotImplemented()
|
||||||
|
return nil, nil
|
||||||
|
}
|
||||||
|
|
||||||
|
func (s *commentServant) GetCommentRepliesByID(ids []int64) ([]*core.CommentReplyFormated, error) {
|
||||||
|
// TODO
|
||||||
|
debug.NotImplemented()
|
||||||
|
return nil, nil
|
||||||
|
}
|
||||||
|
|
||||||
|
func (s *commentManageServant) DeleteComment(comment *core.Comment) error {
|
||||||
|
// TODO
|
||||||
|
debug.NotImplemented()
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
|
||||||
|
func (s *commentManageServant) CreateComment(comment *core.Comment) (*core.Comment, error) {
|
||||||
|
// TODO
|
||||||
|
debug.NotImplemented()
|
||||||
|
return nil, nil
|
||||||
|
}
|
||||||
|
|
||||||
|
func (s *commentManageServant) CreateCommentReply(reply *core.CommentReply) (*core.CommentReply, error) {
|
||||||
|
// TODO
|
||||||
|
debug.NotImplemented()
|
||||||
|
return nil, nil
|
||||||
|
}
|
||||||
|
|
||||||
|
func (s *commentManageServant) DeleteCommentReply(reply *core.CommentReply) error {
|
||||||
|
// TODO
|
||||||
|
debug.NotImplemented()
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
|
||||||
|
func (s *commentManageServant) CreateCommentContent(content *core.CommentContent) (*core.CommentContent, error) {
|
||||||
|
// TODO
|
||||||
|
debug.NotImplemented()
|
||||||
|
return nil, nil
|
||||||
|
}
|
||||||
|
|
||||||
|
func newCommentService(db *pgx.Conn) core.CommentService {
|
||||||
|
return &commentServant{
|
||||||
|
db: db,
|
||||||
|
q: dbr.New(db),
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
func newCommentManageService(db *pgx.Conn) core.CommentManageService {
|
||||||
|
return &commentManageServant{
|
||||||
|
db: db,
|
||||||
|
q: dbr.New(db),
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,64 @@
|
|||||||
|
// 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"
|
||||||
|
dbr "github.com/rocboss/paopao-ce/internal/dao/slonik/ce/postgres"
|
||||||
|
"github.com/rocboss/paopao-ce/pkg/debug"
|
||||||
|
)
|
||||||
|
|
||||||
|
var (
|
||||||
|
_ core.ContactManageService = (*contactManageServant)(nil)
|
||||||
|
)
|
||||||
|
|
||||||
|
type contactManageServant struct {
|
||||||
|
db *pgx.Conn
|
||||||
|
q dbr.Querier
|
||||||
|
}
|
||||||
|
|
||||||
|
func (s *contactManageServant) RequestingFriend(userId int64, friendId int64, greetings string) (err error) {
|
||||||
|
// TODO
|
||||||
|
debug.NotImplemented()
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
|
||||||
|
func (s *contactManageServant) AddFriend(userId int64, friendId int64) (err error) {
|
||||||
|
// TODO
|
||||||
|
debug.NotImplemented()
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
|
||||||
|
func (s *contactManageServant) RejectFriend(userId int64, friendId int64) (err error) {
|
||||||
|
// TODO
|
||||||
|
debug.NotImplemented()
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
|
||||||
|
func (s *contactManageServant) DeleteFriend(userId int64, friendId int64) (err error) {
|
||||||
|
// TODO
|
||||||
|
debug.NotImplemented()
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
|
||||||
|
func (s *contactManageServant) GetContacts(userId int64, offset int, limit int) (*core.ContactList, error) {
|
||||||
|
// TODO
|
||||||
|
debug.NotImplemented()
|
||||||
|
return nil, nil
|
||||||
|
}
|
||||||
|
|
||||||
|
func (s *contactManageServant) IsFriend(userId int64, friendId int64) bool {
|
||||||
|
// TODO
|
||||||
|
debug.NotImplemented()
|
||||||
|
return false
|
||||||
|
}
|
||||||
|
|
||||||
|
func newContactManageService(db *pgx.Conn) core.ContactManageService {
|
||||||
|
return &contactManageServant{
|
||||||
|
db: db,
|
||||||
|
q: dbr.New(db),
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,64 @@
|
|||||||
|
// 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"
|
||||||
|
dbr "github.com/rocboss/paopao-ce/internal/dao/slonik/ce/postgres"
|
||||||
|
"github.com/rocboss/paopao-ce/pkg/debug"
|
||||||
|
)
|
||||||
|
|
||||||
|
var (
|
||||||
|
_ core.MessageService = (*messageServant)(nil)
|
||||||
|
)
|
||||||
|
|
||||||
|
type messageServant struct {
|
||||||
|
db *pgx.Conn
|
||||||
|
q dbr.Querier
|
||||||
|
}
|
||||||
|
|
||||||
|
func (s *messageServant) CreateMessage(msg *core.Message) (*core.Message, error) {
|
||||||
|
// TODO
|
||||||
|
debug.NotImplemented()
|
||||||
|
return nil, nil
|
||||||
|
}
|
||||||
|
|
||||||
|
func (s *messageServant) GetUnreadCount(userID int64) (int64, error) {
|
||||||
|
// TODO
|
||||||
|
debug.NotImplemented()
|
||||||
|
return 0, nil
|
||||||
|
}
|
||||||
|
|
||||||
|
func (s *messageServant) GetMessageByID(id int64) (*core.Message, error) {
|
||||||
|
// TODO
|
||||||
|
debug.NotImplemented()
|
||||||
|
return nil, nil
|
||||||
|
}
|
||||||
|
|
||||||
|
func (s *messageServant) ReadMessage(message *core.Message) error {
|
||||||
|
// TODO
|
||||||
|
debug.NotImplemented()
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
|
||||||
|
func (s *messageServant) GetMessages(conditions *core.ConditionsT, offset, limit int) ([]*core.MessageFormated, error) {
|
||||||
|
// TODO
|
||||||
|
debug.NotImplemented()
|
||||||
|
return nil, nil
|
||||||
|
}
|
||||||
|
|
||||||
|
func (s *messageServant) GetMessageCount(conditions *core.ConditionsT) (int64, error) {
|
||||||
|
// TODO
|
||||||
|
debug.NotImplemented()
|
||||||
|
return 0, nil
|
||||||
|
}
|
||||||
|
|
||||||
|
func newMessageService(db *pgx.Conn) core.MessageService {
|
||||||
|
return &messageServant{
|
||||||
|
db: db,
|
||||||
|
q: dbr.New(db),
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,24 @@
|
|||||||
|
// 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 (
|
||||||
|
"sync"
|
||||||
|
|
||||||
|
"github.com/jackc/pgx/v5"
|
||||||
|
"github.com/rocboss/paopao-ce/internal/conf"
|
||||||
|
)
|
||||||
|
|
||||||
|
var (
|
||||||
|
_pgxDB *pgx.Conn
|
||||||
|
_oncePgx sync.Once
|
||||||
|
)
|
||||||
|
|
||||||
|
func pgxDB() *pgx.Conn {
|
||||||
|
_oncePgx.Do(func() {
|
||||||
|
_pgxDB = conf.MustPgxDB()
|
||||||
|
})
|
||||||
|
return _pgxDB
|
||||||
|
}
|
@ -0,0 +1,49 @@
|
|||||||
|
// 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"
|
||||||
|
dbr "github.com/rocboss/paopao-ce/internal/dao/slonik/ce/postgres"
|
||||||
|
"github.com/rocboss/paopao-ce/pkg/debug"
|
||||||
|
)
|
||||||
|
|
||||||
|
var (
|
||||||
|
_ core.SecurityService = (*securityServant)(nil)
|
||||||
|
)
|
||||||
|
|
||||||
|
type securityServant struct {
|
||||||
|
db *pgx.Conn
|
||||||
|
q dbr.Querier
|
||||||
|
}
|
||||||
|
|
||||||
|
// GetLatestPhoneCaptcha 获取最新短信验证码
|
||||||
|
func (s *securityServant) GetLatestPhoneCaptcha(phone string) (*core.Captcha, error) {
|
||||||
|
// TODO
|
||||||
|
debug.NotImplemented()
|
||||||
|
return nil, nil
|
||||||
|
}
|
||||||
|
|
||||||
|
// UsePhoneCaptcha 更新短信验证码
|
||||||
|
func (s *securityServant) UsePhoneCaptcha(captcha *core.Captcha) error {
|
||||||
|
// TODO
|
||||||
|
debug.NotImplemented()
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
|
||||||
|
// SendPhoneCaptcha 发送短信验证码
|
||||||
|
func (s *securityServant) SendPhoneCaptcha(phone string) error {
|
||||||
|
// TODO
|
||||||
|
debug.NotImplemented()
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
|
||||||
|
func newSecurityService(db *pgx.Conn, phoneVerify core.PhoneVerifyService) core.SecurityService {
|
||||||
|
return &securityServant{
|
||||||
|
db: db,
|
||||||
|
q: dbr.New(db),
|
||||||
|
}
|
||||||
|
}
|
@ -1,23 +1,86 @@
|
|||||||
// Copyright 2022 ROC. All rights reserved.
|
// Copyright 2023 ROC. All rights reserved.
|
||||||
// Use of this source code is governed by a MIT style
|
// Use of this source code is governed by a MIT style
|
||||||
// license that can be found in the LICENSE file.
|
// license that can be found in the LICENSE file.
|
||||||
|
|
||||||
// Core service implement base sqlx+postgresql. All sub-service
|
|
||||||
// will declare here and provide initial function.
|
|
||||||
|
|
||||||
package slonik
|
package slonik
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
"github.com/Masterminds/semver/v3"
|
||||||
|
"github.com/alimy/cfg"
|
||||||
"github.com/rocboss/paopao-ce/internal/core"
|
"github.com/rocboss/paopao-ce/internal/core"
|
||||||
|
"github.com/rocboss/paopao-ce/internal/dao/cache"
|
||||||
|
"github.com/rocboss/paopao-ce/internal/dao/security"
|
||||||
"github.com/sirupsen/logrus"
|
"github.com/sirupsen/logrus"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
var (
|
||||||
|
_ core.DataService = (*dataServant)(nil)
|
||||||
|
_ core.VersionInfo = (*dataServant)(nil)
|
||||||
|
)
|
||||||
|
|
||||||
|
type dataServant struct {
|
||||||
|
core.IndexPostsService
|
||||||
|
core.WalletService
|
||||||
|
core.MessageService
|
||||||
|
core.TopicService
|
||||||
|
core.TweetService
|
||||||
|
core.TweetManageService
|
||||||
|
core.TweetHelpService
|
||||||
|
core.CommentService
|
||||||
|
core.CommentManageService
|
||||||
|
core.UserManageService
|
||||||
|
core.ContactManageService
|
||||||
|
core.SecurityService
|
||||||
|
core.AttachmentCheckService
|
||||||
|
}
|
||||||
|
|
||||||
func NewDataService() (core.DataService, core.VersionInfo) {
|
func NewDataService() (core.DataService, core.VersionInfo) {
|
||||||
logrus.Fatal("not support now")
|
// initialize CacheIndex if needed
|
||||||
return nil, nil
|
var (
|
||||||
|
c core.CacheIndexService
|
||||||
|
v core.VersionInfo
|
||||||
|
)
|
||||||
|
db := pgxDB()
|
||||||
|
pvs := security.NewPhoneVerifyService()
|
||||||
|
|
||||||
|
i := newIndexPostsService(db)
|
||||||
|
if cfg.If("SimpleCacheIndex") {
|
||||||
|
i = newSimpleIndexPostsService(db)
|
||||||
|
c, v = cache.NewSimpleCacheIndexService(i)
|
||||||
|
} else if cfg.If("BigCacheIndex") {
|
||||||
|
a := newAuthorizationManageService(db)
|
||||||
|
c, v = cache.NewBigCacheIndexService(i, a)
|
||||||
|
} else {
|
||||||
|
c, v = cache.NewNoneCacheIndexService(i)
|
||||||
|
}
|
||||||
|
logrus.Infof("use %s as cache index service by version: %s", v.Name(), v.Version())
|
||||||
|
|
||||||
|
ds := &dataServant{
|
||||||
|
IndexPostsService: c,
|
||||||
|
WalletService: newWalletService(db),
|
||||||
|
MessageService: newMessageService(db),
|
||||||
|
TopicService: newTopicService(db),
|
||||||
|
TweetService: newTweetService(db),
|
||||||
|
TweetManageService: newTweetManageService(db, c),
|
||||||
|
TweetHelpService: newTweetHelpService(db),
|
||||||
|
CommentService: newCommentService(db),
|
||||||
|
CommentManageService: newCommentManageService(db),
|
||||||
|
UserManageService: newUserManageService(db),
|
||||||
|
ContactManageService: newContactManageService(db),
|
||||||
|
SecurityService: newSecurityService(db, pvs),
|
||||||
|
AttachmentCheckService: security.NewAttachmentCheckService(),
|
||||||
|
}
|
||||||
|
return ds, ds
|
||||||
}
|
}
|
||||||
|
|
||||||
func NewAuthorizationManageService() core.AuthorizationManageService {
|
func NewAuthorizationManageService() core.AuthorizationManageService {
|
||||||
logrus.Fatal("not support now")
|
return newAuthorizationManageService(pgxDB())
|
||||||
return nil
|
}
|
||||||
|
|
||||||
|
func (s *dataServant) Name() string {
|
||||||
|
return "sqlc/pgx"
|
||||||
|
}
|
||||||
|
|
||||||
|
func (s *dataServant) Version() *semver.Version {
|
||||||
|
return semver.MustParse("v0.1.0")
|
||||||
}
|
}
|
||||||
|
@ -0,0 +1,52 @@
|
|||||||
|
// 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"
|
||||||
|
dbr "github.com/rocboss/paopao-ce/internal/dao/slonik/ce/postgres"
|
||||||
|
"github.com/rocboss/paopao-ce/pkg/debug"
|
||||||
|
)
|
||||||
|
|
||||||
|
var (
|
||||||
|
_ core.TopicService = (*topicServant)(nil)
|
||||||
|
)
|
||||||
|
|
||||||
|
type topicServant struct {
|
||||||
|
db *pgx.Conn
|
||||||
|
q dbr.Querier
|
||||||
|
}
|
||||||
|
|
||||||
|
func (s *topicServant) CreateTag(tag *core.Tag) (*core.Tag, error) {
|
||||||
|
// TODO
|
||||||
|
debug.NotImplemented()
|
||||||
|
return nil, nil
|
||||||
|
}
|
||||||
|
|
||||||
|
func (s *topicServant) DeleteTag(tag *core.Tag) error {
|
||||||
|
// TODO
|
||||||
|
debug.NotImplemented()
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
|
||||||
|
func (s *topicServant) GetTags(conditions *core.ConditionsT, offset, limit int) ([]*core.Tag, error) {
|
||||||
|
// TODO
|
||||||
|
debug.NotImplemented()
|
||||||
|
return nil, nil
|
||||||
|
}
|
||||||
|
|
||||||
|
func (s *topicServant) GetTagsByKeyword(keyword string) ([]*core.Tag, error) {
|
||||||
|
// TODO
|
||||||
|
debug.NotImplemented()
|
||||||
|
return nil, nil
|
||||||
|
}
|
||||||
|
|
||||||
|
func newTopicService(db *pgx.Conn) core.TopicService {
|
||||||
|
return &topicServant{
|
||||||
|
db: db,
|
||||||
|
q: dbr.New(db),
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,243 @@
|
|||||||
|
// 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"
|
||||||
|
dbr "github.com/rocboss/paopao-ce/internal/dao/slonik/ce/postgres"
|
||||||
|
"github.com/rocboss/paopao-ce/pkg/debug"
|
||||||
|
"gorm.io/gorm"
|
||||||
|
)
|
||||||
|
|
||||||
|
var (
|
||||||
|
_ core.TweetService = (*tweetServant)(nil)
|
||||||
|
_ core.TweetManageService = (*tweetManageServant)(nil)
|
||||||
|
_ core.TweetHelpService = (*tweetHelpServant)(nil)
|
||||||
|
)
|
||||||
|
|
||||||
|
type tweetServant struct {
|
||||||
|
db *pgx.Conn
|
||||||
|
q dbr.Querier
|
||||||
|
}
|
||||||
|
|
||||||
|
type tweetManageServant struct {
|
||||||
|
db *pgx.Conn
|
||||||
|
q dbr.Querier
|
||||||
|
}
|
||||||
|
|
||||||
|
type tweetHelpServant struct {
|
||||||
|
db *pgx.Conn
|
||||||
|
q dbr.Querier
|
||||||
|
}
|
||||||
|
|
||||||
|
// MergePosts post数据整合
|
||||||
|
func (s *tweetHelpServant) MergePosts(posts []*core.Post) ([]*core.PostFormated, error) {
|
||||||
|
// TODO
|
||||||
|
debug.NotImplemented()
|
||||||
|
return nil, nil
|
||||||
|
}
|
||||||
|
|
||||||
|
// RevampPosts post数据整形修复
|
||||||
|
func (s *tweetHelpServant) RevampPosts(posts []*core.PostFormated) ([]*core.PostFormated, error) {
|
||||||
|
// TODO
|
||||||
|
debug.NotImplemented()
|
||||||
|
return nil, nil
|
||||||
|
}
|
||||||
|
|
||||||
|
func (s *tweetHelpServant) getPostContentsByIDs(ids []int64) ([]*core.PostContent, error) {
|
||||||
|
// TODO
|
||||||
|
debug.NotImplemented()
|
||||||
|
return nil, nil
|
||||||
|
}
|
||||||
|
|
||||||
|
func (s *tweetHelpServant) getUsersByIDs(ids []int64) ([]*core.User, error) {
|
||||||
|
// TODO
|
||||||
|
debug.NotImplemented()
|
||||||
|
return nil, nil
|
||||||
|
}
|
||||||
|
|
||||||
|
func (s *tweetManageServant) CreatePostCollection(postID, userID int64) (*core.PostCollection, error) {
|
||||||
|
// TODO
|
||||||
|
debug.NotImplemented()
|
||||||
|
return nil, nil
|
||||||
|
}
|
||||||
|
|
||||||
|
func (s *tweetManageServant) DeletePostCollection(p *core.PostCollection) error {
|
||||||
|
// TODO
|
||||||
|
debug.NotImplemented()
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
|
||||||
|
func (s *tweetManageServant) CreatePostContent(content *core.PostContent) (*core.PostContent, error) {
|
||||||
|
// TODO
|
||||||
|
debug.NotImplemented()
|
||||||
|
return nil, nil
|
||||||
|
}
|
||||||
|
|
||||||
|
func (s *tweetManageServant) CreateAttachment(attachment *core.Attachment) (*core.Attachment, error) {
|
||||||
|
// TODO
|
||||||
|
debug.NotImplemented()
|
||||||
|
return nil, nil
|
||||||
|
}
|
||||||
|
|
||||||
|
func (s *tweetManageServant) CreatePost(post *core.Post) (*core.Post, error) {
|
||||||
|
// TODO
|
||||||
|
debug.NotImplemented()
|
||||||
|
return nil, nil
|
||||||
|
}
|
||||||
|
|
||||||
|
func (s *tweetManageServant) DeletePost(post *core.Post) ([]string, error) {
|
||||||
|
// TODO
|
||||||
|
debug.NotImplemented()
|
||||||
|
return nil, nil
|
||||||
|
}
|
||||||
|
|
||||||
|
func (s *tweetManageServant) deleteCommentByPostId(db *gorm.DB, postId int64) ([]string, error) {
|
||||||
|
// TODO
|
||||||
|
debug.NotImplemented()
|
||||||
|
return nil, nil
|
||||||
|
}
|
||||||
|
|
||||||
|
func (s *tweetManageServant) LockPost(post *core.Post) error {
|
||||||
|
// TODO
|
||||||
|
debug.NotImplemented()
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
|
||||||
|
func (s *tweetManageServant) StickPost(post *core.Post) error {
|
||||||
|
// TODO
|
||||||
|
debug.NotImplemented()
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
|
||||||
|
func (s *tweetManageServant) VisiblePost(post *core.Post, visibility core.PostVisibleT) error {
|
||||||
|
// TODO
|
||||||
|
debug.NotImplemented()
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
|
||||||
|
func (s *tweetManageServant) UpdatePost(post *core.Post) error {
|
||||||
|
// TODO
|
||||||
|
debug.NotImplemented()
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
|
||||||
|
func (s *tweetManageServant) CreatePostStar(postID, userID int64) (*core.PostStar, error) {
|
||||||
|
// TODO
|
||||||
|
debug.NotImplemented()
|
||||||
|
return nil, nil
|
||||||
|
}
|
||||||
|
|
||||||
|
func (s *tweetManageServant) DeletePostStar(p *core.PostStar) error {
|
||||||
|
// TODO
|
||||||
|
debug.NotImplemented()
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
|
||||||
|
func (s *tweetServant) GetPostByID(id int64) (*core.Post, error) {
|
||||||
|
// TODO
|
||||||
|
debug.NotImplemented()
|
||||||
|
return nil, nil
|
||||||
|
}
|
||||||
|
|
||||||
|
func (s *tweetServant) GetPosts(conditions *core.ConditionsT, offset, limit int) ([]*core.Post, error) {
|
||||||
|
// TODO
|
||||||
|
debug.NotImplemented()
|
||||||
|
return nil, nil
|
||||||
|
}
|
||||||
|
|
||||||
|
func (s *tweetServant) GetPostCount(conditions *core.ConditionsT) (int64, error) {
|
||||||
|
// TODO
|
||||||
|
debug.NotImplemented()
|
||||||
|
return 0, nil
|
||||||
|
}
|
||||||
|
|
||||||
|
func (s *tweetServant) GetUserPostStar(postID, userID int64) (*core.PostStar, error) {
|
||||||
|
// TODO
|
||||||
|
debug.NotImplemented()
|
||||||
|
return nil, nil
|
||||||
|
}
|
||||||
|
|
||||||
|
func (s *tweetServant) GetUserPostStars(userID int64, offset, limit int) ([]*core.PostStar, error) {
|
||||||
|
// TODO
|
||||||
|
debug.NotImplemented()
|
||||||
|
return nil, nil
|
||||||
|
}
|
||||||
|
|
||||||
|
func (s *tweetServant) GetUserPostStarCount(userID int64) (int64, error) {
|
||||||
|
// TODO
|
||||||
|
debug.NotImplemented()
|
||||||
|
return 0, nil
|
||||||
|
}
|
||||||
|
|
||||||
|
func (s *tweetServant) GetUserPostCollection(postID, userID int64) (*core.PostCollection, error) {
|
||||||
|
// TODO
|
||||||
|
debug.NotImplemented()
|
||||||
|
return nil, nil
|
||||||
|
}
|
||||||
|
|
||||||
|
func (s *tweetServant) GetUserPostCollections(userID int64, offset, limit int) ([]*core.PostCollection, error) {
|
||||||
|
// TODO
|
||||||
|
debug.NotImplemented()
|
||||||
|
return nil, nil
|
||||||
|
}
|
||||||
|
|
||||||
|
func (s *tweetServant) GetUserPostCollectionCount(userID int64) (int64, error) {
|
||||||
|
// TODO
|
||||||
|
debug.NotImplemented()
|
||||||
|
return 0, nil
|
||||||
|
}
|
||||||
|
|
||||||
|
func (s *tweetServant) GetUserWalletBills(userID int64, offset, limit int) ([]*core.WalletStatement, error) {
|
||||||
|
// TODO
|
||||||
|
debug.NotImplemented()
|
||||||
|
return nil, nil
|
||||||
|
}
|
||||||
|
|
||||||
|
func (s *tweetServant) GetUserWalletBillCount(userID int64) (int64, error) {
|
||||||
|
// TODO
|
||||||
|
debug.NotImplemented()
|
||||||
|
return 0, nil
|
||||||
|
}
|
||||||
|
|
||||||
|
func (s *tweetServant) GetPostAttatchmentBill(postID, userID int64) (*core.PostAttachmentBill, error) {
|
||||||
|
// TODO
|
||||||
|
debug.NotImplemented()
|
||||||
|
return nil, nil
|
||||||
|
}
|
||||||
|
|
||||||
|
func (s *tweetServant) GetPostContentsByIDs(ids []int64) ([]*core.PostContent, error) {
|
||||||
|
// TODO
|
||||||
|
debug.NotImplemented()
|
||||||
|
return nil, nil
|
||||||
|
}
|
||||||
|
|
||||||
|
func (s *tweetServant) GetPostContentByID(id int64) (*core.PostContent, error) {
|
||||||
|
// TODO
|
||||||
|
debug.NotImplemented()
|
||||||
|
return nil, nil
|
||||||
|
}
|
||||||
|
|
||||||
|
func newTweetService(db *pgx.Conn) core.TweetService {
|
||||||
|
return &tweetServant{
|
||||||
|
db: db,
|
||||||
|
q: dbr.New(db),
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
func newTweetManageService(db *pgx.Conn, cacheIndex core.CacheIndexService) core.TweetManageService {
|
||||||
|
return &tweetManageServant{
|
||||||
|
db: db,
|
||||||
|
q: dbr.New(db),
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
func newTweetHelpService(db *pgx.Conn) core.TweetHelpService {
|
||||||
|
return &tweetHelpServant{
|
||||||
|
db: db,
|
||||||
|
q: dbr.New(db),
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,76 @@
|
|||||||
|
// 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"
|
||||||
|
dbr "github.com/rocboss/paopao-ce/internal/dao/slonik/ce/postgres"
|
||||||
|
"github.com/rocboss/paopao-ce/pkg/debug"
|
||||||
|
)
|
||||||
|
|
||||||
|
var (
|
||||||
|
_ core.UserManageService = (*userManageServant)(nil)
|
||||||
|
)
|
||||||
|
|
||||||
|
type userManageServant struct {
|
||||||
|
db *pgx.Conn
|
||||||
|
q dbr.Querier
|
||||||
|
}
|
||||||
|
|
||||||
|
func (s *userManageServant) GetUserByID(id int64) (*core.User, error) {
|
||||||
|
// TODO
|
||||||
|
debug.NotImplemented()
|
||||||
|
return nil, nil
|
||||||
|
}
|
||||||
|
|
||||||
|
func (s *userManageServant) GetUserByUsername(username string) (*core.User, error) {
|
||||||
|
// TODO
|
||||||
|
debug.NotImplemented()
|
||||||
|
return nil, nil
|
||||||
|
}
|
||||||
|
|
||||||
|
func (s *userManageServant) GetUserByPhone(phone string) (*core.User, error) {
|
||||||
|
// TODO
|
||||||
|
debug.NotImplemented()
|
||||||
|
return nil, nil
|
||||||
|
}
|
||||||
|
|
||||||
|
func (s *userManageServant) GetUsersByIDs(ids []int64) ([]*core.User, error) {
|
||||||
|
// TODO
|
||||||
|
debug.NotImplemented()
|
||||||
|
return nil, nil
|
||||||
|
}
|
||||||
|
|
||||||
|
func (s *userManageServant) GetUsersByKeyword(keyword string) ([]*core.User, error) {
|
||||||
|
// TODO
|
||||||
|
debug.NotImplemented()
|
||||||
|
return nil, nil
|
||||||
|
}
|
||||||
|
|
||||||
|
func (s *userManageServant) GetTagsByKeyword(keyword string) ([]*core.Tag, error) {
|
||||||
|
// TODO
|
||||||
|
debug.NotImplemented()
|
||||||
|
return nil, nil
|
||||||
|
}
|
||||||
|
|
||||||
|
func (s *userManageServant) CreateUser(user *core.User) (*core.User, error) {
|
||||||
|
// TODO
|
||||||
|
debug.NotImplemented()
|
||||||
|
return nil, nil
|
||||||
|
}
|
||||||
|
|
||||||
|
func (s *userManageServant) UpdateUser(user *core.User) error {
|
||||||
|
// TODO
|
||||||
|
debug.NotImplemented()
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
|
||||||
|
func newUserManageService(db *pgx.Conn) core.UserManageService {
|
||||||
|
return &userManageServant{
|
||||||
|
db: db,
|
||||||
|
q: dbr.New(db),
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,63 @@
|
|||||||
|
// 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"
|
||||||
|
dbr "github.com/rocboss/paopao-ce/internal/dao/slonik/ce/postgres"
|
||||||
|
"github.com/rocboss/paopao-ce/pkg/debug"
|
||||||
|
)
|
||||||
|
|
||||||
|
var (
|
||||||
|
_ core.WalletService = (*walletServant)(nil)
|
||||||
|
)
|
||||||
|
|
||||||
|
type walletServant struct {
|
||||||
|
db *pgx.Conn
|
||||||
|
q dbr.Querier
|
||||||
|
}
|
||||||
|
|
||||||
|
func (s *walletServant) GetRechargeByID(id int64) (*core.WalletRecharge, error) {
|
||||||
|
// TODO
|
||||||
|
debug.NotImplemented()
|
||||||
|
return nil, nil
|
||||||
|
}
|
||||||
|
func (s *walletServant) CreateRecharge(userId, amount int64) (*core.WalletRecharge, error) {
|
||||||
|
// TODO
|
||||||
|
debug.NotImplemented()
|
||||||
|
return nil, nil
|
||||||
|
}
|
||||||
|
|
||||||
|
func (s *walletServant) GetUserWalletBills(userID int64, offset, limit int) ([]*core.WalletStatement, error) {
|
||||||
|
// TODO
|
||||||
|
debug.NotImplemented()
|
||||||
|
return nil, nil
|
||||||
|
}
|
||||||
|
|
||||||
|
func (s *walletServant) GetUserWalletBillCount(userID int64) (int64, error) {
|
||||||
|
// TODO
|
||||||
|
debug.NotImplemented()
|
||||||
|
return 0, nil
|
||||||
|
}
|
||||||
|
|
||||||
|
func (s *walletServant) HandleRechargeSuccess(recharge *core.WalletRecharge, tradeNo string) error {
|
||||||
|
// TODO
|
||||||
|
debug.NotImplemented()
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
|
||||||
|
func (s *walletServant) HandlePostAttachmentBought(post *core.Post, user *core.User) error {
|
||||||
|
// TODO
|
||||||
|
debug.NotImplemented()
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
|
||||||
|
func newWalletService(db *pgx.Conn) core.WalletService {
|
||||||
|
return &walletServant{
|
||||||
|
db: db,
|
||||||
|
q: dbr.New(db),
|
||||||
|
}
|
||||||
|
}
|
Loading…
Reference in new issue