NET7下的WEB API示例
NET7下的WEB API示例
[Route("api/[controller]")] [ApiController] public class ShopADController : ControllerBase { private readonly IRepository<Model.ShopAD, int> _shopAD; public ShopADController(IRepository<ShopAD, int> shopAD) { _shopAD = shopAD; } //http://localhost:5000/api/shopad [HttpGet] public string Get() { return "getget"; } //http://localhost:5000/api/shopad/banner [HttpGet("banner")] public List<Model.ShopAD> Banner() { return _shopAD.GetAllList(a => a.Remark == "banner"); } }
撸码:复制、粘贴,拿起键盘就是“干”!!!