学海无涯

导航

Dapper 经验

 in 查询

public async Task<IReadOnlyList<ResourceWorkCenterView>> GetResourceWorkCenterViewByWorkCenterIdsAsync(long[] workCenterIds)
  {
    string sql = "select * from ResourceWorkCenterView where WorkCenterId in @workCenterIds";
    using var conn = _dapperContext.CreateConnection();
    var result = await conn.QueryAsync<ResourceWorkCenterView>(sql, new { workCenterIds });
    if (result == null)
    {
      result = new List<ResourceWorkCenterView>();
    }
    return result.ToList();
  }

  

[SwaggerOperation(Summary = "根据指定的多个工作中心Id,得到工作中心的资源视图", Description = "根据指定的多个工作中心Id,得到工作中心的资源视图")]
  [HttpPost("ResourceWorkCenterView")]
  public async Task<ActionResult<IEnumerable<WorkCenterView>>> GetResourceWorkCenterViewByIdsAsync(long[] workCenterIds)
  {
    if (!workCenterIds.Any())
    {
      return BadRequest();
    }
    var result = await _unitOfWork.WorkCenters.GetResourceWorkCenterViewByWorkCenterIdsAsync(workCenterIds);
    return Ok(result);
  }

  

posted on 2024-02-01 09:50  宁静致远.  阅读(8)  评论(0编辑  收藏  举报