Compare commits

..

No commits in common. "86414244a858eb8ea65368b63bdbf7a3f68d7ea2" and "7644978e23646fdf59c2c043f768635356309329" have entirely different histories.

8 changed files with 47 additions and 101 deletions

View File

@ -37,7 +37,6 @@ steps:
- name: outdir
path: /root/web
commands:
- rm -rf /root/web/*
- rm -rf ./app/*
- cp -r /go/web/build/* ./app/
- sed -i 's?/static?/static/static?g' ./app/index.html

1
.gitignore vendored
View File

@ -1,2 +1 @@
tmp
__debug_bin*

View File

@ -1,40 +1,36 @@
#!/bin/bash
# CPU_architecture="darwin/amd64
# darwin/arm64
# freebsd/386
# freebsd/amd64
# freebsd/arm
# freebsd/arm64
# linux/386
# linux/amd64
# linux/arm
# linux/arm64
# linux/loong64
# linux/mips
# linux/mips64
# linux/mips64le
# linux/mipsle
# linux/ppc64
# linux/ppc64le
# linux/riscv64
# linux/s390x
# netbsd/386
# netbsd/amd64
# netbsd/arm
# netbsd/arm64
# openbsd/386
# openbsd/amd64
# openbsd/arm
# openbsd/arm64
# openbsd/mips64
# windows/386
# windows/amd64
# windows/arm
# windows/arm64"
#只打包两个版本
CPU_architecture="linux/amd64
windows/amd64"
CPU_architecture="darwin/amd64
darwin/arm64
freebsd/386
freebsd/amd64
freebsd/arm
freebsd/arm64
linux/386
linux/amd64
linux/arm
linux/arm64
linux/loong64
linux/mips
linux/mips64
linux/mips64le
linux/mipsle
linux/ppc64
linux/ppc64le
linux/riscv64
linux/s390x
netbsd/386
netbsd/amd64
netbsd/arm
netbsd/arm64
openbsd/386
openbsd/amd64
openbsd/arm
openbsd/arm64
openbsd/mips64
windows/386
windows/amd64
windows/arm
windows/arm64"
for line in $CPU_architecture
do

View File

@ -52,7 +52,7 @@ func Getall(ws **websocket.Conn, uuid string) {
}
}
func Del(ws **websocket.Conn, uuid string, id int64) {
func Del(ws **websocket.Conn, uuid string, id int) {
database.Del(id)
err := websocket.Message.Send(*ws, res.Get_res_string(200, "", uuid, id))
if err != nil {
@ -60,14 +60,3 @@ func Del(ws **websocket.Conn, uuid string, id int64) {
return
}
}
func Add(ws **websocket.Conn, uuid string, name string, mac string) {
wol := new(database.Wol)
wol.Mac = mac
wol.Name = name
database.Insert(wol)
err := websocket.Message.Send(*ws, res.Get_res_string(200, "", uuid, ""))
if err != nil {
// c.Logger().Error(err)
return
}
}

View File

@ -12,11 +12,7 @@ type MacData struct {
Mac string `json:"mac"`
}
type DelData struct {
ID int64 `json:"id"`
}
type AddData struct {
Nmae string `json:"name"`
Mac string `json:"mac"`
ID int `json:"id"`
}
type TooLTT struct {
Method string `json:"method"`
@ -65,13 +61,6 @@ func Hello(c echo.Context) error {
return
}
Del(&ws, wsValue.Uuid, DelData.ID)
case "add":
var AddData AddData
if err := json.Unmarshal(json_data, &AddData); err != nil {
c.Logger().Error(err)
return
}
Add(&ws, wsValue.Uuid, AddData.Nmae, AddData.Mac)
default:
c.Logger().Error("没有找到方法")

View File

@ -8,7 +8,7 @@ import (
var engine *xorm.Engine
type Wol struct {
ID int64
ID int
Name string `xorm:"varchar(64)"`
Mac string `xorm:"varchar(64)"`
}
@ -18,15 +18,7 @@ func init() {
file := "./wol.db"
engine, err = xorm.NewEngine("sqlite3", file)
if err != nil {
println(err.Error())
}
res, err := engine.IsTableExist("wol")
if !res {
CreateTable()
}
if err != nil {
println(err.Error())
println(err)
}
@ -34,14 +26,14 @@ func init() {
func CreateTable() int {
err := engine.Sync2(new(Wol))
if err != nil {
println(err.Error())
println(err)
}
return 0
}
func Getallwol(everyone *[]Wol) {
err := engine.Find(&(*everyone))
if err != nil {
println("Getallwol err", err.Error())
println("Getallwol err", err)
}
}
@ -49,19 +41,19 @@ func Getallwoltext() {
everyone := make([]Wol, 0)
err := engine.Find(&everyone)
if err != nil {
println("Getallwoltext", err.Error())
println("Getallwoltext", err)
}
println(len(everyone))
}
func Insert(wol *Wol) {
affected, err := engine.Insert(wol)
affected, err := engine.Insert(&wol)
if err != nil {
println(err.Error())
println(err)
}
println(affected)
}
func Del(id int64) {
func Del(id int) {
affected, err := engine.Where("i_d = ?", id).Delete(&Wol{})
if err != nil {
println(err)

View File

@ -1,30 +1,12 @@
package main
import (
"goweb/database"
"testing"
)
// func TestAdd(t *testing.T) {
// if database.CreateTable() != 0 {
// t.Errorf("数据库同步失败")
// }
// }
func TestAdd_Delwol(t *testing.T) {
wol := new(database.Wol)
wol.Mac = "8F:26:58:C1:85:83"
wol.Name = "text"
database.Insert(wol)
wolarray := make([]database.Wol, 0)
database.Getallwol(&wolarray)
for _, item := range wolarray {
if item.Name == wol.Name {
database.Del(item.ID)
return
func TestAdd(t *testing.T) {
if ans := 3; ans == 0 {
t.Errorf("1 + 2 expected be 3, but %d got", ans)
}
}
t.Errorf("并没有找到")
}

BIN
wol.db

Binary file not shown.