package cn.ey.biz.module.system.dal.mapper.category;

import cn.ey.biz.common.pojo.PageResult;
import cn.ey.biz.framework.mybatis.core.mapper.BaseMapperX;
import cn.ey.biz.framework.mybatis.core.query.LambdaQueryWrapperX;
import cn.ey.biz.module.system.controller.admin.category.vo.CategoryAppExportReqVO;
import cn.ey.biz.module.system.controller.admin.category.vo.CategoryAppPageReqVO;
import cn.ey.biz.module.system.dal.dataobject.category.CategoryAppDO;
import org.apache.ibatis.annotations.Mapper;

import java.util.List;

/**
 * 字典分类应用 Mapper
 *
 */
@Mapper
public interface CategoryAppMapper extends BaseMapperX<CategoryAppDO> {

    default PageResult<CategoryAppDO> selectPage(CategoryAppPageReqVO reqVO) {
        return selectPage(reqVO, new LambdaQueryWrapperX<CategoryAppDO>()
                .eqIfPresent(CategoryAppDO::getCategoryId, reqVO.getCategoryId())
                .eqIfPresent(CategoryAppDO::getApp, reqVO.getApp())
                .eqIfPresent(CategoryAppDO::getStatus, reqVO.getStatus())
                .eqIfPresent(CategoryAppDO::getRemark, reqVO.getRemark())
                .betweenIfPresent(CategoryAppDO::getCreateTime, reqVO.getCreateTime())
                .orderByDesc(CategoryAppDO::getId));
    }

    default List<CategoryAppDO> selectList(CategoryAppExportReqVO reqVO) {
        return selectList(new LambdaQueryWrapperX<CategoryAppDO>()
                .eqIfPresent(CategoryAppDO::getCategoryId, reqVO.getCategoryId())
                .eqIfPresent(CategoryAppDO::getApp, reqVO.getApp())
                .eqIfPresent(CategoryAppDO::getStatus, reqVO.getStatus())
                .eqIfPresent(CategoryAppDO::getRemark, reqVO.getRemark())
                .betweenIfPresent(CategoryAppDO::getCreateTime, reqVO.getCreateTime())
                .orderByDesc(CategoryAppDO::getId));
    }

    default List<CategoryAppDO> selectListByCateGoryId(Long id) {
        return selectList(CategoryAppDO::getCategoryId,id);
    }

}
