package logic

import (
	"app.yhyue.com/moapp/jybase/common"
	"context"
	"github.com/gogf/gf/v2/util/gconv"
	"jyBXSubscribe/rpc/model"

	"jyBXSubscribe/rpc/internal/svc"
	"jyBXSubscribe/rpc/type/bxsubscribe"

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

type GetStaffSubscribeListLogic struct {
	ctx    context.Context
	svcCtx *svc.ServiceContext
	logx.Logger
}

func NewGetStaffSubscribeListLogic(ctx context.Context, svcCtx *svc.ServiceContext) *GetStaffSubscribeListLogic {
	return &GetStaffSubscribeListLogic{
		ctx:    ctx,
		svcCtx: svcCtx,
		Logger: logx.WithContext(ctx),
	}
}

// GetStaffSubscribeList 查看企业员工用户订阅
func (l *GetStaffSubscribeListLogic) GetStaffSubscribeList(in *bxsubscribe.StaffSubscribeReq) (*bxsubscribe.StaffSubscribeListResp, error) {
	pNum := common.Int64All(common.If(in.PageNum < 0, 0, in.PageNum))
	pSize := common.Int64All(common.If(in.PageSize != 0, in.PageSize, 5))
	total, list := model.GetStaffSubscribeList(gconv.Int(in.EntId), gconv.Int(in.EntUserId), in.Query, in.EStatus, in.PStatus, pNum, pSize)
	return &bxsubscribe.StaffSubscribeListResp{
		Total: total,
		Items: list,
	}, nil
}
