Merge branch 'master' of e.coding.net:rosydev/baseapi

This commit is contained in:
苏尹岚
2019-12-02 09:55:09 +08:00
9 changed files with 98 additions and 15 deletions

View File

@@ -10,7 +10,8 @@ import (
)
const (
AfsPicPrefix = "http://img10.360buyimg.com/o2o"
AfsPicPrefix = "http://img10.360buyimg.com/o2o"
AfsPicPrefixHttps = "https://img10.360buyimg.com/o2o"
)
const (
@@ -675,11 +676,19 @@ func (a *API) AfsSubmit(OrderID, pin, questionTypeCode, questionDesc, questionPi
}
func ProcessQuestionPic(questionPic string) (outQuestionPic string) {
const httpsPrefix = "https:"
if questionPic != "" {
picList := strings.Split(questionPic, ",")
picList2 := make([]string, len(picList))
for index, pic := range picList {
picList2[index] = AfsPicPrefix + "/" + pic
var picList2 []string
for _, pic := range picList {
baseURL := AfsPicPrefix
pic2 := strings.ReplaceAll(pic, httpsPrefix, "")
if pic2 != pic {
baseURL = AfsPicPrefixHttps
}
if pic2 = utils.TrimBlankChar(pic2); pic2 != "" {
picList2 = append(picList2, utils.GenerateGetURL(baseURL, pic2, nil))
}
}
outQuestionPic = strings.Join(picList2, ",")
}

View File

@@ -259,3 +259,29 @@ func TestCheckSelfPickCode(t *testing.T) {
t.Fatal(err.Error())
}
}
func TestProcessQuestionPic(t *testing.T) {
for _, v := range [][]string{
[]string{
"http://img10.360buyimg.com/o2o/jfs/a.jpg",
",,,jfs/a.jpg",
},
[]string{
"http://img10.360buyimg.com/o2o/jfs/a.jpg,https://img10.360buyimg.com/o2o/jfs/b.jpg",
" , ,, jfs/a.jpg,https:jfs/b.jpg",
},
[]string{
"https://img10.360buyimg.com/o2o/jfs/a.jpg",
",https:jfs/a.jpg",
},
[]string{
"",
",https:",
},
} {
str := ProcessQuestionPic(v[1])
if str != v[0] {
t.Fatalf("%s, desired:%s, but its:%s", v[1], v[0], str)
}
}
}

View File

@@ -153,7 +153,7 @@ func TestUpdateStoreFreightConfigNew(t *testing.T) {
}
func TestPrivilegeSearchUser(t *testing.T) {
result, err := api.PrivilegeSearchUser(1, 1)
result, _, _, err := api.PrivilegeSearchUser(1)
if err != nil {
t.Fatal(err)
}