123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051 |
- package User
- import (
- "context"
- "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,
- },
- }, nil
- }
|