1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253 |
- package User
- import (
- "context"
- "github.com/alibabacloud-go/tea/tea"
- "github.com/suyuan32/simple-admin-common/msg/errormsg"
- "wechat-api/ent"
- "wechat-api/ent/wxcarduser"
- "wechat-api/internal/utils/dberrorhandler"
- "wechat-api/internal/svc"
- "wechat-api/internal/types"
- "github.com/zeromicro/go-zero/core/logx"
- )
- type GetApiUserVipLogic struct {
- logx.Logger
- ctx context.Context
- svcCtx *svc.ServiceContext
- }
- func NewGetApiUserVipLogic(ctx context.Context, svcCtx *svc.ServiceContext) *GetApiUserVipLogic {
- return &GetApiUserVipLogic{
- Logger: logx.WithContext(ctx),
- ctx: ctx,
- svcCtx: svcCtx}
- }
- func (l *GetApiUserVipLogic) GetApiUserVip() (*types.UserVipResp, error) {
- userId := l.ctx.Value("userId").(uint64)
- userInfo, err := l.svcCtx.DB.WxCardUser.Query().Where(wxcarduser.ID(userId)).First(l.ctx)
- if err != nil {
- if ent.IsNotFound(err) {
- return nil, dberrorhandler.DefaultEntError(l.Logger, err, nil)
- }
- return nil, dberrorhandler.DefaultEntError(l.Logger, err, nil)
- }
- isVip := userInfo.IsVip > 0
- return &types.UserVipResp{
- BaseDataInfo: types.BaseDataInfo{
- Code: 0,
- Msg: errormsg.Success,
- },
- Data: types.UserVip{
- IsVip: &isVip,
- WechatAccount: tea.String("boweniac"),
- },
- }, nil
- }
|