app-cloudep-portal-api-gateway/internal/logic/member/info_logic.go

56 lines
1.4 KiB
Go
Raw Permalink Normal View History

2024-08-25 07:08:49 +00:00
package member
import (
2024-08-27 07:40:00 +00:00
"app-cloudep-portal-api-gateway/internal/domain"
"app-cloudep-portal-api-gateway/internal/payload"
2024-08-25 07:08:49 +00:00
"app-cloudep-portal-api-gateway/internal/svc"
"app-cloudep-portal-api-gateway/internal/types"
2024-08-27 07:40:00 +00:00
"context"
"time"
2024-08-25 07:08:49 +00:00
2024-08-27 07:40:00 +00:00
accountRpc "code.30cm.net/digimon/proto-all/pkg/member"
2024-08-25 07:08:49 +00:00
"github.com/zeromicro/go-zero/core/logx"
)
type InfoLogic struct {
logx.Logger
ctx context.Context
svcCtx *svc.ServiceContext
}
func NewInfoLogic(ctx context.Context, svcCtx *svc.ServiceContext) *InfoLogic {
return &InfoLogic{
Logger: logx.WithContext(ctx),
ctx: ctx,
svcCtx: svcCtx,
}
}
2024-08-27 07:40:00 +00:00
func (l *InfoLogic) Info(_ *types.GetMemberHeader) (resp *types.UserInfoResp, err error) {
info, err := l.svcCtx.AccountRpc.GetUserInfo(l.ctx, &accountRpc.GetUserInfoReq{
Uid: payload.UID(l.ctx),
})
if err != nil {
return nil, err
}
2024-08-25 07:08:49 +00:00
2024-08-27 07:40:00 +00:00
return &types.UserInfoResp{
Status: types.Status{
Code: domain.SuccessCode,
Message: domain.SuccessMsg,
},
Data: types.UserInfo{
UID: info.Data.Uid,
VerifyType: info.Data.VerifyType.String(),
AlarmType: info.Data.AlarmType.String(),
Status: info.Data.Status.String(),
Language: info.Data.Language,
Currency: info.Data.Currency,
Avatar: info.Data.Avatar,
CreateTime: time.Unix(info.Data.CreateTime, 0).UTC().Format(time.RFC3339),
UpdateTime: time.Unix(info.Data.UpdateTime, 0).UTC().Format(time.RFC3339),
NickName: info.Data.NickName,
},
}, nil
2024-08-25 07:08:49 +00:00
}