68 lines
		
	
	
		
			2.1 KiB
		
	
	
	
		
			Go
		
	
	
	
	
	
			
		
		
	
	
			68 lines
		
	
	
		
			2.1 KiB
		
	
	
	
		
			Go
		
	
	
	
	
	
| package expense
 | |
| 
 | |
| import (
 | |
| 	"context"
 | |
| 
 | |
| 	db "management/internal/db/sqlc"
 | |
| 	"management/internal/pkg/redis"
 | |
| 
 | |
| 	"github.com/jackc/pgx/v5/pgtype"
 | |
| )
 | |
| 
 | |
| type ExpenseBiz interface {
 | |
| 	Create(ctx context.Context, arg *db.CreateExpenseParams) (*db.Expense, error)
 | |
| 	Update(ctx context.Context, arg *db.UpdateExpenseParams) (*db.Expense, error)
 | |
| 	List(ctx context.Context, arg *db.ListExpenseConditionParam) ([]*db.ExpenseView, int64, error)
 | |
| 	Get(ctx context.Context, id int64) (*db.Expense, error)
 | |
| 	Sum(ctx context.Context) (pgtype.Numeric, error)
 | |
| 	SumByProjectID(ctx context.Context, id int64) (pgtype.Numeric, error)
 | |
| 	Statistics(ctx context.Context) ([]*db.StatisticsExpenseRow, error)
 | |
| 	StatisticsByProjectID(ctx context.Context, projectID int64) ([]*db.StatisticsExpenseByProjectIDRow, error)
 | |
| }
 | |
| 
 | |
| type expenseBiz struct {
 | |
| 	store db.Store
 | |
| 	redis redis.IRedis
 | |
| }
 | |
| 
 | |
| var _ ExpenseBiz = (*expenseBiz)(nil)
 | |
| 
 | |
| func New(store db.Store, redis redis.IRedis) *expenseBiz {
 | |
| 	return &expenseBiz{
 | |
| 		store: store,
 | |
| 		redis: redis,
 | |
| 	}
 | |
| }
 | |
| 
 | |
| func (b *expenseBiz) Create(ctx context.Context, arg *db.CreateExpenseParams) (*db.Expense, error) {
 | |
| 	return b.store.CreateExpense(ctx, arg)
 | |
| }
 | |
| 
 | |
| func (b *expenseBiz) Update(ctx context.Context, arg *db.UpdateExpenseParams) (*db.Expense, error) {
 | |
| 	return b.store.UpdateExpense(ctx, arg)
 | |
| }
 | |
| 
 | |
| func (b *expenseBiz) List(ctx context.Context, arg *db.ListExpenseConditionParam) ([]*db.ExpenseView, int64, error) {
 | |
| 	return b.store.ListExpenseCondition(ctx, arg)
 | |
| }
 | |
| 
 | |
| func (b *expenseBiz) Get(ctx context.Context, id int64) (*db.Expense, error) {
 | |
| 	return b.store.GetExpense(ctx, id)
 | |
| }
 | |
| 
 | |
| func (b *expenseBiz) Sum(ctx context.Context) (pgtype.Numeric, error) {
 | |
| 	return b.store.SumExpense(ctx)
 | |
| }
 | |
| 
 | |
| func (b *expenseBiz) SumByProjectID(ctx context.Context, id int64) (pgtype.Numeric, error) {
 | |
| 	return b.store.SumExpenseByProjectID(ctx, id)
 | |
| }
 | |
| 
 | |
| func (b *expenseBiz) Statistics(ctx context.Context) ([]*db.StatisticsExpenseRow, error) {
 | |
| 	return b.store.StatisticsExpense(ctx)
 | |
| }
 | |
| 
 | |
| func (b *expenseBiz) StatisticsByProjectID(ctx context.Context, projectID int64) ([]*db.StatisticsExpenseByProjectIDRow, error) {
 | |
| 	return b.store.StatisticsExpenseByProjectID(ctx, projectID)
 | |
| }
 |