model

package
v0.0.0-...-e0474ae Latest Latest
Warning

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

Go to latest
Published: Apr 12, 2019 License: MIT Imports: 21 Imported by: ? modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Index

Constants

This section is empty.

Variables

View Source
var CActivity *mgo.Collection
View Source
var CArticle *mgo.Collection
View Source
var CAttachment *mgo.Collection
View Source
var CAttachmentRelation *mgo.Collection
View Source
var CFeedback *mgo.Collection
View Source
var CLottery *mgo.Collection
View Source
var CLotteryNum *mgo.Collection
View Source
var CLotterySetting *mgo.Collection
View Source
var CMenuType *mgo.Collection
View Source
var CSetting *mgo.Collection
View Source
var CThirdPartyLogin *mgo.Collection
View Source
var MDBVersion *mgo.Collection
View Source
var TodoList []Todo

Functions

func ArticleToData

func ArticleToData(md *Article) (dm.Dungeons, error)

func ArticlesToDatas

func ArticlesToDatas(mds []*Article) ([]dm.Dungeons, error)

func DeleteArticlesByIDs

func DeleteArticlesByIDs(ids []*bson.ObjectId, userID *bson.ObjectId) bool

DeleteArticlesByIDs 根据数据的id数组删除数据

func DeleteMenuByIDs

func DeleteMenuByIDs(ids []*bson.ObjectId, userID *bson.ObjectId) bool

DeleteByIDs 根据数据的id数组删除数据

func DeleteTagByIDs

func DeleteTagByIDs(ids []*bson.ObjectId, userID *bson.ObjectId) bool

DeleteByIDs 根据数据的id数组删除数据

func DeleteThirdPartyLoginByIDs

func DeleteThirdPartyLoginByIDs(ids []*bson.ObjectId, userID *bson.ObjectId) bool

DeleteByIDs 根据数据的id数组删除数据

func DeleteUsersByIDs

func DeleteUsersByIDs(ids []*bson.ObjectId) bool

DeleteUsersByIDs 根据数据的id数组删除数据

func ExtLimit

func ExtLimit(ext string, exts []string) bool

ExtLimit 限制上传的文件类型

func GetArticleWhereMap

func GetArticleWhereMap(data []byte, where bson.M) bson.M

GetArticleWhereMap 根据byte数组获取map数据

func GetDeviceTokenByUser

func GetDeviceTokenByUser(uID int64) (string, error)

func GetStrByArticleStatus

func GetStrByArticleStatus(status ArticleStatus) string

GetStrByArticlePictureStatus 获取状态的string

func GetTagWhereMap

func GetTagWhereMap(data []byte, where bson.M) bson.M

GetTagWhereMap 根据byte数组获取map数据

func GetUserIDByToken

func GetUserIDByToken(token string) (int64, error)

func GetUserIDByTokenWithString

func GetUserIDByTokenWithString(token string) (string, error)

func GetUserWhereMap

func GetUserWhereMap(data []byte, where bson.M) bson.M

GetUserWhereMap 根据byte数组获取map数据

func InitMDB

func InitMDB(mdb *mgo.Database)

func InitMDBVersion

func InitMDBVersion(mdb *mgo.Database)

func InsertDeviceToken

func InsertDeviceToken(uID int64, dToken string) (string, error)

func InsertUserToken

func InsertUserToken(uID int64, token string) (string, error)

func InsertUserTokenWithIDString

func InsertUserTokenWithIDString(uID string, token string) (string, error)

func IsExistTag

func IsExistTag(name string, userID *bson.ObjectId) (bool, error)

IsExistTag 根据关键信息查询数据

func IsExistUser

func IsExistUser(name string) (bool, error)

IsExistUserEmail 根据关键信息查询数据用户数据

func IsExistUserEmail

func IsExistUserEmail(email string) (bool, error)

IsExistUserEmail 根据UserEmail查询数据

func IsExistUserName

func IsExistUserName(name string) (bool, error)

IsExistUserName 根据UserName查询数据

func IsExistUserPhoneNumber

func IsExistUserPhoneNumber(phoneNum string) (bool, error)

IsExistUserPhoneNumber 根据UserPhoneNumber查询数据

func MenuToData(md *Menu) (model.Dungeons, error)
func MenusToDatas(mds []*Menu) ([]model.Dungeons, error)

func NewMenus

func NewMenus(ts []*Menu) ([]interface{}, error)

NewMenus 批量创建标签

func NewTags

func NewTags(ts []*Tag) ([]interface{}, error)

NewTags 批量创建标签

func NewThirdPartyLogins

func NewThirdPartyLogins(ts []*ThirdPartyLogin) ([]interface{}, error)

NewThirdPartyLogins 批量创建标签

func RandStringRunes

func RandStringRunes(n int) string

func RequestParams2ProRequestParams

func RequestParams2ProRequestParams(rp *RequestQueryParams) *proto.RequestParams

RequestParams2ProRequestParams 将RequestParams转换为ProRequestParams

func TagToData

func TagToData(md *Tag) model.Dungeons

func TagsToDatas

func TagsToDatas(mds []*Tag) []model.Dungeons

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 字段

func UserToData

func UserToData(md *User) (dm.Dungeons, error)

func UsersToDatas

func UsersToDatas(mds []*User) ([]dm.Dungeons, error)

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

func GetArticleByID(id, userID bson.ObjectId) (u *Article, err error)

GetArticleByID 根据ArticleID查询数据

func GetArticleByIDs

func GetArticleByIDs(ids []*bson.ObjectId, userID *bson.ObjectId, artStatus ArticleStatus) ([]*Article, error)

GetArticleByIDs 根据数据的id数组查询数据

func NewArticles

func NewArticles(ts []*Article) ([]*Article, error)

NewArticles 批量创建Article

func SetTagsForArticle

func SetTagsForArticle(art []*Article) []*Article

SetTagsForArticle 给article对象设置标签

func UpdateArticlesByID

func UpdateArticlesByID(ts []*Article) ([]*Article, error)

UpdateArticlesByID 批量更新Article

func (Article) GetCollectionName

func (v Article) GetCollectionName() string

type ArticleParams

type ArticleParams struct {
	Article
	Status string `json:"article_status"`
}

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 Avatar

type Avatar struct {
	AttachmentID *bson.ObjectId `bson:"attachment_id" json:"attachment_id"`
	Default      bool           `bson:"default" json:"default"`
}

type ContactInfo

type ContactInfo struct {
	Name     string `bson:"attachment_id" json:"attachment_id"`
	Img_Name string `bson:"default" json:"default"`
	Detail   string `bson:"detail" json:"detail"`
	Url      string `bson:"url" json:"url"`
}

type Dungeons

type Dungeons map[string]interface{}

func SuccessResp

func SuccessResp(content string, data interface{}) Dungeons

type Error

type Error struct {
	Code    int
	Message string
}

func NewXFailError

func NewXFailError(e error) *Error

func (Error) Error

func (e Error) Error() string

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 Gender

type Gender int
const (
	GENDER_NULL   Gender = 0
	GENDER_FEMALE Gender = 1
	GENDER_MALE   Gender = 2
)

type LoginType

type LoginType int
const (
	LoginType_NULL   LoginType = 0
	LoginType_WECHAT LoginType = 1
	LoginType_QQ     LoginType = 2
)
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

func FindMenusByParams(req *proto.RequestParams, userID *bson.ObjectId) ([]*Menu, int64, error)

FindMenusByParams 根据查询参数获取标签的分页数据

func GetMenuByIDs

func GetMenuByIDs(ids []*bson.ObjectId, userID *bson.ObjectId) ([]*Menu, error)

GetMenuByIDs 根据数据的id数组查询数据

func UpdateMenus

func UpdateMenus(ts []*Menu) ([]*Menu, error)

UpdateMenus 批量更新标签

func (v Menu) GetCollectionName() string

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 NullBool

type NullBool struct {
	sql.NullBool
}

func NewNullBool

func NewNullBool(b bool, v bool) NullBool

func NewValidNullBool

func NewValidNullBool(b bool) NullBool

func (*NullBool) MarshalJSON

func (i *NullBool) MarshalJSON() ([]byte, error)

type NullFloat

type NullFloat struct {
	sql.NullFloat64
}

func NewNullFloat32

func NewNullFloat32(i float32) NullFloat

func NewNullFloat64

func NewNullFloat64(i float64) NullFloat

func (NullFloat) MarshalJSON

func (n NullFloat) MarshalJSON() ([]byte, error)

type NullInt

type NullInt struct {
	sql.NullInt64
}

func NewNullInt

func NewNullInt(i int64, v bool) NullInt

func NewNullInt32

func NewNullInt32(i int32, v bool) NullInt

func NewValidNullInt

func NewValidNullInt(i int64) NullInt

func NewValidNullIntType

func NewValidNullIntType(i int) NullInt

func (NullInt) MarshalJSON

func (i NullInt) MarshalJSON() ([]byte, error)

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

func FindTagsByParams(req *proto.RequestParams, userID *bson.ObjectId) ([]*Tag, int64, error)

FindTagsByParams 根据查询参数获取标签的分页数据

func GetTagByIDs

func GetTagByIDs(ids []*bson.ObjectId, userID *bson.ObjectId) ([]*Tag, error)

GetTagByIDs 根据数据的id数组查询数据

func UpdateTags

func UpdateTags(ts []*Tag) ([]*Tag, error)

UpdateTags 批量更新标签

func (Tag) GetCollectionName

func (v Tag) GetCollectionName() string

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 Todo

type Todo struct {
	ID   string `json:"id"`
	Text string `json:"text"`
	Done bool   `json:"done"`
}

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

func GetUserByEmail(email string) (u *User, err error)

GetUserByEmail 根据UserEmail查询数据

func GetUserByID

func GetUserByID(id bson.ObjectId) (u *User, err error)

GetUserByID 根据UserID查询数据

func GetUserByIDs

func GetUserByIDs(ids []*bson.ObjectId) ([]*User, error)

GetUserByIDs 根据数据的id数组查询数据

func GetUserByName

func GetUserByName(name string) (u *User, err error)

GetUserByName 根据UserName查询数据

func GetUserByPhoneNumber

func GetUserByPhoneNumber(phoneNum string) (u *User, err error)

GetUserByPhoneNumber 根据UserPhoneNumber查询数据

func GetUserByToken

func GetUserByToken(token string) (u *User, err error)

GetUserByToken 根据UserToken查询数据

func NewUsers

func NewUsers(ts []*User) ([]*User, error)

NewUsers 批量创建User

func UpdateUsersByID

func UpdateUsersByID(ts []*User) ([]*User, error)

UpdateUsersByID 批量更新User

func (User) GetCollectionName

func (v User) GetCollectionName() string

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 UserType

type UserType int
const (
	USERTYPE_NULL          UserType = 0
	USERTYPE_NORMAL        UserType = 1
	USERTYPE_PUP           UserType = 2
	USERTYPE_OPERATIONS    UserType = 3
	USERTYPE_ADMINISTRATOR UserType = 4
	USERTYPE_MERCHANT      UserType = 5
)

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

func GetVersionByTableName(name string) (*Version, error)

GetMoodByNum 根据数据的num查询数据

func IncreseVersion

func IncreseVersion(name string, mdb *mgo.Database) (*Version, error)

GetNewVersion 根据表名称增加版本号

Jump to

Keyboard shortcuts

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