コード例 #1
0
ファイル: user.go プロジェクト: wxaxiaoyao/linux
func (msg *UserMsgItem) SafeMapTimeoutCall(key interface{}) {
	// 超时未删除则保存到db
	c := common.MongoCollection(MSG_DB, MSG_USER_MSG_TABLE)
	if err := c.Insert(msg); err != nil {
		syslog.Info(err, *msg)
	}
}
コード例 #2
0
ファイル: user_detail.go プロジェクト: sunyuantao/windows
func DeleteUserDetailInfoByUid(uid uint64) error {
	c := common.MongoCollection("dudb", "user_detail_info")
	if err := c.Remove(bson.M{"uid": uid}); err != nil {
		return errors.As(err, uid)
	}
	return nil
}
コード例 #3
0
ファイル: user.go プロジェクト: wxaxiaoyao/linux
func DeleteUserInfoByUid(uid uint64) error {
	c := common.MongoCollection(USER_DB, USER_INFO_TABLE)
	if err := c.Remove(bson.M{"uid": uid}); err != nil {
		return errors.As(err, uid)
	}
	return nil
}
コード例 #4
0
ファイル: user.go プロジェクト: wxaxiaoyao/linux
func SetUserInfo(sel, set map[string]interface{}) error {
	c := common.MongoCollection(USER_DB, USER_INFO_TABLE)
	if err := c.Update(bson.M(sel), bson.M{"$set": bson.M(set)}); err != nil {
		return errors.As(err, sel, set)
	}
	return nil
}
コード例 #5
0
ファイル: user_detail.go プロジェクト: sunyuantao/windows
func SetUserDetailInfo(sel, set map[string]interface{}) error {
	c := common.MongoCollection("dudb", "user_detail_info")
	if err := c.Update(bson.M(sel), bson.M{"$set": bson.M(set)}); err != nil {
		return errors.As(err, sel, set)
	}
	return nil
}
コード例 #6
0
ファイル: member.go プロジェクト: wxaxiaoyao/linux
func SetTeamMember(sel, set map[string]interface{}) error {
	c := common.MongoCollection(TEAM_DB, TEAM_MEMBER_TABLE)

	if err := c.Update(bson.M(sel), bson.M{"$set": bson.M(set)}); err != nil {
		return errors.As(err, sel, set)
	}
	return nil
}
コード例 #7
0
ファイル: qiniu.go プロジェクト: wxaxiaoyao/linux
func deleteFile(filelist []string) error {
	c := common.MongoCollection(FILE_DB, FILE_QINIU_FILE_TABLE)
	_, err := c.RemoveAll(bson.M{"filename": bson.M{"$in": filelist}})
	if err != nil && err != mgo.ErrNotFound {
		return errors.As(err, filelist)
	}
	return nil
}
コード例 #8
0
ファイル: user.go プロジェクト: wxaxiaoyao/linux
func GetUserCount() (uint64, error) {
	c := common.MongoCollection(USER_DB, USER_INFO_TABLE)
	count, err := c.Find(nil).Count()
	if err != nil {
		return 0, errors.As(err)
	}
	return uint64(count), nil
}
コード例 #9
0
ファイル: team.go プロジェクト: wxaxiaoyao/linux
func GetTeamList(sel map[string]interface{}, start, count int) ([]TeamInfo, error) {
	c := common.MongoCollection(TEAM_DB, TEAM_INFO_TABLE)

	team_list := []TeamInfo{}
	err := c.Find(bson.M(sel)).Skip(start).Limit(count).All(&team_list)

	return team_list, errors.As(err, sel)
}
コード例 #10
0
ファイル: user_detail.go プロジェクト: sunyuantao/windows
func GetUserDetailInfoByUid(uid uint64) (*UserDetailInfo, error) {
	user := &UserDetailInfo{}
	c := common.MongoCollection("dudb", "user_detail_info")

	if err := c.Find(bson.M{"uid": uid}).One(user); err != nil {
		return nil, errors.As(err, uid)
	}
	return user, nil
}
コード例 #11
0
ファイル: user_detail.go プロジェクト: sunyuantao/windows
func SaveUserDetailInfo(user *UserDetailInfo) error {
	c := common.MongoCollection("dudb", "user_detail_info")

	if err := c.Insert(user); err != nil {
		return errors.As(err, *user)
	}

	return nil
}
コード例 #12
0
ファイル: user.go プロジェクト: wxaxiaoyao/linux
func UserMsgInit() error {
	c := common.MongoCollection(MSG_DB, MSG_USER_MSG_TABLE)

	index := mgo.Index{
		Key: []string{"touid", "msgid"},
	}

	return errors.As(c.EnsureIndex(index))
}
コード例 #13
0
ファイル: member.go プロジェクト: wxaxiaoyao/linux
func DeleteTeamMember(teamid, uid uint64) error {
	c := common.MongoCollection(TEAM_DB, TEAM_MEMBER_TABLE)

	err := c.Remove(bson.M{"teamid": teamid, "uid": uid})
	if err != mgo.ErrNotFound {
		return errors.As(err, uid, teamid)
	}
	return nil
}
コード例 #14
0
ファイル: user.go プロジェクト: wxaxiaoyao/linux
func GetUserInfo(sel map[string]interface{}) (*UserInfo, error) {
	c := common.MongoCollection(USER_DB, USER_INFO_TABLE)

	user := &UserInfo{}
	if err := c.Find(bson.M(sel)).One(user); err != nil {
		return nil, errors.As(err, sel)
	}
	return user, nil
}
コード例 #15
0
ファイル: team.go プロジェクト: wxaxiaoyao/linux
func DeleteTeam(teamid uint64) error {
	c := common.MongoCollection(TEAM_DB, TEAM_INFO_TABLE)

	err := c.Remove(bson.M{"teamid": teamid})
	if err != mgo.ErrNotFound {
		return errors.As(err, teamid)
	}
	return nil
}
コード例 #16
0
ファイル: friend.go プロジェクト: wxaxiaoyao/linux
func DeleteFriend(uid, fid uint64) error {
	c := common.MongoCollection(USER_DB, USER_FRIEND_TABLE)

	err := c.Remove(bson.M{"fuid": fid, "uid": uid})
	if err != mgo.ErrNotFound {
		return errors.As(err, fid)
	}
	return nil
}
コード例 #17
0
ファイル: qiniu.go プロジェクト: wxaxiaoyao/linux
func addFile(file *File) error {
	c := common.MongoCollection(FILE_DB, FILE_QINIU_FILE_TABLE)
	sel := bson.M{"filename": file.Filename}
	set := bson.M{
		"$set":         bson.M{"expiredtime": file.ExpiredTime},
		"$setOnInsert": bson.M{"createtime": file.CreateTime},
	}
	_, err := c.Upsert(sel, set)
	return errors.As(err, *file)
}
コード例 #18
0
ファイル: friend.go プロジェクト: wxaxiaoyao/linux
func FriendInit() error {
	c := common.MongoCollection(USER_DB, USER_FRIEND_TABLE)

	index := mgo.Index{
		Key:      []string{"uid", "fuid"},
		Unique:   true,
		DropDups: true,
	}

	return errors.As(c.EnsureIndex(index))
}
コード例 #19
0
ファイル: member.go プロジェクト: wxaxiaoyao/linux
func TeamMemberInit() error {
	c := common.MongoCollection(TEAM_DB, TEAM_MEMBER_TABLE)

	index := mgo.Index{
		Key:      []string{"teamid", "uid"},
		Unique:   true,
		DropDups: true,
	}

	return errors.As(c.EnsureIndex(index))
}
コード例 #20
0
ファイル: user.go プロジェクト: wxaxiaoyao/linux
func GetNextUserId() (uint64, error) {
	c := common.MongoCollection(USER_DB, USER_INFO_TABLE)

	userInfo := &UserInfo{}
	if err := c.Find(nil).Sort("-uid").One(&userInfo); err != nil {
		if err == mgo.ErrNotFound {
			return uint64(MIN_USER_ID), nil
		}
		return 0, errors.As(err)
	}
	return userInfo.Uid + 1, nil
}
コード例 #21
0
ファイル: friend.go プロジェクト: wxaxiaoyao/linux
func AddFriend(friend *Friend) error {
	//sel := map[string]interface{}{"uid":friend.Uid, "fuid":friend.FUid}
	//set := map[string]interface{}{"type":friend.Type}
	if err := DeleteFriend(friend.Uid, friend.FUid); err != nil {
		return errors.As(err, *friend)
	}
	c := common.MongoCollection(USER_DB, USER_FRIEND_TABLE)

	friend.CreateDT = time.Now().Format(common.DATETIME_FMT)
	friend.UpdateDT = time.Now().Format(common.DATETIME_FMT)
	return errors.As(c.Insert(friend), *friend)
}
コード例 #22
0
ファイル: friend.go プロジェクト: wxaxiaoyao/linux
func GetFriendList(uid uint64, typ int) ([]uint64, error) {
	c := common.MongoCollection(USER_DB, USER_FRIEND_TABLE)

	friend := &Friend{}
	uids := []uint64{}
	iter := c.Find(bson.M{"uid": uid, "type": typ}).Iter()
	defer iter.Close()

	for iter.Next(friend) {
		uids = append(uids, friend.FUid)
	}
	return uids, nil
}
コード例 #23
0
ファイル: friend.go プロジェクト: wxaxiaoyao/linux
func GetFriend(uid, fid uint64) *Friend {
	c := common.MongoCollection(USER_DB, USER_FRIEND_TABLE)

	friend := &Friend{}

	iter := c.Find(bson.M{"fuid": fid, "uid": uid}).Iter()
	defer iter.Close()

	if iter.Next(friend) {
		return friend
	}
	return nil
}
コード例 #24
0
ファイル: member.go プロジェクト: wxaxiaoyao/linux
func GetTeamMember(teamid, uid uint64) *TeamMember {
	c := common.MongoCollection(TEAM_DB, TEAM_MEMBER_TABLE)

	tm := &TeamMember{}
	iter := c.Find(bson.M{"teamid": teamid, "uid": uid}).Iter()
	defer iter.Close()

	if iter.Next(tm) {
		return tm
	}

	return nil
}
コード例 #25
0
ファイル: team.go プロジェクト: wxaxiaoyao/linux
func GetTeam(teamid uint64) *TeamInfo {
	c := common.MongoCollection(TEAM_DB, TEAM_INFO_TABLE)

	team := &TeamInfo{}

	iter := c.Find(bson.M{"teamid": teamid}).Iter()
	defer iter.Close()

	if iter.Next(team) {
		return team
	}
	return nil
}
コード例 #26
0
ファイル: team.go プロジェクト: wxaxiaoyao/linux
func GetSysTeamList() ([]TeamInfo, error) {
	c := common.MongoCollection(TEAM_DB, TEAM_INFO_TABLE)
	teamList := []TeamInfo{}
	team := &TeamInfo{}

	iter := c.Find(bson.M{"teamtype": 1}).Iter()
	defer iter.Close()

	for iter.Next(team) {
		teamList = append(teamList, *team)
	}
	return teamList, nil

}
コード例 #27
0
ファイル: qiniu.go プロジェクト: wxaxiaoyao/linux
func (this *FileMgr) RemoveExpiredFile() error {
	c := common.MongoCollection(FILE_DB, FILE_QINIU_FILE_TABLE)

	expiredTime := time.Now().Unix()
	iter := c.Find(bson.M{"expiredtime": bson.M{"$lt": expiredTime}}).Iter()
	defer iter.Close()
	file := &File{}
	keys := []string{}
	for iter.Next(file) {
		keys = append(keys, file.Filename)
	}
	QiniuDeleteFiles(keys)
	return nil
}
コード例 #28
0
ファイル: user.go プロジェクト: wxaxiaoyao/linux
func UserInfoInit() error {
	c := common.MongoCollection(USER_DB, USER_INFO_TABLE)

	index := mgo.Index{
		Key:        []string{"uid"},
		Unique:     true,
		DropDups:   true,
		Background: true,
	}
	if err := c.EnsureIndex(index); err != nil {
		return errors.As(err, index)
	}
	return nil
}
コード例 #29
0
ファイル: user_detail.go プロジェクト: sunyuantao/windows
func UserDetailInfoInit() error {
	c := common.MongoCollection("dudb", "user_detail_info")

	index := mgo.Index{
		Key:        []string{"uid"},
		Unique:     true,
		DropDups:   true,
		Background: true,
	}
	if err := c.EnsureIndex(index); err != nil {
		return errors.As(err, index)
	}
	return nil
}
コード例 #30
0
ファイル: member.go プロジェクト: wxaxiaoyao/linux
func GetTeamMemberList(teamid uint64) ([]uint64, error) {
	c := common.MongoCollection(TEAM_DB, TEAM_MEMBER_TABLE)

	tm := &TeamMember{}
	uids := []uint64{}

	iter := c.Find(bson.M{"teamid": teamid}).Iter()
	defer iter.Close()

	for iter.Next(tm) {
		uids = append(uids, tm.Uid)
	}

	return uids, nil
}