Init: Create & Init Project...
This commit is contained in:
commit
3ad58780e9
1
.gitignore
vendored
Normal file
1
.gitignore
vendored
Normal file
@ -0,0 +1 @@
|
||||
/vendor
|
230
Gopkg.lock
generated
Normal file
230
Gopkg.lock
generated
Normal file
@ -0,0 +1,230 @@
|
||||
# This file is autogenerated, do not edit; changes may be undone by the next 'dep ensure'.
|
||||
|
||||
|
||||
[[projects]]
|
||||
digest = "1:f9ae348e1f793dcf9ed930ed47136a67343dbd6809c5c91391322267f4476892"
|
||||
name = "github.com/Microsoft/go-winio"
|
||||
packages = ["."]
|
||||
pruneopts = "UT"
|
||||
revision = "97e4973ce50b2ff5f09635a57e2b88a037aae829"
|
||||
version = "v0.4.11"
|
||||
|
||||
[[projects]]
|
||||
digest = "1:3cabbabc9e0e4aa7e12b882bdc213f41cf8bd2b2ce2a7b5e0aceaf8a6a78049b"
|
||||
name = "github.com/docker/distribution"
|
||||
packages = [
|
||||
"digest",
|
||||
"reference",
|
||||
]
|
||||
pruneopts = "UT"
|
||||
revision = "48294d928ced5dd9b378f7fd7c6f5da3ff3f2c89"
|
||||
version = "v2.6.2"
|
||||
|
||||
[[projects]]
|
||||
digest = "1:65e46d4ea06577617ac10d42a4c247200f06a8061ded76a18d5c313ef1b7e0d8"
|
||||
name = "github.com/docker/docker"
|
||||
packages = [
|
||||
"api/types",
|
||||
"api/types/blkiodev",
|
||||
"api/types/container",
|
||||
"api/types/events",
|
||||
"api/types/filters",
|
||||
"api/types/mount",
|
||||
"api/types/network",
|
||||
"api/types/reference",
|
||||
"api/types/registry",
|
||||
"api/types/strslice",
|
||||
"api/types/swarm",
|
||||
"api/types/time",
|
||||
"api/types/versions",
|
||||
"api/types/volume",
|
||||
"client",
|
||||
"pkg/tlsconfig",
|
||||
]
|
||||
pruneopts = "UT"
|
||||
revision = "092cba3727bb9b4a2f0e922cd6c0f93ea270e363"
|
||||
version = "v1.13.1"
|
||||
|
||||
[[projects]]
|
||||
digest = "1:811c86996b1ca46729bad2724d4499014c4b9effd05ef8c71b852aad90deb0ce"
|
||||
name = "github.com/docker/go-connections"
|
||||
packages = [
|
||||
"nat",
|
||||
"sockets",
|
||||
"tlsconfig",
|
||||
]
|
||||
pruneopts = "UT"
|
||||
revision = "7395e3f8aa162843a74ed6d48e79627d9792ac55"
|
||||
version = "v0.4.0"
|
||||
|
||||
[[projects]]
|
||||
digest = "1:6f82cacd0af5921e99bf3f46748705239b36489464f4529a1589bc895764fb18"
|
||||
name = "github.com/docker/go-units"
|
||||
packages = ["."]
|
||||
pruneopts = "UT"
|
||||
revision = "47565b4f722fb6ceae66b95f853feed578a4a51c"
|
||||
version = "v0.3.3"
|
||||
|
||||
[[projects]]
|
||||
branch = "master"
|
||||
digest = "1:36fe9527deed01d2a317617e59304eb2c4ce9f8a24115bcc5c2e37b3aee5bae4"
|
||||
name = "github.com/gin-contrib/sse"
|
||||
packages = ["."]
|
||||
pruneopts = "UT"
|
||||
revision = "22d885f9ecc78bf4ee5d72b937e4bbcdc58e8cae"
|
||||
|
||||
[[projects]]
|
||||
digest = "1:d5083934eb25e45d17f72ffa86cae3814f4a9d6c073c4f16b64147169b245606"
|
||||
name = "github.com/gin-gonic/gin"
|
||||
packages = [
|
||||
".",
|
||||
"binding",
|
||||
"json",
|
||||
"render",
|
||||
]
|
||||
pruneopts = "UT"
|
||||
revision = "b869fe1415e4b9eb52f247441830d502aece2d4d"
|
||||
version = "v1.3.0"
|
||||
|
||||
[[projects]]
|
||||
digest = "1:adea5a94903eb4384abef30f3d878dc9ff6b6b5b0722da25b82e5169216dfb61"
|
||||
name = "github.com/go-sql-driver/mysql"
|
||||
packages = ["."]
|
||||
pruneopts = "UT"
|
||||
revision = "d523deb1b23d913de5bdada721a6071e71283618"
|
||||
version = "v1.4.0"
|
||||
|
||||
[[projects]]
|
||||
digest = "1:97df918963298c287643883209a2c3f642e6593379f97ab400c2a2e219ab647d"
|
||||
name = "github.com/golang/protobuf"
|
||||
packages = ["proto"]
|
||||
pruneopts = "UT"
|
||||
revision = "aa810b61a9c79d51363740d207bb46cf8e620ed5"
|
||||
version = "v1.2.0"
|
||||
|
||||
[[projects]]
|
||||
digest = "1:b6f4477f09f11785097a121811f3a90d8d26cab73c1aa71abda859bdf6ad2334"
|
||||
name = "github.com/jinzhu/gorm"
|
||||
packages = [
|
||||
".",
|
||||
"dialects/mysql",
|
||||
]
|
||||
pruneopts = "UT"
|
||||
revision = "6ed508ec6a4ecb3531899a69cbc746ccf65a4166"
|
||||
version = "v1.9.1"
|
||||
|
||||
[[projects]]
|
||||
branch = "master"
|
||||
digest = "1:fd97437fbb6b7dce04132cf06775bd258cce305c44add58eb55ca86c6c325160"
|
||||
name = "github.com/jinzhu/inflection"
|
||||
packages = ["."]
|
||||
pruneopts = "UT"
|
||||
revision = "04140366298a54a039076d798123ffa108fff46c"
|
||||
|
||||
[[projects]]
|
||||
digest = "1:3e551bbb3a7c0ab2a2bf4660e7fcad16db089fdcfbb44b0199e62838038623ea"
|
||||
name = "github.com/json-iterator/go"
|
||||
packages = ["."]
|
||||
pruneopts = "UT"
|
||||
revision = "1624edc4454b8682399def8740d46db5e4362ba4"
|
||||
version = "v1.1.5"
|
||||
|
||||
[[projects]]
|
||||
digest = "1:d4d17353dbd05cb52a2a52b7fe1771883b682806f68db442b436294926bbfafb"
|
||||
name = "github.com/mattn/go-isatty"
|
||||
packages = ["."]
|
||||
pruneopts = "UT"
|
||||
revision = "0360b2af4f38e8d38c7fce2a9f4e702702d73a39"
|
||||
version = "v0.0.3"
|
||||
|
||||
[[projects]]
|
||||
digest = "1:33422d238f147d247752996a26574ac48dcf472976eda7f5134015f06bf16563"
|
||||
name = "github.com/modern-go/concurrent"
|
||||
packages = ["."]
|
||||
pruneopts = "UT"
|
||||
revision = "bacd9c7ef1dd9b15be4a9909b8ac7a4e313eec94"
|
||||
version = "1.0.3"
|
||||
|
||||
[[projects]]
|
||||
digest = "1:e32bdbdb7c377a07a9a46378290059822efdce5c8d96fe71940d87cb4f918855"
|
||||
name = "github.com/modern-go/reflect2"
|
||||
packages = ["."]
|
||||
pruneopts = "UT"
|
||||
revision = "4b7aa43c6742a2c18fdef89dd197aaae7dac7ccd"
|
||||
version = "1.0.1"
|
||||
|
||||
[[projects]]
|
||||
digest = "1:40e195917a951a8bf867cd05de2a46aaf1806c50cf92eebf4c16f78cd196f747"
|
||||
name = "github.com/pkg/errors"
|
||||
packages = ["."]
|
||||
pruneopts = "UT"
|
||||
revision = "645ef00459ed84a119197bfb8d8205042c6df63d"
|
||||
version = "v0.8.0"
|
||||
|
||||
[[projects]]
|
||||
digest = "1:03aa6e485e528acb119fb32901cf99582c380225fc7d5a02758e08b180cb56c3"
|
||||
name = "github.com/ugorji/go"
|
||||
packages = ["codec"]
|
||||
pruneopts = "UT"
|
||||
revision = "b4c50a2b199d93b13dc15e78929cfb23bfdf21ab"
|
||||
version = "v1.1.1"
|
||||
|
||||
[[projects]]
|
||||
branch = "master"
|
||||
digest = "1:58cb5fbdf85e1f468c749aa31773ff102866831106f52762b2823ae235ca11e7"
|
||||
name = "golang.org/x/net"
|
||||
packages = [
|
||||
"context",
|
||||
"context/ctxhttp",
|
||||
"internal/socks",
|
||||
"proxy",
|
||||
]
|
||||
pruneopts = "UT"
|
||||
revision = "8a410e7b638dca158bf9e766925842f6651ff828"
|
||||
|
||||
[[projects]]
|
||||
branch = "master"
|
||||
digest = "1:0dafafed83f125cdc945a014b2dec15e5b5d8cd2d77a2d1e3763120b08ab381b"
|
||||
name = "golang.org/x/sys"
|
||||
packages = [
|
||||
"unix",
|
||||
"windows",
|
||||
]
|
||||
pruneopts = "UT"
|
||||
revision = "4910a1d54f876d7b22162a85f4d066d3ee649450"
|
||||
|
||||
[[projects]]
|
||||
digest = "1:c25289f43ac4a68d88b02245742347c94f1e108c534dda442188015ff80669b3"
|
||||
name = "google.golang.org/appengine"
|
||||
packages = ["cloudsql"]
|
||||
pruneopts = "UT"
|
||||
revision = "b1f26356af11148e710935ed1ac8a7f5702c7612"
|
||||
version = "v1.1.0"
|
||||
|
||||
[[projects]]
|
||||
digest = "1:cbc72c4c4886a918d6ab4b95e347ffe259846260f99ebdd8a198c2331cf2b2e9"
|
||||
name = "gopkg.in/go-playground/validator.v8"
|
||||
packages = ["."]
|
||||
pruneopts = "UT"
|
||||
revision = "5f1438d3fca68893a817e4a66806cea46a9e4ebf"
|
||||
version = "v8.18.2"
|
||||
|
||||
[[projects]]
|
||||
digest = "1:342378ac4dcb378a5448dd723f0784ae519383532f5e70ade24132c4c8693202"
|
||||
name = "gopkg.in/yaml.v2"
|
||||
packages = ["."]
|
||||
pruneopts = "UT"
|
||||
revision = "5420a8b6744d3b0345ab293f6fcba19c978f1183"
|
||||
version = "v2.2.1"
|
||||
|
||||
[solve-meta]
|
||||
analyzer-name = "dep"
|
||||
analyzer-version = 1
|
||||
input-imports = [
|
||||
"github.com/docker/docker/client",
|
||||
"github.com/gin-gonic/gin",
|
||||
"github.com/jinzhu/gorm",
|
||||
"github.com/jinzhu/gorm/dialects/mysql",
|
||||
]
|
||||
solver-name = "gps-cdcl"
|
||||
solver-version = 1
|
42
Gopkg.toml
Normal file
42
Gopkg.toml
Normal file
@ -0,0 +1,42 @@
|
||||
# Gopkg.toml example
|
||||
#
|
||||
# Refer to https://golang.github.io/dep/docs/Gopkg.toml.html
|
||||
# for detailed Gopkg.toml documentation.
|
||||
#
|
||||
# required = ["github.com/user/thing/cmd/thing"]
|
||||
# ignored = ["github.com/user/project/pkgX", "bitbucket.org/user/project/pkgA/pkgY"]
|
||||
#
|
||||
# [[constraint]]
|
||||
# name = "github.com/user/project"
|
||||
# version = "1.0.0"
|
||||
#
|
||||
# [[constraint]]
|
||||
# name = "github.com/user/project2"
|
||||
# branch = "dev"
|
||||
# source = "github.com/myfork/project2"
|
||||
#
|
||||
# [[override]]
|
||||
# name = "github.com/x/y"
|
||||
# version = "2.4.0"
|
||||
#
|
||||
# [prune]
|
||||
# non-go = false
|
||||
# go-tests = true
|
||||
# unused-packages = true
|
||||
|
||||
|
||||
[[constraint]]
|
||||
name = "github.com/gin-gonic/gin"
|
||||
version = "1.3.0"
|
||||
|
||||
[[constraint]]
|
||||
name = "github.com/jinzhu/gorm"
|
||||
version = "1.9.1"
|
||||
|
||||
[[constraint]]
|
||||
name = "github.com/docker/docker"
|
||||
version = "1.13.1"
|
||||
|
||||
[prune]
|
||||
go-tests = true
|
||||
unused-packages = true
|
4
config.yml
Normal file
4
config.yml
Normal file
@ -0,0 +1,4 @@
|
||||
name: nvwa
|
||||
version: 1.0
|
||||
|
||||
port: 8080
|
5
config/config.go
Normal file
5
config/config.go
Normal file
@ -0,0 +1,5 @@
|
||||
package config
|
||||
|
||||
func Init() {
|
||||
|
||||
}
|
32
controller/common.go
Normal file
32
controller/common.go
Normal file
@ -0,0 +1,32 @@
|
||||
package controller
|
||||
|
||||
import (
|
||||
"github.com/gin-gonic/gin"
|
||||
)
|
||||
|
||||
//Response 返回结构体
|
||||
type Response struct {
|
||||
Code int `json:"code"`
|
||||
Message string `json:"message"`
|
||||
Data interface{} `json:"data"`
|
||||
}
|
||||
|
||||
func message(c *gin.Context, message string) {
|
||||
returnData(c, 0, message, nil)
|
||||
}
|
||||
|
||||
func success(c *gin.Context, data interface{}) {
|
||||
returnData(c, 0, "OK", data)
|
||||
}
|
||||
|
||||
func error(c *gin.Context, code int, message string) {
|
||||
returnData(c, code, message, nil)
|
||||
}
|
||||
|
||||
func returnData(c *gin.Context, code int, message string, data interface{}) {
|
||||
c.JSON(0, Response{
|
||||
Code: code,
|
||||
Message: message,
|
||||
Data: data,
|
||||
})
|
||||
}
|
15
controller/docker.go
Normal file
15
controller/docker.go
Normal file
@ -0,0 +1,15 @@
|
||||
package controller
|
||||
|
||||
import (
|
||||
"github.com/gin-gonic/gin"
|
||||
"yumc.pw/cloud/nvwa/service"
|
||||
)
|
||||
|
||||
var DockerController = &dockerController{}
|
||||
|
||||
type dockerController struct {
|
||||
}
|
||||
|
||||
func (d *dockerController) Version(c *gin.Context) {
|
||||
success(c, service.Docker.Version())
|
||||
}
|
10
controller/docker_container.go
Normal file
10
controller/docker_container.go
Normal file
@ -0,0 +1,10 @@
|
||||
package controller
|
||||
|
||||
import (
|
||||
"github.com/gin-gonic/gin"
|
||||
"yumc.pw/cloud/nvwa/service"
|
||||
)
|
||||
|
||||
func (d *dockerController) ContainerList(c *gin.Context) {
|
||||
success(c, service.Docker.ContainerList())
|
||||
}
|
10
controller/docker_image.go
Normal file
10
controller/docker_image.go
Normal file
@ -0,0 +1,10 @@
|
||||
package controller
|
||||
|
||||
import (
|
||||
"github.com/gin-gonic/gin"
|
||||
"yumc.pw/cloud/nvwa/service"
|
||||
)
|
||||
|
||||
func (d *dockerController) ImageList(c *gin.Context) {
|
||||
success(c, service.Docker.ImageList())
|
||||
}
|
10
controller/docker_node.go
Normal file
10
controller/docker_node.go
Normal file
@ -0,0 +1,10 @@
|
||||
package controller
|
||||
|
||||
import (
|
||||
"github.com/gin-gonic/gin"
|
||||
"yumc.pw/cloud/nvwa/service"
|
||||
)
|
||||
|
||||
func (d *dockerController) NodeList(c *gin.Context) {
|
||||
success(c, service.Docker.NodeList())
|
||||
}
|
26
controller/gitlog.go
Normal file
26
controller/gitlog.go
Normal file
@ -0,0 +1,26 @@
|
||||
package controller
|
||||
|
||||
import (
|
||||
"github.com/gin-gonic/gin"
|
||||
"yumc.pw/cloud/nvwa/database"
|
||||
"yumc.pw/cloud/nvwa/model"
|
||||
"yumc.pw/cloud/nvwa/service"
|
||||
)
|
||||
|
||||
//GitLogCongtoller 控制器
|
||||
var GitLogCongtoller = &gitLogCongtoller{}
|
||||
|
||||
type gitLogCongtoller struct {
|
||||
}
|
||||
|
||||
//List 列出记录
|
||||
func (b *gitLogCongtoller) List(c *gin.Context) {
|
||||
success(c, service.Git.List())
|
||||
}
|
||||
|
||||
//Add 新增记录
|
||||
func (b *gitLogCongtoller) Add(c *gin.Context) {
|
||||
var log = model.GitLog{ProjectID: 1, Hash: "123456789"}
|
||||
database.Create(&log)
|
||||
success(c, nil)
|
||||
}
|
16
controller/index.go
Normal file
16
controller/index.go
Normal file
@ -0,0 +1,16 @@
|
||||
package controller
|
||||
|
||||
import (
|
||||
"github.com/gin-gonic/gin"
|
||||
)
|
||||
|
||||
//IndexController index
|
||||
var IndexController = &indexController{}
|
||||
|
||||
type indexController struct {
|
||||
}
|
||||
|
||||
//Ping Test Method
|
||||
func (b *indexController) Ping(c *gin.Context) {
|
||||
message(c, "Pong!")
|
||||
}
|
36
database/database.go
Normal file
36
database/database.go
Normal file
@ -0,0 +1,36 @@
|
||||
package database
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
|
||||
"github.com/jinzhu/gorm"
|
||||
_ "github.com/jinzhu/gorm/dialects/mysql" //MySQL
|
||||
)
|
||||
|
||||
// Db gorm
|
||||
var Db *gorm.DB
|
||||
|
||||
//Init database
|
||||
func Init() error {
|
||||
config := fmt.Sprintf("%s:%s@tcp(%s)/%s?charset=utf8&parseTime=%t&loc=%s",
|
||||
"nvwa",
|
||||
"nvwa",
|
||||
"server.yumc.pw",
|
||||
"nvwa",
|
||||
true,
|
||||
"Local")
|
||||
db, err := gorm.Open("mysql", config)
|
||||
db.Set("gorm:table_options", "ENGINE=InnoDB")
|
||||
Db = db
|
||||
return err
|
||||
}
|
||||
|
||||
// Create insert the value into database
|
||||
func Create(value interface{}) *gorm.DB {
|
||||
return Db.Create(value)
|
||||
}
|
||||
|
||||
//Close database
|
||||
func Close() {
|
||||
Db.Close()
|
||||
}
|
20
main.go
Normal file
20
main.go
Normal file
@ -0,0 +1,20 @@
|
||||
package main
|
||||
|
||||
import (
|
||||
"github.com/gin-gonic/gin"
|
||||
"yumc.pw/cloud/nvwa/config"
|
||||
"yumc.pw/cloud/nvwa/database"
|
||||
"yumc.pw/cloud/nvwa/model"
|
||||
"yumc.pw/cloud/nvwa/router"
|
||||
)
|
||||
|
||||
func main() {
|
||||
g := gin.Default()
|
||||
|
||||
router.Init(g)
|
||||
config.Init()
|
||||
database.Init()
|
||||
model.Init()
|
||||
|
||||
g.Run(":8080")
|
||||
}
|
12
model/gitlog.go
Normal file
12
model/gitlog.go
Normal file
@ -0,0 +1,12 @@
|
||||
package model
|
||||
|
||||
import (
|
||||
"github.com/jinzhu/gorm"
|
||||
)
|
||||
|
||||
// GitLog GIT日志
|
||||
type GitLog struct {
|
||||
gorm.Model
|
||||
ProjectID uint
|
||||
Hash string
|
||||
}
|
10
model/model.go
Normal file
10
model/model.go
Normal file
@ -0,0 +1,10 @@
|
||||
package model
|
||||
|
||||
import (
|
||||
"yumc.pw/cloud/nvwa/database"
|
||||
)
|
||||
|
||||
//Init 初始化模型
|
||||
func Init() {
|
||||
database.Db.AutoMigrate(&GitLog{})
|
||||
}
|
33
router/router.go
Normal file
33
router/router.go
Normal file
@ -0,0 +1,33 @@
|
||||
package router
|
||||
|
||||
import (
|
||||
"github.com/gin-gonic/gin"
|
||||
//nolint
|
||||
. "yumc.pw/cloud/nvwa/controller"
|
||||
)
|
||||
|
||||
//Init 初始化路由
|
||||
func Init(g *gin.Engine, handle ...gin.HandlerFunc) *gin.Engine {
|
||||
// 初始化中间件
|
||||
g.Use(handle...)
|
||||
|
||||
index := g.Group("/index")
|
||||
{
|
||||
index.GET("/ping", IndexController.Ping)
|
||||
}
|
||||
|
||||
git := g.Group("/git")
|
||||
{
|
||||
git.GET("/list", GitLogCongtoller.List)
|
||||
git.GET("/add", GitLogCongtoller.Add)
|
||||
}
|
||||
|
||||
docker := g.Group("/docker")
|
||||
{
|
||||
docker.GET("/version", DockerController.Version)
|
||||
docker.GET("/container/list", DockerController.ContainerList)
|
||||
docker.GET("/node/list", DockerController.NodeList)
|
||||
docker.GET("/image/list", DockerController.ImageList)
|
||||
}
|
||||
return g
|
||||
}
|
28
service/docker.go
Normal file
28
service/docker.go
Normal file
@ -0,0 +1,28 @@
|
||||
package service
|
||||
|
||||
import (
|
||||
"context"
|
||||
|
||||
docker_client "github.com/docker/docker/client"
|
||||
)
|
||||
|
||||
// Docker client
|
||||
var Docker = newClient("tcp://server.yumc.pw:2376", "1.38")
|
||||
|
||||
type docker struct {
|
||||
client *docker_client.Client
|
||||
context context.Context
|
||||
}
|
||||
|
||||
//Init the Docker Client
|
||||
func newClient(host string, version string) *docker {
|
||||
client, err := docker_client.NewClient(host, version, nil, nil)
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
return &docker{client: client, context: context.TODO()}
|
||||
}
|
||||
|
||||
func (d *docker) Version() string {
|
||||
return d.client.ClientVersion()
|
||||
}
|
18
service/docker_container.go
Normal file
18
service/docker_container.go
Normal file
@ -0,0 +1,18 @@
|
||||
package service
|
||||
|
||||
import (
|
||||
"github.com/docker/docker/api/types"
|
||||
"github.com/docker/docker/api/types/filters"
|
||||
)
|
||||
|
||||
func (d *docker) ContainerList() []types.Container {
|
||||
var (
|
||||
ctx = d.context
|
||||
options = types.ContainerListOptions{Filters: filters.NewArgs()}
|
||||
)
|
||||
containers, err := d.client.ContainerList(ctx, options)
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
return containers
|
||||
}
|
15
service/docker_images.go
Normal file
15
service/docker_images.go
Normal file
@ -0,0 +1,15 @@
|
||||
package service
|
||||
|
||||
import "github.com/docker/docker/api/types"
|
||||
|
||||
func (d *docker) ImageList() []types.ImageSummary {
|
||||
var (
|
||||
context = d.context
|
||||
options = types.ImageListOptions{}
|
||||
)
|
||||
images, err := d.client.ImageList(context, options)
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
return images
|
||||
}
|
19
service/docker_swarm.go
Normal file
19
service/docker_swarm.go
Normal file
@ -0,0 +1,19 @@
|
||||
package service
|
||||
|
||||
import (
|
||||
"github.com/docker/docker/api/types"
|
||||
"github.com/docker/docker/api/types/filters"
|
||||
"github.com/docker/docker/api/types/swarm"
|
||||
)
|
||||
|
||||
func (d *docker) NodeList() []swarm.Node {
|
||||
var (
|
||||
ctx = d.context
|
||||
options = types.NodeListOptions{Filters: filters.NewArgs()}
|
||||
)
|
||||
nodes, err := d.client.NodeList(ctx, options)
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
return nodes
|
||||
}
|
22
service/git.go
Normal file
22
service/git.go
Normal file
@ -0,0 +1,22 @@
|
||||
package service
|
||||
|
||||
import (
|
||||
"yumc.pw/cloud/nvwa/database"
|
||||
"yumc.pw/cloud/nvwa/model"
|
||||
)
|
||||
|
||||
// Git is a git client
|
||||
var Git = &git{}
|
||||
|
||||
type git struct {
|
||||
}
|
||||
|
||||
func (g *git) List() *[]model.GitLog {
|
||||
var users = &[]model.GitLog{}
|
||||
database.Db.Find(&users)
|
||||
return users
|
||||
}
|
||||
|
||||
func (g *git) Add(model *model.GitLog) {
|
||||
database.Db.Create(model)
|
||||
}
|
Loading…
Reference in New Issue
Block a user