作者 yangfu

公告修改

... ... @@ -132,7 +132,7 @@ type TemplateItem struct {
}
type VisibleObject struct {
Id string `json:"id"`
Id int `json:"id"`
Name string `json:"name,omitempty"`
Type int `json:"type"` //0:指定人员 1:部门
}
... ...
... ... @@ -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,
})
... ...
... ... @@ -110,12 +110,13 @@ func getBulletinReceiverIds(orm orm2.Ormer, receivers []protocol.VisibleObject,
`
for i := range receivers {
obj = receivers[i]
id, _ = strconv.ParseInt(obj.Id, 10, 64)
id = int64(obj.Id)
if obj.Type == models.VisibleObject_Department {
did = append(did, obj.Id)
did = append(did, fmt.Sprintf("%v", obj.Id))
}
if obj.Type == models.VisibleObject_User {
id, _ = strconv.ParseInt(obj.Id, 10, 64)
id = int64(obj.Id)
//id, _ = strconv.ParseInt(obj.Id, 10, 64)
ids = append(ids, id)
log.Debug("sendBulletinUserMsg: receiver_id:%v", id)
continue
... ... @@ -188,6 +189,10 @@ func BulletinList(uid, companyId int64, request *protocol.BulletinListRequest) (
Status: int8(bulletin.Status),
CreateAt: bulletin.CreateAt.Format("2006-01-02 15:04:05"),
}
//if e:=json.Unmarshal([]byte(bulletin.Receiver),&item.Receiver);e!=nil{
// log.Error(e.Error())
// return
//}
if item.Receiver, err = agg.GetVisibleObject(bulletin.Receiver); err != nil {
log.Error(bulletin.Receiver, err.Error())
continue
... ... @@ -283,6 +288,7 @@ func UpdateBulletin(companyId int64, request *protocol.UpdateBulletinRequest) (r
bulletinQuestion *models.BulletinQuestion
receiver, questionContent []byte
)
rsp = &protocol.UpdateBulletinResponse{}
if bulletin, err = models.GetBulletinById(request.Id); err != nil {
log.Error(err.Error())
return
... ...