database

package
v0.0.0-...-de73072 Latest Latest
Warning

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

Go to latest
Published: Jan 6, 2019 License: GPL-3.0 Imports: 13 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var DataBase *sql.DB

DataBase is global database var

Functions

func AddUser

func AddUser(LineName, UserID string, course *sql.Tx) (DBErr error)

AddUser add a User to line

func Begin

func Begin(course *sql.Tx) (*sql.Tx, bool, error)

Begin Automatic call DB.Begin to begin a course

func Close

func Close() error

Close database

func Commit

func Commit(course *sql.Tx, selfCourse bool) error

Commit Automatic call DB.Commit to Commit a course

func CreateGroupTable

func CreateGroupTable(course *sql.Tx) (err error)

CreateGroupTable Create Group Table, Group recoder the relation between user and line

func CreateImage

func CreateImage(UserID string, Images []ImgInfo) error

CreateImage will mark a group of img one by one belong to a user

func CreateImageTable

func CreateImageTable(course *sql.Tx) (err error)

CreateImageTable Create image Table, image recoder the image TODO: to recoder img size

func CreateLine

func CreateLine(LineName, UserID string) error

CreateLine Create Line and add a user to it's group

func CreateLineTable

func CreateLineTable(course *sql.Tx) (err error)

CreateLineTable Create Line Table

func CreateSlice

func CreateSlice(LineName, UserID string, Gallery []string, Content, Type, Visibility, Location, Time string) error

CreateSlice Create Slice

func CreateSliceTable

func CreateSliceTable(course *sql.Tx) (err error)

CreateSliceTable Create Slice Table, Slice is the unite in the line, it has two basic type, memory and Anniversary the visibillty Protect means only people join this group can view, Private means only people create this slice can view

func CreateUser

func CreateUser(Phone, Mail, HashPass string, OpenID, UnionID *string) (NickName, Pass string, ErrorMsg error)

CreateUser create a unverify user

func CreateUserTable

func CreateUserTable(course *sql.Tx) (err error)

CreateUserTable Create User Table

func GetImgInfo

func GetImgInfo(UserID, Hash string) (Size, Height, Width int, Time time.Time, err error)

func GetLineDetail

func GetLineDetail(LineName string, course *sql.Tx) (LineID, Name, LatestImg string, Users []string, SliceNum, ImgNum int, CreateTime, LatestTime time.Time, DBErr error)

GetLineDetail Get some statics info of line contain info of GetLineInfo

func GetLineInfo

func GetLineInfo(LineName string, course *sql.Tx) (LineID, Name string, CreateTime time.Time, DBErr error)

GetLineInfo Get Line Info

func GetLines

func GetLines(UserID string) (Lines []string, DBerr error)

GetLines get Lines of user

func GetUserByMail

func GetUserByMail(Mail string) (ID, Phone, NickName, Gender, Salt, SaltPass, ProfilePic string, SignInTime time.Time, ErrorMsg error)

GetUserByMail Found User By Mail

func GetUserByOpenID

func GetUserByOpenID(OpenID string) (ID, UnionID, Phone, Mail, NickName, Gender, Salt, SaltPass, ProfilePic string, SignInTime time.Time, DBErr error)

func GetUserByPhone

func GetUserByPhone(Phone string, course *sql.Tx) (ID, Mail, NickName, Gender, Salt, SaltPass, ProfilePic string, SignInTime time.Time, DBErr error)

GetUserByPhone Found User By Phone Err : DataBase Connection Error User Not Exist DBErr

func GraceCommit

func GraceCommit(course *sql.Tx, selfCourse bool, err error) error

GraceCommit will automitic commit or rollback

func Open

func Open() error

Open using a sql.Open to open database

func Rollback

func Rollback(course *sql.Tx, selfCourse bool) error

Rollback Automatic call DB.Rollback to Commit a Rollback

func UpdateImgVisibility

func UpdateImgVisibility(UserID, ImgHash, Visibility string, course *sql.Tx) (ErrorMsg error)

func UpdateNickName

func UpdateNickName(UserID, NewName string, course *sql.Tx) (DBErr error)

UpdateNickName Update User NickName

func UpdateProfilePic

func UpdateProfilePic(UserID, ImgHash string) (ErrorMsg error)

UpdateProfilePic Update ProfilePicture Mention this func will set img Visibility to Public

func UpdateWeiXin

func UpdateWeiXin(OpenID, Phone, Mail string, UnionID *string) (DBErr error)

Types

type ImgInfo

type ImgInfo struct {
	Hash   string
	Size   int
	Height int
	Width  int
}

type SliceInfo

type SliceInfo struct {
	UserName   string    //创建者昵称
	Gallery    []string  //附带图片
	Content    string    //附带文字
	Type       string    //类型
	Visibility string    //查看权限
	Location   string    //定位
	Time       time.Time //记录时间
}

SliceInfo struct use in GetSlice func

func GetSlices

func GetSlices(LineName string, UserID string, PageNum int) (Res []SliceInfo, DBerr error)

GetSlices Get Slice List

Jump to

Keyboard shortcuts

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