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/>.
Index ¶
- Constants
- Variables
- func AssetTypeIsIgnoreAccumulated(assetType string) bool
- func AssetTypeList() []*echo.KV
- func ClearPasswordData(rawCustomer *dbschema.OfficialCustomer) dbschema.OfficialCustomer
- func ComplaintProcessAdd(key, name string)
- func ComplaintProcessList() []*echo.KV
- func ComplaintTargetAdd(key, name string, fn ComplaintFunc, ...)
- func ComplaintTargetList() []*echo.KV
- func ComplaintTypeAdd(key, name string, fn ComplaintFunc)
- func ComplaintTypeList() []*echo.KV
- func CustomerPermTTL(c echo.Context) int64
- func CustomerPermission(c echo.Context, customers ...*dbschema.OfficialCustomer) *xrole.RolePermission
- func CustomerRolePermissionForBehavior(c echo.Context, behaviorName string, customer ...*dbschema.OfficialCustomer) interface{}
- func CustomerRoles(c echo.Context, customers ...*dbschema.OfficialCustomer) (roleList []*xrole.CustomerRoleWithPermissions)
- func ExecComplaintTargetFunc(key string, mdl *dbschema.OfficialCommonComplaint) error
- func ExecComplaintTypeFunc(key string, mdl *dbschema.OfficialCommonComplaint) error
- func FireSignIn(customer *dbschema.OfficialCustomer) error
- func FireSignOut(customer *dbschema.OfficialCustomer) error
- func FireSignUp(customer *dbschema.OfficialCustomer) error
- func GroupPackageTimeUnitSuffix(c echo.Context, n uint, unit string) string
- func HasSignedInOtherDevice(c echo.Context) bool
- func MakeAnyAssetAmountFormatter(ctx echo.Context) func(assetType string, amount float64) template.HTML
- func MakeAssetAmountFormatter(ctx echo.Context, assetType string) func(amount float64) template.HTML
- func OnSignIn(f Event)
- func OnSignOut(f Event)
- func OnSignUp(f Event)
- type Complaint
- func (f *Complaint) Add() (pk interface{}, err error)
- func (f *Complaint) Delete(mw func(db.Result) db.Result, args ...interface{}) error
- func (f *Complaint) Edit(mw func(db.Result) db.Result, args ...interface{}) error
- func (f *Complaint) ListPage(cond *db.Compounds, orderby ...interface{}) ([]*ComplaintExt, error)
- type ComplaintExt
- type ComplaintFunc
- type Counter
- type Customer
- func (f *Customer) APIData(customers ...*dbschema.OfficialCustomer) echo.H
- func (f *Customer) Add() (pk interface{}, err error)
- func (f *Customer) AddExperience(amount float64, customerID uint64, sourceType string, sourceTable string, ...) error
- func (f *Customer) AddIntegral(amount float64, customerID uint64, sourceType string, sourceTable string, ...) error
- func (f *Customer) AddRewardOnSignIn(amount float64) error
- func (f *Customer) AddRewardOnSignUp(amount float64) error
- func (f *Customer) CheckNewPassword(pass string) error
- func (f *Customer) CheckNewSafePwd(pass string) error
- func (f *Customer) CheckSafePassword(pass string) error
- func (f *Customer) CheckSignInPassword(pass string) error
- func (f *Customer) ClearPasswordData(customers ...*dbschema.OfficialCustomer) dbschema.OfficialCustomer
- func (f *Customer) DecrFileSizeAndNum(customerID uint64, fileSize uint64, fileNum uint64) error
- func (f *Customer) DisabledSession(on bool) *Customer
- func (f *Customer) Edit(mw func(db.Result) db.Result, args ...interface{}) error
- func (f *Customer) Exists(name string, fields ...string) (bool, error)
- func (f *Customer) ExistsAssetSource(assetType string, sourceType string, sourceTable string, sourceID uint64) (bool, error)
- func (f *Customer) ExistsCustomerID(customerID uint64) (bool, error)
- func (f *Customer) ExistsOther(name string, id uint64, fields ...string) (bool, error)
- func (f *Customer) FireSignInSuccess(co *CustomerOptions, authType string) (err error)
- func (f *Customer) FireSignUpSuccess(co *CustomerOptions, authType string) (err error)
- func (f *Customer) GetAdmins(customerIDs ...uint64) (map[uint64]struct{}, error)
- func (f *Customer) GetByJWT() (*dbschema.OfficialCustomer, error)
- func (f *Customer) GetDetail(cond db.Compound) (*CustomerAndGroup, error)
- func (f *Customer) GetUploadConfig(customer *dbschema.OfficialCustomer) *xroleupload.CustomerUpload
- func (f *Customer) IncrFileSizeAndNum(customerID uint64, fileSize uint64, fileNum uint64) error
- func (f *Customer) IncrLoginFails() error
- func (f *Customer) IsSameDay(assetType string, sourceType string) error
- func (f *Customer) JWTClaims(customers ...*dbschema.OfficialCustomer) *jwt.RegisteredClaims
- func (f *Customer) JWTSignedString(key interface{}, customers ...*dbschema.OfficialCustomer) (string, error)
- func (f *Customer) LevelUpOnSignIn(set echo.H) error
- func (f *Customer) LinkOAuthUser() error
- func (f *Customer) ListPage(cond *db.Compounds, orderby ...interface{}) ([]*CustomerAndGroup, error)
- func (f *Customer) NewLoginLog(co *CustomerOptions, authType string) *model.LoginLog
- func (f *Customer) RecountFile(customerId ...uint64) (totalNum uint64, totalSize uint64, err error)
- func (f *Customer) ResetLoginFails() error
- func (f *Customer) SafeDecrFileSizeAndNum(customerID uint64, fileSize uint64, fileNum uint64) error
- func (f *Customer) SetSession(customers ...*dbschema.OfficialCustomer)
- func (f *Customer) SignIn(user, pass, signInType string, options ...CustomerOption) error
- func (f *Customer) SignUp(user, pass, mobile, email string, options ...CustomerOption) error
- func (f *Customer) UnsetSession() error
- func (f *Customer) UpdateInviterID(customerID uint64, inviterID uint64) error
- func (f *Customer) UpdateSafePassword(pass string) error
- func (f *Customer) UpdateSignInPassword(pass string) error
- func (f *Customer) VerifySession(customers ...*dbschema.OfficialCustomer) error
- type CustomerAndGroup
- type CustomerBase
- type CustomerOption
- func CustomerDeviceInfo(deviceInfo DeviceInfo) CustomerOption
- func CustomerDeviceNo(deviceNo string) CustomerOption
- func CustomerEmail(email string) CustomerOption
- func CustomerIPAddress(ipAddr string) CustomerOption
- func CustomerMaxAge(maxAge time.Duration) CustomerOption
- func CustomerMaxAgeSeconds(maxAgeSeconds int) CustomerOption
- func CustomerMobile(mobile string) CustomerOption
- func CustomerName(name string) CustomerOption
- func CustomerPassword(password string) CustomerOption
- func CustomerPlatform(platform string) CustomerOption
- func CustomerScense(scense string) CustomerOption
- func CustomerSessionID(sessionID string) CustomerOption
- func CustomerSignInType(signInType string) CustomerOption
- func GenerateOptionsFromHeader(c echo.Context, maxAge ...int) []CustomerOption
- type CustomerOptions
- type Device
- func (f *Device) Add() (pk interface{}, err error)
- func (f *Device) CleanCustomer(customer *dbschema.OfficialCustomer, co *CustomerOptions) (err error)
- func (f *Device) CleanExceedLimit(customerID uint64, multideviceSignin *multidivicesignin.MultideviceSignin) error
- func (f *Device) CleanExpired() (err error)
- func (f *Device) Delete(mw func(db.Result) db.Result, args ...interface{}) error
- func (f *Device) Edit(mw func(db.Result) db.Result, args ...interface{}) error
- func (f *Device) Exists(customerID uint64, scense, platform, deviceNo string) (bool, error)
- func (f *Device) ExistsCustomerID(customerID uint64) (bool, error)
- func (f *Device) ExistsOther(customerID uint64, scense, platform, deviceNo string, excludeIDs uint64) (bool, error)
- func (f *Device) ExistsSessionID(sessionID string) (bool, error)
- func (f *Device) Kick(customerID uint64) (err error)
- func (f *Device) SetDefaults()
- func (f *Device) SetOptions(options *CustomerOptions) *Device
- func (f *Device) SignOut(mw func(db.Result) db.Result, args ...interface{}) error
- func (f *Device) Upsert() (pk interface{}, err error)
- type DeviceInfo
- type Event
- type Events
- type Following
- type FollowingAndCustomer
- type GroupPackage
- func (u *GroupPackage) Add() (interface{}, error)
- func (f *GroupPackage) Delete(mw func(db.Result) db.Result, args ...interface{}) error
- func (f *GroupPackage) Edit(mw func(db.Result) db.Result, args ...interface{}) error
- func (u *GroupPackage) IncrSold(id uint, n ...int) error
- func (u *GroupPackage) ListByGroup(group string) error
- func (u *GroupPackage) ListGroup() ([]string, error)
- func (u *GroupPackage) MakeExpireTime(baseTime ...time.Time) time.Time
- type Invitation
- func (f *Invitation) Add() (pk interface{}, err error)
- func (f *Invitation) Delete(mw func(db.Result) db.Result, args ...interface{}) error
- func (f *Invitation) Edit(mw func(db.Result) db.Result, args ...interface{}) error
- func (f *Invitation) Exists(code string, excludeIDs ...uint) (bool, error)
- func (f *Invitation) FindCode(invitationCode string) error
- func (f *Invitation) UseCode(invitationID uint, customer *dbschema.OfficialCustomer) error
- type InvitationCustomer
- type InvitationCustomerExt
- type InvitationCustomerWithCode
- type Level
- func (f *Level) Add() (pk interface{}, err error)
- func (f *Level) Delete(mw func(db.Result) db.Result, args ...interface{}) error
- func (f *Level) Edit(mw func(db.Result) db.Result, args ...interface{}) error
- func (f *Level) Exists(customerID uint64, levelID uint) (bool, error)
- func (f *Level) GetByCustomerID(group string, customerID uint64) (result *modelLevel.RelationExt, err error)
- func (f *Level) HasLevel(customerID uint64, levelIds ...interface{}) (bool, error)
- func (f *Level) HasPassedDays() (days uint)
- func (f *Level) LevelUp() error
- func (f *Level) UpdateAllExpired() error
- type Message
- func (f *Message) AddData(customer *dbschema.OfficialCustomer, user *dbschemaNging.NgingUser) (pk interface{}, err error)
- func (f *Message) CheckRecvCustomerPerm(customer *dbschema.OfficialCustomer) bool
- func (f *Message) CheckRecvPerm(customer *dbschema.OfficialCustomer) bool
- func (f *Message) CheckRecvUserPerm(customer *dbschema.OfficialCustomer) bool
- func (f *Message) CountTodaySends(customerID uint64) int64
- func (f *Message) CountUnread(viewerID uint64, groupIDs []uint, isSystemMessage bool, viewerTypes ...string) int64
- func (f *Message) CustomerMaxPerDay() (int64, int64)
- func (f *Message) DecodeContent(row *dbschema.OfficialCommonMessage) *dbschema.OfficialCommonMessage
- func (f *Message) Delete(args ...interface{}) error
- func (f *Message) Edit(mw func(db.Result) db.Result, args ...interface{}) error
- func (f *Message) GetWithViewed(row *dbschema.OfficialCommonMessage) (*MessageWithViewed, error)
- func (f *Message) IsSystemMessage() bool
- func (f *Message) LastSend(customerID uint64) (*dbschema.OfficialCommonMessage, error)
- func (f *Message) ListAll(onlyUnread bool, otherCond db.Compound) ([]*MessageWithViewed, error)
- func (f *Message) ListWithViewedByRecipient(viewerID uint64, groupIDs []uint, isSystemMessage bool, onlyUnread bool, ...) ([]*MessageWithViewed, error)
- func (f *Message) ListWithViewedBySender(senderID uint64, onlyUnread bool, otherCond db.Compound, viewerTypes ...string) ([]*MessageWithViewed, error)
- func (f *Message) MsgUser() *MsgUser
- func (f *Message) SendSystemMessage(customerID uint64, title string, contype string, content string) error
- func (f *Message) ToTable(m sqlbuilder.Name_) string
- func (f *Message) View(row *dbschema.OfficialCommonMessage, viewerID uint64, groupIDs []uint, ...) error
- func (f *Message) WithViewedByAll(rows []*dbschema.OfficialCommonMessage) ([]*MessageWithViewed, error)
- func (f *Message) WithViewedByRecipient(rows []*dbschema.OfficialCommonMessage, viewerID uint64, viewerType string) ([]*MessageWithViewed, error)
- func (f *Message) WithViewedBySender(rows []*dbschema.OfficialCommonMessage) ([]*MessageWithViewed, error)
- type MessageWithViewed
- type MsgUser
- type OAuth
- func (f *OAuth) Add() (pk interface{}, err error)
- func (f *OAuth) CopyFrom(user *goth.User) *OAuth
- func (f *OAuth) DelSession()
- func (f *OAuth) Edit(mw func(db.Result) db.Result, args ...interface{}) error
- func (f *OAuth) Exists(customerID uint64, unionID string, openID string, typ string) (bool, error)
- func (f *OAuth) ExistsOtherBinding(customerID uint64, id uint64) (bool, error)
- func (f *OAuth) GetByOutUser(user *goth.User) (err error)
- func (f *OAuth) GetSession() (*goth.User, bool, error)
- func (f *OAuth) OAuthUserGender(ouser *goth.User) string
- func (f *OAuth) SaveSession(ouser *goth.User) error
- func (f *OAuth) SignUpCustomer(ouser *goth.User) (*Customer, error)
- func (f *OAuth) Upsert(mw func(db.Result) db.Result, args ...interface{}) (interface{}, error)
- type Online
- func (u *Online) Add() (interface{}, error)
- func (u *Online) Cleanup() error
- func (u *Online) Decr(n uint64) error
- func (u *Online) Exists() (bool, error)
- func (u *Online) Incr(n uint) error
- func (u *Online) IsOnlineCustomerID(customerID uint64) bool
- func (u *Online) IsOnlineCustomerIDs(customerIDs []uint64) map[uint64]bool
- func (u *Online) MakeCond(sessionID string, customerID uint64) db.Compound
- func (u *Online) ResetClientCount(isDelete ...bool) error
- type PrepaidCard
- func (f *PrepaidCard) Add() (pk interface{}, err error)
- func (f *PrepaidCard) BatchGenerate(uid uint, count int, amount uint, salePrice float64, start uint, end uint, ...) error
- func (f *PrepaidCard) Delete(mw func(db.Result) db.Result, args ...interface{}) error
- func (f *PrepaidCard) Edit(mw func(db.Result) db.Result, args ...interface{}) error
- func (f *PrepaidCard) Exists(number string, excludeIDs ...uint64) (bool, error)
- func (f *PrepaidCard) UseCard(customerID uint64, number string, password string) error
- type Role
- func (u *Role) Add() (interface{}, error)
- func (u *Role) CancelDefault(excludeID ...uint) error
- func (u *Role) Edit(mw func(db.Result) db.Result, args ...interface{}) error
- func (u *Role) Exists(name string) (bool, error)
- func (u *Role) Exists2(name string, excludeID uint) (bool, error)
- func (u *Role) GetDefault() error
- func (u *Role) ListByCustomer(customer *dbschema.OfficialCustomer) (roleList []*dbschema.OfficialCustomerRole)
- func (u *Role) ListRoleIDsByCustomer(customer *dbschema.OfficialCustomer) (roleIDs []uint)
- type RolePermission
- type U2F
- func (u *U2F) Add() (interface{}, error)
- func (u *U2F) HasType(customerID uint64, authType string, step uint) (bool, error)
- func (u *U2F) ListPageByType(customerID uint64, authType string, step uint, sorts ...interface{}) error
- func (u *U2F) Unbind(customerID uint64, authType string, step uint) error
- func (u *U2F) UnbindByToken(customerID uint64, authType string, step uint, token string) error
- type Wallet
- func (f *Wallet) Add() (pk interface{}, err error)
- func (f *Wallet) AddFlow(flows ...*dbschema.OfficialCustomerWalletFlow) (err error)
- func (f *Wallet) AddRepeatableFlow(flows ...*dbschema.OfficialCustomerWalletFlow) (err error)
- func (f *Wallet) Edit(mw func(db.Result) db.Result, args ...interface{}) error
- func (f *Wallet) FlowListPage(cond *db.Compounds, orderby ...interface{}) ([]*WalletFlowExt, error)
- func (f *Wallet) GetAsset(assetType string, customerID uint64) (*dbschema.OfficialCustomerWallet, error)
- func (f *Wallet) GetAssetBalance(assetType string, customerID uint64) (float64, error)
- func (f *Wallet) GetBalance(assetType string, customerID uint64) (float64, error)
- func (f *Wallet) ListCustomerAllAssets(customerID uint64) (map[string]*dbschema.OfficialCustomerWallet, error)
- func (f *Wallet) ListPage(cond *db.Compounds, orderby ...interface{}) ([]*WalletExt, error)
- type WalletExt
- type WalletFlowExt
- type WalletSettings
Constants ¶
const ( GroupPackageTimeDay = `day` GroupPackageTimeWeek = `week` GroupPackageTimeMonth = `month` GroupPackageTimeYear = `year` GroupPackageTimeForever = `forever` )
const ( AssetTypeMoney = `money` // 人民币 AssetTypeIntegral = `integral` // 积分 AssetTypeCredit = `credit` // 信用分 AssetTypePoint = `point` // 点数 AssetTypeExperience = `experience` // 经验 )
资产类型
const ( AmountTypeBalance = `balance` // 余额 AmountTypeFreeze = `freeze` // 冻结金额 )
金额类型
const ( //状态(pending-待确认;confirmed-已确认;canceled-已取消) FlowStatusPending = `pending` // 待确认 FlowStatusConfirmed = `confirmed` // 已确认 FlowStatusCanceled = `canceled` // 已取消 )
资金流水记录状态
Variables ¶
var ( ComplaintTypes = echo.NewKVData() ComplaintTargets = echo.NewKVData() )
var ( PrivateFields = []string{ `session_id`, `id_card_no`, `real_name`, `password`, `salt`, `safe_pwd`, `created`, `updated`, `file_num`, `file_size`, } PrivateFieldsWithMobileEmail = append([]string{ `mobile_bind`, `mobile`, `email_bind`, `email`, }, PrivateFields...) //CusomterSafeFields 可公开的客户信息字段 CusomterSafeFields = []interface{}{ `id`, `name`, `gender`, `uid`, `group_id`, `avatar`, `online`, `following`, `followers`, `agent_level`, } CusomterSafeFieldsSelector = func(sel sqlbuilder.Selector) sqlbuilder.Selector { return sel.Columns(CusomterSafeFields...) } //UserSafeFields 可公开的后台用户信息字段 UserSafeFields = []interface{}{ `id`, `username`, `gender`, `avatar`, `online`, } UserSafeFieldsSelector = func(sel sqlbuilder.Selector) sqlbuilder.Selector { return sel.Columns(UserSafeFields...) } )
var ( // CustomerPasswordMinLength 客户登录密码最小长度 CustomerPasswordMinLength = 8 // CustomerSafePwdMinLength 客户安全密码最小长度 CustomerSafePwdMinLength = 6 )
var ( DevicePlatforms = echo.NewKVData() DeviceScenses = echo.NewKVData() DefaultDevicePlatform = `pc` DefaultDeviceScense = `web` )
var ( // AssetTypes 资产类型 AssetTypes = echo.NewKVData() // AmountTypes 金额类型 AmountTypes = echo.NewKVData() // 资金流水记录状态 FlowStatus = echo.NewKVData() )
var (
ComplaintProcesses = echo.NewKVData()
)
var ErrCardNumberAlreadyExists = errors.New(`Card number already exists`)
var ErrInvalidSession = errors.New(`invalid session`)
var ErrSameDay = errors.New("same day")
ErrSameDay 同一天不能领取两次奖励
var GroupPackageTimeUnits = echo.NewKVData(). Add(GroupPackageTimeDay, `天`). Add(GroupPackageTimeWeek, `周`). Add(GroupPackageTimeMonth, `月`). Add(GroupPackageTimeYear, `年`). Add(GroupPackageTimeForever, `永久`)
var JWTMaxLifeTime int64 = 90 * 86400
JWTMaxLifeTime JWT寿命(单位:秒)
Functions ¶
func AssetTypeIsIgnoreAccumulated ¶
AssetTypeIsIgnoreAccumulated 判断某种资产类型是否不支持累计历史值
func AssetTypeList ¶
func ClearPasswordData ¶
func ClearPasswordData(rawCustomer *dbschema.OfficialCustomer) dbschema.OfficialCustomer
func ComplaintProcessAdd ¶
func ComplaintProcessAdd(key, name string)
func ComplaintProcessList ¶
func ComplaintTargetAdd ¶
func ComplaintTargetAdd(key, name string, fn ComplaintFunc, urlFormat func(*dbschema.OfficialCommonComplaint) string)
func ComplaintTargetList ¶
func ComplaintTypeAdd ¶
func ComplaintTypeAdd(key, name string, fn ComplaintFunc)
func ComplaintTypeList ¶
func CustomerPermTTL ¶
func CustomerPermission ¶
func CustomerPermission(c echo.Context, customers ...*dbschema.OfficialCustomer) *xrole.RolePermission
func CustomerRolePermissionForBehavior ¶
func CustomerRolePermissionForBehavior(c echo.Context, behaviorName string, customer ...*dbschema.OfficialCustomer) interface{}
func CustomerRoles ¶
func CustomerRoles(c echo.Context, customers ...*dbschema.OfficialCustomer) (roleList []*xrole.CustomerRoleWithPermissions)
func ExecComplaintTargetFunc ¶
func ExecComplaintTargetFunc(key string, mdl *dbschema.OfficialCommonComplaint) error
func ExecComplaintTypeFunc ¶
func ExecComplaintTypeFunc(key string, mdl *dbschema.OfficialCommonComplaint) error
func FireSignIn ¶
func FireSignIn(customer *dbschema.OfficialCustomer) error
func FireSignOut ¶
func FireSignOut(customer *dbschema.OfficialCustomer) error
func FireSignUp ¶
func FireSignUp(customer *dbschema.OfficialCustomer) error
func HasSignedInOtherDevice ¶
func MakeAnyAssetAmountFormatter ¶
func MakeAnyAssetAmountFormatter(ctx echo.Context) func(assetType string, amount float64) template.HTML
MakeAnyAssetAmountFormatter 构造任意类型资产的金额格式化函数
Types ¶
type Complaint ¶
type Complaint struct {
*dbschema.OfficialCommonComplaint
}
func NewComplaint ¶
type ComplaintExt ¶
type ComplaintExt struct { *dbschema.OfficialCommonComplaint Customer *dbschema.OfficialCustomer `db:"-,relation=id:customer_id"` TypeName string `db:"-"` TargetTypeName string `db:"-"` // contains filtered or unexported fields }
func (*ComplaintExt) SetURLFormat ¶
func (c *ComplaintExt) SetURLFormat(fn func(*dbschema.OfficialCommonComplaint) string) *ComplaintExt
func (*ComplaintExt) URLFormat ¶
func (c *ComplaintExt) URLFormat() string
type ComplaintFunc ¶
type ComplaintFunc func(*dbschema.OfficialCommonComplaint) error
type Counter ¶
type Counter struct {
*dbschema.OfficialCustomerCounter
}
func NewCounter ¶
type Customer ¶
type Customer struct { *dbschema.OfficialCustomer // contains filtered or unexported fields }
func NewCustomer ¶
func (*Customer) APIData ¶
func (f *Customer) APIData(customers ...*dbschema.OfficialCustomer) echo.H
APIData 返回给API接口的数据
func (*Customer) AddExperience ¶
func (f *Customer) AddExperience(amount float64, customerID uint64, sourceType string, sourceTable string, sourceID uint64, description string) error
AddExperience 增加经验值
func (*Customer) AddIntegral ¶
func (f *Customer) AddIntegral(amount float64, customerID uint64, sourceType string, sourceTable string, sourceID uint64, description string) error
AddIntegral 增加消费积分
func (*Customer) AddRewardOnSignIn ¶
AddRewardOnSignIn 登录时奖励
func (*Customer) AddRewardOnSignUp ¶
AddRewardOnSignUp 注册时奖励
func (*Customer) CheckNewPassword ¶
func (*Customer) CheckNewSafePwd ¶
func (*Customer) CheckSafePassword ¶
func (*Customer) CheckSignInPassword ¶
func (*Customer) ClearPasswordData ¶
func (f *Customer) ClearPasswordData(customers ...*dbschema.OfficialCustomer) dbschema.OfficialCustomer
func (*Customer) DecrFileSizeAndNum ¶
func (*Customer) DisabledSession ¶
func (*Customer) ExistsAssetSource ¶
func (*Customer) ExistsCustomerID ¶
func (*Customer) ExistsOther ¶
func (*Customer) FireSignInSuccess ¶
func (f *Customer) FireSignInSuccess(co *CustomerOptions, authType string) (err error)
func (*Customer) FireSignUpSuccess ¶
func (f *Customer) FireSignUpSuccess(co *CustomerOptions, authType string) (err error)
func (*Customer) GetDetail ¶
func (f *Customer) GetDetail(cond db.Compound) (*CustomerAndGroup, error)
func (*Customer) GetUploadConfig ¶
func (f *Customer) GetUploadConfig(customer *dbschema.OfficialCustomer) *xroleupload.CustomerUpload
func (*Customer) IncrFileSizeAndNum ¶
func (*Customer) IncrLoginFails ¶
func (*Customer) JWTClaims ¶
func (f *Customer) JWTClaims(customers ...*dbschema.OfficialCustomer) *jwt.RegisteredClaims
func (*Customer) JWTSignedString ¶
func (f *Customer) JWTSignedString(key interface{}, customers ...*dbschema.OfficialCustomer) (string, error)
func (*Customer) LevelUpOnSignIn ¶
LevelUpOnSignIn 登录时检查是否可升级
func (*Customer) LinkOAuthUser ¶
func (*Customer) ListPage ¶
func (f *Customer) ListPage(cond *db.Compounds, orderby ...interface{}) ([]*CustomerAndGroup, error)
func (*Customer) NewLoginLog ¶
func (f *Customer) NewLoginLog(co *CustomerOptions, authType string) *model.LoginLog
func (*Customer) RecountFile ¶
RecountFile 重新统计客户上传的文件数量和尺寸
func (*Customer) ResetLoginFails ¶
func (*Customer) SafeDecrFileSizeAndNum ¶
func (*Customer) SetSession ¶
func (f *Customer) SetSession(customers ...*dbschema.OfficialCustomer)
SetSession 记录登录信息
func (*Customer) SignIn ¶
func (f *Customer) SignIn(user, pass, signInType string, options ...CustomerOption) error
SignIn 用户登录
func (*Customer) SignUp ¶
func (f *Customer) SignUp(user, pass, mobile, email string, options ...CustomerOption) error
SignUp 注册用户
func (*Customer) UpdateInviterID ¶
func (*Customer) UpdateSafePassword ¶
func (*Customer) UpdateSignInPassword ¶
func (*Customer) VerifySession ¶
func (f *Customer) VerifySession(customers ...*dbschema.OfficialCustomer) error
type CustomerAndGroup ¶
type CustomerAndGroup struct { *dbschema.OfficialCustomer Group *dbschema.OfficialCommonGroup `db:"-,relation=id:group_id|gtZero"` Levels []*modelLevel.RelationExt `db:"-,relation=customer_id:id|gtZero" json:",omitempty"` Agent map[string]interface{} `db:"-" json:",omitempty" xml:",omitempty"` Roles []*dbschema.OfficialCustomerRole `db:"-,relation=id:role_ids|notEmpty|split"` }
func (*CustomerAndGroup) AsMap ¶
func (d *CustomerAndGroup) AsMap() param.Store
type CustomerBase ¶
type CustomerBase struct { Id uint64 `db:"id" bson:"id,omitempty" comment:"ID" json:"id" xml:"id"` Name string `db:"name" bson:"name" comment:"名称" json:"name" xml:"name"` Gender string `db:"gender" bson:"gender" comment:"性别(male-男;female-女;secret-保密)" json:"gender" xml:"gender"` Avatar string `db:"avatar" bson:"avatar" comment:"头像" json:"avatar" xml:"avatar"` }
func (*CustomerBase) Name_ ¶
func (c *CustomerBase) Name_() string
func (*CustomerBase) SelectColumns ¶
func (c *CustomerBase) SelectColumns() []interface{}
func (*CustomerBase) Short_ ¶
func (c *CustomerBase) Short_() string
type CustomerOption ¶
type CustomerOption func(*CustomerOptions)
func CustomerDeviceInfo ¶
func CustomerDeviceInfo(deviceInfo DeviceInfo) CustomerOption
func CustomerDeviceNo ¶
func CustomerDeviceNo(deviceNo string) CustomerOption
func CustomerEmail ¶
func CustomerEmail(email string) CustomerOption
func CustomerIPAddress ¶
func CustomerIPAddress(ipAddr string) CustomerOption
func CustomerMaxAge ¶
func CustomerMaxAge(maxAge time.Duration) CustomerOption
func CustomerMaxAgeSeconds ¶
func CustomerMaxAgeSeconds(maxAgeSeconds int) CustomerOption
func CustomerMobile ¶
func CustomerMobile(mobile string) CustomerOption
func CustomerName ¶
func CustomerName(name string) CustomerOption
func CustomerPassword ¶
func CustomerPassword(password string) CustomerOption
func CustomerPlatform ¶
func CustomerPlatform(platform string) CustomerOption
func CustomerScense ¶
func CustomerScense(scense string) CustomerOption
func CustomerSessionID ¶
func CustomerSessionID(sessionID string) CustomerOption
func CustomerSignInType ¶
func CustomerSignInType(signInType string) CustomerOption
func GenerateOptionsFromHeader ¶
func GenerateOptionsFromHeader(c echo.Context, maxAge ...int) []CustomerOption
type CustomerOptions ¶
type CustomerOptions struct { *dbschema.OfficialCustomer MaxAge time.Duration // 登录状态有效时长 SignInType string // 登录方式 // device information DeviceInfo // for qrcode scan login SessionID string IPAddress string }
func NewCustomerOptions ¶
func NewCustomerOptions(customerM *dbschema.OfficialCustomer, noClear ...bool) *CustomerOptions
func (*CustomerOptions) ApplyOptions ¶
func (co *CustomerOptions) ApplyOptions(options ...CustomerOption) *CustomerOptions
type Device ¶
type Device struct {
*dbschema.OfficialCustomerDevice
}
func (*Device) CleanCustomer ¶
func (f *Device) CleanCustomer(customer *dbschema.OfficialCustomer, co *CustomerOptions) (err error)
func (*Device) CleanExceedLimit ¶
func (f *Device) CleanExceedLimit(customerID uint64, multideviceSignin *multidivicesignin.MultideviceSignin) error
func (*Device) CleanExpired ¶
func (*Device) ExistsCustomerID ¶
func (*Device) ExistsOther ¶
func (*Device) SetDefaults ¶
func (f *Device) SetDefaults()
func (*Device) SetOptions ¶
func (f *Device) SetOptions(options *CustomerOptions) *Device
type DeviceInfo ¶
func GetDeviceInfo ¶
func GetDeviceInfo(c echo.Context) *DeviceInfo
func (*DeviceInfo) Init ¶
func (d *DeviceInfo) Init(c echo.Context)
func (*DeviceInfo) SetSession ¶
func (d *DeviceInfo) SetSession(c echo.Context)
func (*DeviceInfo) UnsetSession ¶
func (d *DeviceInfo) UnsetSession(c echo.Context)
type Event ¶
type Event func(*dbschema.OfficialCustomer) error
type Following ¶
type Following struct {
*dbschema.OfficialCustomerFollowing
}
func NewFollowing ¶
type FollowingAndCustomer ¶
type FollowingAndCustomer struct { *dbschema.OfficialCustomerFollowing Customer echo.H }
type GroupPackage ¶
type GroupPackage struct {
*dbschema.OfficialCustomerGroupPackage
}
GroupPackage 等级组套餐价格
func NewGroupPackage ¶
func NewGroupPackage(ctx echo.Context) *GroupPackage
func (*GroupPackage) Add ¶
func (u *GroupPackage) Add() (interface{}, error)
func (*GroupPackage) ListByGroup ¶
func (u *GroupPackage) ListByGroup(group string) error
ListByGroup 列出某个组的套餐信息
func (*GroupPackage) ListGroup ¶
func (u *GroupPackage) ListGroup() ([]string, error)
ListGroup 列出设置有套餐的组名称
func (*GroupPackage) MakeExpireTime ¶
func (u *GroupPackage) MakeExpireTime(baseTime ...time.Time) time.Time
type Invitation ¶
type Invitation struct {
*dbschema.OfficialCustomerInvitation
}
func NewInvitation ¶
func NewInvitation(ctx echo.Context) *Invitation
func (*Invitation) Add ¶
func (f *Invitation) Add() (pk interface{}, err error)
func (*Invitation) Exists ¶
func (f *Invitation) Exists(code string, excludeIDs ...uint) (bool, error)
func (*Invitation) FindCode ¶
func (f *Invitation) FindCode(invitationCode string) error
func (*Invitation) UseCode ¶
func (f *Invitation) UseCode(invitationID uint, customer *dbschema.OfficialCustomer) error
type InvitationCustomer ¶
type InvitationCustomer struct {
*dbschema.OfficialCustomerInvitationUsed
}
func NewInvitationCustomer ¶
func NewInvitationCustomer(ctx echo.Context) *InvitationCustomer
func (*InvitationCustomer) ListCustomer ¶
func (f *InvitationCustomer) ListCustomer(cond *db.Compounds, orderby ...interface{}) ([]*InvitationCustomerExt, error)
func (*InvitationCustomer) ListCustomerWithCode ¶
func (f *InvitationCustomer) ListCustomerWithCode(cond *db.Compounds, orderby ...interface{}) ([]*InvitationCustomerWithCode, error)
type InvitationCustomerExt ¶
type InvitationCustomerExt struct { *dbschema.OfficialCustomerInvitationUsed Customer *dbschema.OfficialCustomer `db:"-,relation=id:customer_id|gtZero"` Level *dbschema.OfficialCustomerLevel `db:"-,relation=id:level_id|gtZero"` AgentLevel map[string]interface{} `db:"-" json:",omitempty" xml:",omitempty"` RoleList []*dbschema.OfficialCustomerRole `db:"-,relation=id:role_ids|split"` }
type InvitationCustomerWithCode ¶
type InvitationCustomerWithCode struct { *dbschema.OfficialCustomerInvitationUsed Customer *dbschema.OfficialCustomer `db:"-,relation=id:customer_id|gtZero"` Level *dbschema.OfficialCustomerLevel `db:"-,relation=id:level_id|gtZero"` AgentLevel map[string]interface{} `db:"-" json:",omitempty" xml:",omitempty"` RoleList []*dbschema.OfficialCustomerRole `db:"-,relation=id:role_ids|split"` Invitation *dbschema.OfficialCustomerInvitation `db:"-,relation=id:invitation_id|gtZero"` }
type Level ¶
type Level struct {
*dbschema.OfficialCustomerLevelRelation
}
func (*Level) GetByCustomerID ¶
func (f *Level) GetByCustomerID(group string, customerID uint64) (result *modelLevel.RelationExt, err error)
func (*Level) HasPassedDays ¶
func (*Level) UpdateAllExpired ¶
type Message ¶
type Message struct { *dbschema.OfficialCommonMessage Viewed *dbschema.OfficialCommonMessageViewed }
func (*Message) AddData ¶
func (f *Message) AddData(customer *dbschema.OfficialCustomer, user *dbschemaNging.NgingUser) (pk interface{}, err error)
AddData 添加消息 * customer 操作客户 * user 操作后台用户
func (*Message) CheckRecvCustomerPerm ¶
func (f *Message) CheckRecvCustomerPerm(customer *dbschema.OfficialCustomer) bool
func (*Message) CheckRecvPerm ¶
func (f *Message) CheckRecvPerm(customer *dbschema.OfficialCustomer) bool
CheckRecvPerm 检查是否为收信人权限
func (*Message) CheckRecvUserPerm ¶
func (f *Message) CheckRecvUserPerm(customer *dbschema.OfficialCustomer) bool
func (*Message) CountTodaySends ¶
func (*Message) CountUnread ¶
func (*Message) CustomerMaxPerDay ¶
func (*Message) DecodeContent ¶
func (f *Message) DecodeContent(row *dbschema.OfficialCommonMessage) *dbschema.OfficialCommonMessage
func (*Message) GetWithViewed ¶
func (f *Message) GetWithViewed(row *dbschema.OfficialCommonMessage) (*MessageWithViewed, error)
func (*Message) IsSystemMessage ¶
func (*Message) LastSend ¶
func (f *Message) LastSend(customerID uint64) (*dbschema.OfficialCommonMessage, error)
func (*Message) ListWithViewedByRecipient ¶
func (f *Message) ListWithViewedByRecipient(viewerID uint64, groupIDs []uint, isSystemMessage bool, onlyUnread bool, otherCond db.Compound, viewerTypes ...string) ([]*MessageWithViewed, error)
ListWithViewedByRecipient 收件箱列表
func (*Message) ListWithViewedBySender ¶
func (f *Message) ListWithViewedBySender(senderID uint64, onlyUnread bool, otherCond db.Compound, viewerTypes ...string) ([]*MessageWithViewed, error)
ListWithViewedBySender 发件箱列表
func (*Message) SendSystemMessage ¶
func (*Message) WithViewedByAll ¶
func (f *Message) WithViewedByAll(rows []*dbschema.OfficialCommonMessage) ([]*MessageWithViewed, error)
func (*Message) WithViewedByRecipient ¶
func (f *Message) WithViewedByRecipient(rows []*dbschema.OfficialCommonMessage, viewerID uint64, viewerType string) ([]*MessageWithViewed, error)
func (*Message) WithViewedBySender ¶
func (f *Message) WithViewedBySender(rows []*dbschema.OfficialCommonMessage) ([]*MessageWithViewed, error)
type MessageWithViewed ¶
type MessageWithViewed struct { *dbschema.OfficialCommonMessage MsgFrom *MsgUser `json:",omitempty"` MsgTo *MsgUser `json:",omitempty"` IsViewed bool }
func (*MessageWithViewed) MsgUser ¶
func (m *MessageWithViewed) MsgUser() *MsgUser
type OAuth ¶
type OAuth struct {
*dbschema.OfficialCustomerOauth
}
func (*OAuth) DelSession ¶
func (f *OAuth) DelSession()
func (*OAuth) ExistsOtherBinding ¶
func (*OAuth) SignUpCustomer ¶
SignUpCustomer 用户不存在,需要新注册
type Online ¶
type Online struct {
*dbschema.OfficialCustomerOnline
}
func (*Online) IsOnlineCustomerID ¶
func (*Online) IsOnlineCustomerIDs ¶
func (*Online) ResetClientCount ¶
type PrepaidCard ¶
type PrepaidCard struct {
*dbschema.OfficialCustomerPrepaidCard
}
func NewPrepaidCard ¶
func NewPrepaidCard(ctx echo.Context) *PrepaidCard
func (*PrepaidCard) Add ¶
func (f *PrepaidCard) Add() (pk interface{}, err error)
func (*PrepaidCard) BatchGenerate ¶
func (f *PrepaidCard) BatchGenerate(uid uint, count int, amount uint, salePrice float64, start uint, end uint, bgImage string) error
BatchGenerate 批量生成
type Role ¶
type Role struct { *dbschema.OfficialCustomerRole // contains filtered or unexported fields }
func (*Role) CancelDefault ¶
func (*Role) GetDefault ¶
func (*Role) ListByCustomer ¶
func (u *Role) ListByCustomer(customer *dbschema.OfficialCustomer) (roleList []*dbschema.OfficialCustomerRole)
func (*Role) ListRoleIDsByCustomer ¶
func (u *Role) ListRoleIDsByCustomer(customer *dbschema.OfficialCustomer) (roleIDs []uint)
type RolePermission ¶
type RolePermission struct {
*dbschema.OfficialCustomerRolePermission
}
func NewRolePermission ¶
func NewRolePermission(ctx echo.Context) *RolePermission
func (*RolePermission) Add ¶
func (u *RolePermission) Add() (interface{}, error)
type U2F ¶
type U2F struct {
*dbschema.OfficialCustomerU2f
}
func (*U2F) ListPageByType ¶
type Wallet ¶
type Wallet struct { *dbschema.OfficialCustomerWallet Flow *dbschema.OfficialCustomerWalletFlow }
func (*Wallet) AddFlow ¶
func (f *Wallet) AddFlow(flows ...*dbschema.OfficialCustomerWalletFlow) (err error)
AddFlow 添加不允许重复的流水记录
func (*Wallet) AddRepeatableFlow ¶
func (f *Wallet) AddRepeatableFlow(flows ...*dbschema.OfficialCustomerWalletFlow) (err error)
AddRepeatableFlow 添加允许重复的流水记录 unique_key: customer_id, asset_type, amount_type, source_type, source_table, source_id, number
func (*Wallet) FlowListPage ¶
func (f *Wallet) FlowListPage(cond *db.Compounds, orderby ...interface{}) ([]*WalletFlowExt, error)
func (*Wallet) GetAssetBalance ¶
func (*Wallet) GetBalance ¶
func (*Wallet) ListCustomerAllAssets ¶
func (f *Wallet) ListCustomerAllAssets(customerID uint64) (map[string]*dbschema.OfficialCustomerWallet, error)
ListCustomerAllAssets 列出客户所有资产
type WalletExt ¶
type WalletExt struct { *dbschema.OfficialCustomerWallet Customer *CustomerBase `db:"-,relation=id:customer_id"` AssetTypeName string `db:"-"` }
type WalletFlowExt ¶
type WalletFlowExt struct { *dbschema.OfficialCustomerWalletFlow Customer *CustomerBase `db:"-,relation=id:customer_id"` SrcCustomer *CustomerBase `db:"-,relation=id:source_customer|gtZero"` AssetTypeName string `db:"-"` }
type WalletSettings ¶
func NewWalletSettings ¶
func NewWalletSettings() *WalletSettings
func (*WalletSettings) FromStore ¶
func (s *WalletSettings) FromStore(r echo.H) *WalletSettings
Source Files ¶
- complaint.go
- complaint_ext.go
- complaint_process.go
- complaint_types.go
- counter.go
- customer.go
- customer_context_utils.go
- customer_counter.go
- customer_events.go
- customer_ext.go
- customer_file.go
- customer_filter_fields.go
- customer_helper.go
- customer_jwt.go
- customer_option.go
- customer_password.go
- customer_session.go
- customer_sign_in.go
- customer_sign_up.go
- device.go
- device_ext.go
- following.go
- following_ext.go
- group_package.go
- group_package_ext.go
- invitation.go
- invitation_customer.go
- invitation_ext.go
- level.go
- message.go
- oauth.go
- online.go
- prepaid_card.go
- role.go
- role_permission.go
- u2f.go
- wallet.go
- wallet_ext.go
- wallet_settings.go
- wallet_types.go