model

package
v4.2.4 Latest Latest
Warning

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

Go to latest
Published: Oct 16, 2022 License: AGPL-3.0 Imports: 28 Imported by: 0

Documentation

Overview

Nging is a toolbox for webmasters Copyright (C) 2018-present Wenhui Shen <swh@admpub.com>

This program is free software: you can redistribute it and/or modify it under the terms of the GNU Affero General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version.

This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License for more details.

You should have received a copy of the GNU Affero General Public License along with this program. If not, see <https://www.gnu.org/licenses/>.

Nging is a toolbox for webmasters Copyright (C) 2018-present Wenhui Shen <swh@admpub.com>

This program is free software: you can redistribute it and/or modify it under the terms of the GNU Affero General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version.

This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License for more details.

You should have received a copy of the GNU Affero General Public License along with this program. If not, see <https://www.gnu.org/licenses/>.

Nging is a toolbox for webmasters Copyright (C) 2018-present Wenhui Shen <swh@admpub.com>

This program is free software: you can redistribute it and/or modify it under the terms of the GNU Affero General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version.

This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License for more details.

You should have received a copy of the GNU Affero General Public License along with this program. If not, see <https://www.gnu.org/licenses/>.

Nging is a toolbox for webmasters Copyright (C) 2018-present Wenhui Shen <swh@admpub.com>

This program is free software: you can redistribute it and/or modify it under the terms of the GNU Affero General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version.

This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License for more details.

You should have received a copy of the GNU Affero General Public License along with this program. If not, see <https://www.gnu.org/licenses/>.

Nging is a toolbox for webmasters Copyright (C) 2018-present Wenhui Shen <swh@admpub.com>

This program is free software: you can redistribute it and/or modify it under the terms of the GNU Affero General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version.

This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License for more details.

You should have received a copy of the GNU Affero General Public License along with this program. If not, see <https://www.gnu.org/licenses/>.

Nging is a toolbox for webmasters Copyright (C) 2018-present Wenhui Shen <swh@admpub.com>

This program is free software: you can redistribute it and/or modify it under the terms of the GNU Affero General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version.

This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License for more details.

You should have received a copy of the GNU Affero General Public License along with this program. If not, see <https://www.gnu.org/licenses/>.

Nging is a toolbox for webmasters Copyright (C) 2018-present Wenhui Shen <swh@admpub.com>

This program is free software: you can redistribute it and/or modify it under the terms of the GNU Affero General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version.

This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License for more details.

You should have received a copy of the GNU Affero General Public License along with this program. If not, see <https://www.gnu.org/licenses/>.

Nging is a toolbox for webmasters Copyright (C) 2018-present Wenhui Shen <swh@admpub.com>

This program is free software: you can redistribute it and/or modify it under the terms of the GNU Affero General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version.

This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License for more details.

You should have received a copy of the GNU Affero General Public License along with this program. If not, see <https://www.gnu.org/licenses/>.

Nging is a toolbox for webmasters Copyright (C) 2018-present Wenhui Shen <swh@admpub.com>

This program is free software: you can redistribute it and/or modify it under the terms of the GNU Affero General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version.

This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License for more details.

You should have received a copy of the GNU Affero General Public License along with this program. If not, see <https://www.gnu.org/licenses/>.

Index

Constants

View Source
const (
	KvRootType        = `root`
	AutoCreatedType   = `autoCreated`
	KvDefaultDataType = `text`
)
View Source
const StorageAccountIDKey = `storerID`

Variables

View Source
var (
	// SMSWaitingSeconds 短信发送后等待秒数
	SMSWaitingSeconds int64 = 60
	// SMSMaxPerDay 短信每人每天发送上限
	SMSMaxPerDay int64 = 10
)
View Source
var KvDataTypes = echo.NewKVData().Add(`number`, `数字`).Add(`text`, `文本`).Add(`json`, `JSON`)
View Source
var SafeItems = echo.NewKVData().
	Add(`gauth_bind`, `两步验证`).
	Add(`password`, `修改密码`)

Functions

func AlertSend

func AlertSend(ctx echo.Context, topic string, alertData *alertRegistry.AlertData) error

func GetU2FStepCondValue added in v4.2.0

func GetU2FStepCondValue(step uint) interface{}

Types

type AlertRecipient

type AlertRecipient struct {
	*dbschema.NgingAlertRecipient
}

func NewAlertRecipient

func NewAlertRecipient(ctx echo.Context) *AlertRecipient

func (*AlertRecipient) Add

func (s *AlertRecipient) Add() (pk interface{}, err error)

func (*AlertRecipient) Delete

func (s *AlertRecipient) Delete(mw func(db.Result) db.Result, args ...interface{}) (err error)

func (*AlertRecipient) Edit

func (s *AlertRecipient) Edit(mw func(db.Result) db.Result, args ...interface{}) (err error)

func (*AlertRecipient) GetWithExt

func (s *AlertRecipient) GetWithExt(mw func(db.Result) db.Result, args ...interface{}) (row *AlertRecipientExt, err error)

type AlertRecipientExt

type AlertRecipientExt struct {
	*dbschema.NgingAlertRecipient
}

func (*AlertRecipientExt) Send

func (a *AlertRecipientExt) Send(alertData *alert.AlertData) (err error)

type AlertTopic

type AlertTopic struct {
	*dbschema.NgingAlertTopic
}

func NewAlertTopic

func NewAlertTopic(ctx echo.Context) *AlertTopic

func (*AlertTopic) Add

func (s *AlertTopic) Add(rows ...*dbschema.NgingAlertTopic) (pk interface{}, err error)

func (*AlertTopic) Edit

func (s *AlertTopic) Edit(mw func(db.Result) db.Result, args ...interface{}) (err error)

func (*AlertTopic) Exists

func (s *AlertTopic) Exists(topic string, recipientId uint) (bool, error)

func (*AlertTopic) ExistsOther

func (s *AlertTopic) ExistsOther(topic string, recipientId uint, excludeID uint) (bool, error)

func (*AlertTopic) Send

func (s *AlertTopic) Send(topic string, alertData *alert.AlertData) (err error)

type AlertTopicExt

type AlertTopicExt struct {
	*dbschema.NgingAlertTopic
	Recipient *dbschema.NgingAlertRecipient `db:"-,relation=id:recipient_id"`
}

func (*AlertTopicExt) Send

func (a *AlertTopicExt) Send(alertData *alertRegistry.AlertData) (err error)

type CloudBackup

type CloudBackup struct {
	*dbschema.NgingCloudBackup
}

func NewCloudBackup

func NewCloudBackup(ctx echo.Context) *CloudBackup

func (*CloudBackup) Add

func (s *CloudBackup) Add() (pk interface{}, err error)

func (*CloudBackup) Edit

func (s *CloudBackup) Edit(mw func(db.Result) db.Result, args ...interface{}) (err error)

func (*CloudBackup) ListPage

func (s *CloudBackup) ListPage(cond *db.Compounds, sorts ...interface{}) ([]*CloudBackupExt, error)

type CloudBackupExt

type CloudBackupExt struct {
	*dbschema.NgingCloudBackup
	Storage       *dbschema.NgingCloudStorage `db:"-,relation=id:dest_storage"`
	Watching      bool
	FullBackuping bool
}

type CloudStorage

type CloudStorage struct {
	*dbschema.NgingCloudStorage
}

func GetCloudStorage added in v4.1.0

func GetCloudStorage(ctx context.Context) (*CloudStorage, error)

func NewCloudStorage

func NewCloudStorage(ctx echo.Context) *CloudStorage

func (*CloudStorage) Add

func (s *CloudStorage) Add() (pk interface{}, err error)

func (*CloudStorage) BaseURL

func (s *CloudStorage) BaseURL() string

func (*CloudStorage) CachedList

func (s *CloudStorage) CachedList() map[string]*dbschema.NgingCloudStorage

func (*CloudStorage) Edit

func (s *CloudStorage) Edit(mw func(db.Result) db.Result, args ...interface{}) (err error)

func (*CloudStorage) Get

func (s *CloudStorage) Get(mw func(db.Result) db.Result, args ...interface{}) error

func (*CloudStorage) RawSecret

func (s *CloudStorage) RawSecret() string

type Code

type Code struct {
	Verification *dbschema.NgingCodeVerification
	Invitation   *dbschema.NgingCodeInvitation
	*base.Base
}

func NewCode

func NewCode(ctx echo.Context) *Code

func (*Code) AddVerificationCode

func (c *Code) AddVerificationCode() (interface{}, error)

func (*Code) CheckFrequency

func (c *Code) CheckFrequency(ownerID uint64, ownerType string, sendMethod string, frequencyCfg echo.H) error

func (*Code) CheckVerificationCode

func (c *Code) CheckVerificationCode(code string, purpose string, ownerID uint64, ownerType string, sendMethod string, sendTo string) (err error)

func (*Code) CountTodayVerificationCode

func (c *Code) CountTodayVerificationCode(ownerID uint64, ownerType string, sendMethod string) (int64, error)

func (*Code) LastVerificationCode

func (c *Code) LastVerificationCode(ownerID uint64, ownerType string, sendMethod string) (err error)

func (*Code) UseInvitationCode

func (c *Code) UseInvitationCode(m *dbschema.NgingCodeInvitation, usedUid uint) (err error)

func (*Code) UseVerificationCode

func (c *Code) UseVerificationCode(m *dbschema.NgingCodeVerification) (err error)

func (*Code) VerfyInvitationCode

func (c *Code) VerfyInvitationCode(code string) (err error)

type Config

type Config struct {
	*dbschema.NgingConfig
}

func NewConfig

func NewConfig(ctx echo.Context) *Config

func (*Config) Add

func (f *Config) Add() (pk interface{}, err error)

func (*Config) Edit

func (f *Config) Edit(mw func(db.Result) db.Result, args ...interface{}) error

func (*Config) EditByPK

func (f *Config) EditByPK(mw func(db.Result) db.Result, group string, key string) error

func (*Config) ListAllMapByGroup

func (f *Config) ListAllMapByGroup() (echo.H, error)

func (*Config) ListByGroup

func (f *Config) ListByGroup(group string) (func() int64, error)

func (*Config) ListMapByGroup

func (f *Config) ListMapByGroup(group string) (echo.H, error)

func (*Config) Upsert

func (f *Config) Upsert() (pk interface{}, err error)

func (*Config) ValueByKey

func (f *Config) ValueByKey(group, key string) string

type Invitation

type Invitation struct {
	*dbschema.NgingCodeInvitation
}

func NewInvitation

func NewInvitation(ctx echo.Context) *Invitation

func (*Invitation) Exists

func (u *Invitation) Exists(code string) (bool, error)

func (*Invitation) Exists2

func (u *Invitation) Exists2(code string, excludeID uint) (bool, error)

type Kv

type Kv struct {
	*dbschema.NgingKv
}

func NewKv

func NewKv(ctx echo.Context) *Kv

func (*Kv) Add

func (s *Kv) Add() (pk interface{}, err error)

func (*Kv) AutoCreateKey

func (s *Kv) AutoCreateKey(key string, value ...string) error

func (*Kv) Delete

func (s *Kv) Delete(mw func(db.Result) db.Result, args ...interface{}) (err error)

func (*Kv) Edit

func (s *Kv) Edit(mw func(db.Result) db.Result, args ...interface{}) (err error)

func (*Kv) Get

func (s *Kv) Get(mw func(db.Result) db.Result, args ...interface{}) error

func (*Kv) GetFromTypeList

func (s *Kv) GetFromTypeList(typeList []*dbschema.NgingKv, key string) string

func (*Kv) GetTypeValues

func (s *Kv) GetTypeValues(typ string, defaultValue ...string) ([]string, error)

func (*Kv) GetValue

func (s *Kv) GetValue(key string, defaultValue ...string) (string, error)

func (*Kv) IsRootType

func (s *Kv) IsRootType(typ string) bool

func (*Kv) KvTypeList

func (s *Kv) KvTypeList(excludeIDs ...uint) []*dbschema.NgingKv

func (*Kv) ListByType

func (s *Kv) ListByType(typ string, excludeIDs ...uint) []*dbschema.NgingKv

func (*Kv) ListToMap

func (s *Kv) ListToMap(typeList []*dbschema.NgingKv) map[string]*dbschema.NgingKv

func (*Kv) SetSingleField

func (s *Kv) SetSingleField(id int, field string, value string) error

type LoginLog

type LoginLog struct {
	*dbschema.NgingLoginLog
}

func NewLoginLog

func NewLoginLog(ctx echo.Context) *LoginLog

func (*LoginLog) Add

func (s *LoginLog) Add() (pk interface{}, err error)

func (*LoginLog) AddAndSaveSession added in v4.2.2

func (s *LoginLog) AddAndSaveSession() (pk interface{}, err error)

func (*LoginLog) Edit

func (s *LoginLog) Edit(mw func(db.Result) db.Result, args ...interface{}) (err error)

func (*LoginLog) GetLastFailure added in v4.2.2

func (s *LoginLog) GetLastFailure(ownerType string, ownerId uint64) (err error)

func (*LoginLog) GetLastSuccess added in v4.2.2

func (s *LoginLog) GetLastSuccess(ownerType string, ownerId uint64, sessionId string) (err error)

func (*LoginLog) InitLocation added in v4.2.2

func (s *LoginLog) InitLocation() (ipInfo ip2regionparser.IpInfo, err error)

func (*LoginLog) ListPage

func (s *LoginLog) ListPage(cond *db.Compounds, sorts ...interface{}) ([]*dbschema.NgingLoginLog, error)

type SendingLog

type SendingLog struct {
	*dbschema.NgingSendingLog
}

func NewSendingLog

func NewSendingLog(ctx echo.Context) *SendingLog

func (*SendingLog) Add

func (c *SendingLog) Add() (interface{}, error)

type Task

type Task struct {
	*dbschema.NgingTask
}

func NewTask

func NewTask(ctx echo.Context) *Task

type TaskAndGroup

type TaskAndGroup struct {
	*dbschema.NgingTask
	Group *dbschema.NgingTaskGroup `db:"-,relation=id:group_id|gtZero"`
}

type TaskGroup

type TaskGroup struct {
	*dbschema.NgingTaskGroup
}

func NewTaskGroup

func NewTaskGroup(ctx echo.Context) *TaskGroup

type TaskLog

type TaskLog struct {
	*dbschema.NgingTaskLog
}

func NewTaskLog

func NewTaskLog(ctx echo.Context) *TaskLog

type User

type User struct {
	*dbschema.NgingUser
}

func NewUser

func NewUser(ctx echo.Context) *User

func (*User) Add

func (u *User) Add() (err error)

func (*User) CheckPasswd

func (u *User) CheckPasswd(username string, password string) (exists bool, err error)

func (*User) ClearPasswordData

func (u *User) ClearPasswordData(users ...*dbschema.NgingUser) dbschema.NgingUser

func (*User) Exists

func (u *User) Exists(username string) (bool, error)

func (*User) Exists2

func (u *User) Exists2(username string, excludeUID uint) (bool, error)

func (*User) FireLoginFailure added in v4.2.2

func (u *User) FireLoginFailure(pass string, err error) error

func (*User) FireLoginSuccess added in v4.2.2

func (u *User) FireLoginSuccess() error

func (*User) GetUserAllU2F

func (u *User) GetUserAllU2F(uid uint) ([]*dbschema.NgingUserU2f, error)

func (*User) IncrLoginFails added in v4.2.2

func (u *User) IncrLoginFails() error

func (*User) NeedCheckU2F

func (u *User) NeedCheckU2F(uid uint, step uint) bool

func (*User) NewLoginLog added in v4.2.2

func (u *User) NewLoginLog(username string) *LoginLog

func (*User) Register

func (u *User) Register(user, pass, email, roleIds string) error

func (*User) ResetLoginFails added in v4.2.2

func (u *User) ResetLoginFails() error

func (*User) SetSession

func (u *User) SetSession(users ...*dbschema.NgingUser)

func (*User) U2F

func (u *User) U2F(uid uint, typ string, step uint) (u2f *dbschema.NgingUserU2f, err error)

func (*User) UnsetSession

func (u *User) UnsetSession()

func (*User) UpdateField

func (u *User) UpdateField(uid uint, set map[string]interface{}) (err error)

func (*User) VerifySession

func (u *User) VerifySession(users ...*dbschema.NgingUser) error

type UserRole

type UserRole struct {
	*dbschema.NgingUserRole
	// contains filtered or unexported fields
}

func NewUserRole

func NewUserRole(ctx echo.Context) *UserRole

func (*UserRole) Add

func (u *UserRole) Add() (interface{}, error)

func (*UserRole) Edit

func (u *UserRole) Edit(mw func(db.Result) db.Result, args ...interface{}) error

func (*UserRole) Exists

func (u *UserRole) Exists(name string) (bool, error)

func (*UserRole) Exists2

func (u *UserRole) Exists2(name string, excludeID uint) (bool, error)

func (*UserRole) ListByUser

func (u *UserRole) ListByUser(user *dbschema.NgingUser) (roleList []*dbschema.NgingUserRole)

type UserRolePermission added in v4.1.0

type UserRolePermission struct {
	*dbschema.NgingUserRolePermission
}

func NewUserRolePermission added in v4.1.0

func NewUserRolePermission(ctx echo.Context) *UserRolePermission

func (*UserRolePermission) Add added in v4.1.0

func (u *UserRolePermission) Add() (interface{}, error)

func (*UserRolePermission) Edit added in v4.1.0

func (u *UserRolePermission) Edit(mw func(db.Result) db.Result, args ...interface{}) error

func (*UserRolePermission) Exists added in v4.1.0

func (u *UserRolePermission) Exists(roleID uint, typ string) (bool, error)

type UserU2F added in v4.2.0

type UserU2F struct {
	*dbschema.NgingUserU2f
}

func NewUserU2F added in v4.2.0

func NewUserU2F(ctx echo.Context) *UserU2F

func (*UserU2F) Add added in v4.2.0

func (u *UserU2F) Add() (interface{}, error)

func (*UserU2F) HasType added in v4.2.2

func (u *UserU2F) HasType(uid uint, authType string, step uint) (bool, error)

func (*UserU2F) ListPageByType added in v4.2.2

func (u *UserU2F) ListPageByType(uid uint, typ string, step uint, sorts ...interface{}) error

func (*UserU2F) Unbind added in v4.2.2

func (u *UserU2F) Unbind(uid uint, typ string, step uint) error

func (*UserU2F) UnbindByToken added in v4.2.2

func (u *UserU2F) UnbindByToken(uid uint, typ string, step uint, token string) error

type Verification

type Verification struct {
	*dbschema.NgingCodeVerification
}

func NewVerification

func NewVerification(ctx echo.Context) *Verification

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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