package com.yolo.keyboard.dal.mysql.productitems;

import java.util.*;

import com.yolo.keyboard.framework.common.pojo.PageResult;
import com.yolo.keyboard.framework.mybatis.core.query.LambdaQueryWrapperX;
import com.yolo.keyboard.framework.mybatis.core.mapper.BaseMapperX;
import com.yolo.keyboard.dal.dataobject.productitems.KeyboardProductItemsDO;
import org.apache.ibatis.annotations.Mapper;
import com.yolo.keyboard.controller.admin.productitems.vo.*;

/**
 * 内购商品 Mapper
 *
 * @author ziin
 */
@Mapper
public interface KeyboardProductItemsMapper extends BaseMapperX<KeyboardProductItemsDO> {

    default PageResult<KeyboardProductItemsDO> selectPage(KeyboardProductItemsPageReqVO reqVO) {
        return selectPage(reqVO, new LambdaQueryWrapperX<KeyboardProductItemsDO>()
                .eqIfPresent(KeyboardProductItemsDO::getProductId, reqVO.getProductId())
                .eqIfPresent(KeyboardProductItemsDO::getType, reqVO.getType())
                .likeIfPresent(KeyboardProductItemsDO::getName, reqVO.getName())
                .eqIfPresent(KeyboardProductItemsDO::getUnit, reqVO.getUnit())
                .eqIfPresent(KeyboardProductItemsDO::getDurationValue, reqVO.getDurationValue())
                .eqIfPresent(KeyboardProductItemsDO::getDurationUnit, reqVO.getDurationUnit())
                .eqIfPresent(KeyboardProductItemsDO::getPrice, reqVO.getPrice())
                .eqIfPresent(KeyboardProductItemsDO::getCurrency, reqVO.getCurrency())
                .eqIfPresent(KeyboardProductItemsDO::getDescription, reqVO.getDescription())
                .eqIfPresent(KeyboardProductItemsDO::getCreatedAt, reqVO.getCreatedAt())
                .eqIfPresent(KeyboardProductItemsDO::getUpdatedAt, reqVO.getUpdatedAt())
                .eqIfPresent(KeyboardProductItemsDO::getDurationDays, reqVO.getDurationDays())
                .orderByDesc(KeyboardProductItemsDO::getId));
    }

}