| 1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253 |
- package logic
- import (
- "context"
- "git.i2edu.net/i2/i2-bill-api/internal/svc"
- "git.i2edu.net/i2/i2-bill-api/internal/types"
- "git.i2edu.net/i2/i2-bill-api/model"
- "git.i2edu.net/i2/i2-bill-erp/transform"
- "git.i2edu.net/i2/go-zero/core/logx"
- )
- type GetUserLogic struct {
- logx.Logger
- ctx context.Context
- svcCtx *svc.ServiceContext
- UserId int64
- SessionKey string
- }
- func NewGetUserLogic(ctx context.Context, svcCtx *svc.ServiceContext) GetUserLogic {
- return GetUserLogic{
- Logger: logx.WithContext(ctx),
- ctx: ctx,
- svcCtx: svcCtx,
- }
- }
- func (l *GetUserLogic) GetUser() (*types.InfoResponse, error) {
- var user model.User
- err := l.svcCtx.SqlConn.QueryRowPartial(&user, "select id, erp_id, avatar, birthday, username, nickname, gender, mobile from user where `id` = ? limit 1", l.UserId)
- if err != nil {
- logx.Error(err)
- return nil, err
- }
- // 每次都去查找, 暂时没有绑定
- // resp, err := l.svcCtx.Transformer.GetUser(l.ctx, &transform.UserRequest{Id: user.ErpId, Phone: user.Mobile})
- resp, err := l.svcCtx.Transformer.GetUser(l.ctx, &transform.UserRequest{Phone: user.Mobile})
- if err != nil {
- logx.Error(err)
- return nil, err
- }
- info := &types.InfoResponse{}
- info.ID = user.Id
- info.Avatar = user.Avatar
- info.Birthday = user.Birthday
- info.UserName = user.Username
- info.NickName = user.Nickname
- info.Gender = user.Gender
- info.ErpRoleType = resp.ErpRoleType
- return info, nil
- }
|