jiaojiao7 пре 3 година
родитељ
комит
50246ad97a

+ 2 - 2
entity/message.go

@@ -10,7 +10,7 @@ import (
 var Engine *xorm.Engine
 
 type Message struct {
-	Id            int       `xorm:"id" form:"id" json:"id"`
+	Id            string       `xorm:"id" form:"id" json:"id"`
 	AppId         string    `xorm:"appid" form:"appid" json:"appid"`
 	ReceiveUserid string    `xorm:"receive_userid" form:"receive_userid" json:"receive_userid"` // 接收方用户id
 	ReceiveName   string    `xorm:"receive_name" form:"receive_name" json:"receive_name"`
@@ -27,7 +27,7 @@ type Message struct {
 }
 
 type Conversation struct {
-	Id          int       `xorm:"id" form:"id" json:"id"`
+	Id          string       `xorm:"id" form:"id" json:"id"`
 	AppId       string    `xorm:"appid" form:"appid" json:"appid"`
 	Key         string    `xorm:"key" form:"key" json:"key"`
 	UserId      string    `xorm:"user_id" form:"user_id" json:"user_id"`

+ 1 - 1
rpc/etc/message.yaml

@@ -5,7 +5,7 @@ Etcd:
   - 127.0.0.1:2379
   Key: message.rpc
   Timeout: 6000
-DataSource: root:Topnet123@tcp(192.168.3.11:3366)/messageCenter?charset=utf8mb4&parseTime=true&loc=Local
+DataSource: jianyu:topnet@123@tcp(am-2ze6crwd6bb0283jn167320o.ads.aliyuncs.com:3306)/messageCentertest?charset=utf8mb4&parseTime=true&loc=Local
 FileSystemConf:
   Etcd:
     Hosts:

+ 2 - 4
rpc/internal/logic/deletemultiplemessagelogic.go

@@ -3,7 +3,6 @@ package logic
 import (
 	"app.yhyue.com/moapp/MessageCenter/service"
 	"context"
-	"strconv"
 	"strings"
 
 	"app.yhyue.com/moapp/MessageCenter/rpc/internal/svc"
@@ -30,11 +29,10 @@ func NewDeleteMultipleMessageLogic(ctx context.Context, svcCtx *svc.ServiceConte
 func (l *DeleteMultipleMessageLogic) DeleteMultipleMessage(in *message.DeleteMultipleMessageRequest) (*message.Response, error) {
 	// todo: add your logic here and delete this line
 	m := &service.MessageService{}
-	var idSlice []int64
+	var idSlice []string
 	tmpList := strings.Split(in.Id, ",")
 	for _, v := range tmpList {
-		id, _ := strconv.Atoi(v)
-		idSlice = append(idSlice, int64(id))
+		idSlice = append(idSlice, v)
 	}
 	code, msg := m.DeleteMessage(idSlice,in.Appid)
 	return &message.Response{

+ 1 - 1
rpc/internal/logic/deletesinglemessagelogic.go

@@ -29,7 +29,7 @@ func (l *DeleteSingleMessageLogic) DeleteSingleMessage(in *message.DeleteSingleM
 	// todo: add your logic here and delete this line
 
 	m := &service.MessageService{}
-	var idSlice []int64
+	var idSlice []string
 	idSlice = append(idSlice, in.Id)
 	code, msg := m.DeleteMessage(idSlice,in.Appid)
 	return &message.Response{

+ 1 - 1
rpc/message.go

@@ -51,5 +51,5 @@ func init() {
 		log.Fatal("数据库连接失败:", err)
 	}
 	fmt.Println(config.ConfigJson.DataSource + "链接成功")
-	
+
 }

+ 4 - 4
rpc/message.proto

@@ -16,7 +16,7 @@ message SendMsgRequest {
 }
 
 message ChangeReadStatusRequest {
-    int64 id = 1; // 消息id
+    string id = 1; // 消息id
     int64 readStatus = 2; // 阅读状态 0-未读 1-已读
     string appid = 3; //应用标识
 }
@@ -26,7 +26,7 @@ message ResCount {
 }
 // 删除单一消息
 message DeleteSingleMessageRequest {
-    int64 id = 1; // 消息id
+    string id = 1; // 消息id
     string appid = 3; //应用标识
 }
 // 批量删除消息
@@ -74,7 +74,7 @@ message Messages {
     int64 isRead = 10; //已读未读 0:未读  1:已读
     string createtime = 11;
     string appid = 12; //应用标识
-    int64 id = 13; //消息id
+    string id = 13; //消息id
 }
 
 message FindUserMsgRes {
@@ -92,7 +92,7 @@ message GetClassUnreadCountReq {
 
 //查看消息内容
 message MessageDetailReq {
-    int64 id = 1; //消息id
+    string id = 1; //消息id
 }
 message MessageDetailResp {
     int64 code = 1; //状态码

+ 16 - 16
rpc/message/message.pb.go

@@ -153,7 +153,7 @@ type ChangeReadStatusRequest struct {
 	sizeCache     protoimpl.SizeCache
 	unknownFields protoimpl.UnknownFields
 
-	Id         int64  `protobuf:"varint,1,opt,name=id,proto3" json:"id,omitempty"`                 // 消息id
+	Id         string `protobuf:"bytes,1,opt,name=id,proto3" json:"id,omitempty"`                  // 消息id
 	ReadStatus int64  `protobuf:"varint,2,opt,name=readStatus,proto3" json:"readStatus,omitempty"` // 阅读状态 0-未读 1-已读
 	Appid      string `protobuf:"bytes,3,opt,name=appid,proto3" json:"appid,omitempty"`            //应用标识
 }
@@ -190,11 +190,11 @@ func (*ChangeReadStatusRequest) Descriptor() ([]byte, []int) {
 	return file_message_proto_rawDescGZIP(), []int{1}
 }
 
-func (x *ChangeReadStatusRequest) GetId() int64 {
+func (x *ChangeReadStatusRequest) GetId() string {
 	if x != nil {
 		return x.Id
 	}
-	return 0
+	return ""
 }
 
 func (x *ChangeReadStatusRequest) GetReadStatus() int64 {
@@ -272,7 +272,7 @@ type DeleteSingleMessageRequest struct {
 	sizeCache     protoimpl.SizeCache
 	unknownFields protoimpl.UnknownFields
 
-	Id    int64  `protobuf:"varint,1,opt,name=id,proto3" json:"id,omitempty"`      // 消息id
+	Id    string `protobuf:"bytes,1,opt,name=id,proto3" json:"id,omitempty"`       // 消息id
 	Appid string `protobuf:"bytes,3,opt,name=appid,proto3" json:"appid,omitempty"` //应用标识
 }
 
@@ -308,11 +308,11 @@ func (*DeleteSingleMessageRequest) Descriptor() ([]byte, []int) {
 	return file_message_proto_rawDescGZIP(), []int{3}
 }
 
-func (x *DeleteSingleMessageRequest) GetId() int64 {
+func (x *DeleteSingleMessageRequest) GetId() string {
 	if x != nil {
 		return x.Id
 	}
-	return 0
+	return ""
 }
 
 func (x *DeleteSingleMessageRequest) GetAppid() string {
@@ -664,7 +664,7 @@ type Messages struct {
 	IsRead        int64  `protobuf:"varint,10,opt,name=isRead,proto3" json:"isRead,omitempty"`             //已读未读 0:未读  1:已读
 	Createtime    string `protobuf:"bytes,11,opt,name=createtime,proto3" json:"createtime,omitempty"`
 	Appid         string `protobuf:"bytes,12,opt,name=appid,proto3" json:"appid,omitempty"` //应用标识
-	Id            int64  `protobuf:"varint,13,opt,name=id,proto3" json:"id,omitempty"`      //消息id
+	Id            string `protobuf:"bytes,13,opt,name=id,proto3" json:"id,omitempty"`       //消息id
 }
 
 func (x *Messages) Reset() {
@@ -783,11 +783,11 @@ func (x *Messages) GetAppid() string {
 	return ""
 }
 
-func (x *Messages) GetId() int64 {
+func (x *Messages) GetId() string {
 	if x != nil {
 		return x.Id
 	}
-	return 0
+	return ""
 }
 
 type FindUserMsgRes struct {
@@ -930,7 +930,7 @@ type MessageDetailReq struct {
 	sizeCache     protoimpl.SizeCache
 	unknownFields protoimpl.UnknownFields
 
-	Id int64 `protobuf:"varint,1,opt,name=id,proto3" json:"id,omitempty"` //消息id
+	Id string `protobuf:"bytes,1,opt,name=id,proto3" json:"id,omitempty"` //消息id
 }
 
 func (x *MessageDetailReq) Reset() {
@@ -965,11 +965,11 @@ func (*MessageDetailReq) Descriptor() ([]byte, []int) {
 	return file_message_proto_rawDescGZIP(), []int{12}
 }
 
-func (x *MessageDetailReq) GetId() int64 {
+func (x *MessageDetailReq) GetId() string {
 	if x != nil {
 		return x.Id
 	}
-	return 0
+	return ""
 }
 
 type MessageDetailResp struct {
@@ -1574,7 +1574,7 @@ var file_message_proto_rawDesc = []byte{
 	0x20, 0x01, 0x28, 0x09, 0x52, 0x05, 0x61, 0x70, 0x70, 0x69, 0x64, 0x22, 0x5f, 0x0a, 0x17, 0x43,
 	0x68, 0x61, 0x6e, 0x67, 0x65, 0x52, 0x65, 0x61, 0x64, 0x53, 0x74, 0x61, 0x74, 0x75, 0x73, 0x52,
 	0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x12, 0x0e, 0x0a, 0x02, 0x69, 0x64, 0x18, 0x01, 0x20, 0x01,
-	0x28, 0x03, 0x52, 0x02, 0x69, 0x64, 0x12, 0x1e, 0x0a, 0x0a, 0x72, 0x65, 0x61, 0x64, 0x53, 0x74,
+	0x28, 0x09, 0x52, 0x02, 0x69, 0x64, 0x12, 0x1e, 0x0a, 0x0a, 0x72, 0x65, 0x61, 0x64, 0x53, 0x74,
 	0x61, 0x74, 0x75, 0x73, 0x18, 0x02, 0x20, 0x01, 0x28, 0x03, 0x52, 0x0a, 0x72, 0x65, 0x61, 0x64,
 	0x53, 0x74, 0x61, 0x74, 0x75, 0x73, 0x12, 0x14, 0x0a, 0x05, 0x61, 0x70, 0x70, 0x69, 0x64, 0x18,
 	0x03, 0x20, 0x01, 0x28, 0x09, 0x52, 0x05, 0x61, 0x70, 0x70, 0x69, 0x64, 0x22, 0x3a, 0x0a, 0x08,
@@ -1584,7 +1584,7 @@ var file_message_proto_rawDesc = []byte{
 	0x03, 0x52, 0x05, 0x63, 0x6f, 0x75, 0x6e, 0x74, 0x22, 0x42, 0x0a, 0x1a, 0x44, 0x65, 0x6c, 0x65,
 	0x74, 0x65, 0x53, 0x69, 0x6e, 0x67, 0x6c, 0x65, 0x4d, 0x65, 0x73, 0x73, 0x61, 0x67, 0x65, 0x52,
 	0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x12, 0x0e, 0x0a, 0x02, 0x69, 0x64, 0x18, 0x01, 0x20, 0x01,
-	0x28, 0x03, 0x52, 0x02, 0x69, 0x64, 0x12, 0x14, 0x0a, 0x05, 0x61, 0x70, 0x70, 0x69, 0x64, 0x18,
+	0x28, 0x09, 0x52, 0x02, 0x69, 0x64, 0x12, 0x14, 0x0a, 0x05, 0x61, 0x70, 0x70, 0x69, 0x64, 0x18,
 	0x03, 0x20, 0x01, 0x28, 0x09, 0x52, 0x05, 0x61, 0x70, 0x70, 0x69, 0x64, 0x22, 0x44, 0x0a, 0x1c,
 	0x44, 0x65, 0x6c, 0x65, 0x74, 0x65, 0x4d, 0x75, 0x6c, 0x74, 0x69, 0x70, 0x6c, 0x65, 0x4d, 0x65,
 	0x73, 0x73, 0x61, 0x67, 0x65, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x12, 0x0e, 0x0a, 0x02,
@@ -1638,7 +1638,7 @@ var file_message_proto_rawDesc = []byte{
 	0x61, 0x74, 0x65, 0x74, 0x69, 0x6d, 0x65, 0x18, 0x0b, 0x20, 0x01, 0x28, 0x09, 0x52, 0x0a, 0x63,
 	0x72, 0x65, 0x61, 0x74, 0x65, 0x74, 0x69, 0x6d, 0x65, 0x12, 0x14, 0x0a, 0x05, 0x61, 0x70, 0x70,
 	0x69, 0x64, 0x18, 0x0c, 0x20, 0x01, 0x28, 0x09, 0x52, 0x05, 0x61, 0x70, 0x70, 0x69, 0x64, 0x12,
-	0x0e, 0x0a, 0x02, 0x69, 0x64, 0x18, 0x0d, 0x20, 0x01, 0x28, 0x03, 0x52, 0x02, 0x69, 0x64, 0x22,
+	0x0e, 0x0a, 0x02, 0x69, 0x64, 0x18, 0x0d, 0x20, 0x01, 0x28, 0x09, 0x52, 0x02, 0x69, 0x64, 0x22,
 	0x7b, 0x0a, 0x0e, 0x46, 0x69, 0x6e, 0x64, 0x55, 0x73, 0x65, 0x72, 0x4d, 0x73, 0x67, 0x52, 0x65,
 	0x73, 0x12, 0x12, 0x0a, 0x04, 0x63, 0x6f, 0x64, 0x65, 0x18, 0x01, 0x20, 0x01, 0x28, 0x03, 0x52,
 	0x04, 0x63, 0x6f, 0x64, 0x65, 0x12, 0x18, 0x0a, 0x07, 0x6d, 0x65, 0x73, 0x73, 0x61, 0x67, 0x65,
@@ -1654,7 +1654,7 @@ var file_message_proto_rawDesc = []byte{
 	0x07, 0x6d, 0x73, 0x67, 0x54, 0x79, 0x70, 0x65, 0x12, 0x14, 0x0a, 0x05, 0x61, 0x70, 0x70, 0x69,
 	0x64, 0x18, 0x03, 0x20, 0x01, 0x28, 0x09, 0x52, 0x05, 0x61, 0x70, 0x70, 0x69, 0x64, 0x22, 0x22,
 	0x0a, 0x10, 0x4d, 0x65, 0x73, 0x73, 0x61, 0x67, 0x65, 0x44, 0x65, 0x74, 0x61, 0x69, 0x6c, 0x52,
-	0x65, 0x71, 0x12, 0x0e, 0x0a, 0x02, 0x69, 0x64, 0x18, 0x01, 0x20, 0x01, 0x28, 0x03, 0x52, 0x02,
+	0x65, 0x71, 0x12, 0x0e, 0x0a, 0x02, 0x69, 0x64, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x02,
 	0x69, 0x64, 0x22, 0x68, 0x0a, 0x11, 0x4d, 0x65, 0x73, 0x73, 0x61, 0x67, 0x65, 0x44, 0x65, 0x74,
 	0x61, 0x69, 0x6c, 0x52, 0x65, 0x73, 0x70, 0x12, 0x12, 0x0a, 0x04, 0x63, 0x6f, 0x64, 0x65, 0x18,
 	0x01, 0x20, 0x01, 0x28, 0x03, 0x52, 0x04, 0x63, 0x6f, 0x64, 0x65, 0x12, 0x18, 0x0a, 0x07, 0x6d,

+ 13 - 13
rpc/messageclient/message.go

@@ -14,28 +14,28 @@ import (
 )
 
 type (
-	GetUnreadCountResponse       = message.GetUnreadCountResponse
+	DeleteMultipleMessageRequest = message.DeleteMultipleMessageRequest
 	FindUserMsgRes               = message.FindUserMsgRes
-	GetLastMessageRes            = message.GetLastMessageRes
+	MessageDetailReq             = message.MessageDetailReq
+	ResCount                     = message.ResCount
+	GetClassUnreadCountReq       = message.GetClassUnreadCountReq
 	GetUnreadClassCountRes       = message.GetUnreadClassCountRes
 	UpdateMessageReadReq         = message.UpdateMessageReadReq
-	SendMsgRequest               = message.SendMsgRequest
+	GetMsgTypeRes                = message.GetMsgTypeRes
 	DeleteSingleMessageRequest   = message.DeleteSingleMessageRequest
-	GetUnreadCountRequest        = message.GetUnreadCountRequest
-	GetMsgTypeReq                = message.GetMsgTypeReq
-	UpdateMessageReadResp        = message.UpdateMessageReadResp
-	Response                     = message.Response
+	MessageDetailResp            = message.MessageDetailResp
 	GetLastMessageReq            = message.GetLastMessageReq
 	GetUnreadClassCountReq       = message.GetUnreadClassCountReq
+	GetMsgTypeReq                = message.GetMsgTypeReq
 	FindUserMsgReq               = message.FindUserMsgReq
-	MessageDetailResp            = message.MessageDetailResp
 	Messages                     = message.Messages
-	GetClassUnreadCountReq       = message.GetClassUnreadCountReq
-	MessageDetailReq             = message.MessageDetailReq
-	GetMsgTypeRes                = message.GetMsgTypeRes
+	GetLastMessageRes            = message.GetLastMessageRes
+	SendMsgRequest               = message.SendMsgRequest
 	ChangeReadStatusRequest      = message.ChangeReadStatusRequest
-	ResCount                     = message.ResCount
-	DeleteMultipleMessageRequest = message.DeleteMultipleMessageRequest
+	GetUnreadCountRequest        = message.GetUnreadCountRequest
+	Response                     = message.Response
+	GetUnreadCountResponse       = message.GetUnreadCountResponse
+	UpdateMessageReadResp        = message.UpdateMessageReadResp
 
 	Message interface {
 		//  修改消息阅读状态

+ 3 - 3
service/messageService.go

@@ -33,7 +33,7 @@ func (service *MessageService) ChangeReadStatus(data *message.ChangeReadStatusRe
 }
 
 // 删除消息
-func (service *MessageService) DeleteMessage(id []int64, appId string) (int64, string) {
+func (service *MessageService) DeleteMessage(id []string, appId string) (int64, string) {
 	orm := entity.Engine.NewSession()
 	defer orm.Close()
 	m := entity.Message{}
@@ -86,7 +86,7 @@ func (service *MessageService) LastMessage(userId string, appId string, msgType
 	if len(m1) > 0 {
 		m := m1[0]
 		msg := message.Messages{
-			Id:            int64(m.Id),
+			Id:            m.Id,
 			Appid:         m.AppId,
 			ReceiveUserId: m.ReceiveUserid,
 			ReceiveName:   m.ReceiveName,
@@ -109,7 +109,7 @@ func (service *MessageService) LastMessage(userId string, appId string, msgType
 }
 
 //查询消息详情
-func FindMessageDetail(id int64) (entity.Message, error) {
+func FindMessageDetail(id string) (entity.Message, error) {
 	orm := entity.Engine.NewSession()
 	defer orm.Close()
 	mess := entity.Message{}

+ 23 - 46
service/sendMsg.go

@@ -8,8 +8,10 @@ import (
 	"app.yhyue.com/moapp/MessageCenter/entity"
 	"app.yhyue.com/moapp/MessageCenter/rpc/message"
 )
+
 // 类型的顺序
 const order = "1,4"
+
 func SendMsg(this message.SendMsgRequest) (int64, string) {
 	orm := entity.Engine.NewSession()
 	defer orm.Close()
@@ -17,57 +19,32 @@ func SendMsg(this message.SendMsgRequest) (int64, string) {
 	fmt.Println(err)
 	count, _ := orm.Table("conversation").Where("user_id = ? or user_id = ?", this.ReceiveUserId, this.SendUserId).Count()
 	if count < 1 {
-		conversation := entity.Conversation{
-			AppId:       this.Appid,
-			ReceiveId:   this.ReceiveUserId,
-			ReceiveName: this.ReceiveName,
-			SendId:      this.SendUserId,
-			SendName:    this.SendName,
-			CreateTime:  time.Now(),
-			Sort:        0,
-			UserId:      this.SendUserId,
-			Key:         "",
-		}
-		_, err = orm.Table("conversation").Insert(&conversation)
+		sql1 := `INSERT INTO conversation(appid,` + "`key`" + `,user_id,receive_id,receive_name,send_id,send_name,sort,createtime) 
+		values ('%s','','%s','%s','%s','%s','%s',0,'%s');`
+		sql1 = fmt.Sprintf(sql1, this.Appid, this.SendUserId, this.ReceiveUserId, this.ReceiveName, this.SendUserId, this.SendName, time.Now().Format("2006-01-02 15:04:05"))
+		//_, err = orm.Table("conversation").Insert(&conversation)
+		_, err = orm.Exec(sql1)
 		if err != nil {
 			log.Panicln("会话创建失败:", err)
 			orm.Rollback()
 			return 0, "会话创建失败"
 		}
-		conversations := entity.Conversation{
-			AppId:       this.Appid,
-			ReceiveId:   this.ReceiveUserId,
-			ReceiveName: this.ReceiveName,
-			SendId:      this.SendUserId,
-			SendName:    this.SendName,
-			CreateTime:  time.Now(),
-			Sort:        0,
-			UserId:      this.ReceiveUserId,
-			Key:         "",
-		}
-		_, err = orm.Table("conversation").Insert(&conversations)
+		sql2 := `INSERT INTO conversation(appid,` + "`key`" + `,user_id,receive_id,receive_name,send_id,send_name,sort,createtime) 
+		values ('%s','','%s','%s','%s','%s','%s',0,'%s');`
+		sql2 = fmt.Sprintf(sql2, this.Appid, this.ReceiveUserId, this.ReceiveUserId, this.ReceiveName, this.SendUserId, this.SendName, time.Now().Format("2006-01-02 15:04:05"))
+		//_, err = orm.Table("conversation").Insert(&conversation)
+		_, err = orm.Exec(sql2)
 		if err != nil {
 			log.Panicln("会话创建失败:", err)
 			orm.Rollback()
 			return 0, "会话创建失败"
 		}
 	}
-	message := entity.Message{
-		AppId:         this.Appid,
-		ReceiveUserid: this.ReceiveUserId,
-		ReceiveName:   this.ReceiveName,
-		SendUserid:    this.SendUserId,
-		SendName:      this.SendName,
-		CreateTime:    time.Now(),
-		Title:         this.Title,
-		MsgType:       int(this.MsgType),
-		Link:          this.Link,
-		CiteId:        int(this.CiteId),
-		Content:       this.Content,
-		IsRead:        0,
-		Isdel:         1,
-	}
-	_, err = orm.Table("message").Insert(&message)
+	sql := `INSERT INTO message(appid,receive_userid,receive_name,send_userid,send_name,title,content,msg_type,link,cite_id,createtime,isRead,isdel) 
+		values ("%s",'%s','%s','%s','%s','%s','%s','%d','%s',0,'%s',0,1);`
+	sql = fmt.Sprintf(sql, this.Appid,this.ReceiveUserId,this.ReceiveName, this.SendUserId, this.SendName,this.Title,this.Content,this.MsgType,this.Link, time.Now().Format("2006-01-02 15:04:05"))
+	//_, err = orm.Table("conversation").Insert(&conversation)
+	_, err = orm.Table("message").Exec(sql)
 	if err != nil {
 		log.Panicln("消息发送失败:", err)
 		orm.Rollback()
@@ -83,24 +60,24 @@ func FindUserMsg(this message.FindUserMsgReq) message.FindUserMsgRes {
 	var err error
 	var count int64
 	q := ""
-	if this.MsgType !=-1{
-		q += fmt.Sprintf(" and msg_type = %d",this.MsgType)
+	if this.MsgType != -1 {
+		q += fmt.Sprintf(" and msg_type = %d", this.MsgType)
 	}
-	if this.Read !=-1{
-		q += fmt.Sprintf(" and isRead = %d",this.Read)
+	if this.Read != -1 {
+		q += fmt.Sprintf(" and isRead = %d", this.Read)
 
 	}
 	count, err = orm.Table("message").Where("((receive_userid = ? and send_userid = ?) or (receive_userid = ? and send_userid = ?)) and isdel = ? and appid = ?"+q, this.UserId, this.ReceiveUserId, this.ReceiveUserId, this.UserId, 1, this.Appid).Count()
 	data := message.FindUserMsgRes{}
 	if count > 0 {
-		err = orm.Table("message").Select("*").Where("((receive_userid = ? and send_userid = ?) or (receive_userid = ? and send_userid = ?)) and isdel = ? and appid = ?" +q, this.UserId, this.ReceiveUserId, this.ReceiveUserId, this.UserId, 1, this.Appid).
+		err = orm.Table("message").Select("*").Where("((receive_userid = ? and send_userid = ?) or (receive_userid = ? and send_userid = ?)) and isdel = ? and appid = ?"+q, this.UserId, this.ReceiveUserId, this.ReceiveUserId, this.UserId, 1, this.Appid).
 			OrderBy("createtime desc").
 			Limit(int(this.PageSize), (int(this.OffSet)-1)*int(this.PageSize)).
 			Find(&messages)
 		//log.Println("数据:", messages)
 		for _, v := range messages {
 			data.Data = append(data.Data, &message.Messages{
-				Id: int64(v.Id),
+				Id:            int64(v.Id),
 				Appid:         v.AppId,
 				ReceiveUserId: v.ReceiveUserid,
 				ReceiveName:   v.ReceiveName,