diff --git a/controller/ws.go b/controller/ws.go index 354d0f5..0c29c48 100644 --- a/controller/ws.go +++ b/controller/ws.go @@ -53,13 +53,7 @@ func Getall(ws **websocket.Conn, uuid string) { } func Del(ws **websocket.Conn, uuid string, id int) { - wol := new(database.Wol) - wol.ID = id - database.Del() - // if err != nil { - // fmt.Println("marshal failed!", err) - // return - // } + database.Del(id) err := websocket.Message.Send(*ws, res.Get_res_string(200, "", uuid, id)) if err != nil { // c.Logger().Error(err) diff --git a/database/database.go b/database/database.go index 00ac888..9efaa9c 100644 --- a/database/database.go +++ b/database/database.go @@ -53,11 +53,8 @@ func Insert(wol *Wol) { } println(affected) } -func Del() { - println("del orm") - wol1 := new(Wol) - wol1.Name = "00:70:0a:f5:9a:a3" - affected, err := engine.Delete(&wol1) +func Del(id int) { + affected, err := engine.Where("i_d = ?", id).Delete(&Wol{}) if err != nil { println(err) } diff --git a/main.go b/main.go index cd3e2dd..d523e0c 100644 --- a/main.go +++ b/main.go @@ -39,52 +39,6 @@ func getFileSystem(useOS bool) http.FileSystem { return http.FS(fsys) } -// func hello(c echo.Context) error { -// type Data struct { -// Mac string `json:"mac"` -// } -// type TooLTT struct { -// Method string `json:"method"` -// Data Data `json:"data"` -// Uuid string `json:"uuid"` -// } -// websocket.Handler(func(ws *websocket.Conn) { -// defer ws.Close() -// var wsValue TooLTT -// for { -// // Write - -// // timeUnix := time.Now().Unix() -// // output, _ := json.Marshal(&wsValue) -// // err := websocket.Message.Send(ws, "Hello, Client!"+string(output)+" time is :"+strconv.FormatInt(timeUnix, 10)) -// // if err != nil { -// // c.Logger().Error(err) -// // } -// // Read -// msg := "" -// err := websocket.Message.Receive(ws, &msg) -// if err != nil { -// c.Logger().Error(err) -// break -// } - -// json.Unmarshal([]byte(msg), &wsValue) -// switch { -// case wsValue.Method == "start": -// controller.Send_start(wsValue.Data.Mac, &ws, wsValue.Uuid) -// case wsValue.Method == "getall": -// controller.Getall(&ws, wsValue.Uuid) -// // case wsValue.Method == "del": -// // controller.Del(&ws, wsValue.Uuid, wsValue.Data) -// default: -// fmt.Printf("error") -// } -// fmt.Printf("%s\n", msg) - -// } -// }).ServeHTTP(c.Response(), c.Request()) -// return nil -// } func main() { e := echo.New() useOS := len(os.Args) > 1 && os.Args[1] == "live" diff --git a/wol.db b/wol.db index a8937d9..b9f48ce 100644 Binary files a/wol.db and b/wol.db differ