package com.jeequan.jeepay.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.jeequan.jeepay.db.entity.BankBranch;
import com.jeequan.jeepay.service.mapper.BankBranchMapper;
import org.springframework.stereotype.Service;
import org.springframework.util.ObjectUtils;

@Service
public class BankBranchService extends ServiceImpl<BankBranchMapper, BankBranch> {

    public Page<BankBranch> pageByArea(Page<BankBranch> page, String cityName, String bankName, String branchName) {
        LambdaQueryWrapper<BankBranch> qWrapper = Wrappers.lambdaQuery();
        qWrapper.eq(BankBranch::getCityName, cityName);
        qWrapper.eq(!ObjectUtils.isEmpty(bankName), BankBranch::getBankName, bankName);
        qWrapper.like(!ObjectUtils.isEmpty(branchName), BankBranch::getBranchName, branchName);
        return page(page, qWrapper);
    }
}
