Documentation ¶
Index ¶
- Constants
- Variables
- type Account
- type AccountBindTelCodeReq
- type AccountBindTelReq
- type AccountBindWechatReq
- type AccountCheckSwitchCodeReq
- type AccountInfoResp
- type AccountSwitchTargetCodeReq
- type AccountSwitchTelCodeReq
- type AccountSwitchTelReq
- type AccountUnBindWechatReq
- type Article
- type ArticleRepository
- type ArticleUsecase
- type AuthLoginReq
- type AuthLoginResp
- type AuthSmsCodeReq
- type Author
- type AuthorRepository
- type Code
- type GithubAccessTokenResp
- type GithubErrResp
- type GithubUserInfoResp
- type IAccessTokenRepository
- type IAccountRepository
- type IAccountUsecase
- type IAuthUsecase
- type ICodeRepository
- type IGithubRepository
- type IPrivateInfoRepository
- type IPrivateTelInfoRepository
- type IProfileRepository
- type IProviceUsecase
- type IUnionidRepository
- type IWechatRepository
- type PrivateInfo
- type PrivateTelInfo
- type Profile
- type Unionid
- type UserProfileResp
- type UserSetBirthdayReq
- type UserSetCityReq
- type UserSetHeadResp
- type UserSetHeightReq
- type UserSetNicknameReq
- type UserSetSexReq
- type UserSetSignatureReq
- type UserSetWeightReq
- type WechatAccessTokenResp
- type WechatErrResp
- type WechatUserInfoResp
Constants ¶
View Source
const ( CodePurposeLogin CodePurposeBindTel )
View Source
const ( CodeStateSent CodeStateUsed )
View Source
const DefaultNationCode = "0086"
View Source
const (
UnionidDtWechat
)
Variables ¶
View Source
var ( // ErrInternalServerError will throw if any the Internal Server Error happen ErrInternalServerError = errors.New("internal Server Error") // ErrNotFound will throw if the requested item is not exists ErrNotFound = errors.New("your requested Item is not found") // ErrConflict will throw if the current action already exists ErrConflict = errors.New("your Item already exist") // ErrBadParamInput will throw if the given request-body or params is not valid ErrBadParamInput = errors.New("given Param is not valid") )
Functions ¶
This section is empty.
Types ¶
type Account ¶
type Account struct { ID int `gorm:"column:id;primaryKey"` Openid string `gorm:"column:openid"` PlatformId int `gorm:"column:platform_id"` UserId int `gorm:"column:user_id"` CreatedAt int64 `gorm:"column:created_at"` UpdatedAt int64 `gorm:"column:updated_at"` DeletedAt int64 `gorm:"column:deleted_at"` }
func NewAccount ¶
type AccountBindTelCodeReq ¶
type AccountBindTelReq ¶
type AccountBindWechatReq ¶
type AccountBindWechatReq struct {
Code string `json:"string"`
}
type AccountCheckSwitchCodeReq ¶
type AccountCheckSwitchCodeReq struct { }
type AccountInfoResp ¶
type AccountSwitchTargetCodeReq ¶
type AccountSwitchTargetCodeReq struct { }
type AccountSwitchTelCodeReq ¶
type AccountSwitchTelCodeReq struct { }
type AccountSwitchTelReq ¶
type AccountSwitchTelReq struct { }
type AccountUnBindWechatReq ¶
type AccountUnBindWechatReq struct { }
type Article ¶
type Article struct { ID int64 `json:"id"` Title string `json:"title" validate:"required"` Content string `json:"content" validate:"required"` Author Author `json:"author"` UpdatedAt time.Time `json:"updated_at"` CreatedAt time.Time `json:"created_at"` }
Article is representing the Article data struct
type ArticleRepository ¶
type ArticleRepository interface { Fetch(ctx context.Context, cursor string, num int64) (res []Article, nextCursor string, err error) GetByID(ctx context.Context, id int64) (Article, error) GetByTitle(ctx context.Context, title string) (Article, error) Update(ctx context.Context, ar *Article) error Store(ctx context.Context, a *Article) error Delete(ctx context.Context, id int64) error }
ArticleRepository represent the article's repository contract
type ArticleUsecase ¶
type ArticleUsecase interface { Fetch(ctx context.Context, cursor string, num int64) ([]Article, string, error) GetByID(ctx context.Context, id int64) (Article, error) Update(ctx context.Context, ar *Article) error GetByTitle(ctx context.Context, title string) (Article, error) Store(context.Context, *Article) error Delete(ctx context.Context, id int64) error }
ArticleUsecase represent the article's usecases
type AuthLoginReq ¶
type AuthLoginResp ¶
type AuthSmsCodeReq ¶
type Author ¶
type Author struct { ID int64 `json:"id"` Name string `json:"name"` CreatedAt string `json:"created_at"` UpdatedAt string `json:"updated_at"` }
Author representing the Author data struct
type AuthorRepository ¶
AuthorRepository represent the author's repository contract
type Code ¶
type Code struct { ID int `gorm:"column:id;primaryKey"` Tel string `gorm:"column:tel"` NationCode string `gorm:"column:nation_code"` Code string `gorm:"column:code"` State int `gorm:"column:state"` Purpose int `gorm:"column:purpose"` CreatedAt int64 `gorm:"column:created_at"` UpdateAt int64 `gorm:"column:updated_at"` ExpiredAt int64 `gorm:"column:expired_at"` }
func NewSmsCode ¶
type GithubAccessTokenResp ¶
type GithubErrResp ¶
type GithubUserInfoResp ¶
type GithubUserInfoResp struct { Openid string `json:"openid"` Nickname string `json:"nickname"` Sex int `json:"sex"` Province string `json:"province"` City string `json:"city"` Country string `json:"country"` Headimgurl string `json:"headimgurl"` Privilege string `json:"privilege"` Unionid string `json:"unionid"` }
type IAccessTokenRepository ¶
type IAccountRepository ¶
type IAccountRepository interface { GetOneByOpenid(ctx context.Context, openid string) (*Account, error) GetByUserID(ctx context.Context, userId int) ([]Account, error) DelByUserIdFromCache(ctx context.Context, userId int) error Save(ctx context.Context, account *Account, privateTet *PrivateTelInfo, privateInfo *PrivateInfo, profile *Profile, update func(account *Account)) error SaveSns(ctx context.Context, account *Account, profile *Profile, unionid *Unionid, update func(account *Account)) error DeleteFromCache(ctx context.Context, openid string) error }
type IAccountUsecase ¶
type IAccountUsecase interface { // Info 账户信息手机号、微信 Info(ctx context.Context) (*AccountInfoResp, error) // BindTelCode 绑定手机号验证码 BindTelCode(ctx context.Context, param *AccountBindTelCodeReq) error // BindTel 绑定手机号 BindTel(ctx context.Context, param *AccountBindTelReq) error // BindWechat 绑定微信 BindWechat(ctx context.Context, param *AccountBindWechatReq) error }
type IAuthUsecase ¶
type IAuthUsecase interface { // Login 登录 Login(ctx context.Context, param *AuthLoginReq) (*AuthLoginResp, error) // SmsCode 发送短信验证码 SmsCode(ctx context.Context, param *AuthSmsCodeReq) error // Logout 登出 Logout(ctx context.Context) error }
type ICodeRepository ¶
type ICodeRepository interface { Save(ctx context.Context, code *Code) error GetByTelAndCode(ctx context.Context, tel, nationCode, code string, purpose int) (*Code, error) GetByTel(ctx context.Context, tel, nationCode string, purpose int) (*Code, error) Update(ctx context.Context, code *Code) error }
type IGithubRepository ¶
type IGithubRepository interface { GetAccessToken(code string) (*GithubAccessTokenResp, error) UserInfo(accessToken, openid string) (*GithubUserInfoResp, error) }
type IPrivateInfoRepository ¶
type IProfileRepository ¶
type IProviceUsecase ¶
type IProviceUsecase interface { // SetHead 设置头像 SetHead(ctx context.Context, fh *multipart.FileHeader) (*UserSetHeadResp, error) // SetNickname 设置昵称 SetNickname(ctx context.Context, nickname string) error // SetSex 设置性别 SetSex(ctx context.Context, sex int) error // SetCity 设置城市 SetCity(ctx context.Context, req *UserSetCityReq) error // Profile 获取用户基本信息 Profile(ctx context.Context) (*UserProfileResp, error) // SetSignature 设置签名 SetSignature(ctx context.Context, signature string) error // SetHeight 设置身高 SetHeight(ctx context.Context, height int) error // SetWeight 设置体重 SetWeight(ctx context.Context, weight int) error // SetBirthday 设置生日 SetBirthday(ctx context.Context, birthday string) error }
type IUnionidRepository ¶
type IWechatRepository ¶
type IWechatRepository interface { GetAccessToken(code string) (*WechatAccessTokenResp, error) UserInfo(accessToken, openid string) (*WechatUserInfoResp, error) }
type PrivateInfo ¶
type PrivateInfo struct { UserId int `gorm:"column:user_id;primaryKey"` Name string `gorm:"column:name"` Tel string `gorm:"column:tel"` TelHash string `gorm:"column:tel_hash"` IdCode string `gorm:"column:id_code"` RealInfo string `gorm:"column:real_info"` IdCodeHash string `gorm:"column:id_code_hash"` IdType string `gorm:"column:id_type"` IdHold string `gorm:"column:id_hold"` IdFront string `gorm:"column:id_front"` IdBack string `gorm:"column:id_back"` IdVerifiedAt int64 `gorm:"column:id_verified_at"` IdExpiredAt int64 `gorm:"column:id_expired_at"` CreatedAt int64 `gorm:"column:created_at` }
func NewPrivateInfo ¶
func NewPrivateInfo(name, tel, telHash string) *PrivateInfo
func (*PrivateInfo) HasTel ¶
func (pt *PrivateInfo) HasTel() bool
func (*PrivateInfo) SetUserID ¶
func (pt *PrivateInfo) SetUserID(Id int)
func (*PrivateInfo) TableName ¶
func (*PrivateInfo) TableName() string
type PrivateTelInfo ¶
type PrivateTelInfo struct { ID int `gorm:"column:id;primaryKey"` TelHash string `gorm:"column:tel_hash"` UserId int `gorm:"column:user_id"` CreatedAt int64 `gorm:"column:created_at"` DeletedAt int64 `gorm:"column:deleted_at"` }
func NewPrivateTelInfo ¶
func NewPrivateTelInfo(hash string) *PrivateTelInfo
func (*PrivateTelInfo) SetUserID ¶
func (pti *PrivateTelInfo) SetUserID(Id int)
func (*PrivateTelInfo) TableName ¶
func (*PrivateTelInfo) TableName() string
type Profile ¶
type Profile struct { UserId int `gorm:"column:user_id;primaryKey"` Uri string `gorm:"column:uri"` Headimgurl string `gorm:"column:headimgurl"` Signature string `gorm:"column:signature"` Nickname string `gorm:"column:nickname"` Sex int `gorm:"column:sex"` Region string `gorm:"column:region"` Country string `gorm:"column:country"` Province string `gorm:"column:province"` City string `gorm:"column:city"` Height int `gorm:"height"` Weight int `gorm:"weight"` Lang string `gorm:"column:lang"` Preferences string `gorm:"column:preferences"` Birthday string `gorm:"column:birthday"` ForbiddenAt int64 `gorm:"column:forbidden_at"` ForbiddenEndAt int64 `gorm:"column:forbidden_end_at"` CreatedAt int64 `gorm:"column:created_at"` UpdatedAt int64 `gorm:"column:updated_at"` DeletedAt int64 `gorm:"column:deleted_at"` }
func InitProfile ¶
func InitProfile() *Profile
func NewProfile ¶
func NewProfile(snsInfo *WechatUserInfoResp) *Profile
func NewProfileWithGithub ¶
func NewProfileWithGithub(snsInfo *GithubUserInfoResp) *Profile
type Unionid ¶
type Unionid struct { ID int `gorm:"column:id;primaryKey"` UserId int `gorm:"column:user_id"` Unionid string `gorm:"column:unionid"` DataType int `gorm:"column:data_type"` CreatedAt int64 `gorm:"column:created_at"` UpdatedAt int64 `gorm:"column:updated_at"` }
func NewUnionid ¶
type UserProfileResp ¶
type UserProfileResp struct { Uri string `json:"uri"` Nickname string `json:"nickname"` Signature string `json:"signature"` Sex int `json:"sex"` Province string `json:"province"` City string `json:"city"` Country string `json:"country"` Region string `json:"region"` Headimgurl string `json:"headimgurl"` Height int `json:"height"` Weight int `json:"weight"` Birthday string `json:"birthday"` }
func TransProfileDto ¶
func TransProfileDto(profile *Profile) *UserProfileResp
type UserSetBirthdayReq ¶
type UserSetBirthdayReq struct {
Birthday string `json:"birthday" binding:"required"`
}
type UserSetCityReq ¶
type UserSetHeadResp ¶
type UserSetHeadResp struct {
Headimgurl string `json:"headimgurl"`
}
type UserSetHeightReq ¶
type UserSetHeightReq struct {
Height int `json:"height" binding:"required"`
}
type UserSetNicknameReq ¶
type UserSetNicknameReq struct {
Nickname string `json:"nickname" binding:"required"`
}
type UserSetSexReq ¶
type UserSetSexReq struct {
Sex int `json:"sex" binding:"required"`
}
type UserSetSignatureReq ¶
type UserSetSignatureReq struct {
Signature string `json:"signature" binding:"required,max=140"`
}
type UserSetWeightReq ¶
type UserSetWeightReq struct {
Weight int `json:"weight" binding:"required"`
}
type WechatAccessTokenResp ¶
type WechatErrResp ¶
type WechatUserInfoResp ¶
type WechatUserInfoResp struct { Openid string `json:"openid"` Nickname string `json:"nickname"` Sex int `json:"sex"` Province string `json:"province"` City string `json:"city"` Country string `json:"country"` Headimgurl string `json:"headimgurl"` Privilege string `json:"privilege"` Unionid string `json:"unionid"` }
Source Files ¶
Click to show internal directories.
Click to hide internal directories.