package cn.iocoder.yudao.module.base.service.impl;

import cn.hutool.core.util.ObjectUtil;
import cn.iocoder.yudao.module.base.entity.DriveSchoolAddress;
import cn.iocoder.yudao.module.base.mapper.DriveSchoolAddressMapper;
import cn.iocoder.yudao.module.base.service.DriveSchoolAddressService;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import org.springframework.stereotype.Service;

import java.util.List;


/**
 * 地址管理表 Service 实现类
 *
 * @author 若依
 */
@Service
public class DriveSchoolAddressServiceImpl extends ServiceImpl<DriveSchoolAddressMapper, DriveSchoolAddress> implements DriveSchoolAddressService {

    /**
     * 查满足条件的所有地址
     *
     * @param type 地点类型（0-训练|1-考试）
     * @return java.util.List<cn.iocoder.yudao.module.base.entity.DriveSchoolAddress>
     * @author vinjor-M
     * @date 18:39 2025/2/6
     **/
    @Override
    public List<DriveSchoolAddress> getList(Integer type, String subject, Long tenantId) {
        LambdaQueryWrapper<DriveSchoolAddress> queryWrapper = new LambdaQueryWrapper<DriveSchoolAddress>();
        queryWrapper.eq(ObjectUtil.isNotEmpty(tenantId), DriveSchoolAddress::getTenantId, tenantId);
        queryWrapper.eq(ObjectUtil.isNotEmpty(type), DriveSchoolAddress::getType, type);
        queryWrapper.eq(ObjectUtil.isNotEmpty(subject), DriveSchoolAddress::getSubjects, subject);
        queryWrapper.orderByAsc(DriveSchoolAddress::getSort);
        return this.list(queryWrapper);
    }
}