package com.unis.module.system.dal.mysql.arealevel;

import java.util.*;

import com.unis.framework.common.pojo.PageResult;
import com.unis.framework.mybatis.core.query.LambdaQueryWrapperX;
import com.unis.framework.mybatis.core.mapper.BaseMapperX;
import com.unis.module.system.dal.dataobject.arealevel.AreaLevelDO;
import org.apache.ibatis.annotations.Mapper;
import com.unis.module.system.controller.admin.arealevel.vo.*;

/**
 * 行政区划 Mapper
 *
 * @author 超级管理员
 */
@Mapper
@SuppressWarnings("all")
public interface AreaLevelMapper extends BaseMapperX<AreaLevelDO> {

    default PageResult<AreaLevelDO> selectPage(AreaLevelPageReqVO reqVO) {
        return selectPage(reqVO, new LambdaQueryWrapperX<AreaLevelDO>()
                .eqIfPresent(AreaLevelDO::getAreaCode, reqVO.getAreaCode())
                .likeIfPresent(AreaLevelDO::getAreaName, reqVO.getAreaName())
                .eqIfPresent(AreaLevelDO::getParentCode, reqVO.getParentCode())
                .eqIfPresent(AreaLevelDO::getAreaLevel, reqVO.getAreaLevel())
                .betweenIfPresent(AreaLevelDO::getCreateTime, reqVO.getCreateTime())
                .orderByDesc(AreaLevelDO::getId));
    }
    default List<AreaLevelDO> selectShengLevel() {
        return selectList(new LambdaQueryWrapperX<AreaLevelDO>()
                .eqIfPresent(AreaLevelDO::getAreaLevel,1));
    }

    default List<AreaLevelDO> selectListByParentCode(String parentCode) {
        return selectList(new LambdaQueryWrapperX<AreaLevelDO>()
                .eqIfPresent(AreaLevelDO::getParentCode,parentCode));
    }

    default AreaLevelDO selectListByAreaCode(String AreaCode) {
        return selectOne(new LambdaQueryWrapperX<AreaLevelDO>()
                .eqIfPresent(AreaLevelDO::getAreaCode,AreaCode));
    }
    default List<AreaLevelDO> selectListByName(List<String> names) {
        return selectList(new LambdaQueryWrapperX<AreaLevelDO>()
                .inIfPresent(AreaLevelDO::getAreaName,names));
    }
}