This commit is contained in:
hoteas 2017-10-24 01:31:20 +00:00
parent 0e935832d3
commit 8a911ac2c7
5 changed files with 96 additions and 123 deletions

View File

@ -1,17 +0,0 @@
<component name="libraryTable">
<library name="GOPATH &lt;hotime&gt;">
<CLASSES>
<root url="file://$PROJECT_DIR$/../../golang.org" />
<root url="file://$PROJECT_DIR$/../../github.com" />
<root url="file://$PROJECT_DIR$/.." />
</CLASSES>
<SOURCES>
<root url="file://$PROJECT_DIR$/../../golang.org" />
<root url="file://$PROJECT_DIR$/../../github.com" />
<root url="file://$PROJECT_DIR$/.." />
</SOURCES>
<excluded>
<root url="file://$PROJECT_DIR$" />
</excluded>
</library>
</component>

View File

@ -5,7 +5,12 @@
</component> </component>
<component name="ChangeListManager"> <component name="ChangeListManager">
<list default="true" readonly="true" id="03ed5703-81a1-441b-849c-c426276586b7" name="Default" comment=""> <list default="true" readonly="true" id="03ed5703-81a1-441b-849c-c426276586b7" name="Default" comment="">
<change type="DELETED" beforePath="$PROJECT_DIR$/.idea/libraries/GOPATH__hotime_.xml" afterPath="" />
<change type="DELETED" beforePath="$PROJECT_DIR$/.idea/libraries" afterPath="" />
<change type="MODIFICATION" beforePath="$PROJECT_DIR$/.idea/workspace.xml" afterPath="$PROJECT_DIR$/.idea/workspace.xml" /> <change type="MODIFICATION" beforePath="$PROJECT_DIR$/.idea/workspace.xml" afterPath="$PROJECT_DIR$/.idea/workspace.xml" />
<change type="MODIFICATION" beforePath="$PROJECT_DIR$/application.go" afterPath="$PROJECT_DIR$/application.go" />
<change type="MODIFICATION" beforePath="$PROJECT_DIR$/objtoobj.go" afterPath="$PROJECT_DIR$/objtoobj.go" />
<change type="MODIFICATION" beforePath="$PROJECT_DIR$/slice.go" afterPath="$PROJECT_DIR$/slice.go" />
</list> </list>
<ignored path=".idea/dataSources.local.xml" /> <ignored path=".idea/dataSources.local.xml" />
<option name="EXCLUDED_CONVERTED_TO_IGNORED" value="true" /> <option name="EXCLUDED_CONVERTED_TO_IGNORED" value="true" />
@ -18,7 +23,6 @@
<component name="CreatePatchCommitExecutor"> <component name="CreatePatchCommitExecutor">
<option name="PATCH_PATH" value="" /> <option name="PATCH_PATH" value="" />
</component> </component>
<component name="ExecutionTargetManager" SELECTED_TARGET="default_target" />
<component name="FavoritesManager"> <component name="FavoritesManager">
<favorites_list name="hotime" /> <favorites_list name="hotime" />
</component> </component>
@ -101,7 +105,7 @@
<file leaf-file-name="objtoobj.go" pinned="false" current-in-tab="false"> <file leaf-file-name="objtoobj.go" pinned="false" current-in-tab="false">
<entry file="file://$PROJECT_DIR$/objtoobj.go"> <entry file="file://$PROJECT_DIR$/objtoobj.go">
<provider selected="true" editor-type-id="text-editor"> <provider selected="true" editor-type-id="text-editor">
<state relative-caret-position="2703"> <state relative-caret-position="2686">
<caret line="163" column="20" lean-forward="false" selection-start-line="163" selection-start-column="20" selection-end-line="163" selection-end-column="20" /> <caret line="163" column="20" lean-forward="false" selection-start-line="163" selection-start-column="20" selection-end-line="163" selection-end-column="20" />
<folding /> <folding />
</state> </state>
@ -220,58 +224,19 @@
<foldersAlwaysOnTop value="true" /> <foldersAlwaysOnTop value="true" />
</navigator> </navigator>
<panes> <panes>
<pane id="Scope" />
<pane id="Scratches" />
<pane id="ProjectPane"> <pane id="ProjectPane">
<subPane> <subPane>
<PATH> <expand>
<PATH_ELEMENT> <path>
<option name="myItemId" value="hotime" /> <item name="hotime" type="b2602c69:ProjectViewProjectNode" />
<option name="myItemType" value="com.intellij.ide.projectView.impl.nodes.ProjectViewProjectNode" /> <item name="hotime" type="2a2b976b:PhpTreeStructureProvider$1" />
</PATH_ELEMENT> </path>
<PATH_ELEMENT> </expand>
<option name="myItemId" value="hotime" /> <select />
<option name="myItemType" value="com.jetbrains.php.projectView.PhpTreeStructureProvider$1" />
</PATH_ELEMENT>
</PATH>
<PATH>
<PATH_ELEMENT>
<option name="myItemId" value="hotime" />
<option name="myItemType" value="com.intellij.ide.projectView.impl.nodes.ProjectViewProjectNode" />
</PATH_ELEMENT>
<PATH_ELEMENT>
<option name="myItemId" value="hotime" />
<option name="myItemType" value="com.jetbrains.php.projectView.PhpTreeStructureProvider$1" />
</PATH_ELEMENT>
<PATH_ELEMENT>
<option name="myItemId" value="dri" />
<option name="myItemType" value="com.jetbrains.php.projectView.PhpTreeStructureProvider$1" />
</PATH_ELEMENT>
<PATH_ELEMENT>
<option name="myItemId" value="upload" />
<option name="myItemType" value="com.jetbrains.php.projectView.PhpTreeStructureProvider$1" />
</PATH_ELEMENT>
</PATH>
<PATH>
<PATH_ELEMENT>
<option name="myItemId" value="hotime" />
<option name="myItemType" value="com.intellij.ide.projectView.impl.nodes.ProjectViewProjectNode" />
</PATH_ELEMENT>
<PATH_ELEMENT>
<option name="myItemId" value="hotime" />
<option name="myItemType" value="com.jetbrains.php.projectView.PhpTreeStructureProvider$1" />
</PATH_ELEMENT>
<PATH_ELEMENT>
<option name="myItemId" value="dri" />
<option name="myItemType" value="com.jetbrains.php.projectView.PhpTreeStructureProvider$1" />
</PATH_ELEMENT>
<PATH_ELEMENT>
<option name="myItemId" value="ddsms" />
<option name="myItemType" value="com.jetbrains.php.projectView.PhpTreeStructureProvider$1" />
</PATH_ELEMENT>
</PATH>
</subPane> </subPane>
</pane> </pane>
<pane id="Scratches" />
<pane id="Scope" />
</panes> </panes>
</component> </component>
<component name="PropertiesComponent"> <component name="PropertiesComponent">
@ -307,33 +272,21 @@
</option> </option>
</component> </component>
<component name="RunManager" selected="Go Application.Build main.go and run"> <component name="RunManager" selected="Go Application.Build main.go and run">
<configuration default="false" name="Build main.go and run" type="GoApplicationRunConfiguration" factoryName="Go Application" temporary="true"> <configuration name="Build main.go and run" type="GoApplicationRunConfiguration" factoryName="Go Application" temporary="true">
<module name="hotime" /> <module name="hotime" />
<working_directory value="$PROJECT_DIR$/" /> <working_directory value="$PROJECT_DIR$/" />
<go_parameters value="-i" /> <go_parameters value="-i" />
<filePath value="$PROJECT_DIR$/example/main.go" />
<kind value="FILE" /> <kind value="FILE" />
<filePath value="$PROJECT_DIR$/example/main.go" />
<package value="hoteas/hotime" /> <package value="hoteas/hotime" />
<method />
</configuration>
<configuration default="true" type="CodeceptionConfigurationType" factoryName="Codeception">
<PhpTestRunnerSettings />
<method />
</configuration> </configuration>
<configuration default="true" type="GoApplicationRunConfiguration" factoryName="Go Application"> <configuration default="true" type="GoApplicationRunConfiguration" factoryName="Go Application">
<module name="hotime" /> <module name="hotime" />
<working_directory value="$PROJECT_DIR$/" /> <working_directory value="$PROJECT_DIR$/" />
<go_parameters value="-i" /> <go_parameters value="-i" />
<filePath value="$PROJECT_DIR$/" />
<kind value="FILE" /> <kind value="FILE" />
<package value="hoteas/hotime" />
<method />
</configuration>
<configuration default="true" type="GoRunFileConfiguration" factoryName="Go Single File">
<module name="hotime" />
<working_directory value="$PROJECT_DIR$/" />
<filePath value="$PROJECT_DIR$/" /> <filePath value="$PROJECT_DIR$/" />
<method /> <package value="hoteas/hotime" />
</configuration> </configuration>
<configuration default="true" type="GoTestRunConfiguration" factoryName="Go Test"> <configuration default="true" type="GoTestRunConfiguration" factoryName="Go Test">
<module name="hotime" /> <module name="hotime" />
@ -342,6 +295,23 @@
<framework value="gotest" /> <framework value="gotest" />
<kind value="DIRECTORY" /> <kind value="DIRECTORY" />
<package value="hoteas/hotime" /> <package value="hoteas/hotime" />
</configuration>
<configuration default="true" type="js.build_tools.gulp" factoryName="Gulp.js">
<node-interpreter>project</node-interpreter>
<node-options />
<gulpfile />
<tasks />
<arguments />
<envs />
</configuration>
<configuration default="true" type="CodeceptionConfigurationType" factoryName="Codeception">
<PhpTestRunnerSettings />
<method />
</configuration>
<configuration default="true" type="GoRunFileConfiguration" factoryName="Go Single File">
<module name="hotime" />
<working_directory value="$PROJECT_DIR$/" />
<filePath value="$PROJECT_DIR$/" />
<method /> <method />
</configuration> </configuration>
<configuration default="true" type="JavaScriptTestRunnerJest" factoryName="Jest"> <configuration default="true" type="JavaScriptTestRunnerJest" factoryName="Jest">
@ -378,15 +348,6 @@
<PhpTestRunnerSettings /> <PhpTestRunnerSettings />
<method /> <method />
</configuration> </configuration>
<configuration default="true" type="js.build_tools.gulp" factoryName="Gulp.js">
<node-interpreter>project</node-interpreter>
<node-options />
<gulpfile />
<tasks />
<arguments />
<envs />
<method />
</configuration>
<configuration default="true" type="js.build_tools.npm" factoryName="npm"> <configuration default="true" type="js.build_tools.npm" factoryName="npm">
<command value="run" /> <command value="run" />
<scripts /> <scripts />
@ -407,9 +368,6 @@
<recursive>false</recursive> <recursive>false</recursive>
<method /> <method />
</configuration> </configuration>
<list size="1">
<item index="0" class="java.lang.String" itemvalue="Go Application.Build main.go and run" />
</list>
<recent_temporary> <recent_temporary>
<list size="1"> <list size="1">
<item index="0" class="java.lang.String" itemvalue="Go Application.Build main.go and run" /> <item index="0" class="java.lang.String" itemvalue="Go Application.Build main.go and run" />
@ -476,6 +434,7 @@
<workItem from="1504488391347" duration="840000" /> <workItem from="1504488391347" duration="840000" />
<workItem from="1504575702799" duration="11303000" /> <workItem from="1504575702799" duration="11303000" />
<workItem from="1504661068799" duration="698000" /> <workItem from="1504661068799" duration="698000" />
<workItem from="1508808650888" duration="41000" />
</task> </task>
<task id="LOCAL-00001"> <task id="LOCAL-00001">
<created>1500458878821</created> <created>1500458878821</created>
@ -663,7 +622,7 @@
<servers /> <servers />
</component> </component>
<component name="TimeTrackingManager"> <component name="TimeTrackingManager">
<option name="totallyTimeSpent" value="89539000" /> <option name="totallyTimeSpent" value="89580000" />
</component> </component>
<component name="TodoView"> <component name="TodoView">
<todo-panel id="selected-file"> <todo-panel id="selected-file">
@ -677,16 +636,16 @@
<component name="ToolWindowManager"> <component name="ToolWindowManager">
<frame x="55" y="-8" width="1873" height="1084" extended-state="0" /> <frame x="55" y="-8" width="1873" height="1084" extended-state="0" />
<layout> <layout>
<window_info id="Project" active="true" anchor="left" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="true" show_stripe_button="true" weight="0.34142306" sideWeight="0.5" order="0" side_tool="false" content_ui="combo" /> <window_info id="Project" active="true" anchor="left" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="true" show_stripe_button="true" weight="0.34528404" sideWeight="0.5" order="0" side_tool="false" content_ui="combo" />
<window_info id="TODO" active="false" anchor="bottom" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" show_stripe_button="true" weight="0.32846716" sideWeight="0.5" order="6" side_tool="false" content_ui="tabs" /> <window_info id="TODO" active="false" anchor="bottom" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" show_stripe_button="true" weight="0.32846716" sideWeight="0.5" order="6" side_tool="false" content_ui="tabs" />
<window_info id="Event Log" active="false" anchor="bottom" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" show_stripe_button="true" weight="0.33" sideWeight="0.5" order="7" side_tool="true" content_ui="tabs" /> <window_info id="Event Log" active="false" anchor="bottom" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" show_stripe_button="true" weight="0.33" sideWeight="0.5" order="7" side_tool="true" content_ui="tabs" />
<window_info id="Database" active="false" anchor="right" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" show_stripe_button="true" weight="0.33" sideWeight="0.5" order="3" side_tool="false" content_ui="tabs" /> <window_info id="Database" active="false" anchor="right" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" show_stripe_button="true" weight="0.33" sideWeight="0.5" order="3" side_tool="false" content_ui="tabs" />
<window_info id="Version Control" active="false" anchor="bottom" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" show_stripe_button="true" weight="0.6330179" sideWeight="0.5" order="7" side_tool="false" content_ui="tabs" />
<window_info id="Run" active="false" anchor="bottom" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" show_stripe_button="true" weight="0.32912722" sideWeight="0.5" order="2" side_tool="false" content_ui="tabs" /> <window_info id="Run" active="false" anchor="bottom" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" show_stripe_button="true" weight="0.32912722" sideWeight="0.5" order="2" side_tool="false" content_ui="tabs" />
<window_info id="Version Control" active="false" anchor="bottom" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" show_stripe_button="true" weight="0.6330179" sideWeight="0.5" order="7" side_tool="false" content_ui="tabs" />
<window_info id="Structure" active="false" anchor="left" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" show_stripe_button="true" weight="0.24972437" sideWeight="0.5" order="1" side_tool="false" content_ui="tabs" /> <window_info id="Structure" active="false" anchor="left" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" show_stripe_button="true" weight="0.24972437" sideWeight="0.5" order="1" side_tool="false" content_ui="tabs" />
<window_info id="Terminal" active="false" anchor="bottom" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" show_stripe_button="true" weight="0.32846716" sideWeight="0.5" order="7" side_tool="false" content_ui="tabs" /> <window_info id="Terminal" active="false" anchor="bottom" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" show_stripe_button="true" weight="0.32846716" sideWeight="0.5" order="7" side_tool="false" content_ui="tabs" />
<window_info id="Favorites" active="false" anchor="left" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" show_stripe_button="true" weight="0.33" sideWeight="0.5" order="2" side_tool="true" content_ui="tabs" />
<window_info id="Debug" active="false" anchor="bottom" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" show_stripe_button="true" weight="0.3997923" sideWeight="0.5" order="3" side_tool="false" content_ui="tabs" /> <window_info id="Debug" active="false" anchor="bottom" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" show_stripe_button="true" weight="0.3997923" sideWeight="0.5" order="3" side_tool="false" content_ui="tabs" />
<window_info id="Favorites" active="false" anchor="left" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" show_stripe_button="true" weight="0.33" sideWeight="0.5" order="2" side_tool="true" content_ui="tabs" />
<window_info id="Cvs" active="false" anchor="bottom" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" show_stripe_button="true" weight="0.25" sideWeight="0.5" order="4" side_tool="false" content_ui="tabs" /> <window_info id="Cvs" active="false" anchor="bottom" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" show_stripe_button="true" weight="0.25" sideWeight="0.5" order="4" side_tool="false" content_ui="tabs" />
<window_info id="Messages" active="false" anchor="bottom" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" show_stripe_button="true" weight="0.33" sideWeight="0.5" order="7" side_tool="false" content_ui="tabs" /> <window_info id="Messages" active="false" anchor="bottom" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" show_stripe_button="true" weight="0.33" sideWeight="0.5" order="7" side_tool="false" content_ui="tabs" />
<window_info id="Message" active="false" anchor="bottom" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" show_stripe_button="true" weight="0.33" sideWeight="0.5" order="0" side_tool="false" content_ui="tabs" /> <window_info id="Message" active="false" anchor="bottom" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" show_stripe_button="true" weight="0.33" sideWeight="0.5" order="0" side_tool="false" content_ui="tabs" />
@ -701,7 +660,7 @@
</layout> </layout>
</component> </component>
<component name="TypeScriptGeneratedFilesManager"> <component name="TypeScriptGeneratedFilesManager">
<option name="processedProjectFiles" value="true" /> <option name="version" value="1" />
</component> </component>
<component name="VcsContentAnnotationSettings"> <component name="VcsContentAnnotationSettings">
<option name="myLimit" value="2678400000" /> <option name="myLimit" value="2678400000" />
@ -919,7 +878,6 @@
<provider selected="true" editor-type-id="text-editor"> <provider selected="true" editor-type-id="text-editor">
<state relative-caret-position="102"> <state relative-caret-position="102">
<caret line="6" column="0" lean-forward="false" selection-start-line="6" selection-start-column="0" selection-end-line="6" selection-end-column="0" /> <caret line="6" column="0" lean-forward="false" selection-start-line="6" selection-start-column="0" selection-end-line="6" selection-end-column="0" />
<folding />
</state> </state>
</provider> </provider>
</entry> </entry>
@ -990,7 +948,7 @@
</entry> </entry>
<entry file="file://$PROJECT_DIR$/objtoobj.go"> <entry file="file://$PROJECT_DIR$/objtoobj.go">
<provider selected="true" editor-type-id="text-editor"> <provider selected="true" editor-type-id="text-editor">
<state relative-caret-position="2703"> <state relative-caret-position="2686">
<caret line="163" column="20" lean-forward="false" selection-start-line="163" selection-start-column="20" selection-end-line="163" selection-end-column="20" /> <caret line="163" column="20" lean-forward="false" selection-start-line="163" selection-start-column="20" selection-end-line="163" selection-end-column="20" />
<folding /> <folding />
</state> </state>

View File

@ -33,7 +33,7 @@ func (this *Application) Run(router Router) {
//this.Port = port //this.Port = port
this.Port = this.Config.GetString("port") this.Port = this.Config.GetString("port")
if this.connectDbFunc != nil { if this.connectDbFunc != nil && this.Db.DB.Ping() != nil {
this.Db.SetConnect(this.connectDbFunc) this.Db.SetConnect(this.connectDbFunc)
} }
@ -57,6 +57,7 @@ func (this *Application) Run(router Router) {
//启动实例 //启动实例
func (this *Application) SetConnectDB(connect func(err ...*Error) *sql.DB) { func (this *Application) SetConnectDB(connect func(err ...*Error) *sql.DB) {
this.connectDbFunc = connect this.connectDbFunc = connect
this.Db.SetConnect(this.connectDbFunc)
} }
//设置配置文件路径全路径或者相对路径 //设置配置文件路径全路径或者相对路径
@ -70,6 +71,10 @@ func (this *Application) SetSession(short CacheIns, Long CacheIns) {
func (this *Application) SetDefault(connect func(err ...*Error) *sql.DB) { func (this *Application) SetDefault(connect func(err ...*Error) *sql.DB) {
this.SetConfig() this.SetConfig()
this.connectDbFunc = connect this.connectDbFunc = connect
if this.connectDbFunc!=nil{
this.Db.SetConnect(this.connectDbFunc)
}
//防止手动设置缓存误伤 //防止手动设置缓存误伤
if this.CacheIns == nil { if this.CacheIns == nil {
this.SetCache(CacheIns(&CacheMemory{})) this.SetCache(CacheIns(&CacheMemory{}))

View File

@ -1,9 +1,10 @@
package hotime package hotime
import ( import (
"encoding/json"
"errors" "errors"
"strconv" "strconv"
"encoding/json" "strings"
) )
//仅限于hotime.Slice //仅限于hotime.Slice
@ -16,14 +17,16 @@ func ObjToMap(obj interface{},e... *Error) Map {
err = errors.New("没有合适的转换对象!") err = errors.New("没有合适的转换对象!")
} else { } else {
switch obj.(type) { switch obj.(type) {
case Map:v = obj.(Map) case Map:
case map[string]interface {}:v=obj.(map[string]interface{}) v = obj.(Map)
case map[string]interface{}:
v = obj.(map[string]interface{})
default: default:
v = nil v = nil
err = errors.New("没有合适的转换对象!") err = errors.New("没有合适的转换对象!")
} }
} }
if(len(e)!=0){ if len(e) != 0 {
e[0].SetError(err) e[0].SetError(err)
} }
return v return v
@ -41,14 +44,15 @@ func ObjToSlice(obj interface{},e... *Error) Slice{
switch obj.(type) { switch obj.(type) {
case Slice: case Slice:
v = obj.(Slice) v = obj.(Slice)
case []interface {}:v=obj.([]interface{}) case []interface{}:
v = obj.([]interface{})
default: default:
v = nil v = nil
err = errors.New("没有合适的转换对象!") err = errors.New("没有合适的转换对象!")
} }
} }
if(len(e)!=0){ if len(e) != 0 {
e[0].SetError(err) e[0].SetError(err)
} }
@ -94,7 +98,7 @@ func ObjToFloat64(obj interface{},e... *Error) float64 {
err = errors.New("没有合适的转换对象!") err = errors.New("没有合适的转换对象!")
} }
} }
if(len(e)!=0){ if len(e) != 0 {
e[0].SetError(err) e[0].SetError(err)
} }
return v return v
@ -138,7 +142,7 @@ func ObjToInt64(obj interface{},e... *Error) int64 {
err = errors.New("没有合适的转换对象!") err = errors.New("没有合适的转换对象!")
} }
} }
if(len(e)!=0){ if len(e) != 0 {
e[0].SetError(err) e[0].SetError(err)
} }
return v return v
@ -182,7 +186,7 @@ func ObjToInt(obj interface{},e... *Error) int {
} }
} }
if(len(e)!=0){ if len(e) != 0 {
e[0].SetError(err) e[0].SetError(err)
} }
return v return v
@ -208,7 +212,7 @@ func ObjToStr(obj interface{}) string {
case float64: case float64:
str = strconv.FormatFloat(obj.(float64), 'f', 6, 64) str = strconv.FormatFloat(obj.(float64), 'f', 6, 64)
default: default:
strbte,err:=json.Marshal(obj); strbte, err := json.Marshal(obj)
if err == nil { if err == nil {
str = string(strbte) str = string(strbte)
} }
@ -218,6 +222,27 @@ func ObjToStr(obj interface{}) string {
return str return str
} }
//字符串数组: a1,a2,a3转["a1","a2","a3"]
func StrArrayToJsonStr(a string) string {
if len(a) != 0 {
a = strings.Replace(a, ",", `","`, -1)
a = `["` + a + `"]`
} else {
a = "[]"
}
return a
}
//字符串数组: a1,a2,a3转["a1","a2","a3"]
func JsonStrToStrArray(a string) string {
a = strings.Replace(a, `"`, "", -1)
if len(a)!=0{
a = Substr(a, 1, len(a)-2)
}
return a
}
//字符串转int //字符串转int
func StrToInt(s string) (int, error) { func StrToInt(s string) (int, error) {
i, err := strconv.Atoi(s) i, err := strconv.Atoi(s)

View File

@ -62,10 +62,12 @@ func (this Slice) Put(key int, value interface{}) {
this[key] = value this[key] = value
} }
func (this Slice) GetJsonString() string { func (this Slice) ToJsonString() string {
return ObjToStr(this) return ObjToStr(this)
} }
func (this Slice) JsonToSlice(jsonStr string) { func (this Slice) JsonToSlice(jsonStr string) {
json.Unmarshal([]byte(jsonStr), &this) json.Unmarshal([]byte(jsonStr), &this)