models

package
v0.0.0-...-6d3268d Latest Latest
Warning

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

Go to latest
Published: Mar 31, 2020 License: Apache-2.0 Imports: 17 Imported by: 2

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func AddDeveloper

func AddDeveloper(d *Developer) error

func DeleteDeveloperByName

func DeleteDeveloperByName(devname string) error

func InitMysql

func InitMysql(user, pwd, addr, db string) error

func InitUserCache

func InitUserCache(limits int)

func IsExist

func IsExist(path string) bool

func UpdateDeveloper

func UpdateDeveloper(p *Developer) error

Types

type AppInfo

type AppInfo struct {
	Id        int64      // Id号
	AppId     string     `orm:"unique;size(50)"`         //appid
	Key       string     `orm:"size(50)"`                //秘钥
	Name      string     `orm:"unique;size(32)"`         //app名字
	Developer *Developer `orm:"rel(fk)"`                 //应用所属的开发者
	Created   time.Time  `orm:"auto_now_add;type(date)"` //应用创建时间
	Email     string     `orm:"size(100)"`               //与应用绑定的Email
	Token     string     `orm:"size(100)"`               // app授权token值
	Users     []*User    `orm:"reverse(many)"`
	// contains filtered or unexported fields
}

AppInfo 应用信息

func GetAppInfoByToken

func GetAppInfoByToken(token string) (*AppInfo, error)

func (*AppInfo) AddAndUpdateUser

func (this *AppInfo) AddAndUpdateUser(user *User) error

func (*AppInfo) AddUser

func (this *AppInfo) AddUser(user *User) error

func (*AppInfo) DeleteUser

func (this *AppInfo) DeleteUser(userid, token string) error

func (*AppInfo) GetAllUsers

func (this *AppInfo) GetAllUsers() (users []*User, count int64, err error)

func (*AppInfo) GetUserById

func (this *AppInfo) GetUserById(userid, token string) (*User, error)

func (*AppInfo) GetUserByIdForTrain

func (this *AppInfo) GetUserByIdForTrain(userid, token string) (*User, error)

func (*AppInfo) NewUser

func (this *AppInfo) NewUser(token, userid string) *User

func (*AppInfo) UpdateUser

func (this *AppInfo) UpdateUser(u *User) error

type CacheMem

type CacheMem struct {
	sync.RWMutex
	// contains filtered or unexported fields
}
var UserCache *CacheMem

func NewCacheMem

func NewCacheMem(limits int) *CacheMem

func (*CacheMem) Add

func (c *CacheMem) Add(key string, u *User) error

func (*CacheMem) Get

func (c *CacheMem) Get(key string) (*User, bool)

func (*CacheMem) Modify

func (c *CacheMem) Modify(key string, u *User) error

func (*CacheMem) Remove

func (c *CacheMem) Remove(key string) (err error)

Remove removes the provided key from the keywordCache.

func (*CacheMem) RemoveAll

func (c *CacheMem) RemoveAll() error

func (*CacheMem) RemoveOldest

func (c *CacheMem) RemoveOldest()

RemoveOldest removes the oldest item from the keywordCache.

type DBEngine

type DBEngine struct {
}

func NewDBEngine

func NewDBEngine() *DBEngine

func (*DBEngine) AddAppInfo

func (this *DBEngine) AddAppInfo(devname, appName string) error

func (*DBEngine) AddDeveloper

func (this *DBEngine) AddDeveloper(devname, password, email string) error

func (*DBEngine) AddUser

func (this *DBEngine) AddUser(token, id string) error

func (*DBEngine) AddWavesAndContents

func (this *DBEngine) AddWavesAndContents(token, id string, wave []byte, content string, step int) error

func (*DBEngine) CheckDeveloper

func (this *DBEngine) CheckDeveloper(devname, password string) (bool, error)

func (*DBEngine) CheckEmailIsExist

func (this *DBEngine) CheckEmailIsExist(email string) bool

func (*DBEngine) ClearWavesAndContents

func (this *DBEngine) ClearWavesAndContents(token, id string) error

func (*DBEngine) DeleteAppInfoByName

func (this *DBEngine) DeleteAppInfoByName(devname, appname string) error

func (*DBEngine) DeleteDeveloperByName

func (this *DBEngine) DeleteDeveloperByName(devname string) error

func (*DBEngine) DeleteUser

func (this *DBEngine) DeleteUser(token, id string) error

func (*DBEngine) FindDeveloperByName

func (this *DBEngine) FindDeveloperByName(devname string) (*Developer, error)

func (*DBEngine) GetAppInfoByName

func (this *DBEngine) GetAppInfoByName(devname, appname string) (*AppInfo, error)

func (*DBEngine) GetAppInfoByToken

func (this *DBEngine) GetAppInfoByToken(devname, token string) (*AppInfo, error)

func (*DBEngine) GetUserById

func (this *DBEngine) GetUserById(token, id string) (*User, error)

func (*DBEngine) GetUserByIdForTrain

func (this *DBEngine) GetUserByIdForTrain(token, id string) (*User, error)

func (*DBEngine) HasPermissionForAppInfo

func (this *DBEngine) HasPermissionForAppInfo(devname, appid, appkey string) (bool, *AppInfo, error)

func (*DBEngine) UpdateAppInfoByName

func (this *DBEngine) UpdateAppInfoByName(devname string, app *AppInfo) error

func (*DBEngine) UpdateDeveloperByName

func (this *DBEngine) UpdateDeveloperByName(dev *Developer) error

func (*DBEngine) UpdateDeveloperPassword

func (this *DBEngine) UpdateDeveloperPassword(devname, oldPassword, newPassword string) (bool, error)

func (*DBEngine) UpdateIsTrained

func (this *DBEngine) UpdateIsTrained(token, id string, isTrain bool) error

type Developer

type Developer struct {
	Id            int64
	DeveloperName string     `orm:"unique;size(32)"`
	Password      string     `orm:"size(50)"`
	Email         string     `orm:"size(50)"`
	CreateTime    time.Time  `orm:"auto_now_add;type(date)"`
	Apps          []*AppInfo `orm:"reverse(many)"`
	// contains filtered or unexported fields
}

func GetAllDevelopers

func GetAllDevelopers() (developers []*Developer, count int64, err error)

func GetDeveloperByName

func GetDeveloperByName(devname string) (*Developer, error)

func NewDeveloper

func NewDeveloper(developername, password, email string) *Developer

func (*Developer) AddAppInfo

func (this *Developer) AddAppInfo(app *AppInfo) error

func (*Developer) DeleteAppInfo

func (this *Developer) DeleteAppInfo(appname string) error

func (*Developer) GetAllAppInfo

func (this *Developer) GetAllAppInfo() (appInfos []*AppInfo, count int64, err error)

获得所有项目

func (*Developer) GetAppInfoById

func (this *Developer) GetAppInfoById(id int64) (*AppInfo, error)

获得项目

func (*Developer) GetAppInfoByName

func (this *Developer) GetAppInfoByName(appname string) (*AppInfo, error)

获得项目

func (*Developer) GetAppInfoByToken

func (this *Developer) GetAppInfoByToken(token string) (*AppInfo, error)

func (*Developer) NewAppInfo

func (this *Developer) NewAppInfo(appname string) *AppInfo

func (*Developer) UpdateAppInfo

func (this *Developer) UpdateAppInfo(app *AppInfo) error

type User

type User struct {
	Id       int64
	App      *AppInfo `orm:"rel(fk)"`
	UserId   string   `orm:"unique;size(32)"` // 用户ID号
	Token    string   `orm:"size(100)"`       // app授权token值
	Waves    [][]byte `orm:"-"`
	Contents []string `orm:"-"` // 5条语音的文本内容
	IsTrain  bool     // 是否已经训练模型
	// contains filtered or unexported fields
}

func (*User) GetAllWavesAndContents

func (this *User) GetAllWavesAndContents() error

Jump to

Keyboard shortcuts

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