package cn.iocoder.yudao.module.basic.dal.mysql.businessinfo;

import java.util.*;

import cn.iocoder.yudao.framework.common.pojo.PageResult;
import cn.iocoder.yudao.framework.mybatis.core.query.LambdaQueryWrapperX;
import cn.iocoder.yudao.framework.mybatis.core.mapper.BaseMapperX;
import cn.iocoder.yudao.module.basic.dal.dataobject.businessinfo.BusinessInfoDO;
import com.alibaba.nacos.common.utils.StringUtils;
import org.apache.ibatis.annotations.Mapper;
import cn.iocoder.yudao.module.basic.controller.admin.businessinfo.vo.*;

/**
 * 商户 Mapper
 *
 * @author 芋道源码
 */
@Mapper
public interface BusinessInfoMapper extends BaseMapperX<BusinessInfoDO> {

    default PageResult<BusinessInfoDO> selectPage(BusinessInfoPageReqVO reqVO) {
        if(!StringUtils.isEmpty(reqVO.getVerifyState())){
            return selectPage(reqVO, new LambdaQueryWrapperX<BusinessInfoDO>()
                    .likeIfPresent(BusinessInfoDO::getBusinessName, reqVO.getBusinessName())
                    .eq(BusinessInfoDO::getVerifyState,reqVO.getVerifyState())
                    .orderByDesc(BusinessInfoDO::getId));
        }else {
            return selectPage(reqVO, new LambdaQueryWrapperX<BusinessInfoDO>()
                    .likeIfPresent(BusinessInfoDO::getBusinessName, reqVO.getBusinessName())
                    .orderByDesc(BusinessInfoDO::getId));
        }
    }

    default List<BusinessInfoDO> selectBusinessNameList() {
        return selectList(new LambdaQueryWrapperX<BusinessInfoDO>()
                .select(BusinessInfoDO::getBusinessName,BusinessInfoDO::getId)
                .orderByDesc(BusinessInfoDO::getId));
    }

}
