package cn.iocoder.yudao.module.member.dal.mysql.activitytable;

import cn.iocoder.yudao.framework.common.pojo.PageResult;
import cn.iocoder.yudao.framework.mybatis.core.mapper.BaseMapperX;
import cn.iocoder.yudao.framework.mybatis.core.query.LambdaQueryWrapperX;
import cn.iocoder.yudao.module.member.controller.admin.activitytable.vo.ActivityTableCountVO;
import cn.iocoder.yudao.module.member.controller.admin.activitytable.vo.ActivityTablePageReqVO;
import cn.iocoder.yudao.module.member.dal.dataobject.activitytable.ActivityTableDO;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;

import java.util.List;

/**
 * 活动用餐桌子 Mapper
 *
 * @author 我是秦俊旗
 */
@Mapper
public interface ActivityTableMapper extends BaseMapperX<ActivityTableDO> {

    default PageResult<ActivityTableDO> selectPage(ActivityTablePageReqVO reqVO) {
        return selectPage(reqVO, new LambdaQueryWrapperX<ActivityTableDO>()
                .eqIfPresent(ActivityTableDO::getActivityId, reqVO.getActivityId())
                .eqIfPresent(ActivityTableDO::getSerialNumber, reqVO.getSerialNumber())
                .eqIfPresent(ActivityTableDO::getPrice, reqVO.getPrice())
                .eqIfPresent(ActivityTableDO::getUserId, reqVO.getUserId())
                .eqIfPresent(ActivityTableDO::getMobile, reqVO.getMobile())
                .betweenIfPresent(ActivityTableDO::getCreateTime, reqVO.getCreateTime())
                .eqIfPresent(ActivityTableDO::getReserveTime, reqVO.getReserveTime())
                .inIfPresent(ActivityTableDO::getSerialNumber, reqVO.getSerialNumbers())
                .isNotNull(reqVO.getIsReserve(),ActivityTableDO::getUserId)
                .orderByAsc(ActivityTableDO::getReserveTime)
                .orderByDesc(ActivityTableDO::getId));
    }

    List<ActivityTableCountVO> countByActivityIds(@Param("activityIds") List<Long> activityIds);


    void deleteByActivityId(@Param("activityId")Long activityId);
}