models

package
v0.0.0-...-54e49cf Latest Latest
Warning

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

Go to latest
Published: Sep 16, 2021 License: MIT Imports: 12 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Close

func Close() error

Close ...

func CloseQuestion

func CloseQuestion() (err error)

func CreateItem

func CreateItem(repo *Repository, item *Item) error

func CreateItemLiker

func CreateItemLiker(repo *Repository, projectId, itemId, userId uint64) error

func CreateLikeItem

func CreateLikeItem(repo *Repository, item *LikeItem) error

func CreateQuestion

func CreateQuestion() (err error)

func DataBase

func DataBase() *gorm.DB

func DeleteItem

func DeleteItem(repo *Repository, itemID uint64) error

func DeleteItemLiker

func DeleteItemLiker(repo *Repository, projectId, itemId, userId uint64) error

func DeleteLikeItem

func DeleteLikeItem(repo *Repository, itemID uint64) error

func DeleteQuestion

func DeleteQuestion() (err error)

func EditQuestion

func EditQuestion() (err error)

func GetActiveListByActiveType

func GetActiveListByActiveType(creatorID uint64, activeType uint) (*[]*Active, error)

func GetActiveListByTimeRange

func GetActiveListByTimeRange(start time.Time, end time.Time) (*[]*Active, error)

func GetAcviteByGroupID

func GetAcviteByGroupID(groupID uint64) (*[]*Active, error)

func GetAcviteByProjectID

func GetAcviteByProjectID(projectID uint64) (*[]*Active, error)

func GetAcviteByUserID

func GetAcviteByUserID(userID uint64) (*[]*Active, error)

func GetCommentByUserID

func GetCommentByUserID(userID uint64) (*[]*Comment, error)

func GetCommentListByItem

func GetCommentListByItem(userID uint64, activeType uint) (*[]*Comment, error)

func GetCommentListByTimeRange

func GetCommentListByTimeRange(start time.Time, end time.Time) (*[]*Comment, error)

func GetQuestion

func GetQuestion() (err error)

func GetQuestionByTags

func GetQuestionByTags() (err error)

func GetQuestionByTitle

func GetQuestionByTitle() (err error)

func Init

func Init(uname, pwd, dbname string) error

Init ...

func IsUserAuthExist

func IsUserAuthExist(account string) bool

func StartWatchingProject

func StartWatchingProject(userID, groupID, projectId uint64) error

func StopWatchingProject

func StopWatchingProject(userID, groupID, projectId uint64) error

func UpdateItemTags

func UpdateItemTags(repo *Repository, itemID uint64, tags string) error

func UpdateItemTitle

func UpdateItemTitle(repo *Repository, itemID uint64, title string) error

func UpdateItemVisable

func UpdateItemVisable(repo *Repository, itemID uint64, vtype api.VisibleType) error

Types

type Active

type Active struct {
	IDBase
	UserId     uint64         `json:"user_id,omitempty"`
	ActiveType api.ActiveType `json:"active_type,omitempty"`
	ItemID     uint64         `json:"item_id,omitempty"`
	ProjectID  uint64         `json:"project_id,omitempty"`
	GroupID    uint64         `json:"group_id,omitempty"`
}
Active

加载用户自己的活动记录 加载一个project的用户活动记录 加载用户的开放project的活动记录 加载一个group内的public project的活动记录

func (*Active) Create

func (a *Active) Create() error

func (*Active) Delete

func (a *Active) Delete() error

func (*Active) Get

func (a *Active) Get() error

func (Active) TableName

func (a Active) TableName() string

type Auth

type Auth struct {
	IDBase
	UID       uint64       `json:"uid,omitempty" gorm:"unique_index,column:uid"`
	Email     string       `json:"email,omitempty" gorm:"unique_index"`
	Phone     string       `json:"phone,omitempty" gorm:"unique_index"`
	Password  string       `json:"-" gorm:"password"`
	Salt      string       `json:"-" gorm:"salt"`
	IsValid   bool         `json:"is_valid,omitempty"`
	AuthType  api.AuthType `json:"auth_type,omitempty" gorm:"authtype"`
	Confirmed bool         `json:"confirmed,omitempty"`
}

func (*Auth) ConfirmAuth

func (a *Auth) ConfirmAuth() error

func (*Auth) CreateWithEmail

func (a *Auth) CreateWithEmail() error

func (*Auth) CreateWithPhone

func (a *Auth) CreateWithPhone() error

func (*Auth) Delete

func (a *Auth) Delete() error

func (*Auth) GetByEmail

func (a *Auth) GetByEmail() error

func (*Auth) GetByPhone

func (a *Auth) GetByPhone() error

func (*Auth) GetByUID

func (a *Auth) GetByUID() error

func (Auth) TableName

func (a Auth) TableName() string

func (*Auth) UpdatePwd

func (a *Auth) UpdatePwd() error

type Base

type Base struct {
	CreatedAt time.Time `gorm:"primary_key,column:create_at" json:"created_at,omitempty"`
	UpdatedAt time.Time `gorm:"primary_key,column:update_at" json:"updated_at,omitempty"`
	Deleted   bool      `gorm:"primary_key,column:deleted" json:"deleted,omitempty"`
}

type ChatSetting

type ChatSetting int
const (
	NoLimit           ChatSetting = 0
	AtleastOneGroup   ChatSetting = 1
	AtleastThreeGroup ChatSetting = 2
	Forbiden          ChatSetting = 4
)

type Comment

type Comment struct {
	IDBase
	UserID    uint64 `json:"user_id,omitempty"`
	GroupID   uint64 `json:"group_id,omitempty"`
	ProjectID uint64 `json:"project_id,omitempty"`
	ItemID    int    `json:"item_id,omitempty"`
	PreID     uint64 `json:"pre_id,omitempty"`
	Content   []byte `json:"content,omitempty"`
	Tags      string `json:"tags,omitempty"`
}
Comment

用户的评论,如果用户的活动是评论的话,评论会被加载 评论可以针对: 视频,图片,短说,长文,音乐,项目,问题(?暂时可以不做)

func (*Comment) Create

func (c *Comment) Create() error

func (*Comment) Delete

func (c *Comment) Delete() error

func (*Comment) GetComment

func (c *Comment) GetComment() error

func (Comment) TableName

func (c Comment) TableName() string

func (*Comment) UpdateContent

func (c *Comment) UpdateContent() error

type Group

type Group struct {
	IDBase
	Name        string          `json:"name,omitempty"`
	ShortDesc   string          `json:"short_desc,omitempty"`
	Gtype       string          `json:"gtype,omitempty"`
	CreatorID   uint64          `json:"creator_id,omitempty"`
	OwnerID     uint64          `json:"owner_id,omitempty"`
	Members     uint64          `json:"members,omitempty"`
	VisableType api.VisibleType `json:"visable_type,omitempty"`
	Description string          `json:"description,omitempty"`
	Avatar      string          `json:"avatar,omitempty"`
	IsDefault   bool            `json:"is_default,omitempty"`
}

用户有默认的自己的一个group,叫做场地或者空间 Group 用户参与的组织: 1.类似于一个大家庭,一个小家庭,情侣的二人世界 2.学校,学院,系,实验室,班级,同学合作小组, 3.一些关系比较近的大学校友同学,或者一些开放组织 4.一些公共组织,类似于气候变化,共同地理位置 5.一些大型公司,或者对抗大型公司恶性事件而结成的组织 6.私密学术讨论组织

func GetUserDefaultGroup

func GetUserDefaultGroup(userID int) (g *Group, err error)

func GetUserGroups

func GetUserGroups(userID int, offset, number int) (list []*Group, err error)

func GetUserJoinedGroups

func GetUserJoinedGroups(userID int, offset, number int) (list []*Group, err error)

GetUserFollowedGroups

func (*Group) Create

func (g *Group) Create() error

func (*Group) Delete

func (g *Group) Delete() error

func (*Group) GetByID

func (g *Group) GetByID() error

func (*Group) GetByName

func (g *Group) GetByName() error

func (Group) TableName

func (g Group) TableName() string

func (*Group) UpdateAll

func (g *Group) UpdateAll() error

func (*Group) UpdateAvatar

func (g *Group) UpdateAvatar() error

func (*Group) UpdateDesc

func (g *Group) UpdateDesc() error

func (*Group) UpdateGroupType

func (g *Group) UpdateGroupType() error

type GroupMember

type GroupMember struct {
	IDBase
	GroupID uint64 `json:"group_id,omitempty"`
	UserID  uint64 `json:"user_id,omitempty"`
}

func GetGroupMembers

func GetGroupMembers(groupID int, offset, number int) (list []*GroupMember, err error)

func (*GroupMember) Create

func (g *GroupMember) Create() error

func (*GroupMember) Delete

func (g *GroupMember) Delete() error

func (*GroupMember) IsInGroup

func (g *GroupMember) IsInGroup() (bool, error)

func (GroupMember) TableName

func (g GroupMember) TableName() string

type IDBase

type IDBase struct {
	ID uint `gorm:"primary_key,column:id" json:"id,omitempty"`
	Base
}

type Item

type Item struct {
	IDBase
	GroupID     uint64          `json:"group_id,omitempty"`
	ProjectID   uint64          `json:"project_id,omitempty"`
	UserID      uint64          `json:"user_id,omitempty"`
	Visable     api.VisibleType `json:"visable,omitempty"`
	Title       string          `json:"title,omitempty"`
	Description string          `json:"description,omitempty"`
	ItemType    api.ItemType    `json:"item_type,omitempty"`
	Content     string          `json:"content,omitempty"`
	Tags        string          `json:"tags,omitempty"`
	LikeCount   uint64          `json:"like_count,omitempty"`
}

内容承载的item: 图片,文字,视频,音乐

func GetItem

func GetItem(repo *Repository, itemID uint64) (*Item, error)

func GetItemByGroup

func GetItemByGroup(repo *Repository, grouId uint64, offset, number int) ([]*Item, error)

func GetItemByProject

func GetItemByProject(repo *Repository, projectID uint64, offset, number int) ([]*Item, error)

func GetItemByProjectAndCreator

func GetItemByProjectAndCreator(repo *Repository, projectID uint64, userID uint64, offset, number int) ([]*Item, error)

func GetItemByTitle

func GetItemByTitle(repo *Repository, title string) (*Item, error)

func GetItemByUser

func GetItemByUser(repo *Repository, userId uint64, offset, number int) ([]*Item, error)

func GetItemsByType

func GetItemsByType(repo *Repository, itemType api.ItemType) ([]*Item, error)

func (Item) TableName

func (it Item) TableName() string

type ItemLiker

type ItemLiker struct {
	IDBase
	ProjectID uint64 `json:"project_id,omitempty"`
	ItemID    uint64 `json:"item_id,omitempty"`
	UserID    uint64 `json:"user_id,omitempty"`
	Ltype     uint64 `json:"ltype,omitempty"`
}

type LikeItem

type LikeItem struct {
	IDBase
	UserID    uint64 `json:"user_id,omitempty"`
	GroupID   uint64 `json:"group_id,omitempty"`
	ProjectID uint64 `json:"project_id,omitempty"`
	ItemID    uint64 `json:"item_id,omitempty"`
	LikeType  uint64 `json:"like_type,omitempty"`
}

func GetLikeItem

func GetLikeItem(repo *Repository, itemID uint64) (*LikeItem, error)

func GetLiteItemByProjectAndUser

func GetLiteItemByProjectAndUser(repo *Repository, projectID int, userID int) (list []*LikeItem, err error)

func (LikeItem) TableName

func (l LikeItem) TableName() string

type Project

type Project struct {
	IDBase
	Name        string `json:"name,omitempty"`
	Tilte       string `json:"tilte,omitempty"`
	ShortDesc   string `json:"short_desc,omitempty"`
	ProjectType int    `json:"project_type,omitempty"`
	CreatorID   uint64 `json:"creator_id,omitempty"`
	OwnerID     uint64 `json:"owner_id,omitempty"`
	GroupID     uint64 `json:"group_id,omitempty"`
	ProjectProfile
}

项目,或者说事件流; 1.包含多种内容 2.项目里可以开放问题(暂时可以不做)

func GeGroupProjectListByCreator

func GeGroupProjectListByCreator(groupID int, creatorID int, offset, number int) (list []*Project, err error)

func GetAllProjects

func GetAllProjects(offset, number int) (list []*Project, err error)

func GetGroupProjectListByName

func GetGroupProjectListByName(groupID int, name string, offset, number int) (list []*Project, err error)

func GetGroupProjectListByOwner

func GetGroupProjectListByOwner(groupID int, ownerID int, offset, number int) (list []*Project, err error)

func GetGroupProjects

func GetGroupProjects(groupID int64, offset, number int) (list []*Project, err error)

func GetProjectListByCreator

func GetProjectListByCreator(creatorID int, offset, number int) (list []*Project, err error)

func GetProjectListByName

func GetProjectListByName(name string, offset, number int) (list []*Project, err error)

func GetProjectListByOwner

func GetProjectListByOwner(ownerID int, offset, number int) (list []*Project, err error)

func GetUserWatchingProjects

func GetUserWatchingProjects(userId int64, number, offset int) (list []*Project, err error)

func (*Project) Create

func (p *Project) Create() error

func (*Project) DecreaseWatcher

func (p *Project) DecreaseWatcher() error

func (*Project) Delete

func (p *Project) Delete() error

func (*Project) Get

func (p *Project) Get() error

func (*Project) GetProfile

func (p *Project) GetProfile() error

func (*Project) IncreaseWatcher

func (p *Project) IncreaseWatcher() error

func (Project) TableName

func (p Project) TableName() string

func (*Project) UpdateAchieve

func (p *Project) UpdateAchieve() error

func (*Project) UpdateDesc

func (p *Project) UpdateDesc() error

func (*Project) UpdateIsClose

func (p *Project) UpdateIsClose() error

func (*Project) UpdateIsPrivate

func (p *Project) UpdateIsPrivate() error

func (*Project) UpdateProfile

func (p *Project) UpdateProfile() error

func (*Project) UpdateTitle

func (p *Project) UpdateTitle() error

type ProjectProfile

type ProjectProfile struct {
	Description   string          `json:"description,omitempty"`
	Avatar        string          `json:"avatar,omitempty"`
	WatchingCount uint64          `json:"watching_count,omitempty"`
	InvolvedCount uint64          `json:"involved_count,omitempty"`
	Visable       api.VisibleType `json:"visable,omitempty"`
	IsAchieve     bool            `json:"is_achieve,omitempty"`
	IsClose       bool            `json:"is_close,omitempty"`
	IsPrivate     bool            `json:"is_private,omitempty"`
}

type ProjectWatcher

type ProjectWatcher struct {
	IDBase
	GroupID   uint64 `json:"group_id,omitempty"`
	ProjectID uint64 `json:"project_id,omitempty"`
	UserID    uint64 `json:"user_id,omitempty"`
}

func (ProjectWatcher) TableName

func (p ProjectWatcher) TableName() string

type Question

type Question struct {
	IDBase
	UserID    uint64 `json:"user_id,omitempty"`
	GroupID   uint64 `json:"group_id,omitempty"`
	ProjectID uint64 `json:"project_id,omitempty"`
	Tital     string `json:"tital,omitempty"`
	Content   string `json:"description,omitempty"`
	Tags      uint64 `json:"tags,omitempty"`
	RefId     uint64 `json:"ref_id,omitempty"`
}

base on project

func GetProjectQuestions

func GetProjectQuestions(projectID int) (list []*Question, err error)

func (Question) TableName

func (q Question) TableName() string

type Repository

type Repository struct {
	Ctx    context.Context
	UserID uint64
	// contains filtered or unexported fields
}

func NewRepository

func NewRepository(ctx context.Context) *Repository

func (*Repository) DB

func (r *Repository) DB() *gorm.DB

type Tags

type Tags struct {
	IDBase
	UserId    uint64 `json:"user_id,omitempty"`
	ItemID    uint64 `json:"item_id,omitempty"`
	ProjectID uint64 `json:"project_id,omitempty"`
	GroupID   uint64 `json:"group_id,omitempty"`
	Title     string `json:"title,omitempty"`
	Desc      string `json:"desc,omitempty"`
	DisAble   bool   `json:"disable,omitempty"`
}

func GetTagsByGroup

func GetTagsByGroup(groupID uint64) ([]*Tags, error)

func GetTagsByProject

func GetTagsByProject(projectID uint64) ([]*Tags, error)

func GetTagsByTitleInGroup

func GetTagsByTitleInGroup(groupID uint64, title string) ([]*Tags, error)

func GetTagsByTitleInProject

func GetTagsByTitleInProject(projectID uint64, title string) ([]*Tags, error)

func (*Tags) Create

func (a *Tags) Create() error

func (*Tags) Delete

func (a *Tags) Delete() error

func (*Tags) Get

func (a *Tags) Get() error

func (Tags) TableName

func (t Tags) TableName() string

type Team

type Team struct {
	IDBase
	UserId  uint64 `json:"user_id,omitempty"`
	GroupID uint64 `json:"group_id,omitempty"`
	Title   string `json:"title,omitempty"`
	Desc    string `json:"desc,omitempty"`
	DisAble bool   `json:"disable,omitempty"`
	Expired int64  `json:"expired,omitempty"`
}

team才可以实时聊天,但是team中的人员不可以互相加好友 team属于一个group,team就类似于协程池一样的东西,一起协作做一件事情

func GetTeamsByCreator

func GetTeamsByCreator(userId uint64) ([]*Team, error)

func GetTeamsByName

func GetTeamsByName(name string) ([]*Team, error)

func (*Team) CreateTeam

func (t *Team) CreateTeam() error

func (*Team) DeleteTeam

func (t *Team) DeleteTeam() error

func (*Team) GetTeam

func (t *Team) GetTeam() error

func (Team) TableName

func (t Team) TableName() string

func (*Team) UpdateTeam

func (t *Team) UpdateTeam() error

type User

type User struct {
	IDBase       `json:"id_base,omitempty"`
	Name         string         `json:"name,omitempty" gorm:"index"`
	Email        string         `json:"email,omitempty" gorm:"index"`
	Phone        string         `json:"phone,omitempty" gorm:"index"`
	Gender       int            `json:"gender,omitempty"`
	BioID        string         `json:"bio,omitempty"`
	Status       api.UserStatus `json:"status,omitempty"`
	Location     string         `json:"location,omitempty"`
	Emotion      int            `json:"emotion,omitempty"`
	Avatar       string         `json:"avatar,omitempty"`
	URL          string         `json:"url,omitempty"`
	NumFollowing int            `json:"num_following,omitempty"`
	NumProjects  int            `json:"num_projects,omitempty"`
	NumGroup     int            `json:"num_group,omitempty"`
	NumTeams     int            `json:"num_teams,omitempty"`
	ShortDesc    string         `json:"short_desc,omitempty"`
}

func GetGroupMemberInfoList

func GetGroupMemberInfoList(groupID int, offset, number int) (users []*User, err error)

func GetUsersByIds

func GetUsersByIds(ids []int) (users []*User, err error)

func (*User) Create

func (u *User) Create() error

func (*User) Delete

func (u *User) Delete() error

func (*User) GetByEmail

func (u *User) GetByEmail() error

func (*User) GetById

func (u *User) GetById() error

func (*User) GetByName

func (u *User) GetByName() error

func (*User) GetByPhone

func (u *User) GetByPhone() error

func (User) TableName

func (u User) TableName() string

func (*User) UpdateAll

func (u *User) UpdateAll() error

func (*User) UpdateAvatar

func (u *User) UpdateAvatar() error

func (*User) UpdateBio

func (u *User) UpdateBio() error

func (*User) UpdateName

func (u *User) UpdateName() error

Jump to

Keyboard shortcuts

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