Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

查询接口路由 #5

Open
wurangbo opened this issue Apr 25, 2020 · 4 comments
Open

查询接口路由 #5

wurangbo opened this issue Apr 25, 2020 · 4 comments

Comments

@wurangbo
Copy link

hi 有个小问题想咨询一下,就是带参数的查询接口路由问题,我想征对一类数据做多种业务场景下的查询接口,如下面的接口就可以
http://10.169.42.116:1112/api/cors?coreSourceId=316000677
[HttpGet]
public IActionResult GetCOR([FromQuery(Name = "coreSourceId")] string coreSourceId)
{
return Ok(RealDataMapper.Instance.GetCORByCoreSourceId(coreSourceId));
}

   但我如果想定一个另外一个查询接口,就报适配错误, 
    http://10.169.42.116:1112/api/cors?categoryId=201
    [HttpGet]
    public IActionResult GetCORS([FromQuery(Name = "categoryId")] string categoryId)
    {
        return Ok(RealDataMapper.Instance.GetCORS(categoryId));
    }

   这种请先改如何解决?
@axzxs2001
Copy link
Owner

方法名称可以不一定,HttpGet("/cors")一样来区分

@wurangbo
Copy link
Author

@axzxs2001
Copy link
Owner

可以的,方法名不同就行

@wurangbo
Copy link
Author

wurangbo commented May 6, 2020

测试了不行啊。调用发生了AmbiguousActionException
[HttpGet]
public IActionResult GetCORSByCoreSourceId(string coreSourceId)
{
return Ok(RealDataMapper.Instance.GetCORByCoreSourceId(coreSourceId));
}

    [HttpGet]
    public IActionResult GetCORSByCategoryId(string categoryId)
    {
        return Ok(RealDataMapper.Instance.GetCORS(categoryId));
    }

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants