package co.yixiang.yshop.module.shop.dal.mysql.canvas;

import java.util.*;

import co.yixiang.yshop.framework.common.pojo.PageResult;
import co.yixiang.yshop.framework.mybatis.core.query.LambdaQueryWrapperX;
import co.yixiang.yshop.framework.mybatis.core.mapper.BaseMapperX;
import co.yixiang.yshop.module.shop.dal.dataobject.canvas.CanvasDO;
import org.apache.ibatis.annotations.Mapper;
import co.yixiang.yshop.module.shop.controller.admin.canvas.vo.*;

/**
 * 画布信息 Mapper
 *
 * @author moxiangrong
 */
@Mapper
public interface CanvasMapper extends BaseMapperX<CanvasDO> {

    default PageResult<CanvasDO> selectPage(CanvasPageReqVO reqVO) {
        return selectPage(reqVO, new LambdaQueryWrapperX<CanvasDO>()
                .likeIfPresent(CanvasDO::getName, reqVO.getName())
                .eqIfPresent(CanvasDO::getState, reqVO.getState())
                .eqIfPresent(CanvasDO::getType, reqVO.getType())
                .betweenIfPresent(CanvasDO::getCreateTime, reqVO.getCreateTime())
                .orderByDesc(CanvasDO::getId));
    }

    default List<CanvasDO> selectList(CanvasExportReqVO reqVO) {
        return selectList(new LambdaQueryWrapperX<CanvasDO>()
                .likeIfPresent(CanvasDO::getName, reqVO.getName())
                .eqIfPresent(CanvasDO::getState, reqVO.getState())
                .betweenIfPresent(CanvasDO::getCreateTime, reqVO.getCreateTime())
                .orderByDesc(CanvasDO::getId));
    }

}
