types

package
v0.0.0-...-05fee8b Latest Latest
Warning

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

Go to latest
Published: Jun 6, 2024 License: MIT Imports: 1 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var PaymentMethods []string = []string{"cash", "bank_transfer", "card", "mobile_money", "paypal"}

Functions

This section is empty.

Types

type AuthRepository

type AuthRepository interface {
	IsEmailExist(email string) bool
	IsUsernameExist(email string) bool
	CreateUser(user *User) error
	GetUserByUsername(username string) (*User, error)
	GetUserByEmail(email string) (*User, error)
}

type AuthService

type AuthService interface {
	Signup(params SignupDTO) error
	Login(params LoginDTO) (*LoginResponse, error)
	ForgotPassword(params ForgotPasswordDTO) error
}

type Category

type Category struct {
	ID          uint      `json:"id" gorm:"primaryKey"`
	Name        string    `json:"name" gorm:"not null;size:100;uniqueIndex:name_createdbyid"`
	IsSystem    bool      `json:"isSystem" gorm:"default:0"`
	CreatedById uint      `json:"createdById,omitempty" gorm:"default:0;index;uniqueIndex:name_createdbyid"`
	CreatedAt   time.Time `json:"createdAt" gorm:"autoCreateTime;type:TIMESTAMP"`
	UpdatedAt   time.Time `json:"updatedAt" gorm:"autoUpdateTime;type:TIMESTAMP"`
}

type CategoryRepository

type CategoryRepository interface {
	IsExist(userId int, name string) bool
	Create(category *Category) error
	GetById(id int) (*Category, error)
	GetAll(userId int, params GetAllCategoryDTO) (*[]Category, error)
	Update(userId int, params UpdateCategoryDTO) error
	Delete(userId int, id int) error
}

type CategoryService

type CategoryService interface {
	Create(userId int, params CreateCategoryDTO) error
	GetAll(userId int, params GetAllCategoryDTO) (*[]Category, error)
	Update(userId int, params UpdateCategoryDTO) error
	Delete(userId int, params DeleteCategoryDTO) error
}

type CreateCategoryDTO

type CreateCategoryDTO struct {
	Name     string `json:"name"`
	IsSystem bool   `json:"isSystem"`
}

type CreateExpenseDTO

type CreateExpenseDTO struct {
	Category      string    `json:"category"`
	PaymentMethod string    `json:"paymentMethod"`
	Amount        float64   `json:"amount"`
	Currency      string    `json:"currency"`
	Description   string    `json:"description"`
	PayedAt       time.Time `json:"payedAt"`
}

type DeleteCategoryDTO

type DeleteCategoryDTO struct {
	ID int `json:"id"`
}

type DeleteExpenseDTO

type DeleteExpenseDTO struct {
	ID int `json:"id"`
}

type Expense

type Expense struct {
	ID            uint      `json:"id" gorm:"primaryKey"`
	UserID        uint      `json:"userId" gorm:"index"`
	CategoryId    uint      `json:"categoryId" gorm:"not null"`
	Category      string    `json:"category" gorm:"not null;size:100"`
	PaymentMethod string    `json:"paymentMethod" gorm:"not null;size:100"`
	Amount        float64   `json:"amount" gorm:"not null"`
	Currency      string    `json:"currency" gorm:"size:5;not null"`
	Description   string    `json:"description" gorm:"not null"`
	PayedAt       time.Time `json:"payedAt" gorm:"type:TIMESTAMP"`
	CreatedAt     time.Time `json:"createdAt" gorm:"autoCreateTime;type:TIMESTAMP"`
	UpdatedAt     time.Time `json:"updatedAt" gorm:"autoUpdateTime;type:TIMESTAMP"`
}

type ExpenseRepository

type ExpenseRepository interface {
	Create(expense *Expense) error
	GetCategoryByName(name string) (*Category, error)
	GetAll(userId int, params GetAllExpensesDTO) (*[]Expense, error)
	GetById(userId int, id int) (*Expense, error)
	Update(userId int, params UpdateExpenseDTO) error
	Delete(userId int, id int) error
	GetUserDefaultCurrency(userId int) string
}

type ExpenseService

type ExpenseService interface {
	Create(userId int, params CreateExpenseDTO) error
	GetAll(userId int, params GetAllExpensesDTO) (*[]Expense, error)
	GetById(userId int, params GetOneExpenseDTO) (*Expense, error)
	Update(userId int, params UpdateExpenseDTO) error
	Delete(userId int, params DeleteExpenseDTO) error
}

type ForgotPasswordDTO

type ForgotPasswordDTO struct {
	Email string `json:"email"`
}

type GetAllCategoryDTO

type GetAllCategoryDTO struct {
	Page    int `json:"page"`
	PerPage int `json:"perPage"`
}

type GetAllExpensesDTO

type GetAllExpensesDTO struct {
	Page        int `json:"page"`
	PerPage     int `json:"perPage"`
	SearchQuery int `json:"searchQuery"`
}

type GetOneExpenseDTO

type GetOneExpenseDTO struct {
	ID int `json:"id"`
}

type LoginDTO

type LoginDTO struct {
	Username string `json:"username"`
	Password string `json:"password"`
}

type LoginResponse

type LoginResponse struct {
	ID    int64  `json:"id"`
	Token string `json:"token"`
}

type PasswordResetLog

type PasswordResetLog struct {
	ID        uint      `json:"id" gorm:"primaryKey"`
	UserID    uint      `json:"userId" gorm:"not null;index;uniqueIndex:userid_code"`
	Code      int       `json:"code" gorm:"not null;uniqueIndex:userid_code"`
	IsUsed    bool      `json:"isUsed" gorm:"default:0"`
	CreatedAt time.Time `json:"createdAt" gorm:"autoCreateTime;type:TIMESTAMP"`
	UpdatedAt time.Time `json:"updatedAt" gorm:"autoUpdateTime;type:TIMESTAMP"`
}

type SignupDTO

type SignupDTO struct {
	Name     string `json:"name"`
	Username string `json:"username"`
	Email    string `json:"email"`
	Password string `json:"password"`
}

type UpdateCategoryDTO

type UpdateCategoryDTO struct {
	ID   int    `json:"id"`
	Name string `json:"name"`
}

type UpdateExpenseDTO

type UpdateExpenseDTO struct {
	ID int `json:"id"`
	CreateExpenseDTO
}

type UpdateUserDetailsDTO

type UpdateUserDetailsDTO struct {
	ID              int    `json:"id"`
	Name            string `json:"name"`
	DefaultCurrency string `json:"defaultCurrency"`
}

type User

type User struct {
	ID              uint      `json:"id" gorm:"primaryKey"`
	Name            string    `json:"name" gorm:"size:100;not null"`
	Username        string    `json:"username" gorm:"unique;size:100;not null"`
	Email           string    `json:"email" gorm:"unique;not null"`
	Password        string    `json:"password,omitempty"`
	IsActive        bool      `json:"isActive" gorm:"default:1"`
	DefaultCurrency string    `json:"defaultCurrency" gorm:"size:5"`
	CreatedAt       time.Time `json:"createdAt" gorm:"autoCreateTime;type:TIMESTAMP"`
	UpdatedAt       time.Time `json:"updatedAt" gorm:"autoUpdateTime;type:TIMESTAMP"`
}

type UserRepository

type UserRepository interface {
	GetById(id int) (*User, error)
	UpdateUserDetails(params UpdateUserDetailsDTO) error
}

type UserService

type UserService interface {
	GetLoggedInUser(id int) (*User, error)
	UpdateUserDetails(params UpdateUserDetailsDTO) error
}

Jump to

Keyboard shortcuts

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