package com.vctgo.system.mapper;

import com.vctgo.common.mybatisplus.mapper.BaseMapperX;
import com.vctgo.system.domain.SysCity;
import com.vctgo.system.domain.SysDistrict;
import com.vctgo.system.domain.SysProvince;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;
import org.springframework.stereotype.Repository;

import java.util.List;

/**
 * 省份信息Mapper接口
 *
 * @author wanglonghua
 * @date 2023-06-08
 */
@Repository
public interface SysProvinceMapper extends BaseMapperX<SysProvince>
{

    @Select("<script> select id, province_id, province " +
            " from sys_province " +
            " where 1=1 " +
            " <if test=\" provinceId !=null and provinceId != ''\" > and province_id = #{provinceId} </if>" +
            " </script>")
    List<SysProvince> selectProvinceList(@Param("provinceId") String provinceId);

    @Select("<script> select id, city_id, city, province_id " +
            " from sys_city " +
            " where 1=1 " +
            " <if test=\" cityId !=null and cityId != ''\" > and city_id = #{cityId} </if>" +
            " <if test=\" provinceId !=null and provinceId != ''\" > and province_id = #{provinceId} </if>" +
            " </script>")
    List<SysCity> selectCityList(@Param("provinceId") String provinceId,
                                 @Param("cityId") String cityId);

    @Select("<script> select id, district_id, district, city_id " +
            " from sys_district " +
            " where 1=1 " +
            " <if test=\" cityId !=null and cityId != ''\" > and city_id = #{cityId} </if>" +
            " </script>")
    List<SysDistrict> selectDistrictList(@Param("cityId") String cityId);

}
