作者 唐旭辉

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

... ... @@ -61,6 +61,7 @@ func BulletinRelease(uid, companyId int64, request *protocol.BulletinReleaseRequ
log.Error("BulletinRelease:question.content not empty.", uid)
return
}
validQuestion(&request.Question)
if questionContent, err = json.Marshal(request.Question.Content); err != nil {
log.Error(err.Error())
return
... ... @@ -97,6 +98,19 @@ func BulletinRelease(uid, companyId int64, request *protocol.BulletinReleaseRequ
return
}
//检查序号
func validQuestion(question *protocol.Question) {
var id = 1
for i := range question.Content {
//option :=question.Content[i]
if question.Content[i].Id == -1 {
continue
}
question.Content[i].Id = id
id++
}
}
func getBulletinReceiverIds(orm orm2.Ormer, receivers []protocol.VisibleObject, companyId int64, sourceId int64, message string) (ids []int64, err error) {
var (
//ids []int64
... ... @@ -354,6 +368,7 @@ func UpdateBulletin(companyId int64, request *protocol.UpdateBulletinRequest) (r
if bulletin.QuestionSwitch == 1 {
bulletinQuestion, err = models.GetBulletinQuestionByBulletinId(bulletin.Id)
validQuestion(&request.Question)
if err != nil && err != orm2.ErrNoRows {
log.Error(err.Error())
return
... ...
package bulletin
import (
"oppmg/protocol"
"testing"
)
func Test_validQuestion(t *testing.T) {
input := protocol.Question{
Content: []protocol.QuestionContent{{Id: 5, Content: "A"}, {Id: 7, Content: "B"}, {-1, "C"}},
}
t.Log(input)
validQuestion(&input)
t.Log(input)
}
... ...