package logic

import (
	"app.yhyue.com/moapp/jybase/common"
	"context"
	"jyBXBase/rpc/type/bxbase"
	"net/http"

	"jyBXBase/api/internal/svc"
	"jyBXBase/api/internal/types"

	"github.com/zeromicro/go-zero/core/logx"
)

type ShowSearchScreenLogic struct {
	logx.Logger
	ctx    context.Context
	svcCtx *svc.ServiceContext
	r      *http.Request
}

func NewShowSearchScreenLogic(ctx context.Context, svcCtx *svc.ServiceContext, r *http.Request) *ShowSearchScreenLogic {
	return &ShowSearchScreenLogic{
		Logger: logx.WithContext(ctx),
		ctx:    ctx,
		svcCtx: svcCtx,
		r:      r,
	}
}

func (l *ShowSearchScreenLogic) ShowSearchScreen(req *types.ShowSearchScreen) (resp *types.CommonRes, err error) {
	res, err0 := l.svcCtx.Bxbase.ShowSearch(l.ctx, &bxbase.ShowSearchReq{
		UserId: req.UserId,
		Type:   req.Type,
		AppId:  req.AppId,
	})
	if err0 != nil {
		return &types.CommonRes{
			Err_code: -1,
			Err_msg:  err0.Error(),
			Data:     nil,
		}, nil
	}
	return &types.CommonRes{
		Err_code: common.IntAll(res.ErrCode),
		Err_msg:  res.ErrMsg,
		Data:     res.Data,
	}, nil
}
