diff --git a/Bootstrap.Admin/Controllers/Api/GiteeController.cs b/Bootstrap.Admin/Controllers/Api/GiteeController.cs new file mode 100644 index 00000000..0a74a030 --- /dev/null +++ b/Bootstrap.Admin/Controllers/Api/GiteeController.cs @@ -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" }); + } + } +}