api

package
v0.0.0-...-6414604 Latest Latest
Warning

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

Go to latest
Published: Aug 19, 2023 License: MIT Imports: 15 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func AppInit

func AppInit(app *BaseApp)

func BindNoteApi

func BindNoteApi(app *BaseApp, rg *echo.Group)

func BindUserApi

func BindUserApi(app *BaseApp, rg *echo.Group)

func NewBaseApp

func NewBaseApp() error

Types

type BaseApp

type BaseApp struct {
	Echo       *echo.Echo
	Connection *gorm.DB
}

func (*BaseApp) AppCleanup

func (app *BaseApp) AppCleanup() error

type BaseModel

type BaseModel struct {
	ID        string          `gorm:"type:uuid;primaryKey;not null" json:"id,omitempty"`
	CreatedAt time.Time       `gorm:"not null;"                     json:"created_at,omitempty"`
	UpdatedAt time.Time       `gorm:"not null;"                     json:"updated_at,omitempty"`
	DeletedAt *gorm.DeletedAt `gorm:"index"                         json:"deleted_at,omitempty"`
}

func (*BaseModel) GenerateId

func (b *BaseModel) GenerateId()

type Note

type Note struct {
	BaseModel
	NoteSchema
	User   *User  `gorm:"foreignKey:UserId;references:ID" json:"user,omitempty"`
	UserId string `gorm:"type:uuid;"                      json:"user_id,omitempty" form:"user_id"`
}

type NoteController

type NoteController struct {
	App *BaseApp
}

func (*NoteController) DestroyNote

func (ctrl *NoteController) DestroyNote(ctx echo.Context) error

func (*NoteController) IndexNote

func (ctrl *NoteController) IndexNote(ctx echo.Context) error

func (*NoteController) ShowNote

func (ctrl *NoteController) ShowNote(ctx echo.Context) error

func (*NoteController) StoreNote

func (ctrl *NoteController) StoreNote(ctx echo.Context) error

func (*NoteController) UpdateNote

func (ctrl *NoteController) UpdateNote(ctx echo.Context) error

type NoteSchema

type NoteSchema struct {
	Title   string `gorm:"not null;"      json:"title,omitempty"   form:"title"`
	Body    string `gorm:"not null;"      json:"body,omitempty"    form:"body"`
	Private bool   `gorm:"default:false;" json:"private,omitempty" form:"private"`
}

--------------- Note Model ---------------

type User

type User struct {
	BaseModel
	UserSchema
	Notes []Note `gorm:"foreignKey:UserId;references:ID;Constraints:onDelete:Cascade;" json:"notes"`
}

type UserController

type UserController struct {
	App *BaseApp
}

func (*UserController) DestroyUser

func (ctrl *UserController) DestroyUser(ctx echo.Context) error

func (*UserController) IndexUser

func (ctrl *UserController) IndexUser(ctx echo.Context) error

func (*UserController) ShowUser

func (ctrl *UserController) ShowUser(ctx echo.Context) error

func (*UserController) StoreUser

func (ctrl *UserController) StoreUser(ctx echo.Context) error

func (*UserController) UpdateUser

func (ctrl *UserController) UpdateUser(ctx echo.Context) error

type UserSchema

type UserSchema struct {
	Username string `gorm:"unique;not null;" json:"username,omitempty" form:"username"`
	Email    string `gorm:"unique;not null;" json:"email,omitempty"    form:"email"`
	Password string `gorm:"not null;"        json:"password,omitempty" form:"password"`
}

--------------- User Model ---------------

Jump to

Keyboard shortcuts

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