| 123456789101112131415161718192021222324252627 |
- 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
- }
|