package com.miaxis.school.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.miaxis.school.domain.SchoolRegion;
import com.miaxis.school.mapper.SchoolRegionMapper;
import com.miaxis.school.service.ISchoolRegionService;
import com.miaxis.school.vo.SchoolRegionPcVO;
import org.apache.commons.lang3.StringUtils;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.List;

/**
 * 驾校训练场Service业务层处理
 *
 * @author zhangbin
 * @date 2020-12-28
 */
@Service
public class SchoolRegionServiceImpl extends ServiceImpl<SchoolRegionMapper, SchoolRegion> implements ISchoolRegionService {

    @Resource
    private SchoolRegionMapper schoolRegionMapper;

    @Override
    public List<SchoolRegion> queryList(SchoolRegion schoolRegion) {
        LambdaQueryWrapper<SchoolRegion> lqw = Wrappers.lambdaQuery();
        if (StringUtils.isNotBlank(schoolRegion.getInscode())){
            lqw.eq(SchoolRegion::getInscode ,schoolRegion.getInscode());
        }
        if (StringUtils.isNotBlank(schoolRegion.getSeq())){
            lqw.eq(SchoolRegion::getSeq ,schoolRegion.getSeq());
        }
        if (StringUtils.isNotBlank(schoolRegion.getName())){
            lqw.like(SchoolRegion::getName ,schoolRegion.getName());
        }
        if (StringUtils.isNotBlank(schoolRegion.getAddress())){
            lqw.eq(SchoolRegion::getAddress ,schoolRegion.getAddress());
        }
        if (schoolRegion.getArea() != null){
            lqw.eq(SchoolRegion::getArea ,schoolRegion.getArea());
        }
        if (schoolRegion.getType() != null){
            lqw.eq(SchoolRegion::getType ,schoolRegion.getType());
        }
        if (StringUtils.isNotBlank(schoolRegion.getVehicletype())){
            lqw.eq(SchoolRegion::getVehicletype ,schoolRegion.getVehicletype());
        }
        if (StringUtils.isNotBlank(schoolRegion.getPolygon())){
            lqw.eq(SchoolRegion::getPolygon ,schoolRegion.getPolygon());
        }
        if (schoolRegion.getTotalvehnum() != null){
            lqw.eq(SchoolRegion::getTotalvehnum ,schoolRegion.getTotalvehnum());
        }
        if (schoolRegion.getCurvehnum() != null){
            lqw.eq(SchoolRegion::getCurvehnum ,schoolRegion.getCurvehnum());
        }
        if (schoolRegion.getStatus() != null){
            lqw.eq(SchoolRegion::getStatus ,schoolRegion.getStatus());
        }
        if (schoolRegion.getFlag() != null){
            lqw.eq(SchoolRegion::getFlag ,schoolRegion.getFlag());
        }
        if (schoolRegion.getAuditDate() != null){
            lqw.eq(SchoolRegion::getAuditDate ,schoolRegion.getAuditDate());
        }
        if (StringUtils.isNotBlank(schoolRegion.getAreaCode())){
            lqw.eq(SchoolRegion::getAreaCode ,schoolRegion.getAreaCode());
        }
        if (schoolRegion.getPoiLon() != null){
            lqw.eq(SchoolRegion::getPoiLon ,schoolRegion.getPoiLon());
        }
        if (schoolRegion.getPoiLat() != null){
            lqw.eq(SchoolRegion::getPoiLat ,schoolRegion.getPoiLat());
        }
        return this.list(lqw);
    }

    /**
     * pc查询场地管理列表
     * @param schoolRegion
     * @return
     */
    @Override
    public List<SchoolRegionPcVO> queryRegionList(SchoolRegion schoolRegion) {
        return schoolRegionMapper.queryRegionList(schoolRegion);
    }
}
