...
|
...
|
@@ -2,12 +2,10 @@ package agg |
|
|
|
|
|
import (
|
|
|
"encoding/json"
|
|
|
"fmt"
|
|
|
orm2 "github.com/astaxie/beego/orm"
|
|
|
"oppmg/common/log"
|
|
|
"oppmg/models"
|
|
|
"oppmg/protocol"
|
|
|
"strconv"
|
|
|
)
|
|
|
|
|
|
func getUsers(jsonData string) (v []models.User, err error) {
|
...
|
...
|
@@ -15,15 +13,18 @@ func getUsers(jsonData string) (v []models.User, err error) { |
|
|
var ids []int64
|
|
|
var id int64
|
|
|
if err = json.Unmarshal([]byte(jsonData), &vObjs); err != nil {
|
|
|
log.Error(err.Error())
|
|
|
err = nil
|
|
|
return
|
|
|
}
|
|
|
for i := 0; i < len(vObjs); i++ {
|
|
|
if vObjs[i].Type != models.VisibleObject_User {
|
|
|
continue
|
|
|
}
|
|
|
if id, err = strconv.ParseInt(vObjs[i].Id, 10, 64); err != nil {
|
|
|
return
|
|
|
}
|
|
|
id = int64(vObjs[i].Id)
|
|
|
//if id, err = strconv.ParseInt(vObjs[i].Id, 10, 64); err != nil {
|
|
|
// return
|
|
|
//}
|
|
|
if id == 0 {
|
|
|
continue
|
|
|
}
|
...
|
...
|
@@ -46,9 +47,7 @@ func getDepartments(jsonData string) (v []models.Department, err error) { |
|
|
if vObjs[i].Type != models.VisibleObject_Department {
|
|
|
continue
|
|
|
}
|
|
|
if id, err = strconv.ParseInt(vObjs[i].Id, 10, 64); err != nil {
|
|
|
return
|
|
|
}
|
|
|
id = int64(vObjs[i].Id)
|
|
|
if id == 0 {
|
|
|
continue
|
|
|
}
|
...
|
...
|
@@ -63,29 +62,29 @@ func getDepartments(jsonData string) (v []models.Department, err error) { |
|
|
func GetVisibleObject(jsonData string) (v []protocol.VisibleObject, err error) {
|
|
|
var (
|
|
|
users []models.User
|
|
|
departments []models.Department
|
|
|
//departments []models.Department
|
|
|
)
|
|
|
if len(jsonData) == 0 {
|
|
|
return
|
|
|
}
|
|
|
if departments, err = getDepartments(jsonData); err != nil && err != orm2.ErrNoRows {
|
|
|
log.Error(err.Error())
|
|
|
return
|
|
|
}
|
|
|
for i := range departments {
|
|
|
v = append(v, protocol.VisibleObject{
|
|
|
Id: fmt.Sprintf("%v", departments[i].Id),
|
|
|
Name: departments[i].Name,
|
|
|
Type: models.VisibleObject_Department,
|
|
|
})
|
|
|
}
|
|
|
//if departments, err = getDepartments(jsonData); err != nil && err != orm2.ErrNoRows {
|
|
|
// log.Error(err.Error())
|
|
|
// return
|
|
|
//}
|
|
|
//for i := range departments {
|
|
|
// v = append(v, protocol.VisibleObject{
|
|
|
// Id: int(departments[i].Id),
|
|
|
// Name: departments[i].Name,
|
|
|
// Type: models.VisibleObject_Department,
|
|
|
// })
|
|
|
//}
|
|
|
if users, err = getUsers(jsonData); err != nil && err != orm2.ErrNoRows {
|
|
|
log.Error(err.Error())
|
|
|
return
|
|
|
}
|
|
|
for i := range users {
|
|
|
v = append(v, protocol.VisibleObject{
|
|
|
Id: fmt.Sprintf("%v", users[i].Id),
|
|
|
Id: int(users[i].Id),
|
|
|
Name: users[i].NickName,
|
|
|
Type: models.VisibleObject_User,
|
|
|
})
|
...
|
...
|
|