Documentation
¶
Index ¶
- Variables
- func ArticleToData(md *Article) (dm.Dungeons, error)
- func ArticlesToDatas(mds []*Article) ([]dm.Dungeons, error)
- func DeleteArticlesByIDs(ids []*bson.ObjectId, userID *bson.ObjectId) bool
- func DeleteMenuByIDs(ids []*bson.ObjectId, userID *bson.ObjectId) bool
- func DeleteTagByIDs(ids []*bson.ObjectId, userID *bson.ObjectId) bool
- func DeleteThirdPartyLoginByIDs(ids []*bson.ObjectId, userID *bson.ObjectId) bool
- func DeleteUsersByIDs(ids []*bson.ObjectId) bool
- func ExtLimit(ext string, exts []string) bool
- func GetArticleWhereMap(data []byte, where bson.M) bson.M
- func GetDeviceTokenByUser(uID int64) (string, error)
- func GetStrByArticleStatus(status ArticleStatus) string
- func GetTagWhereMap(data []byte, where bson.M) bson.M
- func GetUserIDByToken(token string) (int64, error)
- func GetUserIDByTokenWithString(token string) (string, error)
- func GetUserWhereMap(data []byte, where bson.M) bson.M
- func InitMDB(mdb *mgo.Database)
- func InitMDBVersion(mdb *mgo.Database)
- func InsertDeviceToken(uID int64, dToken string) (string, error)
- func InsertUserToken(uID int64, token string) (string, error)
- func InsertUserTokenWithIDString(uID string, token string) (string, error)
- func IsExistTag(name string, userID *bson.ObjectId) (bool, error)
- func IsExistUser(name string) (bool, error)
- func IsExistUserEmail(email string) (bool, error)
- func IsExistUserName(name string) (bool, error)
- func IsExistUserPhoneNumber(phoneNum string) (bool, error)
- func MenuToData(md *Menu) (model.Dungeons, error)
- func MenusToDatas(mds []*Menu) ([]model.Dungeons, error)
- func NewMenus(ts []*Menu) ([]interface{}, error)
- func NewTags(ts []*Tag) ([]interface{}, error)
- func NewThirdPartyLogins(ts []*ThirdPartyLogin) ([]interface{}, error)
- func RandStringRunes(n int) string
- func RequestParams2ProRequestParams(rp *RequestQueryParams) *proto.RequestParams
- func TagToData(md *Tag) model.Dungeons
- func TagsToDatas(mds []*Tag) []model.Dungeons
- func ThirdPartyLoginToData(md *ThirdPartyLogin) (model.Dungeons, error)
- func ThirdPartyLoginsToDatas(mds []*ThirdPartyLogin) ([]model.Dungeons, error)
- func UserSecretsCollection(MDB *mgo.Database) *mgo.Collection
- func UserSecretsCollectionName() string
- func UserToData(md *User) (dm.Dungeons, error)
- func UsersToDatas(mds []*User) ([]dm.Dungeons, error)
- type Article
- func FindArticlesByParams(req *proto.RequestParams) ([]*Article, int64, error)
- func GetArticleByID(id, userID bson.ObjectId) (u *Article, err error)
- func GetArticleByIDs(ids []*bson.ObjectId, userID *bson.ObjectId, artStatus ArticleStatus) ([]*Article, error)
- func NewArticles(ts []*Article) ([]*Article, error)
- func SetTagsForArticle(art []*Article) []*Article
- func UpdateArticlesByID(ts []*Article) ([]*Article, error)
- type ArticleParams
- type ArticleRequestQueryParams
- type ArticleStatus
- type Avatar
- type ContactInfo
- type Dungeons
- type Error
- type ErrorMsgDefault
- type Gender
- type LoginType
- type Menu
- type Model
- type NullBool
- type NullFloat
- type NullInt
- type NullString
- type PageModelBase
- type RequestQueryParams
- type ResultModel
- type Secret
- type Tag
- type TagRequestQueryParams
- type ThirdPartyLogin
- func FindThirdPartyLoginsByParams(req *proto.RequestParams, lt LoginType) ([]*ThirdPartyLogin, int64, error)
- func GetThirdPartyLoginByIDs(ids []*bson.ObjectId, userID *bson.ObjectId) ([]*ThirdPartyLogin, error)
- func GetThirdPartyLoginByUserIDAndType(userID *bson.ObjectId, lt LoginType) (*ThirdPartyLogin, error)
- type Todo
- type User
- func FindUsersByParams(req *proto.RequestParams) ([]*User, int64, error)
- func GetUserByEmail(email string) (u *User, err error)
- func GetUserByID(id bson.ObjectId) (u *User, err error)
- func GetUserByIDs(ids []*bson.ObjectId) ([]*User, error)
- func GetUserByName(name string) (u *User, err error)
- func GetUserByPhoneNumber(phoneNum string) (u *User, err error)
- func GetUserByToken(token string) (u *User, err error)
- func NewUsers(ts []*User) ([]*User, error)
- func UpdateUsersByID(ts []*User) ([]*User, error)
- type UserSecretType
- type UserSecrets
- func (u *UserSecrets) AppendSecret(MDB *mgo.Database, s *Secret) (*UserSecrets, error)
- func (u *UserSecrets) Collection(MDB *mgo.Database) *mgo.Collection
- func (u *UserSecrets) CollectionName() string
- func (u *UserSecrets) GetSecretForNewEmail(MDB *mgo.Database) (*Secret, error)
- func (u *UserSecrets) GetSecretForNewMobile(MDB *mgo.Database) (*Secret, error)
- func (u *UserSecrets) GetSecretForNewPassword(MDB *mgo.Database) (*Secret, error)
- func (u *UserSecrets) GetSecretForType(MDB *mgo.Database, uType UserSecretType) (*Secret, error)
- func (u *UserSecrets) GetSecrets() []*Secret
- func (u *UserSecrets) RemoveSecretsByType(MDB *mgo.Database, uType UserSecretType) (*UserSecrets, error)
- type UserStatus
- type UserType
- type Version
Constants ¶
This section is empty.
Variables ¶
var CActivity *mgo.Collection
var CArticle *mgo.Collection
var CAttachment *mgo.Collection
var CAttachmentRelation *mgo.Collection
var CFeedback *mgo.Collection
var CForm *mgo.Collection
var CLottery *mgo.Collection
var CLotteryNum *mgo.Collection
var CLotterySetting *mgo.Collection
var CMenu *mgo.Collection
var CMenuType *mgo.Collection
var CSetting *mgo.Collection
var CTag *mgo.Collection
var CThirdPartyLogin *mgo.Collection
var CUser *mgo.Collection
var MDB *mgo.Database
var MDBVersion *mgo.Collection
var MG *mgo.Database
var TodoList []Todo
Functions ¶
func DeleteArticlesByIDs ¶
DeleteArticlesByIDs 根据数据的id数组删除数据
func DeleteMenuByIDs ¶
DeleteByIDs 根据数据的id数组删除数据
func DeleteTagByIDs ¶
DeleteByIDs 根据数据的id数组删除数据
func DeleteThirdPartyLoginByIDs ¶
DeleteByIDs 根据数据的id数组删除数据
func DeleteUsersByIDs ¶
DeleteUsersByIDs 根据数据的id数组删除数据
func GetArticleWhereMap ¶
GetArticleWhereMap 根据byte数组获取map数据
func GetDeviceTokenByUser ¶
func GetStrByArticleStatus ¶
func GetStrByArticleStatus(status ArticleStatus) string
GetStrByArticlePictureStatus 获取状态的string
func GetTagWhereMap ¶
GetTagWhereMap 根据byte数组获取map数据
func GetUserIDByToken ¶
func GetUserWhereMap ¶
GetUserWhereMap 根据byte数组获取map数据
func InitMDBVersion ¶
func IsExistTag ¶
IsExistTag 根据关键信息查询数据
func IsExistUserEmail ¶
IsExistUserEmail 根据UserEmail查询数据
func IsExistUserName ¶
IsExistUserName 根据UserName查询数据
func IsExistUserPhoneNumber ¶
IsExistUserPhoneNumber 根据UserPhoneNumber查询数据
func NewThirdPartyLogins ¶
func NewThirdPartyLogins(ts []*ThirdPartyLogin) ([]interface{}, error)
NewThirdPartyLogins 批量创建标签
func RandStringRunes ¶
func RequestParams2ProRequestParams ¶
func RequestParams2ProRequestParams(rp *RequestQueryParams) *proto.RequestParams
RequestParams2ProRequestParams 将RequestParams转换为ProRequestParams
func TagsToDatas ¶
func ThirdPartyLoginToData ¶
func ThirdPartyLoginToData(md *ThirdPartyLogin) (model.Dungeons, error)
func ThirdPartyLoginsToDatas ¶
func ThirdPartyLoginsToDatas(mds []*ThirdPartyLogin) ([]model.Dungeons, error)
func UserSecretsCollection ¶
func UserSecretsCollection(MDB *mgo.Database) *mgo.Collection
SMSAccountCollection 方法, 返回 Collection
func UserSecretsCollectionName ¶
func UserSecretsCollectionName() string
SMSAccountCollectionName 方法, 返回 Collection 字段
Types ¶
type Article ¶
type Article struct {
ID *bson.ObjectId `bson:"_id" json:"id"`
UserID *bson.ObjectId `bson:"user_id" json:"user_id"`
Title string `bson:"title" json:"title"`
KeyWords string `bson:"key_words" json:"key_words"`
Description string `bson:"description" json:"description"`
Content string `bson:"content" json:"content"`
TagIDs []*bson.ObjectId `bson:"tag_ids" json:"tag_ids"`
Tags []*Tag `json:"tags"`
Cover string `bson:"cover" json:"cover"`
Status ArticleStatus `bson:"article_status" json:"article_status"`
CreatedAt *time.Time `bson:"created_at" json:"created_at"`
UpdatedAt *time.Time `bson:"updated_at" json:"updated_at"`
DeletedAt *time.Time `bson:"deleted_at" json:"deleted_at"`
}
func FindArticlesByParams ¶
func FindArticlesByParams(req *proto.RequestParams) ([]*Article, int64, error)
FindArticlesByParams 根据查询参数获取Article的分页数据
func GetArticleByID ¶
GetArticleByID 根据ArticleID查询数据
func GetArticleByIDs ¶
func GetArticleByIDs(ids []*bson.ObjectId, userID *bson.ObjectId, artStatus ArticleStatus) ([]*Article, error)
GetArticleByIDs 根据数据的id数组查询数据
func SetTagsForArticle ¶
SetTagsForArticle 给article对象设置标签
func UpdateArticlesByID ¶
UpdateArticlesByID 批量更新Article
func (Article) GetCollectionName ¶
type ArticleParams ¶
type ArticleRequestQueryParams ¶
type ArticleRequestQueryParams struct {
dm.RequestQueryParams
Where ArticleParams `json:"where"`
}
type ArticleStatus ¶
type ArticleStatus int32
const ( ArticleStatusNULL ArticleStatus = 0 ArticleStatusUnpublished ArticleStatus = 1 ArticleStatusPublished ArticleStatus = 2 )
func GetArticleStatusByStr ¶
func GetArticleStatusByStr(status string) ArticleStatus
GetArticleStatusByStr 根据string获取状态
type ContactInfo ¶
type Error ¶
func NewXFailError ¶
type ErrorMsgDefault ¶
type ErrorMsgDefault struct {
HttpCode int `json:"-"`
ErrorType utils.ErrorType `json:"-"`
ErrorCode int `json:"code,omitempty"`
Message string `json:"message,omitempty"`
}
TODO 错误的代码可能不需要几个 之后可以合并
func NewError ¶
func NewError(err error) *ErrorMsgDefault
func NewResponseError ¶
func NewResponseError(message string, errorCode, httpCode int, errorType utils.ErrorType) *ErrorMsgDefault
func (ErrorMsgDefault) Error ¶
func (p ErrorMsgDefault) Error() string
type Menu ¶
type Menu struct {
ID bson.ObjectId `bson:"_id" json:"id"`
UserID *bson.ObjectId `bson:"user_id" json:"user_id"`
Name string `bson:"name" json:"name"`
Description string `bson:"description" json:"description"`
CreatedAt *time.Time `bson:"created_at" json:"created_at"`
UpdatedAt *time.Time `bson:"updated_at" json:"updated_at"`
DeletedAt *time.Time `bson:"deleted_at" json:"deleted_at"`
}
func FindMenusByParams ¶
FindMenusByParams 根据查询参数获取标签的分页数据
func GetMenuByIDs ¶
GetMenuByIDs 根据数据的id数组查询数据
func (Menu) GetCollectionName ¶
type Model ¶
type Model struct {
ID int64 `gorm:"primary_key" json:"id,omitempty"`
UUID uuid.UUID `sql:"type:uuid;default:uuid_generate_v4()" json:"uuid,omitempty"`
CreatedAt time.Time `json:"-"`
UpdatedAt time.Time `json:"-"`
DeletedAt *time.Time `sql:"index" json:"-"`
}
Model something
type NullFloat ¶
type NullFloat struct {
sql.NullFloat64
}
func NewNullFloat32 ¶
func NewNullFloat64 ¶
func (NullFloat) MarshalJSON ¶
type NullInt ¶
func NewNullInt ¶
func NewNullInt32 ¶
func NewValidNullInt ¶
func NewValidNullIntType ¶
func (NullInt) MarshalJSON ¶
type NullString ¶
type NullString struct {
sql.NullString
}
func NewNullString ¶
func NewNullString(s string, v bool) NullString
func NewValidNullString ¶
func NewValidNullString(s string) NullString
func (*NullString) MarshalJSON ¶
func (i *NullString) MarshalJSON() ([]byte, error)
type PageModelBase ¶
type PageModelBase struct {
Count int64 `json:"count,omitempty"`
PageData interface{} `json:"list,omitempty"`
}
type RequestQueryParams ¶
type RequestQueryParams struct {
StartTime string `json:"startTime"`
EndTime string `json:"endTime"`
OrderBy string `json:"orderBy"`
IsDesc bool `json:"isDesc"`
OffsetHead int64 `json:"offsetHead"`
OffsetTail int64 `json:"offsetTail"`
UserID int64 `json:"userID"`
Where interface{} `json:"where"`
Keywords string `json:"keywords"`
UserUUID string `json:"user_uuid"`
}
type ResultModel ¶
type ResultModel struct {
Errors []*ErrorMsgDefault `json:"errors,omitempty"`
Data interface{} `json:"data,omitempty"`
}
params model that server return data and message info
func NewReultModel ¶
func NewReultModel(data interface{}, e ...*ErrorMsgDefault) ResultModel
func (ResultModel) Error ¶
func (p ResultModel) Error() string
type Secret ¶
type Secret struct {
UserSecretType UserSecretType
Code string
Secret string
}
type Tag ¶
type Tag struct {
ID bson.ObjectId `bson:"_id" json:"id"`
UserID *bson.ObjectId `bson:"user_id" json:"user_id"`
Name string `bson:"name" json:"name"`
Color string `bson:"color" json:"color"`
Description string `bson:"description" json:"description"`
CreatedAt *time.Time `bson:"created_at" json:"created_at"`
UpdatedAt *time.Time `bson:"updated_at" json:"updated_at"`
DeletedAt *time.Time `bson:"deleted_at" json:"deleted_at"`
}
func FindTagsByParams ¶
FindTagsByParams 根据查询参数获取标签的分页数据
func GetTagByIDs ¶
GetTagByIDs 根据数据的id数组查询数据
func (Tag) GetCollectionName ¶
type TagRequestQueryParams ¶
type TagRequestQueryParams struct {
model.RequestQueryParams
Where Tag `json:"where"`
}
type ThirdPartyLogin ¶
type ThirdPartyLogin struct {
ID bson.ObjectId `bson:"_id" json:"id"`
UserID *bson.ObjectId `bson:"user_id" json:"user_id"`
UnionID string `bson:"union_id" json:"union_id"`
LotteryDrawNum string `bson:"lottery_draw_num" json:"lottery_draw_num"`
LoginType LoginType `bson:"login_type" json:"login_type"`
CreatedAt *time.Time `bson:"created_at" json:"created_at"`
UpdatedAt *time.Time `bson:"updated_at" json:"updated_at"`
DeletedAt *time.Time `bson:"deleted_at" json:"deleted_at"`
}
func FindThirdPartyLoginsByParams ¶
func FindThirdPartyLoginsByParams(req *proto.RequestParams, lt LoginType) ([]*ThirdPartyLogin, int64, error)
FindThirdPartyLoginsByParams 根据查询参数获取标签的分页数据
func GetThirdPartyLoginByIDs ¶
func GetThirdPartyLoginByIDs(ids []*bson.ObjectId, userID *bson.ObjectId) ([]*ThirdPartyLogin, error)
GetThirdPartyLoginByIDs 根据数据的id数组查询数据
func GetThirdPartyLoginByUserIDAndType ¶
func GetThirdPartyLoginByUserIDAndType(userID *bson.ObjectId, lt LoginType) (*ThirdPartyLogin, error)
GetThirdPartyLoginByIDs 根据数据的id数组查询数据
func (ThirdPartyLogin) GetCollectionName ¶
func (v ThirdPartyLogin) GetCollectionName() string
type User ¶
type User struct {
ID *bson.ObjectId `bson:"_id" json:"id"`
Name string `bson:"name" json:"name"`
Gender Gender `bson:"gender" json:"gender"`
Nickname string `bson:"nickname" json:"nickname"`
RealName string `bson:"real_name" json:"real_name"`
Birthday string `bson:"birthday" json:"birthday"`
Location string `bson:"location" json:"location"`
PhoneNumber string `bson:"phone_number" json:"phone_number"`
Password string `bson:"password" json:"password"`
Email string `bson:"email" json:"email"`
Salt string `bson:"salt" json:"salt"`
Token string `bson:"token" json:"token"`
Type UserType `bson:"type" json:"type"`
Status UserStatus `bson:"status" json:"status"`
Avatars []*Avatar `bson:"avatars" json:"avatars"`
ContactInfos []*ContactInfo `bson:"contact_infos" json:"contact_infos"`
CreatedAt *time.Time `bson:"created_at" json:"created_at"`
UpdatedAt *time.Time `bson:"updated_at" json:"updated_at"`
DeletedAt *time.Time `bson:"deleted_at" json:"deleted_at"`
}
func FindUsersByParams ¶
func FindUsersByParams(req *proto.RequestParams) ([]*User, int64, error)
FindUsersByParams 根据查询参数获取User的分页数据
func GetUserByEmail ¶
GetUserByEmail 根据UserEmail查询数据
func GetUserByIDs ¶
GetUserByIDs 根据数据的id数组查询数据
func GetUserByName ¶
GetUserByName 根据UserName查询数据
func GetUserByPhoneNumber ¶
GetUserByPhoneNumber 根据UserPhoneNumber查询数据
func GetUserByToken ¶
GetUserByToken 根据UserToken查询数据
func (User) GetCollectionName ¶
type UserSecretType ¶
type UserSecretType int
UserSecretType 用户指示用户 UserSecret 的类型
const ( // UserSecretType 标示用户在更换密码 UserSecretTypeNewPassword UserSecretType = 1 + iota // UserSecretType 标示用户在更换邮箱 UserSecretTypeNewEmail // UserSecretTypeNewMobile 标示用户在更换手机号 UserSecretTypeNewMobile )
type UserSecrets ¶
type UserSecrets struct {
ID bson.ObjectId `json:"id" bson:"_id,omitempty"`
UserUUID string `bson:"user_uuid"`
Secrets []*Secret `bson:"secrets"`
}
func GetUserSecrets ¶
func GetUserSecrets(MDB *mgo.Database, uUUID uuid.UUID) (*UserSecrets, error)
Mark - Begin secret methods GetSecrets 方法: 获取 User 的 UserSecrete 数组
func (*UserSecrets) AppendSecret ¶
func (u *UserSecrets) AppendSecret(MDB *mgo.Database, s *Secret) (*UserSecrets, error)
func (*UserSecrets) Collection ¶
func (u *UserSecrets) Collection(MDB *mgo.Database) *mgo.Collection
Collection 方法, 返回 UserSecret 的 Collection
func (*UserSecrets) CollectionName ¶
func (u *UserSecrets) CollectionName() string
CollectionName 方法, 返回 UserSecret 的 Collection 字段
func (*UserSecrets) GetSecretForNewEmail ¶
func (u *UserSecrets) GetSecretForNewEmail(MDB *mgo.Database) (*Secret, error)
func (*UserSecrets) GetSecretForNewMobile ¶
func (u *UserSecrets) GetSecretForNewMobile(MDB *mgo.Database) (*Secret, error)
func (*UserSecrets) GetSecretForNewPassword ¶
func (u *UserSecrets) GetSecretForNewPassword(MDB *mgo.Database) (*Secret, error)
func (*UserSecrets) GetSecretForType ¶
func (u *UserSecrets) GetSecretForType(MDB *mgo.Database, uType UserSecretType) (*Secret, error)
func (*UserSecrets) GetSecrets ¶
func (u *UserSecrets) GetSecrets() []*Secret
func (*UserSecrets) RemoveSecretsByType ¶
func (u *UserSecrets) RemoveSecretsByType(MDB *mgo.Database, uType UserSecretType) (*UserSecrets, error)
type UserStatus ¶
type UserStatus int
const ( USERSTATUS_NULL UserStatus = 0 USERSTATUS_ACTIVATED UserStatus = 1 USERSTATUS_DEACTIVATED UserStatus = 2 USERSTATUS_CLOSED UserStatus = 3 )
type Version ¶
type Version struct {
ID *bson.ObjectId `bson:"_id" json:"id"`
Name string `bson:"name" json:"name"`
Version int64 `bson:"version" json:"version"`
CreatedAt *time.Time `bson:"created_at" json:"created_at"`
UpdatedAt *time.Time `bson:"updated_at" json:"updated_at"`
}
func GetVersionByTableName ¶
GetMoodByNum 根据数据的num查询数据