management_log_add.go 742 B

1234567891011121314151617181920212223242526272829303132333435
  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 ManagementLogAdd(ctx context.Context, req *v1.ManagementLogAddRequest) (reply *v1.ManagementLogAddReply, err error) {
  13. p := &model.TManagementLog{}
  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.CreatedAt = time.Unix(req.Timestamp, 0)
  21. err = p.Insert(database.DB())
  22. if err != nil {
  23. return nil, errors.DataBaseError
  24. }
  25. reply = &v1.ManagementLogAddReply{}
  26. return reply, nil
  27. }