管理端初步
This commit is contained in:
parent
66c4b177c1
commit
cd242cc9d6
@ -7,7 +7,6 @@
|
|||||||
<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="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$/example/main.go" afterPath="$PROJECT_DIR$/example/main.go" />
|
<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>
|
</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" />
|
||||||
@ -46,7 +45,7 @@
|
|||||||
</provider>
|
</provider>
|
||||||
</entry>
|
</entry>
|
||||||
</file>
|
</file>
|
||||||
<file leaf-file-name="map.go" pinned="false" current-in-tab="true">
|
<file leaf-file-name="map.go" pinned="false" current-in-tab="false">
|
||||||
<entry file="file://$PROJECT_DIR$/map.go">
|
<entry file="file://$PROJECT_DIR$/map.go">
|
||||||
<provider selected="true" editor-type-id="text-editor">
|
<provider selected="true" editor-type-id="text-editor">
|
||||||
<state relative-caret-position="303">
|
<state relative-caret-position="303">
|
||||||
@ -58,13 +57,13 @@
|
|||||||
</provider>
|
</provider>
|
||||||
</entry>
|
</entry>
|
||||||
</file>
|
</file>
|
||||||
<file leaf-file-name="main.go" pinned="false" current-in-tab="false">
|
<file leaf-file-name="main.go" pinned="false" current-in-tab="true">
|
||||||
<entry file="file://$PROJECT_DIR$/example/main.go">
|
<entry file="file://$PROJECT_DIR$/example/main.go">
|
||||||
<provider selected="true" editor-type-id="text-editor">
|
<provider selected="true" editor-type-id="text-editor">
|
||||||
<state relative-caret-position="238">
|
<state relative-caret-position="289">
|
||||||
<caret line="14" column="17" lean-forward="false" selection-start-line="14" selection-start-column="17" selection-end-line="14" selection-end-column="17" />
|
<caret line="17" column="11" lean-forward="true" selection-start-line="17" selection-start-column="11" selection-end-line="17" selection-end-column="11" />
|
||||||
<folding>
|
<folding>
|
||||||
<element signature="e#14#102#0" expanded="true" />
|
<element signature="e#14#137#0" expanded="true" />
|
||||||
</folding>
|
</folding>
|
||||||
</state>
|
</state>
|
||||||
</provider>
|
</provider>
|
||||||
@ -450,7 +449,7 @@
|
|||||||
<workItem from="1504252839700" duration="18000" />
|
<workItem from="1504252839700" duration="18000" />
|
||||||
<workItem from="1504488004086" duration="365000" />
|
<workItem from="1504488004086" duration="365000" />
|
||||||
<workItem from="1504488391347" duration="840000" />
|
<workItem from="1504488391347" duration="840000" />
|
||||||
<workItem from="1504575702799" duration="4395000" />
|
<workItem from="1504575702799" duration="5238000" />
|
||||||
</task>
|
</task>
|
||||||
<task id="LOCAL-00001">
|
<task id="LOCAL-00001">
|
||||||
<created>1500458878821</created>
|
<created>1500458878821</created>
|
||||||
@ -606,11 +605,18 @@
|
|||||||
<option name="project" value="LOCAL" />
|
<option name="project" value="LOCAL" />
|
||||||
<updated>1504579259295</updated>
|
<updated>1504579259295</updated>
|
||||||
</task>
|
</task>
|
||||||
<option name="localTasksCounter" value="23" />
|
<task id="LOCAL-00023" summary="管理端初步">
|
||||||
|
<created>1504580135665</created>
|
||||||
|
<option name="number" value="00023" />
|
||||||
|
<option name="presentableId" value="LOCAL-00023" />
|
||||||
|
<option name="project" value="LOCAL" />
|
||||||
|
<updated>1504580135666</updated>
|
||||||
|
</task>
|
||||||
|
<option name="localTasksCounter" value="24" />
|
||||||
<servers />
|
<servers />
|
||||||
</component>
|
</component>
|
||||||
<component name="TimeTrackingManager">
|
<component name="TimeTrackingManager">
|
||||||
<option name="totallyTimeSpent" value="81933000" />
|
<option name="totallyTimeSpent" value="82776000" />
|
||||||
</component>
|
</component>
|
||||||
<component name="TodoView">
|
<component name="TodoView">
|
||||||
<todo-panel id="selected-file">
|
<todo-panel id="selected-file">
|
||||||
@ -938,7 +944,7 @@
|
|||||||
<state relative-caret-position="289">
|
<state relative-caret-position="289">
|
||||||
<caret line="18" column="1" lean-forward="true" selection-start-line="18" selection-start-column="1" selection-end-line="18" selection-end-column="1" />
|
<caret line="18" column="1" lean-forward="true" selection-start-line="18" selection-start-column="1" selection-end-line="18" selection-end-column="1" />
|
||||||
<folding>
|
<folding>
|
||||||
<marker date="1504577466934" expanded="true" signature="201:235" ph="[...]" />
|
<marker date="1504580163801" expanded="true" signature="201:235" ph="[...]" />
|
||||||
</folding>
|
</folding>
|
||||||
</state>
|
</state>
|
||||||
</provider>
|
</provider>
|
||||||
@ -1007,16 +1013,6 @@
|
|||||||
</state>
|
</state>
|
||||||
</provider>
|
</provider>
|
||||||
</entry>
|
</entry>
|
||||||
<entry file="file://$PROJECT_DIR$/example/main.go">
|
|
||||||
<provider selected="true" editor-type-id="text-editor">
|
|
||||||
<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#102#0" expanded="true" />
|
|
||||||
</folding>
|
|
||||||
</state>
|
|
||||||
</provider>
|
|
||||||
</entry>
|
|
||||||
<entry file="file://$PROJECT_DIR$/map.go">
|
<entry file="file://$PROJECT_DIR$/map.go">
|
||||||
<provider selected="true" editor-type-id="text-editor">
|
<provider selected="true" editor-type-id="text-editor">
|
||||||
<state relative-caret-position="303">
|
<state relative-caret-position="303">
|
||||||
@ -1027,5 +1023,15 @@
|
|||||||
</state>
|
</state>
|
||||||
</provider>
|
</provider>
|
||||||
</entry>
|
</entry>
|
||||||
|
<entry file="file://$PROJECT_DIR$/example/main.go">
|
||||||
|
<provider selected="true" editor-type-id="text-editor">
|
||||||
|
<state relative-caret-position="289">
|
||||||
|
<caret line="17" column="11" lean-forward="true" selection-start-line="17" selection-start-column="11" selection-end-line="17" selection-end-column="11" />
|
||||||
|
<folding>
|
||||||
|
<element signature="e#14#137#0" expanded="true" />
|
||||||
|
</folding>
|
||||||
|
</state>
|
||||||
|
</provider>
|
||||||
|
</entry>
|
||||||
</component>
|
</component>
|
||||||
</project>
|
</project>
|
154
example/main.go
154
example/main.go
@ -1,54 +1,41 @@
|
|||||||
package main
|
package main
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
"database/sql"
|
||||||
|
"fmt"
|
||||||
_ "github.com/go-sql-driver/mysql"
|
_ "github.com/go-sql-driver/mysql"
|
||||||
"go.hoteas.com/hotime"
|
"go.hoteas.com/hotime"
|
||||||
"time"
|
"golang.org/x/net/websocket"
|
||||||
//"fmt"
|
|
||||||
)
|
)
|
||||||
|
|
||||||
func main() {
|
func main() {
|
||||||
|
|
||||||
a:=hotime.Map{}
|
appIns := hotime.Application{}
|
||||||
a.Put("x",1)
|
i := 0
|
||||||
for i:=0;i<30 ;i++ {
|
|
||||||
go func() {
|
|
||||||
for j:=0;j<30 ;j++ {
|
|
||||||
if j/2==0{
|
|
||||||
hotime.SafeMutex("test", func() interface{} {
|
|
||||||
|
|
||||||
a.Put("x","1")
|
appIns.SetConnectListener(func(context *hotime.Context) bool {
|
||||||
|
fmt.Println(i)
|
||||||
|
i++
|
||||||
|
//this.HandlerStr = "/test.html"
|
||||||
|
return true
|
||||||
|
})
|
||||||
|
|
||||||
|
//手动模式,
|
||||||
|
appIns.SetConfig()
|
||||||
|
appIns.SetConnectDB(func(err ...*hotime.Error) *sql.DB {
|
||||||
|
query := appIns.Config.GetString("dbUser") + ":" + appIns.Config.GetString("dbPwd") +
|
||||||
|
"@tcp(" + appIns.Config.GetString("dbHost") + ":" + appIns.Config.GetString("dbPort") + ")/" + appIns.Config.GetString("dbName") + "?charset=utf8"
|
||||||
|
DB, e := sql.Open("mysql", query)
|
||||||
|
if e != nil && len(err) != 0 {
|
||||||
|
err[0].SetError(e)
|
||||||
|
}
|
||||||
|
return DB
|
||||||
|
})
|
||||||
|
appIns.SetSession(hotime.CacheIns(&hotime.CacheMemory{}), hotime.CacheIns(&hotime.CacheDb{Db: &appIns.Db, Time: appIns.Config.GetInt64("cacheTime")}))
|
||||||
|
appIns.SetCache(hotime.CacheIns(&hotime.CacheMemory{}))
|
||||||
|
|
||||||
return nil
|
//快捷模式
|
||||||
})
|
//appIns.SetDefault(func(err ...*hotime.Error) *sql.DB {
|
||||||
}else {
|
|
||||||
//fmt.Println(a.GetInt64("x"))
|
|
||||||
a.Delete("x")
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
}()
|
|
||||||
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
time.Sleep(time.Second*5)
|
|
||||||
|
|
||||||
//appIns := hotime.Application{}
|
|
||||||
//i := 0
|
|
||||||
//
|
|
||||||
//appIns.SetConnectListener(func(context *hotime.Context) bool {
|
|
||||||
// fmt.Println(i)
|
|
||||||
// i++
|
|
||||||
// //this.HandlerStr = "/test.html"
|
|
||||||
// return true
|
|
||||||
//})
|
|
||||||
//
|
|
||||||
////手动模式,
|
|
||||||
//appIns.SetConfig()
|
|
||||||
//appIns.SetConnectDB(func(err ...*hotime.Error) *sql.DB {
|
|
||||||
// query := appIns.Config.GetString("dbUser") + ":" + appIns.Config.GetString("dbPwd") +
|
// query := appIns.Config.GetString("dbUser") + ":" + appIns.Config.GetString("dbPwd") +
|
||||||
// "@tcp(" + appIns.Config.GetString("dbHost") + ":" + appIns.Config.GetString("dbPort") + ")/" + appIns.Config.GetString("dbName") + "?charset=utf8"
|
// "@tcp(" + appIns.Config.GetString("dbHost") + ":" + appIns.Config.GetString("dbPort") + ")/" + appIns.Config.GetString("dbName") + "?charset=utf8"
|
||||||
// DB, e := sql.Open("mysql", query)
|
// DB, e := sql.Open("mysql", query)
|
||||||
@ -57,55 +44,42 @@ func main() {
|
|||||||
// }
|
// }
|
||||||
// return DB
|
// return DB
|
||||||
//})
|
//})
|
||||||
//appIns.SetSession(hotime.CacheIns(&hotime.CacheMemory{}), hotime.CacheIns(&hotime.CacheDb{Db: &appIns.Db, Time: appIns.Config.GetInt64("cacheTime")}))
|
|
||||||
//appIns.SetCache(hotime.CacheIns(&hotime.CacheMemory{}))
|
appIns.Run(hotime.Router{
|
||||||
//
|
"app": hotime.Proj{
|
||||||
////快捷模式
|
"index": hotime.Ctr{
|
||||||
////appIns.SetDefault(func(err ...*hotime.Error) *sql.DB {
|
"test": func(this *hotime.Context) {
|
||||||
//// query := appIns.Config.GetString("dbUser") + ":" + appIns.Config.GetString("dbPwd") +
|
fmt.Println(this.Db.GetTag())
|
||||||
//// "@tcp(" + appIns.Config.GetString("dbHost") + ":" + appIns.Config.GetString("dbPort") + ")/" + appIns.Config.GetString("dbName") + "?charset=utf8"
|
x:=this.Db.Action(func(db hotime.HoTimeDB) bool {
|
||||||
//// DB, e := sql.Open("mysql", query)
|
|
||||||
//// if e != nil && len(err) != 0 {
|
db.Insert("user",hotime.Map{"unickname":"dasdas"})
|
||||||
//// err[0].SetError(e)
|
|
||||||
//// }
|
return true
|
||||||
//// return DB
|
})
|
||||||
////})
|
this.Display(5, x)
|
||||||
//
|
},
|
||||||
//appIns.Run(hotime.Router{
|
"websocket": func(this *hotime.Context) {
|
||||||
// "app": hotime.Proj{
|
hdler := websocket.Handler(func(ws *websocket.Conn) {
|
||||||
// "index": hotime.Ctr{
|
for true {
|
||||||
// "test": func(this *hotime.Context) {
|
msg := make([]byte, 5120)
|
||||||
// fmt.Println(this.Db.GetTag())
|
n, err := ws.Read(msg)
|
||||||
// x:=this.Db.Action(func(db hotime.HoTimeDB) bool {
|
|
||||||
//
|
if err != nil {
|
||||||
// db.Insert("user",hotime.Map{"unickname":"dasdas"})
|
return
|
||||||
//
|
}
|
||||||
// return true
|
fmt.Printf("Receive: %s\n", msg[:n])
|
||||||
// })
|
|
||||||
// this.Display(5, x)
|
send_msg := "[" + string(msg[:n]) + "]"
|
||||||
// },
|
m, err := ws.Write([]byte(send_msg))
|
||||||
// "websocket": func(this *hotime.Context) {
|
if err != nil {
|
||||||
// hdler := websocket.Handler(func(ws *websocket.Conn) {
|
return
|
||||||
// for true {
|
}
|
||||||
// msg := make([]byte, 5120)
|
fmt.Printf("Send: %s\n", msg[:m])
|
||||||
// n, err := ws.Read(msg)
|
}
|
||||||
//
|
})
|
||||||
// if err != nil {
|
hdler.ServeHTTP(this.Resp, this.Req)
|
||||||
// return
|
},
|
||||||
// }
|
},
|
||||||
// fmt.Printf("Receive: %s\n", msg[:n])
|
},
|
||||||
//
|
})
|
||||||
// send_msg := "[" + string(msg[:n]) + "]"
|
|
||||||
// m, err := ws.Write([]byte(send_msg))
|
|
||||||
// if err != nil {
|
|
||||||
// return
|
|
||||||
// }
|
|
||||||
// fmt.Printf("Send: %s\n", msg[:m])
|
|
||||||
// }
|
|
||||||
// })
|
|
||||||
// hdler.ServeHTTP(this.Resp, this.Req)
|
|
||||||
// },
|
|
||||||
// },
|
|
||||||
// },
|
|
||||||
//})
|
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user