作者 yangfu

fix:1.机会编辑修改

... ... @@ -3,11 +3,10 @@ package v1
import (
"encoding/json"
"github.com/astaxie/beego"
"gitlab.fjmaimaimai.com/mmm-go/gocomm/pkg/log"
"opp/controllers"
"opp/protocol"
"opp/services/auth"
"gitlab.fjmaimaimai.com/mmm-go/gocomm/pkg/log"
)
//var (
... ...
... ... @@ -121,13 +121,12 @@ func ValidVersion(current, compare string) bool {
curVersions := strings.Split(current, ".")
comVersions := strings.Split(compare, ".")
for i := range curVersions {
//v1,v2:=strings.TrimSpace(curVersions[i]),""
v1, _ := strconv.ParseInt(strings.TrimSpace(curVersions[i]), 10, 64)
var v2 int64
if i < len(comVersions) {
v2, _ = strconv.ParseInt(strings.TrimSpace(comVersions[i]), 10, 64)
}
if v1 == 0 && v2 == 0 {
if v1 == v2 {
continue
}
if v1 >= v2 {
... ... @@ -137,7 +136,7 @@ func ValidVersion(current, compare string) bool {
return false
}
}
return false
return true
}
// 统计某函数执行时间
... ...
... ... @@ -43,6 +43,14 @@ func TestValidVersion(t *testing.T) {
{In: "1.8.0", Compare: "0.8.0", Out: true},
{In: "0.99.0", Compare: "0.8.0", Out: true},
{In: "01.0.0", Compare: "0.8.0", Out: true},
{In: "1.4.1", Compare: "1.3.0", Out: true},
{In: "1.3.0", Compare: "1.3.0", Out: true},
{In: "1.3.1", Compare: "1.3.0", Out: true},
{In: "1.2.1", Compare: "1.3.0", Out: false},
{In: "1.1.0", Compare: "1.3.0", Out: false},
{In: "1.1", Compare: "1.3.0", Out: false},
{In: "0.9.99", Compare: "1.3.0", Out: false},
{In: "0.0.1", Compare: "1.3.0", Out: false},
}
for i := range inputs {
input := inputs[i]
... ...
... ... @@ -687,10 +687,13 @@ func ChanceUpdate(header *protocol.RequestHeader, request *protocol.ChanceUpdate
if chanceData, err = models.GetChanceDataByChanceId(chance.Id); err == nil {
chanceDataMap := map[string]interface{}{
"Speechs": common.AssertJson(request.Speechs),
"Images": common.AssertJson(request.Pictures),
"Videos": common.AssertJson(request.Videos),
"UpdateAt": time.Now(),
}
//TODO:下版本移除
if !utils.ValidVersion(header.Version, "1.3.0") {
chanceDataMap["Images"] = common.AssertJson(request.Pictures)
chanceDataMap["Videos"] = common.AssertJson(request.Videos)
}
if err = utils.UpdateTableByMapWithOrmer(orm, chanceData, chanceDataMap); err != nil {
log.Error(err)
orm.Rollback()
... ...