作者 yangfu

公告修改

@@ -132,7 +132,7 @@ type TemplateItem struct { @@ -132,7 +132,7 @@ type TemplateItem struct {
132 } 132 }
133 133
134 type VisibleObject struct { 134 type VisibleObject struct {
135 - Id string `json:"id"` 135 + Id int `json:"id"`
136 Name string `json:"name,omitempty"` 136 Name string `json:"name,omitempty"`
137 Type int `json:"type"` //0:指定人员 1:部门 137 Type int `json:"type"` //0:指定人员 1:部门
138 } 138 }
@@ -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 })
@@ -110,12 +110,13 @@ func getBulletinReceiverIds(orm orm2.Ormer, receivers []protocol.VisibleObject, @@ -110,12 +110,13 @@ func getBulletinReceiverIds(orm orm2.Ormer, receivers []protocol.VisibleObject,
110 ` 110 `
111 for i := range receivers { 111 for i := range receivers {
112 obj = receivers[i] 112 obj = receivers[i]
113 - id, _ = strconv.ParseInt(obj.Id, 10, 64) 113 + id = int64(obj.Id)
114 if obj.Type == models.VisibleObject_Department { 114 if obj.Type == models.VisibleObject_Department {
115 - did = append(did, obj.Id) 115 + did = append(did, fmt.Sprintf("%v", obj.Id))
116 } 116 }
117 if obj.Type == models.VisibleObject_User { 117 if obj.Type == models.VisibleObject_User {
118 - id, _ = strconv.ParseInt(obj.Id, 10, 64) 118 + id = int64(obj.Id)
  119 + //id, _ = strconv.ParseInt(obj.Id, 10, 64)
119 ids = append(ids, id) 120 ids = append(ids, id)
120 log.Debug("sendBulletinUserMsg: receiver_id:%v", id) 121 log.Debug("sendBulletinUserMsg: receiver_id:%v", id)
121 continue 122 continue
@@ -188,6 +189,10 @@ func BulletinList(uid, companyId int64, request *protocol.BulletinListRequest) ( @@ -188,6 +189,10 @@ func BulletinList(uid, companyId int64, request *protocol.BulletinListRequest) (
188 Status: int8(bulletin.Status), 189 Status: int8(bulletin.Status),
189 CreateAt: bulletin.CreateAt.Format("2006-01-02 15:04:05"), 190 CreateAt: bulletin.CreateAt.Format("2006-01-02 15:04:05"),
190 } 191 }
  192 + //if e:=json.Unmarshal([]byte(bulletin.Receiver),&item.Receiver);e!=nil{
  193 + // log.Error(e.Error())
  194 + // return
  195 + //}
191 if item.Receiver, err = agg.GetVisibleObject(bulletin.Receiver); err != nil { 196 if item.Receiver, err = agg.GetVisibleObject(bulletin.Receiver); err != nil {
192 log.Error(bulletin.Receiver, err.Error()) 197 log.Error(bulletin.Receiver, err.Error())
193 continue 198 continue
@@ -283,6 +288,7 @@ func UpdateBulletin(companyId int64, request *protocol.UpdateBulletinRequest) (r @@ -283,6 +288,7 @@ func UpdateBulletin(companyId int64, request *protocol.UpdateBulletinRequest) (r
283 bulletinQuestion *models.BulletinQuestion 288 bulletinQuestion *models.BulletinQuestion
284 receiver, questionContent []byte 289 receiver, questionContent []byte
285 ) 290 )
  291 + rsp = &protocol.UpdateBulletinResponse{}
286 if bulletin, err = models.GetBulletinById(request.Id); err != nil { 292 if bulletin, err = models.GetBulletinById(request.Id); err != nil {
287 log.Error(err.Error()) 293 log.Error(err.Error())
288 return 294 return