dao

package
v0.0.0-...-d80f745 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Dec 9, 2024 License: Apache-2.0 Imports: 17 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Dao

type Dao struct {
	NoteDao       *NoteDao
	NoteAssetRepo *NoteAssetDao
	// contains filtered or unexported fields
}

func New

func New(c *config.Config, cache *redis.Redis) *Dao

func (*Dao) CreateNote

func (d *Dao) CreateNote(ctx context.Context, note *Note, assets []*NoteAsset) (uint64, error)

事务插入

func (*Dao) DB

func (d *Dao) DB() sqlx.SqlConn

func (*Dao) DeleteNote

func (d *Dao) DeleteNote(ctx context.Context, noteId uint64) error

事务删除

func (*Dao) TransactCtx

func (d *Dao) TransactCtx(ctx context.Context, fns ...xsql.TransactFunc) error

事务中执行

func (*Dao) UpdateNote

func (d *Dao) UpdateNote(ctx context.Context, note *Note, assets []*NoteAsset) error

事务更新

type Note

type Note struct {
	Id       uint64 `db:"id"`
	Title    string `db:"title"`     // 标题
	Desc     string `db:"desc"`      // 描述
	Privacy  int8   `db:"privacy"`   // 公开类型
	Owner    uint64 `db:"owner"`     // 笔记作者
	CreateAt int64  `db:"create_at"` // 创建时间
	UpdateAt int64  `db:"update_at"` // 更新时间
}

type NoteAsset

type NoteAsset struct {
	Id        uint64 `db:"id"`
	AssetKey  string `db:"asset_key"`  // 资源key 不包含bucket name
	AssetType int8   `db:"asset_type"` // 资源类型
	NoteId    uint64 `db:"note_id"`    // 所属笔记id
	CreateAt  int64  `db:"create_at"`  // 创建时间
}

type NoteAssetDao

type NoteAssetDao struct {
	// contains filtered or unexported fields
}

func NewNoteAssetDao

func NewNoteAssetDao(db sqlx.SqlConn) *NoteAssetDao

func (*NoteAssetDao) BatchInsert

func (r *NoteAssetDao) BatchInsert(ctx context.Context, assets []*NoteAsset) error

func (*NoteAssetDao) BatchInsertTx

func (r *NoteAssetDao) BatchInsertTx(ctx context.Context, tx sqlx.Session, assets []*NoteAsset) error

func (*NoteAssetDao) DeleteByNoteId

func (r *NoteAssetDao) DeleteByNoteId(ctx context.Context, noteId uint64) error

func (*NoteAssetDao) DeleteByNoteIdTx

func (r *NoteAssetDao) DeleteByNoteIdTx(ctx context.Context, tx sqlx.Session, noteId uint64) error

func (*NoteAssetDao) ExcludeDeleteByNoteId

func (r *NoteAssetDao) ExcludeDeleteByNoteId(ctx context.Context, noteId uint64, assetKeys []string) error

func (*NoteAssetDao) ExcludeDeleteByNoteIdTx

func (r *NoteAssetDao) ExcludeDeleteByNoteIdTx(ctx context.Context, tx sqlx.Session, noteId uint64, assetKeys []string) error

func (*NoteAssetDao) FindByNoteId

func (r *NoteAssetDao) FindByNoteId(ctx context.Context, noteId uint64) ([]*NoteAsset, error)

func (*NoteAssetDao) FindByNoteIdTx

func (r *NoteAssetDao) FindByNoteIdTx(ctx context.Context, tx sqlx.Session, noteId uint64) ([]*NoteAsset, error)

func (*NoteAssetDao) FindByNoteIds

func (r *NoteAssetDao) FindByNoteIds(ctx context.Context, noteIds []uint64) ([]*NoteAsset, error)

func (*NoteAssetDao) FindOne

func (r *NoteAssetDao) FindOne(ctx context.Context, id uint64) (*NoteAsset, error)

func (*NoteAssetDao) Insert

func (r *NoteAssetDao) Insert(ctx context.Context, asset *NoteAsset) error

func (*NoteAssetDao) InsertTx

func (r *NoteAssetDao) InsertTx(ctx context.Context, tx sqlx.Session, asset *NoteAsset) error

type NoteDao

type NoteDao struct {
	// contains filtered or unexported fields
}

func NewNoteDao

func NewNoteDao(db sqlx.SqlConn, cache *redis.Redis) *NoteDao

func (*NoteDao) CacheDelNote

func (d *NoteDao) CacheDelNote(ctx context.Context, nid uint64) error

func (*NoteDao) CacheGetNote

func (d *NoteDao) CacheGetNote(ctx context.Context, nid uint64) (*Note, error)

func (*NoteDao) CacheSetNote

func (d *NoteDao) CacheSetNote(ctx context.Context, model *Note) error

func (*NoteDao) Delete

func (r *NoteDao) Delete(ctx context.Context, id uint64) error

func (*NoteDao) DeleteTx

func (r *NoteDao) DeleteTx(ctx context.Context, tx sqlx.Session, id uint64) error

func (*NoteDao) FindOne

func (r *NoteDao) FindOne(ctx context.Context, id uint64) (*Note, error)

func (*NoteDao) GetPrivateAll

func (r *NoteDao) GetPrivateAll(ctx context.Context) ([]*Note, error)

func (*NoteDao) GetPrivateByCursor

func (r *NoteDao) GetPrivateByCursor(ctx context.Context, id uint64, count int) ([]*Note, error)

func (*NoteDao) GetPrivateCount

func (r *NoteDao) GetPrivateCount(ctx context.Context) (uint64, error)

func (*NoteDao) GetPrivateLastId

func (r *NoteDao) GetPrivateLastId(ctx context.Context) (uint64, error)

func (*NoteDao) GetPublicAll

func (r *NoteDao) GetPublicAll(ctx context.Context) ([]*Note, error)

func (*NoteDao) GetPublicByCursor

func (r *NoteDao) GetPublicByCursor(ctx context.Context, id uint64, count int) ([]*Note, error)

func (*NoteDao) GetPublicCount

func (r *NoteDao) GetPublicCount(ctx context.Context) (uint64, error)

func (*NoteDao) GetPublicLastId

func (r *NoteDao) GetPublicLastId(ctx context.Context) (uint64, error)

func (*NoteDao) Insert

func (r *NoteDao) Insert(ctx context.Context, note *Note) (uint64, error)

func (*NoteDao) InsertTx

func (r *NoteDao) InsertTx(ctx context.Context, tx sqlx.Session, note *Note) (uint64, error)

func (*NoteDao) ListByOwner

func (r *NoteDao) ListByOwner(ctx context.Context, uid uint64) ([]*Note, error)

func (*NoteDao) Update

func (r *NoteDao) Update(ctx context.Context, note *Note) error

func (*NoteDao) UpdateTx

func (r *NoteDao) UpdateTx(ctx context.Context, tx sqlx.Session, note *Note) error

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL