member

package
v0.14.0 Latest Latest
Warning

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

Go to latest
Published: Oct 11, 2025 License: MIT Imports: 21 Imported by: 0

Documentation

Overview

Package member 会员管理

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Config

type Config struct {
	// User 用户相关的配置
	User *user.Config `json:"user" xml:"user" yaml:"user" toml:"user"`

	// 上传接口的相关配置
	Upload *upload.Config `json:"upload" xml:"upload" yaml:"upload" toml:"upload"`
}

func (*Config) SanitizeConfig

func (c *Config) SanitizeConfig() *web.FieldError

type InvitedMember added in v0.8.3

type InvitedMember struct {
	XMLName struct{} `json:"-" cbor:"-" yaml:"-" xml:"member"`

	ID       int64     `json:"id,omitempty" yaml:"id,omitempty" xml:"id,attr,omitempty" cbor:"id,omitempty" comment:"id"`
	NO       string    `json:"no" xml:"no" cbor:"no" yaml:"no" comment:"user no"`
	Username string    `json:"username" yaml:"username" xml:"username" cbor:"username" comment:"username"`
	Inviter  int64     `json:"inviter,omitempty" yaml:"inviter,omitempty" xml:"inviter,omitempty" cbor:"inviter,omitempty" comment:"inviter"`
	Birthday time.Time `json:"birthday,omitzero" yaml:"birthday,omitempty" cbor:"birthday,omitzero" xml:"birthday,omitzero" comment:"birthday"`
	Sex      types.Sex `json:"sex,omitempty" xml:"sex,attr,omitempty" cbor:"sex,omitempty" yaml:"sex,omitempty" comment:"sex"`
	Nickname string    `json:"nickname,omitempty" xml:"nickname,omitempty" cbor:"nickname,omitempty" yaml:"nickname,omitempty" comment:"nickname"`
	Avatar   string    `json:"avatar,omitempty" xml:"avatar,omitempty" cbor:"avatar,omitempty" yaml:"avatar,omitempty" comment:"avatar"`
	Level    int64     `json:"level,omitempty" yaml:"level,omitempty" xml:"level,attr,omitempty" cbor:"level,omitempty"`
	Type     int64     `json:"type,omitempty" yaml:"type,omitempty" xml:"type,attr,omitempty" cbor:"type,omitempty"`
}

type Module

type Module struct {
	// contains filtered or unexported fields
}

Module 不带权限功能的会员管理模块

func Install

func Install(mod *cmfx.Module, o *Config, up *upload.Module, adminL *admin.Module, ts []string, levels []string) *Module

Install 安装数据

ts 可用的类型名称; levels 可用的级别名称;

func Load

func Load(mod *cmfx.Module, conf *Config, up *upload.Module, adminMod *admin.Module) *Module

Load 加载模块

func (*Module) Add added in v0.8.3

func (m *Module) Add(state user.State, data *RegisterInfo, ip, ua, msg string) (*user.User, error)

Add 添加新的会员

func (*Module) AddSecurityLog

func (m *Module) AddSecurityLog(tx *orm.Tx, uid int64, content, ip, ua string) error

AddSecurityLog 记录一条安全日志

func (*Module) AddSecurityLogWithContext

func (m *Module) AddSecurityLogWithContext(tx *orm.Tx, uid int64, ctx *web.Context, content web.LocaleStringer) error

AddSecurityLogWithContext 从 web.Context 中记录一条安全日志

func (*Module) CurrentUser

func (m *Module) CurrentUser(ctx *web.Context) *user.User

CurrentUser 获取当前登录的用户信息

func (*Module) Invited added in v0.8.3

func (m *Module) Invited(uid int64, q *invitedQuery) (*query.Page[InvitedMember], error)

Invited 返回所有被 uid 邀请的用户列表

如果查找不到数据,则会同时返回两个 nil

func (*Module) LeftJoin added in v0.8.7

func (m *Module) LeftJoin(sql *sqlbuilder.SelectStmt, alias, on string)

LeftJoin 将 以 LEFT JOIN 的形式插入到 sql 语句中

alias 为 [infoPO] 表的别名,on 为 LEFT JOIN 的条件。

func (*Module) Middleware

func (m *Module) Middleware(next web.HandlerFunc, method, path, router string) web.HandlerFunc

Middleware 验证是否登录

func (*Module) SetLevel added in v0.8.3

func (m *Module) SetLevel(tx *orm.Tx, uid, lv int64) error

SetLevel 设置用户的等级

func (*Module) SetType added in v0.8.3

func (m *Module) SetType(tx *orm.Tx, uid, t int64) error

SetType 设置用户的类型

func (*Module) URLPrefix

func (m *Module) URLPrefix() string

func (*Module) UserModule

func (m *Module) UserModule() *user.Users

type RegisterInfo added in v0.8.3

type RegisterInfo struct {
	Username string
	Password string
	Birthday time.Time
	Sex      types.Sex
	Nickname string
	Avatar   string
	Level    int64
	Type     int64
	Inviter  int64
}

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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