info.go 938 B

123456789101112131415161718192021222324252627282930313233343536373839
  1. // Copyright 2019 githup.com. All rights reserved.
  2. // Use of this source code is governed by githup.com.
  3. package user
  4. import (
  5. "context"
  6. "github.com/jaryhe/gopkgs/database"
  7. "github.com/jaryhe/gopkgs/logger"
  8. "github.com/jinzhu/gorm"
  9. "go.uber.org/zap"
  10. "smart-enterprise-management/errors"
  11. dbmodel "smart-enterprise-management/model"
  12. pb_v1 "smart-enterprise-management/pb/v1"
  13. )
  14. func UserInfo(ctx context.Context, req *pb_v1.UserInfoRequest)(reply *pb_v1.UserInfoReply, err error) {
  15. p := &dbmodel.TCompany{}
  16. where := map[string]interface{}{
  17. "id":req.Id,
  18. }
  19. // 状态判断
  20. err = p.Find(database.DB(), where, nil)
  21. if err != nil && err != gorm.ErrRecordNotFound {
  22. logger.Error("UserInfo",
  23. zap.String("err", err.Error()))
  24. return nil, errors.DataBaseError
  25. }
  26. if p.Id == 0 {
  27. return nil, errors.NoRecordError
  28. }
  29. reply = &pb_v1.UserInfoReply{
  30. Phone:p.BusinessContactPhone,
  31. Email:p.Email,
  32. }
  33. return reply, nil
  34. }