管理端初步
This commit is contained in:
parent
822d9708e4
commit
66c4b177c1
@ -6,7 +6,6 @@
|
||||
<component name="ChangeListManager">
|
||||
<list default="true" readonly="true" id="03ed5703-81a1-441b-849c-c426276586b7" name="Default" comment="">
|
||||
<change type="MODIFICATION" beforePath="$PROJECT_DIR$/.idea/workspace.xml" afterPath="$PROJECT_DIR$/.idea/workspace.xml" />
|
||||
<change type="MODIFICATION" beforePath="$PROJECT_DIR$/config/config.json" afterPath="$PROJECT_DIR$/config/config.json" />
|
||||
<change type="MODIFICATION" beforePath="$PROJECT_DIR$/example/main.go" afterPath="$PROJECT_DIR$/example/main.go" />
|
||||
<change type="MODIFICATION" beforePath="$PROJECT_DIR$/map.go" afterPath="$PROJECT_DIR$/map.go" />
|
||||
</list>
|
||||
@ -50,10 +49,10 @@
|
||||
<file leaf-file-name="map.go" pinned="false" current-in-tab="true">
|
||||
<entry file="file://$PROJECT_DIR$/map.go">
|
||||
<provider selected="true" editor-type-id="text-editor">
|
||||
<state relative-caret-position="184">
|
||||
<caret line="47" column="16" lean-forward="false" selection-start-line="47" selection-start-column="16" selection-end-line="47" selection-end-column="16" />
|
||||
<state relative-caret-position="303">
|
||||
<caret line="43" column="0" lean-forward="true" selection-start-line="43" selection-start-column="0" selection-end-line="43" selection-end-column="0" />
|
||||
<folding>
|
||||
<element signature="e#16#74#0" expanded="true" />
|
||||
<element signature="e#16#64#0" expanded="true" />
|
||||
</folding>
|
||||
</state>
|
||||
</provider>
|
||||
@ -62,10 +61,10 @@
|
||||
<file leaf-file-name="main.go" pinned="false" current-in-tab="false">
|
||||
<entry file="file://$PROJECT_DIR$/example/main.go">
|
||||
<provider selected="true" editor-type-id="text-editor">
|
||||
<state relative-caret-position="85">
|
||||
<caret line="13" column="7" lean-forward="true" selection-start-line="13" selection-start-column="7" selection-end-line="13" selection-end-column="7" />
|
||||
<state relative-caret-position="238">
|
||||
<caret line="14" column="17" lean-forward="false" selection-start-line="14" selection-start-column="17" selection-end-line="14" selection-end-column="17" />
|
||||
<folding>
|
||||
<element signature="e#14#100#0" expanded="true" />
|
||||
<element signature="e#14#102#0" expanded="true" />
|
||||
</folding>
|
||||
</state>
|
||||
</provider>
|
||||
@ -84,8 +83,8 @@
|
||||
<file leaf-file-name="objtoobj.go" pinned="false" current-in-tab="false">
|
||||
<entry file="file://$PROJECT_DIR$/objtoobj.go">
|
||||
<provider selected="true" editor-type-id="text-editor">
|
||||
<state relative-caret-position="308">
|
||||
<caret line="32" column="5" lean-forward="false" selection-start-line="32" selection-start-column="5" selection-end-line="32" selection-end-column="5" />
|
||||
<state relative-caret-position="493">
|
||||
<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 />
|
||||
</state>
|
||||
</provider>
|
||||
@ -125,7 +124,7 @@
|
||||
<entry file="file://$PROJECT_DIR$/cache_memory.go">
|
||||
<provider selected="true" editor-type-id="text-editor">
|
||||
<state relative-caret-position="816">
|
||||
<caret line="92" column="1" lean-forward="true" selection-start-line="92" selection-start-column="1" selection-end-line="92" selection-end-column="1" />
|
||||
<caret line="92" column="1" lean-forward="false" selection-start-line="92" selection-start-column="1" selection-end-line="92" selection-end-column="1" />
|
||||
<folding />
|
||||
</state>
|
||||
</provider>
|
||||
@ -184,8 +183,8 @@
|
||||
<option value="$PROJECT_DIR$/error.go" />
|
||||
<option value="$PROJECT_DIR$/const.go" />
|
||||
<option value="$PROJECT_DIR$/session.go" />
|
||||
<option value="$PROJECT_DIR$/example/main.go" />
|
||||
<option value="$PROJECT_DIR$/map.go" />
|
||||
<option value="$PROJECT_DIR$/example/main.go" />
|
||||
</list>
|
||||
</option>
|
||||
</component>
|
||||
@ -451,7 +450,7 @@
|
||||
<workItem from="1504252839700" duration="18000" />
|
||||
<workItem from="1504488004086" duration="365000" />
|
||||
<workItem from="1504488391347" duration="840000" />
|
||||
<workItem from="1504575702799" duration="3525000" />
|
||||
<workItem from="1504575702799" duration="4395000" />
|
||||
</task>
|
||||
<task id="LOCAL-00001">
|
||||
<created>1500458878821</created>
|
||||
@ -600,11 +599,18 @@
|
||||
<option name="project" value="LOCAL" />
|
||||
<updated>1504575745842</updated>
|
||||
</task>
|
||||
<option name="localTasksCounter" value="22" />
|
||||
<task id="LOCAL-00022" summary="管理端初步">
|
||||
<created>1504579259295</created>
|
||||
<option name="number" value="00022" />
|
||||
<option name="presentableId" value="LOCAL-00022" />
|
||||
<option name="project" value="LOCAL" />
|
||||
<updated>1504579259295</updated>
|
||||
</task>
|
||||
<option name="localTasksCounter" value="23" />
|
||||
<servers />
|
||||
</component>
|
||||
<component name="TimeTrackingManager">
|
||||
<option name="totallyTimeSpent" value="81063000" />
|
||||
<option name="totallyTimeSpent" value="81933000" />
|
||||
</component>
|
||||
<component name="TodoView">
|
||||
<todo-panel id="selected-file">
|
||||
@ -623,7 +629,7 @@
|
||||
<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="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.63343716" sideWeight="0.5" order="7" 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="true" show_stripe_button="true" weight="0.32912722" sideWeight="0.5" order="2" 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" />
|
||||
@ -961,14 +967,6 @@
|
||||
</state>
|
||||
</provider>
|
||||
</entry>
|
||||
<entry file="file://$PROJECT_DIR$/objtoobj.go">
|
||||
<provider selected="true" editor-type-id="text-editor">
|
||||
<state relative-caret-position="308">
|
||||
<caret line="32" column="5" lean-forward="false" selection-start-line="32" selection-start-column="5" selection-end-line="32" selection-end-column="5" />
|
||||
<folding />
|
||||
</state>
|
||||
</provider>
|
||||
</entry>
|
||||
<entry file="file://$PROJECT_DIR$/session.go">
|
||||
<provider selected="true" editor-type-id="text-editor">
|
||||
<state relative-caret-position="969">
|
||||
@ -980,7 +978,7 @@
|
||||
<entry file="file://$PROJECT_DIR$/cache_memory.go">
|
||||
<provider selected="true" editor-type-id="text-editor">
|
||||
<state relative-caret-position="816">
|
||||
<caret line="92" column="1" lean-forward="true" selection-start-line="92" selection-start-column="1" selection-end-line="92" selection-end-column="1" />
|
||||
<caret line="92" column="1" lean-forward="false" selection-start-line="92" selection-start-column="1" selection-end-line="92" selection-end-column="1" />
|
||||
<folding />
|
||||
</state>
|
||||
</provider>
|
||||
@ -1001,22 +999,30 @@
|
||||
</state>
|
||||
</provider>
|
||||
</entry>
|
||||
<entry file="file://$PROJECT_DIR$/objtoobj.go">
|
||||
<provider selected="true" editor-type-id="text-editor">
|
||||
<state relative-caret-position="493">
|
||||
<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 />
|
||||
</state>
|
||||
</provider>
|
||||
</entry>
|
||||
<entry file="file://$PROJECT_DIR$/example/main.go">
|
||||
<provider selected="true" editor-type-id="text-editor">
|
||||
<state relative-caret-position="85">
|
||||
<caret line="13" column="7" lean-forward="true" selection-start-line="13" selection-start-column="7" selection-end-line="13" selection-end-column="7" />
|
||||
<state relative-caret-position="238">
|
||||
<caret line="14" column="17" lean-forward="false" selection-start-line="14" selection-start-column="17" selection-end-line="14" selection-end-column="17" />
|
||||
<folding>
|
||||
<element signature="e#14#100#0" expanded="true" />
|
||||
<element signature="e#14#102#0" expanded="true" />
|
||||
</folding>
|
||||
</state>
|
||||
</provider>
|
||||
</entry>
|
||||
<entry file="file://$PROJECT_DIR$/map.go">
|
||||
<provider selected="true" editor-type-id="text-editor">
|
||||
<state relative-caret-position="184">
|
||||
<caret line="47" column="16" lean-forward="false" selection-start-line="47" selection-start-column="16" selection-end-line="47" selection-end-column="16" />
|
||||
<state relative-caret-position="303">
|
||||
<caret line="43" column="0" lean-forward="true" selection-start-line="43" selection-start-column="0" selection-end-line="43" selection-end-column="0" />
|
||||
<folding>
|
||||
<element signature="e#16#74#0" expanded="true" />
|
||||
<element signature="e#16#64#0" expanded="true" />
|
||||
</folding>
|
||||
</state>
|
||||
</provider>
|
||||
|
@ -5,20 +5,27 @@ import (
|
||||
_ "github.com/go-sql-driver/mysql"
|
||||
"go.hoteas.com/hotime"
|
||||
"time"
|
||||
"fmt"
|
||||
//"fmt"
|
||||
)
|
||||
|
||||
func main() {
|
||||
|
||||
a:=hotime.Map{}
|
||||
a.Get("y")
|
||||
for i:=0;i<300 ;i++ {
|
||||
a.Put("x",1)
|
||||
for i:=0;i<30 ;i++ {
|
||||
go func() {
|
||||
for j:=0;j<30 ;j++ {
|
||||
if j/2==0{
|
||||
a.Put("x","1")
|
||||
}else {
|
||||
fmt.Println(a.GetInt64("x"))
|
||||
hotime.SafeMutex("test", func() interface{} {
|
||||
|
||||
a.Put("x","1")
|
||||
|
||||
|
||||
return nil
|
||||
})
|
||||
}else {
|
||||
//fmt.Println(a.GetInt64("x"))
|
||||
a.Delete("x")
|
||||
}
|
||||
|
||||
}
|
||||
|
160
map.go
160
map.go
@ -4,7 +4,6 @@ import (
|
||||
"encoding/json"
|
||||
"errors"
|
||||
"reflect"
|
||||
//"time"
|
||||
)
|
||||
|
||||
//hotime的常用map
|
||||
@ -12,12 +11,11 @@ type Map map[string]interface{}
|
||||
|
||||
//获取string
|
||||
func (this Map) GetString(key string, err ...*Error) string {
|
||||
return SafeMutex(this.GetTag(), func() interface{} {
|
||||
if len(err) != 0 {
|
||||
err[0].SetError(nil)
|
||||
}
|
||||
return ObjToStr((this)[key])
|
||||
}).(string)
|
||||
|
||||
if len(err) != 0 {
|
||||
err[0].SetError(nil)
|
||||
}
|
||||
return ObjToStr((this)[key])
|
||||
|
||||
}
|
||||
|
||||
@ -28,159 +26,109 @@ func (this *Map) Pointer() *Map {
|
||||
|
||||
//增加接口
|
||||
func (this Map) Put(key string, value interface{}) {
|
||||
SafeMutex(this.GetTag(), func() interface{} {
|
||||
this[key] = value
|
||||
return nil
|
||||
})
|
||||
|
||||
//if this==nil{
|
||||
// this=Map{}
|
||||
//}
|
||||
this[key] = value
|
||||
}
|
||||
|
||||
//删除接口
|
||||
func (this Map) Delete(key string) {
|
||||
SafeMutex(this.GetTag(), func() interface{} {
|
||||
delete(this, key)
|
||||
return nil
|
||||
})
|
||||
delete(this, key)
|
||||
|
||||
}
|
||||
|
||||
//唯一标志
|
||||
func (this Map) GetTag() string {
|
||||
|
||||
//return SafeMutex(MUTEX_MAP, func() interface{} {
|
||||
// if this[MUTEX_MAP] == nil {
|
||||
// this[MUTEX_MAP] = ObjToStr(time.Now().UnixNano())
|
||||
//
|
||||
// }
|
||||
// return ObjToStr(this[MUTEX_MAP])
|
||||
//}).(string)
|
||||
return MUTEX_MAP
|
||||
}
|
||||
|
||||
//获取Int
|
||||
func (this Map) GetInt(key string, err ...*Error) int {
|
||||
v := ObjToInt((this)[key], err...)
|
||||
|
||||
return SafeMutex(this.GetTag(), func() interface{} {
|
||||
v := ObjToInt((this)[key], err...)
|
||||
return v
|
||||
}).(int)
|
||||
return v
|
||||
|
||||
}
|
||||
|
||||
//获取Int
|
||||
func (this Map) GetInt64(key string, err ...*Error) int64 {
|
||||
|
||||
return SafeMutex(this.GetTag(), func() interface{} {
|
||||
v := ObjToInt64((this)[key], err...)
|
||||
return v
|
||||
}).(int64)
|
||||
v := ObjToInt64((this)[key], err...)
|
||||
return v
|
||||
|
||||
}
|
||||
|
||||
//获取Float64
|
||||
func (this Map) GetFloat64(key string, err ...*Error) float64 {
|
||||
|
||||
return SafeMutex(this.GetTag(), func() interface{} {
|
||||
v := ObjToFloat64((this)[key], err...)
|
||||
return v
|
||||
}).(float64)
|
||||
v := ObjToFloat64((this)[key], err...)
|
||||
|
||||
return v
|
||||
|
||||
}
|
||||
|
||||
func (this Map) GetSlice(key string, err ...*Error) Slice {
|
||||
|
||||
res := SafeMutex(this.GetTag(), func() interface{} {
|
||||
v := ObjToSlice((this)[key], err...)
|
||||
return v
|
||||
})
|
||||
//var v Slice
|
||||
if res != nil {
|
||||
return res.(Slice)
|
||||
}
|
||||
v := ObjToSlice((this)[key], err...)
|
||||
|
||||
return nil
|
||||
return v
|
||||
|
||||
}
|
||||
|
||||
func (this Map) GetMap(key string, err ...*Error) Map {
|
||||
//var data Slice
|
||||
|
||||
res := SafeMutex(this.GetTag(), func() interface{} {
|
||||
v := ObjToMap((this)[key], err...)
|
||||
return v
|
||||
})
|
||||
//var v Slice
|
||||
if res != nil {
|
||||
return res.(Map)
|
||||
}
|
||||
v := ObjToMap((this)[key], err...)
|
||||
|
||||
return nil
|
||||
return v
|
||||
|
||||
}
|
||||
|
||||
func (this Map) Get(key string, err ...*Error) interface{} {
|
||||
|
||||
res := SafeMutex(this.GetTag(), func() interface{} {
|
||||
if v, ok := (this)[key]; ok {
|
||||
return v
|
||||
}
|
||||
e := errors.New("没有存储key及对应的数据")
|
||||
if v, ok := (this)[key]; ok {
|
||||
return v
|
||||
}
|
||||
e := errors.New("没有存储key及对应的数据")
|
||||
|
||||
if len(err) != 0 {
|
||||
err[0].SetError(e)
|
||||
|
||||
}
|
||||
return nil
|
||||
})
|
||||
|
||||
return res
|
||||
if len(err) != 0 {
|
||||
err[0].SetError(e)
|
||||
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
//请传递指针过来
|
||||
func (this Map) ToStruct(stct interface{}) {
|
||||
|
||||
SafeMutex(this.GetTag(), func() interface{} {
|
||||
data := reflect.ValueOf(stct).Elem()
|
||||
for k, v := range this {
|
||||
ks := StrFirstToUpper(k)
|
||||
dkey := data.FieldByName(ks)
|
||||
if !dkey.IsValid() {
|
||||
continue
|
||||
}
|
||||
switch dkey.Type().String() {
|
||||
case "int":
|
||||
dkey.SetInt(this.GetInt64(k))
|
||||
case "int64":
|
||||
dkey.Set(reflect.ValueOf(this.GetInt64(k)))
|
||||
case "float64":
|
||||
dkey.Set(reflect.ValueOf(this.GetFloat64(k)))
|
||||
case "string":
|
||||
dkey.Set(reflect.ValueOf(this.GetString(k)))
|
||||
case "interface{}":
|
||||
dkey.Set(reflect.ValueOf(v))
|
||||
}
|
||||
data := reflect.ValueOf(stct).Elem()
|
||||
for k, v := range this {
|
||||
ks := StrFirstToUpper(k)
|
||||
dkey := data.FieldByName(ks)
|
||||
if !dkey.IsValid() {
|
||||
continue
|
||||
}
|
||||
return nil
|
||||
})
|
||||
switch dkey.Type().String() {
|
||||
case "int":
|
||||
dkey.SetInt(this.GetInt64(k))
|
||||
case "int64":
|
||||
dkey.Set(reflect.ValueOf(this.GetInt64(k)))
|
||||
case "float64":
|
||||
dkey.Set(reflect.ValueOf(this.GetFloat64(k)))
|
||||
case "string":
|
||||
dkey.Set(reflect.ValueOf(this.GetString(k)))
|
||||
case "interface{}":
|
||||
dkey.Set(reflect.ValueOf(v))
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
func (this Map) ToJsonString() string {
|
||||
res := SafeMutex(this.GetTag(), func() interface{} {
|
||||
return ObjToStr(this)
|
||||
})
|
||||
return res.(string)
|
||||
return ObjToStr(this)
|
||||
|
||||
}
|
||||
|
||||
func (this Map) JsonToMap(jsonStr string, err ...*Error) {
|
||||
|
||||
SafeMutex(this.GetTag(), func() interface{} {
|
||||
e := json.Unmarshal([]byte(jsonStr), &this)
|
||||
if e != nil && len(err) != 0 {
|
||||
err[0].SetError(e)
|
||||
}
|
||||
return nil
|
||||
})
|
||||
e := json.Unmarshal([]byte(jsonStr), &this)
|
||||
if e != nil && len(err) != 0 {
|
||||
err[0].SetError(e)
|
||||
}
|
||||
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user