package com.usky.fire.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.toolkit.StringUtils;
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
import com.usky.fire.domain.BaseCompany;
import com.usky.fire.domain.BaseStreetTown;
import com.usky.fire.mapper.BaseStreetTownMapper;
import com.usky.fire.service.BaseStreetTownService;
import com.usky.common.mybatis.core.AbstractCrudService;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * <p>
 * 街镇 服务实现类
 * </p>
 *
 * @author han
 * @since 2023-02-23
 */
@Service
public class BaseStreetTownServiceImpl extends AbstractCrudService<BaseStreetTownMapper, BaseStreetTown> implements BaseStreetTownService {
    @Override
    public List<BaseStreetTown> baseStreetTownList(String economize,String market,String districtCounty) {
        LambdaQueryWrapper<BaseStreetTown> queryWrapper = Wrappers.lambdaQuery();
        queryWrapper.select(BaseStreetTown::getId, BaseStreetTown::getEconomize,BaseStreetTown::getMarket,
                BaseStreetTown::getDistrictCounty, BaseStreetTown::getStreetTownName)
                .eq(StringUtils.isNotBlank(economize),BaseStreetTown::getEconomize, economize)
                .eq(StringUtils.isNotBlank(market),BaseStreetTown::getMarket, market)
                .eq(StringUtils.isNotBlank(districtCounty),BaseStreetTown::getDistrictCounty, districtCounty)
                .orderByDesc(BaseStreetTown::getId);
        List<BaseStreetTown> list = this.list(queryWrapper);
        return list;
    }
}
