46 lines
1.2 KiB
Go
46 lines
1.2 KiB
Go
package customer
|
|
|
|
import (
|
|
"context"
|
|
|
|
db "management/internal/db/sqlc"
|
|
"management/internal/pkg/redis"
|
|
)
|
|
|
|
type CustomerBiz interface {
|
|
Create(ctx context.Context, arg *db.CreateCustomerParams) (*db.Customer, error)
|
|
Update(ctx context.Context, arg *db.UpdateCustomerParams) (*db.Customer, error)
|
|
List(ctx context.Context, arg *db.ListCustomerConditionParam) ([]*db.CustomerView, int64, error)
|
|
Get(ctx context.Context, id int64) (*db.Customer, error)
|
|
}
|
|
|
|
type customerBiz struct {
|
|
store db.Store
|
|
redis redis.IRedis
|
|
}
|
|
|
|
var _ CustomerBiz = (*customerBiz)(nil)
|
|
|
|
func New(store db.Store, redis redis.IRedis) *customerBiz {
|
|
return &customerBiz{
|
|
store: store,
|
|
redis: redis,
|
|
}
|
|
}
|
|
|
|
func (b *customerBiz) Create(ctx context.Context, arg *db.CreateCustomerParams) (*db.Customer, error) {
|
|
return b.store.CreateCustomer(ctx, arg)
|
|
}
|
|
|
|
func (b *customerBiz) Update(ctx context.Context, arg *db.UpdateCustomerParams) (*db.Customer, error) {
|
|
return b.store.UpdateCustomer(ctx, arg)
|
|
}
|
|
|
|
func (b *customerBiz) List(ctx context.Context, arg *db.ListCustomerConditionParam) ([]*db.CustomerView, int64, error) {
|
|
return b.store.ListCustomerCondition(ctx, arg)
|
|
}
|
|
|
|
func (b *customerBiz) Get(ctx context.Context, id int64) (*db.Customer, error) {
|
|
return b.store.GetCustomer(ctx, id)
|
|
}
|