company_log_add.go 744 B

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