添加持续集成部署部分数据库部分,handler大概框架
This commit is contained in:
parent
7c78231d91
commit
2501db94f5
|
|
@ -0,0 +1,85 @@
|
|||
package dao
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"gorm.io/gorm"
|
||||
)
|
||||
|
||||
type CID struct {
|
||||
gorm.Model
|
||||
Auth_id int `gorm:"column:auth_id"`
|
||||
Name string `gorm:"column:name"`
|
||||
Url string `gorm:"column:url"`
|
||||
Script string `gorm:"column:script"`
|
||||
End string `gorm:"column:end"`
|
||||
}
|
||||
|
||||
type CIDRunLog struct {
|
||||
gorm.Model
|
||||
CID_id int `gorm:"column:cid_id"`
|
||||
Auth_id int `form:"column:auth_id"`
|
||||
Log string `gorm:"column:log"`
|
||||
}
|
||||
|
||||
// CreateCID 创建持续集成、部署
|
||||
func CreateCID(name, url, script, end string, auth_id int) uint {
|
||||
cid := CID{Name: name, Url: url, Script: script, End: end, Auth_id: auth_id}
|
||||
result := DB.Debug().Create(&cid)
|
||||
if result.Error != nil {
|
||||
return 0
|
||||
}
|
||||
return cid.ID
|
||||
}
|
||||
|
||||
// DeleteCIDByID 删除持续集成、部署
|
||||
func DeleteCIDByID(id, auth_id int) bool {
|
||||
res := DB.Debug().Model(&CID{}).Where("id = ? and auth_id = ?", id, auth_id).Delete(&CID{})
|
||||
if res.Error != nil {
|
||||
return false
|
||||
}
|
||||
return true
|
||||
}
|
||||
|
||||
// FindCIDByID 查找持续集成、部署
|
||||
func FindCIDByID(id, auth_id int) CID {
|
||||
var cid CID
|
||||
DB.Debug().Where("id = ? and auth_id = ?", id, auth_id).First(&cid)
|
||||
return cid
|
||||
}
|
||||
|
||||
// FindCIDByAuthID 查找持续集成、部署
|
||||
func FindCIDByAuthID(auth_id int) []CID {
|
||||
var cids []CID
|
||||
DB.Debug().Where("auth_id = ?", auth_id).Find(&cids)
|
||||
return cids
|
||||
}
|
||||
|
||||
// UpdateCIDByID 更新持续集成、部署
|
||||
func UpdateCIDByID(id, auth_id int, name, url, script, end string) bool {
|
||||
pd := FindCIDByID(id, auth_id)
|
||||
if pd.ID == 0 {
|
||||
return false
|
||||
}
|
||||
result := DB.Debug().Model(&CID{}).Where("id = ? and auth_id = ?", id, auth_id).Updates(CID{Name: name, Url: url, Script: script, End: end})
|
||||
if result.Error != nil {
|
||||
return false
|
||||
}
|
||||
return true
|
||||
}
|
||||
|
||||
// CreateRunLog,添加执行日志
|
||||
func CreateRunLog(cid_id, auth_id int, log string) uint {
|
||||
cidRunLog := CIDRunLog{CID_id: cid_id, Auth_id: auth_id, Log: log}
|
||||
err := DB.Debug().Model(cidRunLog)
|
||||
if err != nil {
|
||||
fmt.Println(err)
|
||||
return 0
|
||||
}
|
||||
return cidRunLog.ID
|
||||
}
|
||||
|
||||
func FindRunLogByAuthID(auth_id, cid_id int) []CIDRunLog {
|
||||
var cidRunLogs []CIDRunLog
|
||||
DB.Debug().Where("cid_id = ? and auth_id = ?", cid_id, auth_id).Find(&cidRunLogs)
|
||||
return cidRunLogs
|
||||
}
|
||||
|
|
@ -0,0 +1,31 @@
|
|||
package handler
|
||||
|
||||
import "github.com/gin-gonic/gin"
|
||||
|
||||
func SetUpCIDGroup(router *gin.Engine) {
|
||||
cidGroup := router.Group("/cid") //持续集成、部署
|
||||
cidGroup.POST("/create", GetImKey)
|
||||
cidGroup.POST("/delete", DeleteCID)
|
||||
cidGroup.POST("/update", UpdateCID)
|
||||
cidGroup.POST("/list", GetCIDList)
|
||||
cidGroup.POST("/run", RunCID)
|
||||
}
|
||||
func RunCID(c *gin.Context) {
|
||||
|
||||
}
|
||||
|
||||
func CreateCID(c *gin.Context) {
|
||||
|
||||
}
|
||||
|
||||
func DeleteCID(c *gin.Context) {
|
||||
|
||||
}
|
||||
|
||||
func UpdateCID(c *gin.Context) {
|
||||
|
||||
}
|
||||
|
||||
func GetCIDList(c *gin.Context) {
|
||||
|
||||
}
|
||||
Loading…
Reference in New Issue