...
|
...
|
@@ -578,7 +578,7 @@ func ChanceUpdate(header *protocol.RequestHeader, request *protocol.ChanceUpdate |
|
|
}
|
|
|
auditConfig = &protocol.AuditConfig{NoApprover: template.NoApprover}
|
|
|
|
|
|
go CheckChanceDifferent(header, chance, request)
|
|
|
CheckChanceDifferent(header, chance, request)
|
|
|
|
|
|
orm := orm.NewOrm()
|
|
|
orm.Begin()
|
...
|
...
|
@@ -717,21 +717,22 @@ func CheckChanceDifferent(header *protocol.RequestHeader, chance *models.Chance, |
|
|
isSaveLog bool = false
|
|
|
chanceReviseLog *models.ChanceReviseLog
|
|
|
message string
|
|
|
changeCount int
|
|
|
)
|
|
|
defer func() {
|
|
|
if p := recover(); p != nil {
|
|
|
log.Error(p)
|
|
|
}
|
|
|
}()
|
|
|
//TODO:测试
|
|
|
if header.UserId == chance.UserId {
|
|
|
return
|
|
|
}
|
|
|
if chance.ReviewStatus != protocol.ReviewStatusPass {
|
|
|
return
|
|
|
}
|
|
|
var modifyLog = protocol.ChanceReviseLog{}
|
|
|
var modifyLog = protocol.ChanceReviseLog{
|
|
|
RemoveAllPhotoVideo: false,
|
|
|
RemoveAllSpeech: false,
|
|
|
}
|
|
|
checkIsSaveLog := func() {
|
|
|
if !isSaveLog {
|
|
|
isSaveLog = true
|
...
|
...
|
@@ -777,7 +778,7 @@ func CheckChanceDifferent(header *protocol.RequestHeader, chance *models.Chance, |
|
|
jsonUnmarshal(chanceData.Speechs, &speechs)
|
|
|
jsonUnmarshal(chanceData.Images, &pictures)
|
|
|
jsonUnmarshal(chanceData.Videos, &videos)
|
|
|
if !reflect.DeepEqual(request.Videos, videos) || !reflect.DeepEqual(request.Pictures, pictures) {
|
|
|
if !reflect.DeepEqual(request.Videos, videos) {
|
|
|
checkIsSaveLog()
|
|
|
modifyLog.Videos = request.Videos
|
|
|
}
|
...
|
...
|
@@ -789,6 +790,20 @@ func CheckChanceDifferent(header *protocol.RequestHeader, chance *models.Chance, |
|
|
checkIsSaveLog()
|
|
|
modifyLog.Speechs = request.Speechs
|
|
|
}
|
|
|
|
|
|
if (len(videos) > 0 && len(request.Videos) == 0) && len(pictures) > 0 && len(request.Pictures) == 0 {
|
|
|
modifyLog.RemoveAllPhotoVideo = true
|
|
|
}
|
|
|
if (len(videos) > 0 && len(request.Videos) == 0) && len(pictures) == 0 && len(request.Pictures) == 0 {
|
|
|
modifyLog.RemoveAllPhotoVideo = true
|
|
|
}
|
|
|
if (len(videos) == 0 && len(request.Videos) == 0) && len(pictures) > 0 && len(request.Pictures) == 0 {
|
|
|
modifyLog.RemoveAllPhotoVideo = true
|
|
|
}
|
|
|
|
|
|
if len(speechs) > 0 && len(request.Speechs) == 0 {
|
|
|
modifyLog.RemoveAllSpeech = true
|
|
|
}
|
|
|
} else {
|
|
|
checkIsSaveLog()
|
|
|
modifyLog.Speechs = request.Speechs
|
...
|
...
|
@@ -800,25 +815,21 @@ func CheckChanceDifferent(header *protocol.RequestHeader, chance *models.Chance, |
|
|
diffFormList(chance.SourceContent, request.FormList)
|
|
|
diffChanceData()
|
|
|
checkModifyLog := func() {
|
|
|
changeCount += len(modifyLog.Speechs)
|
|
|
if len(modifyLog.Speechs) == 0 {
|
|
|
modifyLog.Speechs = make([]protocol.Speech, 0)
|
|
|
}
|
|
|
changeCount += len(modifyLog.Pictures)
|
|
|
if len(modifyLog.Pictures) == 0 {
|
|
|
modifyLog.Pictures = make([]protocol.Picture, 0)
|
|
|
}
|
|
|
changeCount += len(modifyLog.Videos)
|
|
|
if len(modifyLog.Videos) == 0 {
|
|
|
modifyLog.Videos = make([]protocol.Video, 0)
|
|
|
}
|
|
|
changeCount += len(modifyLog.DiffContents)
|
|
|
if len(modifyLog.DiffContents) == 0 {
|
|
|
modifyLog.DiffContents = make([]protocol.ReviseContent, 0)
|
|
|
}
|
|
|
}
|
|
|
checkModifyLog()
|
|
|
if isSaveLog && changeCount > 0 {
|
|
|
if isSaveLog { //&& changeCount > 0
|
|
|
orm := orm.NewOrm()
|
|
|
orm.Begin()
|
|
|
var logId int64
|
...
|
...
|
|