db

package
v0.0.0-...-1b38902 Latest Latest
Warning

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

Go to latest
Published: Feb 5, 2020 License: MIT Imports: 5 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func DeleteUser

func DeleteUser(UserID int, PassWord string) error

DeleteUser delete user on database

func FindDataSpecifiedNumber

func FindDataSpecifiedNumber(GroupID string, num int) ([]string, error)

FindDataSpecifiedNumber return all data information in specified number of GroupID

func FindUserIDbyMail

func FindUserIDbyMail(mail string) (int, error)

FindUserIDbyMail Return UserID from mail

func GetGroupIDFromLineID

func GetGroupIDFromLineID(lineID string) (string, error)

GetGroupIDFromLineID Return GroupID from LineID

func GroupCheck

func GroupCheck(UserID int, PassWord string, GroupID string) (err error)

GroupCheck check group and user auth

func InitDB

func InitDB()

InitDB check connection and auto create tables if not available

func InsertDataData

func InsertDataData(UserID int, PassWord string, GroupID string, DataName string, ImageName string, Title string, DataType int) error

InsertDataData insert data data to data table

func InsertUserData

func InsertUserData(UserName string, PassWord string, Mail string, GroupID string) (int, error)

InsertUserData i nsert user data to users table

func UpdateGroupID

func UpdateGroupID(UserID int, GroupID string, PassWord string) (gid string, err error)

UpdateGroupID update database's user's GroupID

func UpdateLineID

func UpdateLineID(UserID int, LineID, PassWord string) error

UpdateLineID update database's user's LIneID

func UserAuth

func UserAuth(mail string, password string) error

UserAuth test user authentication by mail and password

Types

type Data

type Data struct {
	gorm.Model
	UserID    int    `grom:"primary_key:true"`
	GroupID   string `gorm:"not null"`
	DataName  string `gorm:"primary_key"`
	ImageName string
	Title     string
	DataType  int `gorm:"not null"`
}

Data struct define data table's struct

type Model

type Model struct {
	ID        uint `gorm:"primary_key"`
	CreatedAt time.Time
	UpdatedAt time.Time
	DeletedAt *time.Time `sql:"index"`
}

Model base model definition, including fields `ID`, `CreatedAt`, `UpdatedAt`, `DeletedAt`, which could be embedded in your models

type Result

type Result struct {
	UserID    int
	UserName  string
	GroupID   string
	DataName  string
	ImageName string
	Title     string
	DataType  int
}

Result struct define return data's list

func FindAllDataInGroup

func FindAllDataInGroup(GroupID string) ([]Result, error)

FindAllDataInGroup return all data information of GroupID

type User

type User struct {
	gorm.Model
	UserName string `gorm:"not null"`
	Password string `gorm:"not null"`
	Mail     string `gorm:"not null"`
	GroupID  string `gorm:"not null"`
	LineID   string `gorm:"default:null"`
}

User struct define users table's struct

func RetUserStruct

func RetUserStruct(Mail string) (User, error)

RetUserStruct return user as struct

Jump to

Keyboard shortcuts

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