package service import ( "designs/global" "designs/model" "encoding/json" "time" ) func SetActionLog(action string, userId int, object string, data interface{}) error { dataString, _ := json.Marshal(data) err := global.App.DB.Table(model.TableActionLog).Create(&model.ActionLog{ Action: action, UserId: userId, Object: object, Data: string(dataString), CreatedAt: model.XTime{Time: time.Now()}, }).Error if err != nil { global.App.Log.Error(err.Error()) return err } return nil }