refactor operation log new
This commit is contained in:
parent
2d9287805e
commit
ae705e1b40
4
go.mod
4
go.mod
|
@ -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
|
||||
|
|
|
@ -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{
|
||||
|
|
|
@ -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())
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue