作者 yangfu

fix:1.机会编辑修改

@@ -3,11 +3,10 @@ package v1 @@ -3,11 +3,10 @@ package v1
3 import ( 3 import (
4 "encoding/json" 4 "encoding/json"
5 "github.com/astaxie/beego" 5 "github.com/astaxie/beego"
  6 + "gitlab.fjmaimaimai.com/mmm-go/gocomm/pkg/log"
6 "opp/controllers" 7 "opp/controllers"
7 "opp/protocol" 8 "opp/protocol"
8 "opp/services/auth" 9 "opp/services/auth"
9 -  
10 - "gitlab.fjmaimaimai.com/mmm-go/gocomm/pkg/log"  
11 ) 10 )
12 11
13 //var ( 12 //var (
@@ -121,13 +121,12 @@ func ValidVersion(current, compare string) bool { @@ -121,13 +121,12 @@ func ValidVersion(current, compare string) bool {
121 curVersions := strings.Split(current, ".") 121 curVersions := strings.Split(current, ".")
122 comVersions := strings.Split(compare, ".") 122 comVersions := strings.Split(compare, ".")
123 for i := range curVersions { 123 for i := range curVersions {
124 - //v1,v2:=strings.TrimSpace(curVersions[i]),""  
125 v1, _ := strconv.ParseInt(strings.TrimSpace(curVersions[i]), 10, 64) 124 v1, _ := strconv.ParseInt(strings.TrimSpace(curVersions[i]), 10, 64)
126 var v2 int64 125 var v2 int64
127 if i < len(comVersions) { 126 if i < len(comVersions) {
128 v2, _ = strconv.ParseInt(strings.TrimSpace(comVersions[i]), 10, 64) 127 v2, _ = strconv.ParseInt(strings.TrimSpace(comVersions[i]), 10, 64)
129 } 128 }
130 - if v1 == 0 && v2 == 0 { 129 + if v1 == v2 {
131 continue 130 continue
132 } 131 }
133 if v1 >= v2 { 132 if v1 >= v2 {
@@ -137,7 +136,7 @@ func ValidVersion(current, compare string) bool { @@ -137,7 +136,7 @@ func ValidVersion(current, compare string) bool {
137 return false 136 return false
138 } 137 }
139 } 138 }
140 - return false 139 + return true
141 } 140 }
142 141
143 // 统计某函数执行时间 142 // 统计某函数执行时间
@@ -43,6 +43,14 @@ func TestValidVersion(t *testing.T) { @@ -43,6 +43,14 @@ func TestValidVersion(t *testing.T) {
43 {In: "1.8.0", Compare: "0.8.0", Out: true}, 43 {In: "1.8.0", Compare: "0.8.0", Out: true},
44 {In: "0.99.0", Compare: "0.8.0", Out: true}, 44 {In: "0.99.0", Compare: "0.8.0", Out: true},
45 {In: "01.0.0", Compare: "0.8.0", Out: true}, 45 {In: "01.0.0", Compare: "0.8.0", Out: true},
  46 + {In: "1.4.1", Compare: "1.3.0", Out: true},
  47 + {In: "1.3.0", Compare: "1.3.0", Out: true},
  48 + {In: "1.3.1", Compare: "1.3.0", Out: true},
  49 + {In: "1.2.1", Compare: "1.3.0", Out: false},
  50 + {In: "1.1.0", Compare: "1.3.0", Out: false},
  51 + {In: "1.1", Compare: "1.3.0", Out: false},
  52 + {In: "0.9.99", Compare: "1.3.0", Out: false},
  53 + {In: "0.0.1", Compare: "1.3.0", Out: false},
46 } 54 }
47 for i := range inputs { 55 for i := range inputs {
48 input := inputs[i] 56 input := inputs[i]
@@ -687,10 +687,13 @@ func ChanceUpdate(header *protocol.RequestHeader, request *protocol.ChanceUpdate @@ -687,10 +687,13 @@ func ChanceUpdate(header *protocol.RequestHeader, request *protocol.ChanceUpdate
687 if chanceData, err = models.GetChanceDataByChanceId(chance.Id); err == nil { 687 if chanceData, err = models.GetChanceDataByChanceId(chance.Id); err == nil {
688 chanceDataMap := map[string]interface{}{ 688 chanceDataMap := map[string]interface{}{
689 "Speechs": common.AssertJson(request.Speechs), 689 "Speechs": common.AssertJson(request.Speechs),
690 - "Images": common.AssertJson(request.Pictures),  
691 - "Videos": common.AssertJson(request.Videos),  
692 "UpdateAt": time.Now(), 690 "UpdateAt": time.Now(),
693 } 691 }
  692 + //TODO:下版本移除
  693 + if !utils.ValidVersion(header.Version, "1.3.0") {
  694 + chanceDataMap["Images"] = common.AssertJson(request.Pictures)
  695 + chanceDataMap["Videos"] = common.AssertJson(request.Videos)
  696 + }
694 if err = utils.UpdateTableByMapWithOrmer(orm, chanceData, chanceDataMap); err != nil { 697 if err = utils.UpdateTableByMapWithOrmer(orm, chanceData, chanceDataMap); err != nil {
695 log.Error(err) 698 log.Error(err)
696 orm.Rollback() 699 orm.Rollback()