example

package
v0.3.5 Latest Latest
Warning

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

Go to latest
Published: Apr 12, 2021 License: Apache-2.0 Imports: 19 Imported by: 0

README

Example

How to run

CFG_FILE=./config/config.yml go run cmd/main.go

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func NewDB

func NewDB(gormDB *gorm.DB) (*sql.DB, error)

func NewGormDB

func NewGormDB(log logger.LogInfoFormat) (*gorm.DB, error)

func NewUserCtrl

func NewUserCtrl(svc Service) app.Handler

Types

type Repository

type Repository interface {
	Create(*User) error
	Update(*User) error
	Delete(uint64) error
	FindByID(uint64) (*User, error)
	FindAll() ([]*User, error)
	UpdatePassword(username string, password string) error
}

func NewUserRepository

func NewUserRepository(db *gorm.DB) Repository

type Service

type Service interface {
	Create(*User) error
	Update(*User) error
	Delete(uint64) error
	FindByID(uint64) (*User, error)
	FindAll() ([]*User, error)
	UpdatePassword(string, string) error
}

func NewUserService

func NewUserService(repo Repository) Service

type UpdatePasswdReq

type UpdatePasswdReq struct {
	Username    string `json:"username"`
	NewPassword string `json:"new_password"`
}

type User

type User struct {
	ID        uint64     `json:"id" gorm:"primaryKey,autoIncrement"`
	Username  string     `json:"username" binding:"required"`
	Password  string     `json:"password" binding:"required"`
	Deleted   db.Deleted `json:"-"`
	Version   db.Version `json:"version" gorm:"default:1"`
	CreatedAt *time.Time `json:"created_at"`
	UpdatedAt *time.Time `json:"updated_at"`
}

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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