This commit is contained in:
aozhiwei 2024-03-23 08:59:55 +08:00
parent 33589caa1d
commit e603d1b9b2
6 changed files with 34 additions and 5 deletions

View File

@ -38,7 +38,7 @@ DROP TABLE IF EXISTS `t_friend_relationship`;
/*!40101 SET @saved_cs_client = @@character_set_client */;
/*!40101 SET character_set_client = utf8 */;
CREATE TABLE `t_friend_relationship` (
`idx` int(11) NOT NULL AUTO_INCREMENT COMMENT '自增id',
`idx` bigint(20) NOT NULL AUTO_INCREMENT COMMENT '自增id',
`account_id1` varchar(60) CHARACTER SET utf8 NOT NULL COMMENT '账号1',
`account_id2` varchar(60) CHARACTER SET utf8 NOT NULL COMMENT '账号2',
`deleted` int(11) NOT NULL DEFAULT '0' COMMENT '是否已删除',
@ -60,15 +60,17 @@ DROP TABLE IF EXISTS `t_friend_apply`;
/*!40101 SET @saved_cs_client = @@character_set_client */;
/*!40101 SET character_set_client = utf8 */;
CREATE TABLE `t_friend_apply` (
`idx` int(11) NOT NULL AUTO_INCREMENT COMMENT '自增id',
`idx` bigint(20) NOT NULL AUTO_INCREMENT COMMENT '自增id',
`sender_id` varchar(60) CHARACTER SET utf8 NOT NULL COMMENT '申请者id',
`target_id` varchar(60) CHARACTER SET utf8 NOT NULL COMMENT '被申请者id',
`status` int(11) NOT NULL DEFAULT '0' COMMENT '0:未处理 1:同意 2拒绝 3忽略',
`last_apply_time` int(11) NOT NULL DEFAULT '0' COMMENT '最后申请时间',
`createtime` int(11) NOT NULL DEFAULT '0' COMMENT '创建时间',
`modifytime` int(11) NOT NULL DEFAULT '0' COMMENT '修改时间',
PRIMARY KEY (`idx`),
KEY `sender_id` (`sender_id`),
KEY `target_id` (`target_id`),
KEY `sender_id_target_id` (`sender_id`, `target_id`)
) ENGINE=InnoDB AUTO_INCREMENT=10000 DEFAULT CHARSET=utf8 COLLATE=utf8_bin;
/*!40101 SET character_set_client = @saved_cs_client */;
/*!40103 SET TIME_ZONE=@OLD_TIME_ZONE */;

View File

@ -30,3 +30,7 @@ func (this *CacheMgr) GetUserProfile(accountId string) common.UserProfile {
func (this *CacheMgr) PreLoad(accountIds []string) {
}
func (this *CacheMgr) Search(sinceId int64, q string, cb func(int64, []string)) {
}

View File

@ -1,5 +1,9 @@
package cache
import (
"cs"
)
type userProfile struct {
accountId string
name string
@ -52,3 +56,6 @@ func (this *userProfile) GetOnlineStatus() int32 {
func (this *userProfile) GetLastLoginTime() int32 {
return this.lastLoginTime
}
func (this *userProfile) FillMFUser(pbUser *cs.MFUser) {
}

View File

@ -73,6 +73,7 @@ type CacheMgr interface {
PreLoadUser([]string)
AsyncGetUsers([]string, func(bool))
GetUserProfile(string) UserProfile
Search(int64, string, func(int64, []string))
}
type ChatMgr interface {
@ -87,6 +88,7 @@ type UserProfile interface {
GetTotalKills() int32
GetTotalWinTimes() int32
GetRank() int32
GetOnlineStatus() int32
GetOnlineStatus() int32
GetLastLoginTime() int32
FillMFUser(*cs.MFUser)
}

View File

@ -2,6 +2,7 @@ package player
import (
"cs"
"q5"
"f5"
"github.com/golang/protobuf/proto"
"main/common"
@ -51,6 +52,21 @@ func (this *player) CMPing(hdr *f5.MsgHdr, msg *cs.CMPing) {
}
func (this *player) CMSearchUser(hdr *f5.MsgHdr, msg *cs.CMSearchUser) {
GetCacheMgr().Search(msg.GetSinceId(),
msg.GetUsername(),
func (sinceId int64, accountIds []string) {
rspMsg := new(cs.SMSearchUser)
rspMsg.SinceId = proto.Int64(sinceId)
q5.NewSlice(&rspMsg.Users, 0, int32(len(accountIds)))
for _, accountId := range(accountIds) {
userProfile := GetCacheMgr().GetUserProfile(accountId)
if userProfile != nil {
ele := q5.NewSliceElement(&rspMsg.Users)
userProfile.FillMFUser(*ele)
}
}
this.SendMsg(rspMsg)
})
}
func (this *player) CMSearchUserByAccountId(hdr *f5.MsgHdr, msg *cs.CMSearchUserByAccountId) {

View File

@ -203,7 +203,6 @@ message SMReconnect
optional string errmsg = 2; //
}
//
message CMSearchUser
{
@ -701,7 +700,6 @@ message CMSetJoinCond
optional int32 join_cond_value = 2; // only cond star, value:
}
//
message SMSetJoinCond
{
optional int32 errcode = 1;