修改打包的版本数量 完成添加接口 增加测试函数
This commit is contained in:
parent
7644978e23
commit
aa3e66a37c
|
@ -37,6 +37,7 @@ 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 +1,2 @@
|
||||||
tmp
|
tmp
|
||||||
|
__debug_bin*
|
68
bulid.sh
68
bulid.sh
|
@ -1,36 +1,40 @@
|
||||||
#!/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 int) {
|
func Del(ws **websocket.Conn, uuid string, id int64) {
|
||||||
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,3 +60,14 @@ func Del(ws **websocket.Conn, uuid string, id int) {
|
||||||
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,7 +12,11 @@ type MacData struct {
|
||||||
Mac string `json:"mac"`
|
Mac string `json:"mac"`
|
||||||
}
|
}
|
||||||
type DelData struct {
|
type DelData struct {
|
||||||
ID int `json:"id"`
|
ID int64 `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"`
|
||||||
|
@ -61,6 +65,13 @@ 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 int
|
ID int64
|
||||||
Name string `xorm:"varchar(64)"`
|
Name string `xorm:"varchar(64)"`
|
||||||
Mac string `xorm:"varchar(64)"`
|
Mac string `xorm:"varchar(64)"`
|
||||||
}
|
}
|
||||||
|
@ -18,7 +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)
|
println(err.Error())
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -26,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)
|
println(err.Error())
|
||||||
}
|
}
|
||||||
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)
|
println("Getallwol err", err.Error())
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -41,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)
|
println("Getallwoltext", err.Error())
|
||||||
}
|
}
|
||||||
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)
|
println(err.Error())
|
||||||
}
|
}
|
||||||
println(affected)
|
println(affected)
|
||||||
}
|
}
|
||||||
func Del(id int) {
|
func Del(id int64) {
|
||||||
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,12 +1,30 @@
|
||||||
package main
|
package main
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
"goweb/database"
|
||||||
"testing"
|
"testing"
|
||||||
)
|
)
|
||||||
|
|
||||||
func TestAdd(t *testing.T) {
|
// func TestAdd(t *testing.T) {
|
||||||
if ans := 3; ans == 0 {
|
// if database.CreateTable() != 0 {
|
||||||
t.Errorf("1 + 2 expected be 3, but %d got", ans)
|
// 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
|
||||||
|
}
|
||||||
|
}
|
||||||
|
t.Errorf("并没有找到")
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue