|
@@ -654,7 +654,7 @@ func ChanceUpdate(header *protocol.RequestHeader, request *protocol.ChanceUpdate |
|
@@ -654,7 +654,7 @@ func ChanceUpdate(header *protocol.RequestHeader, request *protocol.ChanceUpdate |
654
|
err = protocol.NewErrWithMessage(5301)
|
654
|
err = protocol.NewErrWithMessage(5301)
|
655
|
return
|
655
|
return
|
656
|
}
|
656
|
}
|
657
|
- auditConfig = &protocol.AuditConfig{NoApprover: template.NoApprover}
|
657
|
+ auditConfig = &protocol.AuditConfig{NoApprover: template.NoApprover, SelfCheckNeed: template.SelfCheckNeed}
|
658
|
|
658
|
|
659
|
CheckChanceDifferent(header, chance, request)
|
659
|
CheckChanceDifferent(header, chance, request)
|
660
|
|
660
|
|
|
@@ -797,11 +797,6 @@ func ChanceUpdate(header *protocol.RequestHeader, request *protocol.ChanceUpdate |
|
@@ -797,11 +797,6 @@ func ChanceUpdate(header *protocol.RequestHeader, request *protocol.ChanceUpdate |
797
|
|
797
|
|
798
|
//检查机会更新
|
798
|
//检查机会更新
|
799
|
func CheckChanceDifferent(header *protocol.RequestHeader, chance *models.Chance, request *protocol.ChanceUpdateRequest) {
|
799
|
func CheckChanceDifferent(header *protocol.RequestHeader, chance *models.Chance, request *protocol.ChanceUpdateRequest) {
|
800
|
- var (
|
|
|
801
|
- isSaveLog bool = false
|
|
|
802
|
- chanceReviseLog *models.ChanceReviseLog
|
|
|
803
|
- message string
|
|
|
804
|
- )
|
|
|
805
|
defer func() {
|
800
|
defer func() {
|
806
|
if p := recover(); p != nil {
|
801
|
if p := recover(); p != nil {
|
807
|
log.Error(p)
|
802
|
log.Error(p)
|
|
@@ -813,49 +808,76 @@ func CheckChanceDifferent(header *protocol.RequestHeader, chance *models.Chance, |
|
@@ -813,49 +808,76 @@ func CheckChanceDifferent(header *protocol.RequestHeader, chance *models.Chance, |
813
|
if chance.ReviewStatus != protocol.ReviewStatusPass {
|
808
|
if chance.ReviewStatus != protocol.ReviewStatusPass {
|
814
|
return
|
809
|
return
|
815
|
}
|
810
|
}
|
816
|
- var modifyLog = protocol.ChanceReviseLog{
|
811
|
+
|
|
|
812
|
+ var (
|
|
|
813
|
+ isSaveLog bool = false
|
|
|
814
|
+ modifyLog = protocol.ChanceReviseLog{
|
817
|
RemoveAllPhotoVideo: false,
|
815
|
RemoveAllPhotoVideo: false,
|
818
|
RemoveAllSpeech: false,
|
816
|
RemoveAllSpeech: false,
|
819
|
}
|
817
|
}
|
820
|
- checkIsSaveLog := func() {
|
818
|
+ )
|
|
|
819
|
+ funcCheckSave := func() {
|
821
|
if !isSaveLog {
|
820
|
if !isSaveLog {
|
822
|
isSaveLog = true
|
821
|
isSaveLog = true
|
823
|
}
|
822
|
}
|
824
|
}
|
823
|
}
|
825
|
-
|
|
|
826
|
- diffFormList := func(source string, dis []*protocol.Form) {
|
824
|
+ funcDiffForms := func(source string, src []*protocol.Form) {
|
827
|
var (
|
825
|
var (
|
828
|
- src []*protocol.Form
|
|
|
829
|
- mapForm map[string]*protocol.Form = make(map[string]*protocol.Form)
|
826
|
+ dst []*protocol.Form
|
|
|
827
|
+ mapForm = make(map[string]*protocol.Form)
|
830
|
reviseContents []protocol.ReviseContent
|
828
|
reviseContents []protocol.ReviseContent
|
831
|
)
|
829
|
)
|
832
|
- jsonUnmarshal(source, &src)
|
|
|
833
|
- keyFunc := func(form *protocol.Form) string {
|
830
|
+ utils.JsonUnmarshal(source, &dst)
|
|
|
831
|
+ funcKey := func(form *protocol.Form) string {
|
834
|
return fmt.Sprintf("%v_%v", form.Label, form.SectionType)
|
832
|
return fmt.Sprintf("%v_%v", form.Label, form.SectionType)
|
835
|
}
|
833
|
}
|
836
|
- for i := range src {
|
|
|
837
|
- mapForm[keyFunc(src[i])] = src[i]
|
834
|
+ for i := range dst {
|
|
|
835
|
+ mapForm[funcKey(dst[i])] = dst[i]
|
838
|
}
|
836
|
}
|
839
|
- for i := range dis {
|
|
|
840
|
- isDiff := false
|
|
|
841
|
- srcValue := ""
|
|
|
842
|
- if v, ok := mapForm[keyFunc(dis[i])]; ok {
|
837
|
+ for i := range src {
|
|
|
838
|
+ var (
|
|
|
839
|
+ isDiff = false
|
|
|
840
|
+ oldForm *protocol.Form
|
|
|
841
|
+ srcValue = ""
|
|
|
842
|
+ )
|
|
|
843
|
+
|
|
|
844
|
+ if v, ok := mapForm[funcKey(src[i])]; ok {
|
843
|
srcValue = v.Value
|
845
|
srcValue = v.Value
|
844
|
- if dis[i].Value != v.Value {
|
846
|
+ if src[i].Value != v.Value {
|
|
|
847
|
+ isDiff = true
|
|
|
848
|
+ }
|
|
|
849
|
+ if len(src[i].Data) > 0 {
|
|
|
850
|
+ if !reflect.DeepEqual(src[i].Data, v.Data) {
|
845
|
isDiff = true
|
851
|
isDiff = true
|
846
|
}
|
852
|
}
|
|
|
853
|
+ }
|
|
|
854
|
+ oldForm = v
|
847
|
} else {
|
855
|
} else {
|
848
|
isDiff = true
|
856
|
isDiff = true
|
849
|
}
|
857
|
}
|
|
|
858
|
+
|
850
|
if isDiff {
|
859
|
if isDiff {
|
851
|
- reviseContents = append(reviseContents, protocol.ReviseContent{
|
|
|
852
|
- Content: fmt.Sprintf("将“%v”由“%v”改为 “%v”", dis[i].Label, srcValue, dis[i].Value)})
|
|
|
853
|
- checkIsSaveLog()
|
860
|
+ c := protocol.ReviseContent{
|
|
|
861
|
+ Content: fmt.Sprintf("将“%v”由“%v”改为 “%v”", src[i].Label, srcValue, src[i].Value),
|
|
|
862
|
+ Label: src[i].Label,
|
|
|
863
|
+ InputType: src[i].InputType,
|
|
|
864
|
+ Data: src[i].Data,
|
|
|
865
|
+ }
|
|
|
866
|
+
|
|
|
867
|
+ //文件表单
|
|
|
868
|
+ if src[i].InputType == protocol.InputFiles {
|
|
|
869
|
+ if oldForm != nil && len(oldForm.Data) > 0 && len(src[i].Data) == 0 {
|
|
|
870
|
+ c.RemoveAllPhotoVideo = true
|
|
|
871
|
+ }
|
|
|
872
|
+ c.Content = fmt.Sprintf("将%v修改为:", src[i].Label)
|
|
|
873
|
+ }
|
|
|
874
|
+ reviseContents = append(reviseContents, c)
|
|
|
875
|
+ funcCheckSave()
|
854
|
}
|
876
|
}
|
855
|
}
|
877
|
}
|
856
|
modifyLog.DiffContents = reviseContents
|
878
|
modifyLog.DiffContents = reviseContents
|
857
|
}
|
879
|
}
|
858
|
- diffChanceData := func() {
|
880
|
+ funcDiffChanceData := func() {
|
859
|
var (
|
881
|
var (
|
860
|
speechs []protocol.Speech
|
882
|
speechs []protocol.Speech
|
861
|
pictures []protocol.Picture
|
883
|
pictures []protocol.Picture
|
|
@@ -866,12 +888,12 @@ func CheckChanceDifferent(header *protocol.RequestHeader, chance *models.Chance, |
|
@@ -866,12 +888,12 @@ func CheckChanceDifferent(header *protocol.RequestHeader, chance *models.Chance, |
866
|
jsonUnmarshal(chanceData.Images, &pictures)
|
888
|
jsonUnmarshal(chanceData.Images, &pictures)
|
867
|
jsonUnmarshal(chanceData.Videos, &videos)
|
889
|
jsonUnmarshal(chanceData.Videos, &videos)
|
868
|
if !reflect.DeepEqual(request.Videos, videos) || !reflect.DeepEqual(request.Pictures, pictures) {
|
890
|
if !reflect.DeepEqual(request.Videos, videos) || !reflect.DeepEqual(request.Pictures, pictures) {
|
869
|
- checkIsSaveLog()
|
891
|
+ funcCheckSave()
|
870
|
modifyLog.Videos = request.Videos
|
892
|
modifyLog.Videos = request.Videos
|
871
|
modifyLog.Pictures = request.Pictures
|
893
|
modifyLog.Pictures = request.Pictures
|
872
|
}
|
894
|
}
|
873
|
if !reflect.DeepEqual(request.Speechs, speechs) {
|
895
|
if !reflect.DeepEqual(request.Speechs, speechs) {
|
874
|
- checkIsSaveLog()
|
896
|
+ funcCheckSave()
|
875
|
modifyLog.Speechs = request.Speechs
|
897
|
modifyLog.Speechs = request.Speechs
|
876
|
}
|
898
|
}
|
877
|
|
899
|
|
|
@@ -888,16 +910,13 @@ func CheckChanceDifferent(header *protocol.RequestHeader, chance *models.Chance, |
|
@@ -888,16 +910,13 @@ func CheckChanceDifferent(header *protocol.RequestHeader, chance *models.Chance, |
888
|
modifyLog.RemoveAllSpeech = true
|
910
|
modifyLog.RemoveAllSpeech = true
|
889
|
}
|
911
|
}
|
890
|
} else {
|
912
|
} else {
|
891
|
- checkIsSaveLog()
|
913
|
+ funcCheckSave()
|
892
|
modifyLog.Speechs = request.Speechs
|
914
|
modifyLog.Speechs = request.Speechs
|
893
|
modifyLog.Videos = request.Videos
|
915
|
modifyLog.Videos = request.Videos
|
894
|
modifyLog.Speechs = request.Speechs
|
916
|
modifyLog.Speechs = request.Speechs
|
895
|
}
|
917
|
}
|
896
|
}
|
918
|
}
|
897
|
-
|
|
|
898
|
- diffFormList(chance.SourceContent, request.FormList)
|
|
|
899
|
- diffChanceData()
|
|
|
900
|
- checkModifyLog := func() {
|
919
|
+ funcFormatEmpty := func() {
|
901
|
if len(modifyLog.Speechs) == 0 {
|
920
|
if len(modifyLog.Speechs) == 0 {
|
902
|
modifyLog.Speechs = make([]protocol.Speech, 0)
|
921
|
modifyLog.Speechs = make([]protocol.Speech, 0)
|
903
|
}
|
922
|
}
|
|
@@ -911,8 +930,21 @@ func CheckChanceDifferent(header *protocol.RequestHeader, chance *models.Chance, |
|
@@ -911,8 +930,21 @@ func CheckChanceDifferent(header *protocol.RequestHeader, chance *models.Chance, |
911
|
modifyLog.DiffContents = make([]protocol.ReviseContent, 0)
|
930
|
modifyLog.DiffContents = make([]protocol.ReviseContent, 0)
|
912
|
}
|
931
|
}
|
913
|
}
|
932
|
}
|
914
|
- checkModifyLog()
|
|
|
915
|
- if isSaveLog { //&& changeCount > 0
|
933
|
+
|
|
|
934
|
+ funcDiffForms(chance.SourceContent, request.FormList) //比对表单
|
|
|
935
|
+ funcDiffChanceData() //比对机会数据
|
|
|
936
|
+ funcFormatEmpty() //格式化变更日志
|
|
|
937
|
+ if isSaveLog {
|
|
|
938
|
+ _ = SaveChanceReviseLog(header, chance, modifyLog)
|
|
|
939
|
+ }
|
|
|
940
|
+}
|
|
|
941
|
+
|
|
|
942
|
+//保存机会变更日志
|
|
|
943
|
+func SaveChanceReviseLog(header *protocol.RequestHeader, chance *models.Chance, modifyLog protocol.ChanceReviseLog) (err error) {
|
|
|
944
|
+ var (
|
|
|
945
|
+ chanceReviseLog *models.ChanceReviseLog
|
|
|
946
|
+ message string
|
|
|
947
|
+ )
|
916
|
orm := orm.NewOrm()
|
948
|
orm := orm.NewOrm()
|
917
|
orm.Begin()
|
949
|
orm.Begin()
|
918
|
var logId int64
|
950
|
var logId int64
|
|
@@ -951,9 +983,8 @@ func CheckChanceDifferent(header *protocol.RequestHeader, chance *models.Chance, |
|
@@ -951,9 +983,8 @@ func CheckChanceDifferent(header *protocol.RequestHeader, chance *models.Chance, |
951
|
orm.Rollback()
|
983
|
orm.Rollback()
|
952
|
return
|
984
|
return
|
953
|
}
|
985
|
}
|
954
|
-
|
|
|
955
|
orm.Commit()
|
986
|
orm.Commit()
|
956
|
- }
|
987
|
+ return
|
957
|
}
|
988
|
}
|
958
|
|
989
|
|
959
|
//修改公开状态
|
990
|
//修改公开状态
|
|
@@ -1627,6 +1658,8 @@ func ChancePool(header *protocol.RequestHeader, request *protocol.ChancePoolRequ |
|
@@ -1627,6 +1658,8 @@ func ChancePool(header *protocol.RequestHeader, request *protocol.ChancePoolRequ |
1627
|
jsonUnmarshal(chance.Images, &item.Pictures)
|
1658
|
jsonUnmarshal(chance.Images, &item.Pictures)
|
1628
|
jsonUnmarshal(chance.Voices, &item.Speechs)
|
1659
|
jsonUnmarshal(chance.Voices, &item.Speechs)
|
1629
|
jsonUnmarshal(chance.Videos, &item.Videos)
|
1660
|
jsonUnmarshal(chance.Videos, &item.Videos)
|
|
|
1661
|
+ item.Pictures, item.Videos = agg.CombineAllFiles(item.FormList, item.Pictures, item.Videos)
|
|
|
1662
|
+ item.FormList = agg.FormFilter(item.FormList, agg.ClearEmptyForm, agg.ClearFilesForm)
|
1630
|
commItem.Chance = item
|
1663
|
commItem.Chance = item
|
1631
|
|
1664
|
|
1632
|
//点赞评论数据
|
1665
|
//点赞评论数据
|