model

package
v0.0.0-...-23d3c29 Latest Latest
Warning

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

Go to latest
Published: May 20, 2024 License: MIT Imports: 3 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type MenuItem struct {
	ID            uint      `json:"id" gorm:"primary_key"`
	Name          string    `json:"name"`
	Description   string    `json:"description" gorm:"unique"`
	Picture       string    `json:"picture"`
	Price         float32   `json:"price"`
	Qty           string    `json:"qty"`
	DiscountType  string    `json:"discount_type" gorm:"default:'nominal'"`
	DiscountValue float32   `json:"discount_value" gorm:"default:0"`
	Category      string    `json:"category"`
	CreatedBy     uint      `json:"created_by" gorm:"default:1"`
	UpdatedBy     uint      `json:"updated_by" gorm:"default:1"`
	CreatedAt     time.Time `json:"created_at" gorm:"default:CURRENT_TIMESTAMP"`
	UpdatedAt     time.Time `json:"updated_at" gorm:"default:CURRENT_TIMESTAMP"`
}

User adalah struktur untuk representasi data pengguna

func (m *MenuItem) Delete() error
func (m *MenuItem) Update() error

type User

type User struct {
	ID          uint      `json:"id" gorm:"primary_key"`
	Username    string    `json:"username" gorm:"unique"`
	Password    string    `json:"-"` // "-" untuk menyembunyikan field ini dari serialisasi JSON
	Email       string    `json:"email" gorm:"unique"`
	GoogleID    string    `json:"google_id"`
	Role        string    `json:"role" gorm:"default:'customer'"`
	Fullname    string    `json:"fullname"`
	Picture     string    `json:"picture"`
	Gender      string    `json:"gender"`
	Birthdate   time.Time `json:"birthdate"`
	PhoneNumber string    `json:"phone_number"`
	Address     string    `json:"address"`
	CreatedBy   uint      `json:"created_by" gorm:"default:1"`
	UpdatedBy   uint      `json:"updated_by" gorm:"default:1"`
	CreatedAt   time.Time `json:"created_at" gorm:"default:CURRENT_TIMESTAMP"`
	UpdatedAt   time.Time `json:"updated_at" gorm:"default:CURRENT_TIMESTAMP"`
}

User adalah struktur untuk representasi data pengguna

func (*User) CheckPassword

func (u *User) CheckPassword(password string) error

CheckPassword memeriksa apakah password yang diberikan cocok dengan password yang disimpan

func (*User) Delete

func (u *User) Delete() error

func (*User) SetPassword

func (u *User) SetPassword(password string) error

SetPassword mengenkripsi password menggunakan bcrypt sebelum disimpan ke database

func (*User) Update

func (u *User) Update() error

Jump to

Keyboard shortcuts

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