package com.lideeyunji.service.system.mapper;

import com.lideeyunji.tool.framework.common.pojo.PageResult;
import com.lideeyunji.tool.framework.mybatis.core.mapper.BaseMapperX;
import com.lideeyunji.tool.framework.mybatis.core.query.LambdaQueryWrapperX;
import com.lideeyunji.service.system.controller.vo.tenant.packages.TenantPackagePageReqVO;
import com.lideeyunji.service.system.entity.TenantPackageDO;
import org.apache.ibatis.annotations.Mapper;

import java.util.List;

/**
 * 租户套餐 Mapper
 *
 * @author 金灯剑客
 */
@Mapper
public interface TenantPackageMapper extends BaseMapperX<TenantPackageDO> {

    default PageResult<TenantPackageDO> selectPage(TenantPackagePageReqVO reqVO) {
        return selectPage(reqVO, new LambdaQueryWrapperX<TenantPackageDO>()
                .likeIfPresent(TenantPackageDO::getName, reqVO.getName())
                .eqIfPresent(TenantPackageDO::getStatus, reqVO.getStatus())
                .likeIfPresent(TenantPackageDO::getRemark, reqVO.getRemark())
                .betweenIfPresent(TenantPackageDO::getCreateTime, reqVO.getCreateTime())
                .orderByDesc(TenantPackageDO::getId));
    }

    default List<TenantPackageDO> selectListByStatus(Integer status) {
        return selectList(TenantPackageDO::getStatus, status);
    }
}
