refactor operation log new

This commit is contained in:
Ulric Qin 2020-09-26 21:45:23 +08:00
parent 2d9287805e
commit ae705e1b40
4 changed files with 14 additions and 10 deletions

View File

@ -1,4 +1,4 @@
#!/bin/bash -x
#!/bin/bash
# release version
version=3.0.0

4
go.mod
View File

@ -10,6 +10,8 @@ require (
github.com/coreos/go-oidc v2.2.1+incompatible
github.com/dgryski/go-tsz v0.0.0-20180227144327-03b7d791f4fe
github.com/eapache/go-resiliency v1.2.0 // indirect
github.com/eapache/go-xerial-snappy v0.0.0-20180814174437-776d5712da21 // indirect
github.com/eapache/queue v1.1.0 // indirect
github.com/garyburd/redigo v1.6.2
github.com/gin-contrib/pprof v1.3.0
github.com/gin-gonic/gin v1.6.3
@ -22,6 +24,8 @@ require (
github.com/influxdata/influxdb v1.8.0
github.com/mattn/go-isatty v0.0.12
github.com/mattn/go-sqlite3 v1.14.0 // indirect
github.com/onsi/ginkgo v1.7.0 // indirect
github.com/onsi/gomega v1.4.3 // indirect
github.com/open-falcon/rrdlite v0.0.0-20200214140804-bf5829f786ad
github.com/pquerna/cachecontrol v0.0.0-20200819021114-67c6ae64274f // indirect
github.com/rcrowley/go-metrics v0.0.0-20200313005456-10cdbea86bc0 // indirect

View File

@ -14,6 +14,13 @@ type OperationLog struct {
Detail string `json:"detail"`
}
func (ol *OperationLog) New() error {
ol.Clock = time.Now().Unix()
ol.Id = 0
_, err := DB["rdb"].Insert(ol)
return err
}
func OperationLogNew(username, rescl string, resid interface{}, detail string) error {
now := time.Now().Unix()
obj := OperationLog{

View File

@ -63,15 +63,8 @@ func operationLogResGets(c *gin.Context) {
}, nil)
}
type oplogForm struct {
Username string `json:"username"`
ResCl string `json:"rescl"`
ResID string `json:"resid"`
Detail string `json:"detail"`
}
func v1OperationLogResPost(c *gin.Context) {
var f oplogForm
var f models.OperationLog
bind(c, &f)
renderMessage(c, models.OperationLogNew(f.Username, f.ResCl, f.ResID, f.Detail))
renderMessage(c, f.New())
}