|
@@ -2,12 +2,10 @@ package agg |
|
@@ -2,12 +2,10 @@ package agg |
2
|
|
2
|
|
3
|
import (
|
3
|
import (
|
4
|
"encoding/json"
|
4
|
"encoding/json"
|
5
|
- "fmt"
|
|
|
6
|
orm2 "github.com/astaxie/beego/orm"
|
5
|
orm2 "github.com/astaxie/beego/orm"
|
7
|
"oppmg/common/log"
|
6
|
"oppmg/common/log"
|
8
|
"oppmg/models"
|
7
|
"oppmg/models"
|
9
|
"oppmg/protocol"
|
8
|
"oppmg/protocol"
|
10
|
- "strconv"
|
|
|
11
|
)
|
9
|
)
|
12
|
|
10
|
|
13
|
func getUsers(jsonData string) (v []models.User, err error) {
|
11
|
func getUsers(jsonData string) (v []models.User, err error) {
|
|
@@ -15,15 +13,18 @@ func getUsers(jsonData string) (v []models.User, err error) { |
|
@@ -15,15 +13,18 @@ func getUsers(jsonData string) (v []models.User, err error) { |
15
|
var ids []int64
|
13
|
var ids []int64
|
16
|
var id int64
|
14
|
var id int64
|
17
|
if err = json.Unmarshal([]byte(jsonData), &vObjs); err != nil {
|
15
|
if err = json.Unmarshal([]byte(jsonData), &vObjs); err != nil {
|
|
|
16
|
+ log.Error(err.Error())
|
|
|
17
|
+ err = nil
|
18
|
return
|
18
|
return
|
19
|
}
|
19
|
}
|
20
|
for i := 0; i < len(vObjs); i++ {
|
20
|
for i := 0; i < len(vObjs); i++ {
|
21
|
if vObjs[i].Type != models.VisibleObject_User {
|
21
|
if vObjs[i].Type != models.VisibleObject_User {
|
22
|
continue
|
22
|
continue
|
23
|
}
|
23
|
}
|
24
|
- if id, err = strconv.ParseInt(vObjs[i].Id, 10, 64); err != nil {
|
|
|
25
|
- return
|
|
|
26
|
- }
|
24
|
+ id = int64(vObjs[i].Id)
|
|
|
25
|
+ //if id, err = strconv.ParseInt(vObjs[i].Id, 10, 64); err != nil {
|
|
|
26
|
+ // return
|
|
|
27
|
+ //}
|
27
|
if id == 0 {
|
28
|
if id == 0 {
|
28
|
continue
|
29
|
continue
|
29
|
}
|
30
|
}
|
|
@@ -46,9 +47,7 @@ func getDepartments(jsonData string) (v []models.Department, err error) { |
|
@@ -46,9 +47,7 @@ func getDepartments(jsonData string) (v []models.Department, err error) { |
46
|
if vObjs[i].Type != models.VisibleObject_Department {
|
47
|
if vObjs[i].Type != models.VisibleObject_Department {
|
47
|
continue
|
48
|
continue
|
48
|
}
|
49
|
}
|
49
|
- if id, err = strconv.ParseInt(vObjs[i].Id, 10, 64); err != nil {
|
|
|
50
|
- return
|
|
|
51
|
- }
|
50
|
+ id = int64(vObjs[i].Id)
|
52
|
if id == 0 {
|
51
|
if id == 0 {
|
53
|
continue
|
52
|
continue
|
54
|
}
|
53
|
}
|
|
@@ -62,30 +61,30 @@ func getDepartments(jsonData string) (v []models.Department, err error) { |
|
@@ -62,30 +61,30 @@ func getDepartments(jsonData string) (v []models.Department, err error) { |
62
|
|
61
|
|
63
|
func GetVisibleObject(jsonData string) (v []protocol.VisibleObject, err error) {
|
62
|
func GetVisibleObject(jsonData string) (v []protocol.VisibleObject, err error) {
|
64
|
var (
|
63
|
var (
|
65
|
- users []models.User
|
|
|
66
|
- departments []models.Department
|
64
|
+ users []models.User
|
|
|
65
|
+ //departments []models.Department
|
67
|
)
|
66
|
)
|
68
|
if len(jsonData) == 0 {
|
67
|
if len(jsonData) == 0 {
|
69
|
return
|
68
|
return
|
70
|
}
|
69
|
}
|
71
|
- if departments, err = getDepartments(jsonData); err != nil && err != orm2.ErrNoRows {
|
|
|
72
|
- log.Error(err.Error())
|
|
|
73
|
- return
|
|
|
74
|
- }
|
|
|
75
|
- for i := range departments {
|
|
|
76
|
- v = append(v, protocol.VisibleObject{
|
|
|
77
|
- Id: fmt.Sprintf("%v", departments[i].Id),
|
|
|
78
|
- Name: departments[i].Name,
|
|
|
79
|
- Type: models.VisibleObject_Department,
|
|
|
80
|
- })
|
|
|
81
|
- }
|
70
|
+ //if departments, err = getDepartments(jsonData); err != nil && err != orm2.ErrNoRows {
|
|
|
71
|
+ // log.Error(err.Error())
|
|
|
72
|
+ // return
|
|
|
73
|
+ //}
|
|
|
74
|
+ //for i := range departments {
|
|
|
75
|
+ // v = append(v, protocol.VisibleObject{
|
|
|
76
|
+ // Id: int(departments[i].Id),
|
|
|
77
|
+ // Name: departments[i].Name,
|
|
|
78
|
+ // Type: models.VisibleObject_Department,
|
|
|
79
|
+ // })
|
|
|
80
|
+ //}
|
82
|
if users, err = getUsers(jsonData); err != nil && err != orm2.ErrNoRows {
|
81
|
if users, err = getUsers(jsonData); err != nil && err != orm2.ErrNoRows {
|
83
|
log.Error(err.Error())
|
82
|
log.Error(err.Error())
|
84
|
return
|
83
|
return
|
85
|
}
|
84
|
}
|
86
|
for i := range users {
|
85
|
for i := range users {
|
87
|
v = append(v, protocol.VisibleObject{
|
86
|
v = append(v, protocol.VisibleObject{
|
88
|
- Id: fmt.Sprintf("%v", users[i].Id),
|
87
|
+ Id: int(users[i].Id),
|
89
|
Name: users[i].NickName,
|
88
|
Name: users[i].NickName,
|
90
|
Type: models.VisibleObject_User,
|
89
|
Type: models.VisibleObject_User,
|
91
|
})
|
90
|
})
|