feat(Gitee): 更新接口功能支持color关键字
This commit is contained in:
parent
d7dea56a7a
commit
24baa440d2
|
@ -21,15 +21,17 @@ namespace Bootstrap.Admin.Controllers.Api
|
|||
/// <param name="httpClientFactory"></param>
|
||||
/// <param name="userName"></param>
|
||||
/// <param name="repoName"></param>
|
||||
/// <param name="label"></param>
|
||||
/// <param name="color"></param>
|
||||
/// <returns></returns>
|
||||
public async Task<ActionResult> Issues([FromServices]IHttpClientFactory httpClientFactory, [FromQuery]string userName = "LongbowEnterprise", [FromQuery]string repoName = "BootstrapAdmin")
|
||||
public async Task<ActionResult> Issues([FromServices]IHttpClientFactory httpClientFactory, [FromQuery]string userName = "LongbowEnterprise", [FromQuery]string repoName = "BootstrapAdmin", [FromQuery]string label = "custom badge", [FromQuery]string color = "orange")
|
||||
{
|
||||
var client = httpClientFactory.CreateClient();
|
||||
var content = await client.GetStringAsync($"https://gitee.com/{userName}/{repoName}/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" });
|
||||
return new JsonResult(new { schemaVersion = 1, label, message = string.Join(" ", result), color });
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
|
@ -38,15 +40,17 @@ namespace Bootstrap.Admin.Controllers.Api
|
|||
/// <param name="httpClientFactory"></param>
|
||||
/// <param name="userName"></param>
|
||||
/// <param name="repoName"></param>
|
||||
/// <param name="label"></param>
|
||||
/// <param name="color"></param>
|
||||
/// <returns></returns>
|
||||
public async Task<ActionResult> Pulls([FromServices]IHttpClientFactory httpClientFactory, [FromQuery]string userName = "LongbowEnterprise", [FromQuery]string repoName = "BootstrapAdmin")
|
||||
public async Task<ActionResult> Pulls([FromServices]IHttpClientFactory httpClientFactory, [FromQuery]string userName = "LongbowEnterprise", [FromQuery]string repoName = "BootstrapAdmin", [FromQuery]string label = "custom badge", [FromQuery]string color = "orange")
|
||||
{
|
||||
var client = httpClientFactory.CreateClient();
|
||||
var content = await client.GetStringAsync($"https://gitee.com/{userName}/{repoName}/pulls");
|
||||
var regex = Regex.Matches(content, "<div class='ui mini circular label'>([\\d]+)</div>", RegexOptions.IgnoreCase);
|
||||
var labels = new string[] { "open", "merged", "closed" };
|
||||
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" });
|
||||
return new JsonResult(new { schemaVersion = 1, label, message = string.Join(" ", result), color });
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
|
@ -55,14 +59,16 @@ namespace Bootstrap.Admin.Controllers.Api
|
|||
/// <param name="httpClientFactory"></param>
|
||||
/// <param name="userName"></param>
|
||||
/// <param name="repoName"></param>
|
||||
/// <param name="label"></param>
|
||||
/// <param name="color"></param>
|
||||
/// <returns></returns>
|
||||
public async Task<ActionResult> Releases([FromServices]IHttpClientFactory httpClientFactory, [FromQuery]string userName = "LongbowEnterprise", [FromQuery]string repoName = "BootstrapAdmin")
|
||||
public async Task<ActionResult> Releases([FromServices]IHttpClientFactory httpClientFactory, [FromQuery]string userName = "LongbowEnterprise", [FromQuery]string repoName = "BootstrapAdmin", [FromQuery]string label = "custom badge", [FromQuery]string color = "orange")
|
||||
{
|
||||
var client = httpClientFactory.CreateClient();
|
||||
var content = await client.GetStringAsync($"https://gitee.com/{userName}/{repoName}/releases");
|
||||
var regex = Regex.Match(content, $"<a href=\"/{userName}/{repoName}/releases/([^\\s]+)\" target=\"_blank\">", RegexOptions.IgnoreCase);
|
||||
var result = regex.Groups[1].Value;
|
||||
return new JsonResult(new { schemaVersion = 1, label = result, message = "sweet world", color = "orange" });
|
||||
return new JsonResult(new { schemaVersion = 1, label, message = result, color });
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
|
@ -71,12 +77,14 @@ namespace Bootstrap.Admin.Controllers.Api
|
|||
/// <param name="httpClientFactory"></param>
|
||||
/// <param name="userName"></param>
|
||||
/// <param name="projName"></param>
|
||||
/// <param name="label"></param>
|
||||
/// <param name="color"></param>
|
||||
/// <returns></returns>
|
||||
public async Task<ActionResult> Builds([FromServices]IHttpClientFactory httpClientFactory, [FromQuery]string userName = "ArgoZhang", [FromQuery]string projName = "bootstrapadmin")
|
||||
public async Task<ActionResult> Builds([FromServices]IHttpClientFactory httpClientFactory, [FromQuery]string userName = "ArgoZhang", [FromQuery]string projName = "bootstrapadmin", [FromQuery]string label = "custom badge", [FromQuery]string color = "orange")
|
||||
{
|
||||
var client = httpClientFactory.CreateClient();
|
||||
var content = await client.GetAsJsonAsync<AppveyorBuildResult>($"https://ci.appveyor.com/api/projects/{userName}/{projName}");
|
||||
return new JsonResult(new { schemaVersion = 1, label = content.Build.Version, message = "sweet world", color = "orange" });
|
||||
return new JsonResult(new { schemaVersion = 1, label, message = content.Build.Version, color });
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
|
|
Loading…
Reference in New Issue