system_log_add.go 766 B

12345678910111213141516171819202122232425262728293031323334353637
  1. // Copyright 2019 github.com. All rights reserved.
  2. // Use of this source code is governed by github.com.
  3. package log
  4. import (
  5. "context"
  6. "git.getensh.com/common/gopkgs/database"
  7. "property-log/model"
  8. "property-log/pb/v1"
  9. "time"
  10. "property-log/errors"
  11. )
  12. func SystemLogAdd(ctx context.Context, req *v1.SystemLogAddRequest) (reply *v1.SystemLogAddReply, err error) {
  13. p := &model.TSystemLog{}
  14. p.Uid = req.Uid
  15. p.Module = req.Module
  16. p.Action = req.Action
  17. p.Origin = req.Origin
  18. p.Target = req.Target
  19. p.Username = req.Username
  20. p.Cid = req.Cid
  21. p.GardenId = req.GardenId
  22. p.CreatedAt = time.Unix(req.Timestamp, 0)
  23. err = p.Insert(database.DB())
  24. if err != nil {
  25. return nil, errors.DataBaseError
  26. }
  27. reply = &v1.SystemLogAddReply{}
  28. return reply, nil
  29. }