models

package
v0.0.0-...-c6b4f3c Latest Latest
Warning

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

Go to latest
Published: Jun 13, 2020 License: MIT Imports: 14 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	// DB variable for connection DB postgresql
	DB *sql.DB
)

Functions

func CekExistData

func CekExistData(id int) error

CekExistData function for validate data exist

func Connect

func Connect() error

Connect function for checking connection to postgresql

func DeleteAllRoom

func DeleteAllRoom(w http.ResponseWriter, r *http.Request) (string, error)

DeleteAllRoom function for Delete all data in table rooms

func DeleteRoom

func DeleteRoom(w http.ResponseWriter, r *http.Request) (string, error)

DeleteRoom function for delete one data in table rooms

func InitViper

func InitViper()

InitViper from file toml

func InsertRooms

func InsertRooms(data *Rooms) (map[string]interface{}, error)

InsertRooms function for insert data in table Rooms

func LimitOffset

func LimitOffset(limit string, offset string) string

LimitOffset function for get limit and offset in request API

func ShortBy

func ShortBy(query string) string

ShortBy function for shorting data

func UpdateRooms

func UpdateRooms(r http.ResponseWriter, h *http.Request) (map[string]interface{}, error)

UpdateRooms function for update data rooms

Types

type Borrow

type Borrow struct {
	ID        int    `json:"id,omitempty"`
	RoomID    int    `json:"room_id,omitempty"`
	EventName string `json:"event_name,omitempty"`
	Borrower  string `json:"borrower,omitempty"`
	StartDate string `json:"start_date,omitempty"`
	EndDate   string `json:"end_date,omitempty"`
}

Borrow struct for get Borrow

type ManyRooms

type ManyRooms []Rooms

ManyRooms strtuck for many room array

func GetBorrows

func GetBorrows(w http.ResponseWriter, r *http.Request) (ManyRooms, error)

GetBorrows functin for get all borrow

func GetRooms

func GetRooms(w http.ResponseWriter, r *http.Request) (ManyRooms, error)

GetRooms function for get all data from table

type Rooms

type Rooms struct {
	RmID      int    `json:"rm_id,omitemp"`
	RmName    string `json:"rm_name,omitemp"`
	RmPlace   string `json:"rm_place,omitemp"`
	RmSumpart int    `json:"rm_sumpart,omitemp"`
	RmPrice   int    `json:"rm_price,omitemp"`
	RmStatus  int    `json:"rm_status,omitemp"`
}

Rooms struct for table ROoms

func GetRoom

func GetRoom(w http.ResponseWriter, r *http.Request) (*Rooms, error)

GetRoom functionfor get perRooms

type Token

type Token struct {
	UserID  uint      `json:"user_id,omitemp"`
	Email   string    `json:"email,omitemp"`
	TimeExp time.Time `json:"time_exp,omitemp"`
	jwt.StandardClaims
}

Token function for response token

type User

type User struct {
	ID       int    `json:"id,omitemp"`
	Email    string `json:"email,omitemp"`
	Username string `json:"username,omitemp"`
	Password string `json:"password,omitemp"`
	gorm.Model
}

User struct for get users struct

func (*User) CreateAccount

func (user *User) CreateAccount() map[string]interface{}

CreateAccount function for create account for login

func (*User) Login

func (user *User) Login() map[string]interface{}

Login function for checking login valid or not

func (*User) Validate

func (user *User) Validate() (map[string]interface{}, bool)

Validate function for validate

Jump to

Keyboard shortcuts

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