Compare commits
No commits in common. "86414244a858eb8ea65368b63bdbf7a3f68d7ea2" and "7644978e23646fdf59c2c043f768635356309329" have entirely different histories.
86414244a8
...
7644978e23
|
@ -37,7 +37,6 @@ steps:
|
||||||
- name: outdir
|
- name: outdir
|
||||||
path: /root/web
|
path: /root/web
|
||||||
commands:
|
commands:
|
||||||
- rm -rf /root/web/*
|
|
||||||
- rm -rf ./app/*
|
- rm -rf ./app/*
|
||||||
- cp -r /go/web/build/* ./app/
|
- cp -r /go/web/build/* ./app/
|
||||||
- sed -i 's?/static?/static/static?g' ./app/index.html
|
- sed -i 's?/static?/static/static?g' ./app/index.html
|
||||||
|
|
|
@ -1,2 +1 @@
|
||||||
tmp
|
tmp
|
||||||
__debug_bin*
|
|
68
bulid.sh
68
bulid.sh
|
@ -1,40 +1,36 @@
|
||||||
#!/bin/bash
|
#!/bin/bash
|
||||||
# CPU_architecture="darwin/amd64
|
CPU_architecture="darwin/amd64
|
||||||
# darwin/arm64
|
darwin/arm64
|
||||||
# freebsd/386
|
freebsd/386
|
||||||
# freebsd/amd64
|
freebsd/amd64
|
||||||
# freebsd/arm
|
freebsd/arm
|
||||||
# freebsd/arm64
|
freebsd/arm64
|
||||||
# linux/386
|
linux/386
|
||||||
# linux/amd64
|
linux/amd64
|
||||||
# linux/arm
|
linux/arm
|
||||||
# linux/arm64
|
linux/arm64
|
||||||
# linux/loong64
|
linux/loong64
|
||||||
# linux/mips
|
linux/mips
|
||||||
# linux/mips64
|
linux/mips64
|
||||||
# linux/mips64le
|
linux/mips64le
|
||||||
# linux/mipsle
|
linux/mipsle
|
||||||
# linux/ppc64
|
linux/ppc64
|
||||||
# linux/ppc64le
|
linux/ppc64le
|
||||||
# linux/riscv64
|
linux/riscv64
|
||||||
# linux/s390x
|
linux/s390x
|
||||||
# netbsd/386
|
netbsd/386
|
||||||
# netbsd/amd64
|
netbsd/amd64
|
||||||
# netbsd/arm
|
netbsd/arm
|
||||||
# netbsd/arm64
|
netbsd/arm64
|
||||||
# openbsd/386
|
openbsd/386
|
||||||
# openbsd/amd64
|
openbsd/amd64
|
||||||
# openbsd/arm
|
openbsd/arm
|
||||||
# openbsd/arm64
|
openbsd/arm64
|
||||||
# openbsd/mips64
|
openbsd/mips64
|
||||||
# windows/386
|
windows/386
|
||||||
# windows/amd64
|
windows/amd64
|
||||||
# windows/arm
|
windows/arm
|
||||||
# windows/arm64"
|
windows/arm64"
|
||||||
|
|
||||||
#只打包两个版本
|
|
||||||
CPU_architecture="linux/amd64
|
|
||||||
windows/amd64"
|
|
||||||
|
|
||||||
for line in $CPU_architecture
|
for line in $CPU_architecture
|
||||||
do
|
do
|
||||||
|
|
|
@ -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)
|
database.Del(id)
|
||||||
err := websocket.Message.Send(*ws, res.Get_res_string(200, "", uuid, id))
|
err := websocket.Message.Send(*ws, res.Get_res_string(200, "", uuid, id))
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
@ -60,14 +60,3 @@ func Del(ws **websocket.Conn, uuid string, id int64) {
|
||||||
return
|
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
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
|
@ -12,11 +12,7 @@ type MacData struct {
|
||||||
Mac string `json:"mac"`
|
Mac string `json:"mac"`
|
||||||
}
|
}
|
||||||
type DelData struct {
|
type DelData struct {
|
||||||
ID int64 `json:"id"`
|
ID int `json:"id"`
|
||||||
}
|
|
||||||
type AddData struct {
|
|
||||||
Nmae string `json:"name"`
|
|
||||||
Mac string `json:"mac"`
|
|
||||||
}
|
}
|
||||||
type TooLTT struct {
|
type TooLTT struct {
|
||||||
Method string `json:"method"`
|
Method string `json:"method"`
|
||||||
|
@ -65,13 +61,6 @@ func Hello(c echo.Context) error {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
Del(&ws, wsValue.Uuid, DelData.ID)
|
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:
|
default:
|
||||||
c.Logger().Error("没有找到方法")
|
c.Logger().Error("没有找到方法")
|
||||||
|
|
||||||
|
|
|
@ -8,7 +8,7 @@ import (
|
||||||
var engine *xorm.Engine
|
var engine *xorm.Engine
|
||||||
|
|
||||||
type Wol struct {
|
type Wol struct {
|
||||||
ID int64
|
ID int
|
||||||
Name string `xorm:"varchar(64)"`
|
Name string `xorm:"varchar(64)"`
|
||||||
Mac string `xorm:"varchar(64)"`
|
Mac string `xorm:"varchar(64)"`
|
||||||
}
|
}
|
||||||
|
@ -18,15 +18,7 @@ func init() {
|
||||||
file := "./wol.db"
|
file := "./wol.db"
|
||||||
engine, err = xorm.NewEngine("sqlite3", file)
|
engine, err = xorm.NewEngine("sqlite3", file)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
println(err.Error())
|
println(err)
|
||||||
|
|
||||||
}
|
|
||||||
res, err := engine.IsTableExist("wol")
|
|
||||||
if !res {
|
|
||||||
CreateTable()
|
|
||||||
}
|
|
||||||
if err != nil {
|
|
||||||
println(err.Error())
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -34,14 +26,14 @@ func init() {
|
||||||
func CreateTable() int {
|
func CreateTable() int {
|
||||||
err := engine.Sync2(new(Wol))
|
err := engine.Sync2(new(Wol))
|
||||||
if err != nil {
|
if err != nil {
|
||||||
println(err.Error())
|
println(err)
|
||||||
}
|
}
|
||||||
return 0
|
return 0
|
||||||
}
|
}
|
||||||
func Getallwol(everyone *[]Wol) {
|
func Getallwol(everyone *[]Wol) {
|
||||||
err := engine.Find(&(*everyone))
|
err := engine.Find(&(*everyone))
|
||||||
if err != nil {
|
if err != nil {
|
||||||
println("Getallwol err", err.Error())
|
println("Getallwol err", err)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -49,19 +41,19 @@ func Getallwoltext() {
|
||||||
everyone := make([]Wol, 0)
|
everyone := make([]Wol, 0)
|
||||||
err := engine.Find(&everyone)
|
err := engine.Find(&everyone)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
println("Getallwoltext", err.Error())
|
println("Getallwoltext", err)
|
||||||
}
|
}
|
||||||
println(len(everyone))
|
println(len(everyone))
|
||||||
}
|
}
|
||||||
|
|
||||||
func Insert(wol *Wol) {
|
func Insert(wol *Wol) {
|
||||||
affected, err := engine.Insert(wol)
|
affected, err := engine.Insert(&wol)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
println(err.Error())
|
println(err)
|
||||||
}
|
}
|
||||||
println(affected)
|
println(affected)
|
||||||
}
|
}
|
||||||
func Del(id int64) {
|
func Del(id int) {
|
||||||
affected, err := engine.Where("i_d = ?", id).Delete(&Wol{})
|
affected, err := engine.Where("i_d = ?", id).Delete(&Wol{})
|
||||||
if err != nil {
|
if err != nil {
|
||||||
println(err)
|
println(err)
|
||||||
|
|
26
main_test.go
26
main_test.go
|
@ -1,30 +1,12 @@
|
||||||
package main
|
package main
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"goweb/database"
|
|
||||||
"testing"
|
"testing"
|
||||||
)
|
)
|
||||||
|
|
||||||
// func TestAdd(t *testing.T) {
|
func TestAdd(t *testing.T) {
|
||||||
// if database.CreateTable() != 0 {
|
if ans := 3; ans == 0 {
|
||||||
// t.Errorf("数据库同步失败")
|
t.Errorf("1 + 2 expected be 3, but %d got", ans)
|
||||||
// }
|
|
||||||
|
|
||||||
// }
|
|
||||||
|
|
||||||
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
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
t.Errorf("并没有找到")
|
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue