|
@@ -491,24 +491,56 @@ namespace OASystem.API.Controllers
|
|
|
}
|
|
|
|
|
|
/// <summary>
|
|
|
- /// 国家数据源
|
|
|
+ /// 国家数据源
|
|
|
/// </summary>
|
|
|
+ /// <param name="pageIndex">当前页码</param>
|
|
|
+ /// <param name="pageSize">每页条数</param>
|
|
|
+ /// <param name="search">查询条件</param>
|
|
|
/// <returns></returns>
|
|
|
[HttpGet]
|
|
|
[ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
|
|
|
- public async Task<IActionResult> CountryInit()
|
|
|
+ public async Task<IActionResult> CountryInit([FromQuery] int pageIndex, [FromQuery] int pageSize, [FromQuery] string search)
|
|
|
{
|
|
|
var countrys = await _sqlSugar.Queryable<Grp_NationalTravelFee>().Where(x => x.IsDel == 0).Select(x => x.Country).Distinct().ToListAsync();
|
|
|
- return Ok(JsonView(countrys));
|
|
|
+
|
|
|
+ if (pageIndex == 0 && pageSize == 0)
|
|
|
+ {
|
|
|
+ //所有数据
|
|
|
+ return Ok(JsonView(countrys, countrys.Count));
|
|
|
+ }
|
|
|
+
|
|
|
+ //分页
|
|
|
+ int skip = (pageIndex - 1) * pageSize;
|
|
|
+ int take = pageSize;
|
|
|
+
|
|
|
+ if (!string.IsNullOrEmpty(search))
|
|
|
+ {
|
|
|
+ IEnumerable<char> charSequence = search.Select(c => c);
|
|
|
+ var pageResult1 = countrys.Where(x => charSequence.All(x1 => x.Contains(x1))).ToList();
|
|
|
+ var pageData = pageResult1.Skip(skip).Take(take).ToList();
|
|
|
+ return Ok(JsonView(pageData, pageResult1.Count));
|
|
|
+ }
|
|
|
+
|
|
|
+ var pageResult2 = countrys.Skip(skip).Take(take).ToList();
|
|
|
+ return Ok(JsonView(pageResult2, countrys.Count));
|
|
|
+
|
|
|
}
|
|
|
|
|
|
/// <summary>
|
|
|
- /// 城市数据源
|
|
|
+ /// 城市数据源
|
|
|
/// </summary>
|
|
|
+ /// <param name="countryLabel">国家名称 多个使用英文逗号隔开</param>
|
|
|
+ /// <param name="pageIndex">当前页码</param>
|
|
|
+ /// <param name="pageSize">每页条数</param>
|
|
|
+ /// <param name="search">查询条件</param>
|
|
|
/// <returns></returns>
|
|
|
[HttpGet("{countryLabel}")]
|
|
|
[ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
|
|
|
- public async Task<IActionResult> CityByCountry(string countryLabel)
|
|
|
+ public async Task<IActionResult> CityByCountry(
|
|
|
+ string countryLabel,
|
|
|
+ [FromQuery] int pageIndex,
|
|
|
+ [FromQuery] int pageSize,
|
|
|
+ [FromQuery] string search)
|
|
|
{
|
|
|
countryLabel = HttpUtility.UrlDecode(countryLabel);
|
|
|
var countryList = countryLabel.Split(',', StringSplitOptions.RemoveEmptyEntries).ToArray();
|
|
@@ -532,7 +564,27 @@ namespace OASystem.API.Controllers
|
|
|
citys = cityDatas1.Select(x => x.City).Distinct().ToArray();
|
|
|
}
|
|
|
|
|
|
- return Ok(JsonView(citys));
|
|
|
+
|
|
|
+ if (pageIndex == 0 && pageSize == 0)
|
|
|
+ {
|
|
|
+ //所有数据
|
|
|
+ return Ok(JsonView(citys, citys?.Length ?? 0));
|
|
|
+ }
|
|
|
+
|
|
|
+ //分页
|
|
|
+ int skip = (pageIndex - 1) * pageSize;
|
|
|
+ int take = pageSize;
|
|
|
+
|
|
|
+ if (!string.IsNullOrEmpty(search))
|
|
|
+ {
|
|
|
+ IEnumerable<char> charSequence = search.Select(c => c);
|
|
|
+ var pageResult1 = citys.Where(x => charSequence.All(x1 => x.Contains(x1))).ToList();
|
|
|
+ var pageData = pageResult1.Skip(skip).Take(take).ToList();
|
|
|
+ return Ok(JsonView(pageData, pageResult1.Count()));
|
|
|
+ }
|
|
|
+
|
|
|
+ var pageResult2 = citys.Skip(skip).Take(take).ToList();
|
|
|
+ return Ok(JsonView(pageResult2, citys?.Length ?? 0));
|
|
|
}
|
|
|
|
|
|
/// <summary>
|