repository

package
v0.0.0-...-a7198d8 Latest Latest
Warning

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

Go to latest
Published: Nov 29, 2024 License: MIT Imports: 15 Imported by: 0

README

Repository

repository 层负责为上层(通常是服务层或业务逻辑层)提供统一的数据访问接口,
它封装了数据的获取、存储和更新等操作,对上层屏蔽了底层数据存储的具体实现细节

调用链路如下

            service
              |
              |
            repository
              | (calls)
              |
               ------
              |      |      |
             dal
             /   |   \
            /    |    \
           /     |     \
        db   rpc   cache

Documentation

Index

Constants

This section is empty.

Variables

View Source
var ProviderSet = wire.NewSet(dal.Init, NewUserRepo)

ProviderSet is repo providers.

Functions

This section is empty.

Types

type UserRepo

type UserRepo interface {
	CreateUser(ctx context.Context, data model.UserInfoModel) (id int64, err error)
	UpdateUser(ctx context.Context, id int64, data model.UserInfoModel) error
	GetUser(ctx context.Context, id int64) (ret *model.UserInfoModel, err error)
	BatchGetUsers(ctx context.Context, ids []int64) (ret []*model.UserInfoModel, err error)
	GetUserByUsername(ctx context.Context, username string) (ret *model.UserInfoModel, err error)
	GetUserByEmail(ctx context.Context, email string) (ret *model.UserInfoModel, err error)
	GetUserByPhone(ctx context.Context, phone string) (ret *model.UserInfoModel, err error)
}

UserRepo define a repo interface

func NewUserRepo

func NewUserRepo(db *dal.DBClient, cache cache.UserCache) UserRepo

NewUser new a repository and return

Jump to

Keyboard shortcuts

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