作者 tangxvhui

Merge branch 'test' of http://gitlab.fjmaimaimai.com/mmm-go/oppmg into test

@@ -40,8 +40,9 @@ const ( @@ -40,8 +40,9 @@ const (
40 ) 40 )
41 41
42 const ( 42 const (
43 - SqlDeleteUserMsg = "delete from user_msg where company_id=? and msg_type=? and source_id=?"  
44 - SqlUpdateUserMsgPublic = "update user_msg set is_public=? where company_id=? and msg_type=? and source_id=?" 43 + SqlDeleteUserMsg = "delete from user_msg where company_id=? and msg_type=? and source_id=?"
  44 + SqlUpdateUserMsgPublic = "update user_msg set is_public=? where company_id=? and msg_type=? and source_id=?"
  45 + SqlUpdateUserMsgPublicInUsers = "update user_msg set is_public=? where company_id=? and msg_type=? and source_id=? and receive_user_id in (%v)"
45 ) 46 )
46 47
47 func (t *UserMsg) TableName() string { 48 func (t *UserMsg) TableName() string {
@@ -169,7 +169,7 @@ func sendBulletinUserMsg(orm orm2.Ormer, receivers []protocol.VisibleObject, com @@ -169,7 +169,7 @@ func sendBulletinUserMsg(orm orm2.Ormer, receivers []protocol.VisibleObject, com
169 return 169 return
170 } 170 }
171 } 171 }
172 - if err = utils.ExecuteSQLWithOrmer(orm, models.SqlUpdateUserMsgPublic, models.Public, companyId, models.MsgTypeBulletin, sourceId); err != nil { 172 + if err = utils.ExecuteSQLWithOrmer(orm, fmt.Sprintf(models.SqlUpdateUserMsgPublicInUsers, utils.JoinInt64s(ids, ",")), models.Public, companyId, models.MsgTypeBulletin, sourceId); err != nil {
173 log.Error(err.Error()) 173 log.Error(err.Error())
174 orm.Rollback() 174 orm.Rollback()
175 return 175 return
@@ -310,9 +310,11 @@ func GetBulletin(id int, companyId int64, request *protocol.GetBulletinRequest) @@ -310,9 +310,11 @@ func GetBulletin(id int, companyId int64, request *protocol.GetBulletinRequest)
310 Type: int(question.Type), 310 Type: int(question.Type),
311 Title: question.Title, 311 Title: question.Title,
312 } 312 }
313 - if err = json.Unmarshal([]byte(question.Content), &rsp.Question.Content); err != nil {  
314 - log.Error(err.Error())  
315 - return 313 + if len(question.Content) > 0 {
  314 + if err = json.Unmarshal([]byte(question.Content), &rsp.Question.Content); err != nil {
  315 + log.Error(err.Error())
  316 + return
  317 + }
316 } 318 }
317 for i := range rsp.Question.Content { 319 for i := range rsp.Question.Content {
318 if rsp.Question.Content[i].Id == -1 && len(rsp.Question.Content[i].Content) == 0 { 320 if rsp.Question.Content[i].Id == -1 && len(rsp.Question.Content[i].Content) == 0 {
@@ -406,7 +408,7 @@ func UpdateBulletin(companyId int64, request *protocol.UpdateBulletinRequest) (r @@ -406,7 +408,7 @@ func UpdateBulletin(companyId int64, request *protocol.UpdateBulletinRequest) (r
406 log.Error(err.Error()) 408 log.Error(err.Error())
407 return 409 return
408 } 410 }
409 - bulletinQuestion.Title = request.Title 411 + bulletinQuestion.Title = request.Question.Title
410 bulletinQuestion.Content = string(questionContent) 412 bulletinQuestion.Content = string(questionContent)
411 bulletinQuestion.Type = int8(request.Question.Type) 413 bulletinQuestion.Type = int8(request.Question.Type)
412 bulletinQuestion.UpdateAt = time.Now() 414 bulletinQuestion.UpdateAt = time.Now()
@@ -418,10 +420,16 @@ func UpdateBulletin(companyId int64, request *protocol.UpdateBulletinRequest) (r @@ -418,10 +420,16 @@ func UpdateBulletin(companyId int64, request *protocol.UpdateBulletinRequest) (r
418 } 420 }
419 if err == orm2.ErrNoRows { 421 if err == orm2.ErrNoRows {
420 //添加 422 //添加
  423 + questionContent, err = json.Marshal(request.Question.Content)
  424 + if err != nil {
  425 + orm.Rollback()
  426 + log.Error("格式化问题失败:%s", err)
  427 + return
  428 + }
421 bulletinQuestion = &models.BulletinQuestion{ 429 bulletinQuestion = &models.BulletinQuestion{
422 BulletinId: bulletin.Id, 430 BulletinId: bulletin.Id,
423 Type: int8(request.Question.Type), 431 Type: int8(request.Question.Type),
424 - Title: request.Title, 432 + Title: request.Question.Title,
425 Content: string(questionContent), 433 Content: string(questionContent),
426 CreateAt: time.Now(), 434 CreateAt: time.Now(),
427 UpdateAt: time.Now(), 435 UpdateAt: time.Now(),