管理端初步

This commit is contained in:
hoteas 2017-09-05 03:09:13 +00:00
parent 66c4b177c1
commit cd242cc9d6
2 changed files with 90 additions and 110 deletions

46
.idea/workspace.xml generated
View File

@ -7,7 +7,6 @@
<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$/example/main.go" afterPath="$PROJECT_DIR$/example/main.go" />
<change type="MODIFICATION" beforePath="$PROJECT_DIR$/map.go" afterPath="$PROJECT_DIR$/map.go" />
</list>
<ignored path=".idea/dataSources.local.xml" />
<option name="EXCLUDED_CONVERTED_TO_IGNORED" value="true" />
@ -46,7 +45,7 @@
</provider>
</entry>
</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">
<provider selected="true" editor-type-id="text-editor">
<state relative-caret-position="303">
@ -58,13 +57,13 @@
</provider>
</entry>
</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">
<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" />
<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#102#0" expanded="true" />
<element signature="e#14#137#0" expanded="true" />
</folding>
</state>
</provider>
@ -450,7 +449,7 @@
<workItem from="1504252839700" duration="18000" />
<workItem from="1504488004086" duration="365000" />
<workItem from="1504488391347" duration="840000" />
<workItem from="1504575702799" duration="4395000" />
<workItem from="1504575702799" duration="5238000" />
</task>
<task id="LOCAL-00001">
<created>1500458878821</created>
@ -606,11 +605,18 @@
<option name="project" value="LOCAL" />
<updated>1504579259295</updated>
</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 />
</component>
<component name="TimeTrackingManager">
<option name="totallyTimeSpent" value="81933000" />
<option name="totallyTimeSpent" value="82776000" />
</component>
<component name="TodoView">
<todo-panel id="selected-file">
@ -938,7 +944,7 @@
<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" />
<folding>
<marker date="1504577466934" expanded="true" signature="201:235" ph="[...]" />
<marker date="1504580163801" expanded="true" signature="201:235" ph="[...]" />
</folding>
</state>
</provider>
@ -1007,16 +1013,6 @@
</state>
</provider>
</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">
<provider selected="true" editor-type-id="text-editor">
<state relative-caret-position="303">
@ -1027,5 +1023,15 @@
</state>
</provider>
</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>
</project>

View File

@ -1,54 +1,41 @@
package main
import (
"database/sql"
"fmt"
_ "github.com/go-sql-driver/mysql"
"go.hoteas.com/hotime"
"time"
//"fmt"
"golang.org/x/net/websocket"
)
func main() {
a:=hotime.Map{}
a.Put("x",1)
for i:=0;i<30 ;i++ {
go func() {
for j:=0;j<30 ;j++ {
if j/2==0{
hotime.SafeMutex("test", func() interface{} {
appIns := hotime.Application{}
i := 0
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
})
}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 {
//快捷模式
//appIns.SetDefault(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)
@ -57,55 +44,42 @@ func main() {
// }
// 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.SetDefault(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.Run(hotime.Router{
// "app": hotime.Proj{
// "index": hotime.Ctr{
// "test": func(this *hotime.Context) {
// fmt.Println(this.Db.GetTag())
// x:=this.Db.Action(func(db hotime.HoTimeDB) bool {
//
// db.Insert("user",hotime.Map{"unickname":"dasdas"})
//
// return true
// })
// this.Display(5, x)
// },
// "websocket": func(this *hotime.Context) {
// hdler := websocket.Handler(func(ws *websocket.Conn) {
// for true {
// msg := make([]byte, 5120)
// n, err := ws.Read(msg)
//
// if err != nil {
// 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)
// },
// },
// },
//})
appIns.Run(hotime.Router{
"app": hotime.Proj{
"index": hotime.Ctr{
"test": func(this *hotime.Context) {
fmt.Println(this.Db.GetTag())
x:=this.Db.Action(func(db hotime.HoTimeDB) bool {
db.Insert("user",hotime.Map{"unickname":"dasdas"})
return true
})
this.Display(5, x)
},
"websocket": func(this *hotime.Context) {
hdler := websocket.Handler(func(ws *websocket.Conn) {
for true {
msg := make([]byte, 5120)
n, err := ws.Read(msg)
if err != nil {
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)
},
},
},
})
}