feat(Gitee): 增加接口抓取Gitee Issues数据
This commit is contained in:
parent
dd3003ffc2
commit
0543a40655
|
@ -0,0 +1,33 @@
|
|||
using Microsoft.AspNetCore.Authorization;
|
||||
using Microsoft.AspNetCore.Mvc;
|
||||
using System.Linq;
|
||||
using System.Net.Http;
|
||||
using System.Text.RegularExpressions;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace Bootstrap.Admin.Controllers.Api
|
||||
{
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
[Route("api/[controller]/[action]")]
|
||||
[ApiController]
|
||||
[AllowAnonymous]
|
||||
public class GiteeController : ControllerBase
|
||||
{
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
/// <param name="httpClientFactory"></param>
|
||||
/// <returns></returns>
|
||||
public async Task<ActionResult> Issues([FromServices]IHttpClientFactory httpClientFactory)
|
||||
{
|
||||
var client = httpClientFactory.CreateClient();
|
||||
var content = await client.GetStringAsync("https://gitee.com/LongbowEnterprise/BootstrapAdmin/issues");
|
||||
var regex = Regex.Matches(content, "<div class='ui mini circular label'>([\\d]+)</div>", RegexOptions.IgnoreCase);
|
||||
var labels = new string[] { "open", "closed", "rejected" };
|
||||
var result = regex.Select((m, i) => $"{labels[i]} {m.Groups[1].Value}");
|
||||
return new JsonResult(new { schemaVersion = 1, label = string.Join(" ", result), message = "sweet world", color = "orange" });
|
||||
}
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue