Finish the prop set feature.

This commit is contained in:
zicla
2020-03-26 02:19:43 +08:00
parent 1f047e25c7
commit 4bfae38176
5 changed files with 81 additions and 9 deletions

View File

@ -6,6 +6,7 @@ import (
"github.com/eyebluecn/tank/code/tool/i18n"
"github.com/eyebluecn/tank/code/tool/result"
"github.com/eyebluecn/tank/code/tool/util"
jsoniter "github.com/json-iterator/go"
"net/http"
"regexp"
"strings"
@ -114,3 +115,31 @@ func CheckMatterName(request *http.Request, name string) string {
}
return name
}
//fetch the props
func (this *Matter) FetchPropMap() map[string]string {
m := make(map[string]string)
json := this.Prop
if json == "" {
json = EMPTY_JSON_MAP
}
err := jsoniter.ConfigCompatibleWithStandardLibrary.Unmarshal([]byte(json), &m)
if err != nil {
panic(err)
}
return m
}
//fetch the props
func (this *Matter) SetPropMap(propMap map[string]string) {
b, err := jsoniter.ConfigCompatibleWithStandardLibrary.Marshal(propMap)
if err != nil {
panic(err)
}
this.Prop = string(b)
}