package com.yuchen.saas.park.service.service.building.impl;


import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.yuchen.saas.park.api.dto.building.PmgBatBuildingApartmentTypeQryDto;
import com.yuchen.saas.park.api.dto.building.PmgBatBuildingApartmentTypeQueryDto;
import com.yuchen.saas.park.api.entity.building.PmgBatBuildingApartmentType;
import com.yuchen.saas.park.api.vo.building.PmgBatBuildingApartmentTypeCountVO;
import com.yuchen.saas.park.service.mapper.building.PmgBatBuildingApartmentTypeMapper;
import com.yuchen.saas.park.service.service.building.IPmgBatBuildingApartmentTypeService;
import org.nest.springwrap.core.mp.base.BaseServiceImpl;
import org.nest.springwrap.core.tool.utils.Func;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * <p>
 * 户型信息表 服务实现类
 * </p>
 *
 * @author yuanzhelin
 * @since 2024-10-17
 */
@Service
public class PmgBatBuildingApartmentTypeServiceImpl extends BaseServiceImpl<PmgBatBuildingApartmentTypeMapper, PmgBatBuildingApartmentType> implements IPmgBatBuildingApartmentTypeService {

    @Override
    public Page<PmgBatBuildingApartmentType> pages(PmgBatBuildingApartmentTypeQueryDto dto) {
        Page<PmgBatBuildingApartmentType> page = new Page<>(dto.getCurrent(), dto.getSize());
        LambdaQueryWrapper<PmgBatBuildingApartmentType> wrapper = new LambdaQueryWrapper<>();
        wrapper.eq(Func.isNotEmpty(dto.getProjectId()),PmgBatBuildingApartmentType::getProjectId, dto.getProjectId());
        wrapper.like(Func.isNotEmpty(dto.getApartmentTypeName()),PmgBatBuildingApartmentType::getApartmentTypeName, dto.getApartmentTypeName());
        wrapper.eq(Func.isNotEmpty(dto.getApartmentType()),PmgBatBuildingApartmentType::getApartmentType, dto.getApartmentType());
        wrapper.eq(Func.isNotEmpty(dto.getSellStatus()),PmgBatBuildingApartmentType::getSellStatus, dto.getSellStatus());
        wrapper.like(Func.isNotEmpty(dto.getOrientation()),PmgBatBuildingApartmentType::getOrientation, dto.getOrientation());
        return this.page(page,wrapper);
    }

    @Override
    public List<PmgBatBuildingApartmentType> getList(PmgBatBuildingApartmentTypeQryDto dto) {
        LambdaQueryWrapper<PmgBatBuildingApartmentType> wrapper = new LambdaQueryWrapper<>();
        wrapper.eq(Func.isNotEmpty(dto.getProjectId()),PmgBatBuildingApartmentType::getProjectId, dto.getProjectId());
        wrapper.like(Func.isNotEmpty(dto.getApartmentType()),PmgBatBuildingApartmentType::getApartmentType, dto.getApartmentType());
        return list(wrapper);
    }

    @Override
    public List<PmgBatBuildingApartmentTypeCountVO> typeCount(Long projectId) {
        return baseMapper.typeCount(projectId);
    }
}
