models

package
v0.0.0-...-caf5947 Latest Latest
Warning

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

Go to latest
Published: Jul 8, 2020 License: MIT Imports: 8 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var DB *gorm.DB

Functions

func CloseDB

func CloseDB()

func CreateChannelTable

func CreateChannelTable()

func CreateFirstUsers

func CreateFirstUsers()

func CreateGalleryChat

func CreateGalleryChat() error

func CreateUserAuthTable

func CreateUserAuthTable()

func CreateUserChannelTable

func CreateUserChannelTable()

func CreateUserPrefTable

func CreateUserPrefTable()

func CreateUserTable

func CreateUserTable()

func DropChannelTable

func DropChannelTable()

func DropDBTables

func DropDBTables()

func DropUserAuthTable

func DropUserAuthTable()

func DropUserChannelTable

func DropUserChannelTable()

func DropUserPrefTable

func DropUserPrefTable()

func DropUserTable

func DropUserTable()

func Init

func Init()

func InitializeTable

func InitializeTable()

func VerifyUserChannel

func VerifyUserChannel(userId int, channelId int) bool

Types

type AuthenticateUserModel

type AuthenticateUserModel struct {
	Password string `form:"password" 	json:"password" binding:"required"`
	Email    string `form:"email"			json:"email" binding:"required"`
}

type Channel

type Channel struct {
	gorm.Model
	OwnerId     uint    `json:"ownerId" gorm:"default:0"`
	Name        string  `json:"name" gorm:"type:varchar(100)"`
	Description string  `json:"description" gorm:"type:varchar(512)"`
	IsPrivate   bool    `json:"isPrivate" gorm:"default:true"`
	IsAChatBot  bool    `json:"chatBot" gorm:"default:false"`
	Users       []*User `json:"users" gorm:"PRELOAD:true;many2many:user_channels;"`
}

func ChannelListUser

func ChannelListUser(userId uint) []*Channel

func CreateAChatBot

func CreateAChatBot(userId uint) (Channel, error)

func CreateChannel

func CreateChannel(user User, name string, description string, isPrivate bool) (Channel, error)

func GetChannel

func GetChannel(id int) (Channel, error)

func GetChannelGallery

func GetChannelGallery() (Channel, error)

func GetChannels

func GetChannels() ([]*Channel, int, error)

func UpdateChannel

func UpdateChannel(id int, maps interface{}) (Channel, error)

type CreateUserModel

type CreateUserModel struct {
	Firstname string `form:"firstname" json:"firstname" binding:"required"`
	Lastname  string `form:"lastname"	json:"lastname" binding:"required"`
	Nickname  string `form:"nickname"  json:"nickname" binding:"required"`
	Password  string `form:"password" 	json:"password" binding:"required"`
	Email     string `form:"email"			json:"email" binding:"required"`
}

type CreateUserPrefModel

type CreateUserPrefModel struct {
	UserId   uint   `form:"userId" 			json:"userId" binding:"required"`
	Nickname string `form:"nickname" 		json:"nickname" binding:"required"`
	Firsname string `form:"firstname" 	json:"firstname" binding:"required"`
	Lastname string `form:"lastname" 		json:"lastname" binding:"required"`
	Gravatar string `form:"gravatar" 		json:"gravatar" binding:"required"`
	Status   string `form:"status" 			json:"status" binding:"required"`
	IsLocal  string `form:"isLocal" 		json:"isLocal" binding:"required"`
}

type User

type User struct {
	gorm.Model
	Email    string     `json:"email" valid:"email;required" gorm:"type:varchar(100);unique_index" email:"required"`
	UserPref UserPref   `json:"profile" gorm:"PRELOAD:true;ForeignKey:UserId;AssociationForeignKey:ID"`
	Channels []*Channel `json:"channels" gorm:"PRELOAD:true;many2many:user_channels;"`
}

func CreateUser

func CreateUser(data CreateUserModel) (User, error)

func GetUser

func GetUser(id int) (User, error)

func GetUserByEmail

func GetUserByEmail(email string) (User, error)

func GetUserWithPref

func GetUserWithPref(user User, userPref UserPref) User

func GetUsers

func GetUsers() ([]*User, int, error)

func UserListChannel

func UserListChannel(channelId uint) []*User

type UserAuth

type UserAuth struct {
	gorm.Model
	UserId      uint      `gorm:"primary_key:UserId;unique_index"`
	LastLogin   time.Time `sql:"DEFAULT:current_timestamp"`
	AuthProfile string    `gorm:"default:'local'"`
	PassHash    string    `gorm:"type:varchar(512);unique_index"`
	PassSalt    string    `gorm:"type:varchar(512);unique_index"`
}

func CreateUserAuth

func CreateUserAuth(user User, hash string, salt string) (UserAuth, error)

func GetUserAuthByUserId

func GetUserAuthByUserId(userId uint) (UserAuth, error)

func UpdateUserAuth

func UpdateUserAuth(userId int, lastLogin *time.Time) (UserAuth, error)

type UserChannel

type UserChannel struct {
	gorm.Model
	UserId    string `gorm:"primary_key"`
	ChannelId string `gorm:"primary_key"`
	IsActive  bool   `gorm:"default:true"`
}

type UserPref

type UserPref struct {
	gorm.Model
	UserId    uint   `json:"userId" gorm:"primary_key";valid:"required"`
	Firstname string `json:"firstname" gorm:"type:varchar(100)"`
	Lastname  string `json:"lastname"  gorm:"type:varchar(100)"`
	Nickname  string `json:"nickname" 	valid:"required" gorm:"type:varchar(100);unique_index; not null"`
	Gravatar  string `json:"gravatar"`
	Color     string `json:"color" valid:"required"`
	Status    string `json:"status" gorm:"type:varchar(500)"`
	IsLocal   bool   `json:"isLocal" gorm:"default:true"`
}

func CreateBasicUserPref

func CreateBasicUserPref(userId uint) (UserPref, error)

func CreateUserPref

func CreateUserPref(userId uint, data map[string]interface{}) (UserPref, error)

func GetUserPref

func GetUserPref(userId uint) (UserPref, error)

func UpdateUserPref

func UpdateUserPref(userId uint) (UserPref, error)

Jump to

Keyboard shortcuts

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