Documentation
¶
Index ¶
- type APIer
- type App
- type AuthService
- type Code
- type Command
- type Config
- type Creater
- type FieldError
- type IDModel
- type LoginForm
- type NumModel
- type Partyer
- type Service
- func (s *Service) Bind(ctx iris.Context, obj interface{}, errMsg string) bool
- func (s *Service) Get(url string, p interface{}) error
- func (s *Service) Int(ctx iris.Context, name, errMsg string) int
- func (s *Service) String(ctx iris.Context, name, errMsg string) string
- func (s *Service) URLInt(ctx iris.Context, name, errMsg string) int
- func (s *Service) URLString(ctx iris.Context, name, errMsg string) string
- type User
- type UserService
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type AuthService ¶ added in v0.0.7
type AuthService struct {
DB *gorm.DB
CS *Service
US *UserService
TS *wx.TokenService
Created Created
WxURL string
}
AuthService 身份认证
func NewAuthService ¶ added in v0.0.7
func NewAuthService(db *gorm.DB, cs *Service, us *UserService, ts *wx.TokenService) *AuthService
NewAuthService 新建身份认证服务
type Config ¶ added in v0.0.3
type Config struct {
Address string // 监听端口
Secret []byte // JWT密钥
MockID string // 模拟用户ID
Develop bool // 开发模式
Redirect string // 重定向目录
LogDir string // 日志目录
StaticDir string // 静态资源目录
WxURL string // 微信首页
}
Config 配置信息
type FieldError ¶
type FieldError struct {
Field string `json:"field"` // 字段
Tag string `json:"tag"` // 标签
Param string `json:"param"` // 参数
}
FieldError 字段错误信息
type IDModel ¶ added in v0.0.4
type IDModel struct {
ID string `gorm:"primary_key;size:22" json:"id"`
CreatedAt time.Time `json:"createdAt"`
UpdatedAt time.Time `json:"updatedAt"`
}
IDModel 主键UUID模型
type LoginForm ¶ added in v0.0.7
type LoginForm struct {
Phone string `validate:"required"` // 手机
Password string `validate:"required"` // 密码
}
LoginForm 用户登录
type NumModel ¶ added in v0.0.4
type NumModel struct {
ID int `gorm:"primary_key;auto_increment:false" json:"id"`
CreatedAt time.Time `json:"createdAt"`
UpdatedAt time.Time `json:"updatedAt"`
}
NumModel 主键int模型
type Service ¶
Service 公共服务
type User ¶ added in v0.0.5
type User struct {
IDModel
IssuesNum int `gorm:"default:0" json:"-"` // 问题数量
Nick string `gorm:"size:60" json:"nickname"` // 昵称
Openid string `gorm:"size:36" json:"openid"` // 微信ID
Unionid string `gorm:"unique;size:36" json:"unionid"` // 微信唯一标识
Sex int `json:"sex"` // 性别
Province string `gorm:"size:36" json:"province"` // 省份
City string `gorm:"size:36" json:"city"` // 城市
Country string `gorm:"size:16" json:"country"` // 国家
Headimgurl string `gorm:"size:250" json:"headimgurl"` // 头像
// 用户可修改
Phone string `gorm:"size:20" json:"phone"` // 手机
Password string `gorm:"-" json:"token"` // 密码
Cipher []byte `gorm:"size:16" json:"-"` // 密文
}
User 用户
func (*User) BeforeCreate ¶ added in v0.0.5
BeforeCreate 创建用户前加密密码
type UserService ¶ added in v0.0.5
UserService 用户服务
func NewUserService ¶ added in v0.0.5
func NewUserService(db *gorm.DB, secret []byte) *UserService
NewUserService 新建用户服务
func (*UserService) Find ¶ added in v0.0.6
func (s *UserService) Find(unionid string, user interface{})
Find 查找用户,参数是用户指针
func (*UserService) GetUser ¶ added in v0.0.5
func (s *UserService) GetUser(ctx iris.Context, user interface{})
GetUser 获取用户
func (*UserService) GetUserID ¶ added in v0.0.5
func (s *UserService) GetUserID(ctx iris.Context) string
GetUserID 获取用户ID
func (*UserService) Token ¶ added in v0.0.5
func (s *UserService) Token(userID string) string
Token 生成token
Click to show internal directories.
Click to hide internal directories.