增加删除功能

This commit is contained in:
giaogiao 2023-09-08 11:21:13 +08:00
parent e488ed7adf
commit f2218df084
4 changed files with 3 additions and 58 deletions

View File

@ -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)

View File

@ -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)
}

46
main.go
View File

@ -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"

BIN
wol.db

Binary file not shown.