ソースを参照

未读sql修改

renjiaojiao 2 年 前
コミット
b781476b82
3 ファイル変更16 行追加301 行削除
  1. 12 6
      rpc/messagecenter/test/message_test.go
  2. 0 285
      service/chat_group_test.go
  3. 4 10
      service/message_mail_box.go

+ 12 - 6
rpc/messagecenter/test/message_test.go

@@ -27,7 +27,7 @@ func Test_Count(t *testing.T) {
 	TestSystem := messagecenter.NewMessageCenter(zrpc.MustNewClient(c.TestConf))
 	req := &messagecenter.CountReq{
 		UserType:  2,
-		NewUserId: 831,
+		NewUserId: 5524,
 	}
 	res, err := TestSystem.Count(ctx, req)
 	log.Println("res ", res)
@@ -56,11 +56,17 @@ func Test_FindMessage(t *testing.T) {
 	ctx, _ := context.WithTimeout(context.Background(), 10*time.Second)
 	TestSystem := messagecenter.NewMessageCenter(zrpc.MustNewClient(c.TestConf))
 	req := &messagecenter.MessageReq{
-		MsgType:  4,
-		UserType: 1,
-		SendId:   68826,
-		PageSize: 10,
-		EntId:    14929,
+		MsgType:   2,
+		UserType:  2,
+		SendId:    68826,
+		PageSize:  10,
+		EntId:     14929,
+		LastId:    0,
+		NewUserId: 74175,
+		EntUserId: 0,
+		Sort:      "",
+		//ChatGroupId: 1,
+		PositionId: 584,
 	}
 	res, err := TestSystem.FindMessage(ctx, req)
 	log.Println("res ", res)

+ 0 - 285
service/chat_group_test.go

@@ -1,285 +0,0 @@
-package service
-
-import (
-	"reflect"
-	"testing"
-)
-
-func TestChatGroupService_ChatGroupAdd(t *testing.T) {
-	type args struct {
-		entId      int64
-		positionId int64
-		userIdArr  []int64
-		appid      string
-	}
-	tests := []struct {
-		name string
-		args args
-		want bool
-	}{
-		// TODO: Add test cases.
-		{
-			name: "群组新增",
-			args: args{
-				entId:      15755,
-				positionId: 1204781623,
-				userIdArr:  []int64{1204841316},
-				appid:      "10000",
-			},
-		},
-	}
-	for _, tt := range tests {
-		t.Run(tt.name, func(t *testing.T) {
-			b := ChatGroupService{}
-			if got := b.ChatGroupAdd(tt.args.entId, tt.args.positionId, tt.args.userIdArr, tt.args.appid); got != tt.want {
-				t.Errorf("ChatGroupAdd() = %v, want %v", got, tt.want)
-			}
-		})
-	}
-}
-
-func TestChatGroupService_ChatGroupJoin(t *testing.T) {
-	type args struct {
-		chatGroupId int64
-		positionId  int64
-		userIdArr   []int64
-		appid       string
-	}
-	tests := []struct {
-		name string
-		args args
-		want bool
-	}{
-		// TODO: Add test cases.
-		{
-			name: "拉人进群",
-			args: args{
-				chatGroupId: 3,
-				positionId:  1204781623,
-				userIdArr:   []int64{1204841317},
-				appid:       "10000",
-			},
-		},
-	}
-	for _, tt := range tests {
-		t.Run(tt.name, func(t *testing.T) {
-			b := ChatGroupService{}
-			if got := b.ChatGroupJoin(tt.args.chatGroupId, tt.args.positionId, tt.args.userIdArr, tt.args.appid); got != tt.want {
-				t.Errorf("ChatGroupJoin() = %v, want %v", got, tt.want)
-			}
-		})
-	}
-}
-
-func TestChatGroupService_ChatGroupList(t *testing.T) {
-	type args struct {
-		entId      int64
-		positionId int64
-		userName   string
-		groupName  string
-		appid      string
-	}
-	tests := []struct {
-		name string
-		args args
-		want []map[string]interface{}
-	}{
-		// TODO: Add test cases.
-		{name: "我的群聊列表默认",
-			args: args{
-				entId:      15755,
-				positionId: 1204781623,
-				userName:   "张",
-				groupName:  "",
-				appid:      "10000",
-			},
-		},
-	}
-	for _, tt := range tests {
-		t.Run(tt.name, func(t *testing.T) {
-			b := ChatGroupService{}
-			if got := b.ChatGroupList(tt.args.entId, tt.args.positionId, tt.args.userName, tt.args.groupName, tt.args.appid); !reflect.DeepEqual(got, tt.want) {
-				t.Errorf("ChatGroupList() = %v, want %v", got, tt.want)
-			}
-		})
-	}
-}
-
-func TestChatGroupService_ChatGroupPerson(t *testing.T) {
-	type args struct {
-		ChatGroupId int64
-		entId       int64
-		appid       string
-	}
-	tests := []struct {
-		name string
-		args args
-		want map[string][]map[string]interface{}
-	}{
-		// TODO: Add test cases.
-		{
-			name: "群成员",
-			args: args{
-				ChatGroupId: 3,
-				entId:       15755,
-				appid:       "10000",
-			},
-		},
-	}
-	for _, tt := range tests {
-		t.Run(tt.name, func(t *testing.T) {
-			b := ChatGroupService{}
-			if got := b.ChatGroupPerson(tt.args.ChatGroupId, tt.args.entId, tt.args.appid); !reflect.DeepEqual(got, tt.want) {
-				t.Errorf("ChatGroupPerson() = %v, want %v", got, tt.want)
-			}
-		})
-	}
-}
-
-func TestChatGroupService_GroupNameUpdate(t *testing.T) {
-	type args struct {
-		chatGroupId int64
-		groupName   string
-		appid       string
-	}
-	tests := []struct {
-		name string
-		args args
-		want bool
-	}{
-		// TODO: Add test cases.
-		{
-			name: "表名修改",
-			args: args{
-				chatGroupId: 3,
-				groupName:   "策士",
-				appid:       "10000",
-			},
-		},
-	}
-	for _, tt := range tests {
-		t.Run(tt.name, func(t *testing.T) {
-			b := ChatGroupService{}
-			if got := b.GroupNameUpdate(tt.args.chatGroupId, tt.args.groupName, tt.args.appid); got != tt.want {
-				t.Errorf("GroupNameUpdate() = %v, want %v", got, tt.want)
-			}
-		})
-	}
-}
-
-func TestChatGroupService_GroupNoticeAdd(t *testing.T) {
-	type args struct {
-		chatGroupId int64
-		content     string
-		appid       string
-	}
-	tests := []struct {
-		name string
-		args args
-		want bool
-	}{
-		// TODO: Add test cases.
-		{
-			name: "公告新增",
-			args: args{
-				chatGroupId: 3,
-				content:     "一起来玩啊",
-				appid:       "10000",
-			},
-		},
-	}
-	for _, tt := range tests {
-		t.Run(tt.name, func(t *testing.T) {
-			b := ChatGroupService{}
-			if got := b.GroupNoticeAdd(tt.args.chatGroupId, tt.args.content, tt.args.appid); got != tt.want {
-				t.Errorf("GroupNoticeAdd() = %v, want %v", got, tt.want)
-			}
-		})
-	}
-}
-
-func TestChatGroupService_GroupNoticeGet(t *testing.T) {
-	type args struct {
-		chatGroupId int64
-		appid       string
-	}
-	tests := []struct {
-		name string
-		args args
-		want map[string]interface{}
-	}{
-		// TODO: Add test cases.
-		{
-			name: "公告获取",
-			args: args{
-				chatGroupId: 3,
-				appid:       "10000",
-			},
-		},
-	}
-	for _, tt := range tests {
-		t.Run(tt.name, func(t *testing.T) {
-			b := ChatGroupService{}
-			if got := b.GroupNoticeGet(tt.args.chatGroupId, tt.args.appid); !reflect.DeepEqual(got, tt.want) {
-				t.Errorf("GroupNoticeGet() = %v, want %v", got, tt.want)
-			}
-		})
-	}
-}
-
-func TestChatGroupService_GroupNoticeUpdate(t *testing.T) {
-	type args struct {
-		groupNoticeId int64
-		content       string
-		appid         string
-	}
-	tests := []struct {
-		name string
-		args args
-		want bool
-	}{
-		// TODO: Add test cases.
-		{
-			name: "公告修改",
-			args: args{
-				groupNoticeId: 1,
-				content:       "一起来吗qqqqq",
-				appid:         "10000",
-			},
-		},
-	}
-	for _, tt := range tests {
-		t.Run(tt.name, func(t *testing.T) {
-			b := ChatGroupService{}
-			if got := b.GroupNoticeUpdate(tt.args.groupNoticeId, tt.args.content, tt.args.appid); got != tt.want {
-				t.Errorf("GroupNoticeUpdate() = %v, want %v", got, tt.want)
-			}
-		})
-	}
-}
-
-func TestEntPerson(t *testing.T) {
-	type args struct {
-		entId int64
-		isAll bool
-	}
-	tests := []struct {
-		name  string
-		args  args
-		want  map[string]string
-		want1 map[string]string
-	}{
-		// TODO: Add test cases.
-	}
-	for _, tt := range tests {
-		t.Run(tt.name, func(t *testing.T) {
-			got, got1 := EntPerson(tt.args.entId, tt.args.isAll)
-			if !reflect.DeepEqual(got, tt.want) {
-				t.Errorf("EntPerson() got = %v, want %v", got, tt.want)
-			}
-			if !reflect.DeepEqual(got1, tt.want1) {
-				t.Errorf("EntPerson() got1 = %v, want %v", got1, tt.want1)
-			}
-		})
-	}
-}

+ 4 - 10
service/message_mail_box.go

@@ -37,7 +37,7 @@ func (b MessaggeService) Count(newUserId int64) (count int, last map[string]inte
 							c.nickname AS name,
 							c.headimg,
 							d.content,
-							d.type 
+							d.type,
 							d.create_time,
 							a.unread as number,
 						    a.timestamp
@@ -84,13 +84,8 @@ func (b MessaggeService) Count(newUserId int64) (count int, last map[string]inte
 
 	allSql = strings.Join(append(sqlArr, oneSql, groupSql, serviceSql), " union ")
 
-	sqlStr := fmt.Sprintf(`SELECT * FROM
-					(
-						%s
-					) a 
-				a.ORDER BY a.timestamp DESC`, allSql)
-	log.Println("查询sql", sqlStr)
-	data := IC.BaseMysql.SelectBySql(sqlStr)
+	log.Println("查询sql", allSql)
+	data := IC.BaseMysql.SelectBySql(allSql)
 	log.Println("查询数据:", data)
 	return
 }
@@ -199,8 +194,7 @@ func (b MessaggeService) UserList(in *messagecenter.UserReq) (data *[]map[string
 		}
 		sqlStr = fmt.Sprintf(`SELECT * FROM(
 						%s
-					) a LIMIT 0,500
-				a.ORDER BY a.timestamp DESC`, allSql)
+					) a ORDER BY a.timestamp DESC LIMIT 0,500`, allSql)
 	} else {
 		var timeSql, phoneSql, filtrationSql string
 		if in.StartTime != "" {