123456789101112131415161718192021222324252627282930313233343536373839 |
- // Copyright 2019 githup.com. All rights reserved.
- // Use of this source code is governed by githup.com.
- package user
- import (
- "context"
- "github.com/jaryhe/gopkgs/database"
- "github.com/jaryhe/gopkgs/logger"
- "github.com/jinzhu/gorm"
- "go.uber.org/zap"
- "smart-enterprise-management/errors"
- dbmodel "smart-enterprise-management/model"
- pb_v1 "smart-enterprise-management/pb/v1"
- )
- func UserInfo(ctx context.Context, req *pb_v1.UserInfoRequest)(reply *pb_v1.UserInfoReply, err error) {
- p := &dbmodel.TCompany{}
- where := map[string]interface{}{
- "id":req.Id,
- }
- // 状态判断
- err = p.Find(database.DB(), where, nil)
- if err != nil && err != gorm.ErrRecordNotFound {
- logger.Error("UserInfo",
- zap.String("err", err.Error()))
- return nil, errors.DataBaseError
- }
- if p.Id == 0 {
- return nil, errors.NoRecordError
- }
- reply = &pb_v1.UserInfoReply{
- Phone:p.BusinessContactPhone,
- Email:p.Email,
- }
- return reply, nil
- }
|