-
Notifications
You must be signed in to change notification settings - Fork 12
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
4d23c0e
commit d961431
Showing
32 changed files
with
487 additions
and
165 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,18 +1,41 @@ | ||
using Microsoft.AspNetCore.Authorization; | ||
using System.Threading.Tasks; | ||
using Danmu.Controllers.Base; | ||
using Danmu.Model.DataTable; | ||
using Danmu.Model.WebResult; | ||
using Danmu.Utils.Dao; | ||
using Microsoft.AspNetCore.Mvc; | ||
using static Danmu.Utils.Global.VariableDictionary; | ||
|
||
namespace Danmu.Controllers.Admin | ||
{ | ||
[Authorize(Policy = AdminRolePolicy)] | ||
[ApiController] | ||
[Route("/admin/danmuList")] | ||
public class DanmuListController : ControllerBase | ||
[Route("/api/admin/danmulist")] | ||
public class DanmuListController : AdminBaseController | ||
{ | ||
public DanmuListController(DanmuDao danmuDao, VideoDao videoDao) : base(danmuDao, videoDao) { } | ||
|
||
/// <summary> | ||
/// 获取全部弹幕数量 | ||
/// </summary> | ||
/// <returns></returns> | ||
[HttpGet("count")] | ||
public async Task<WebResult<int>> GetCount() | ||
{ | ||
var count = await DanmuDao.GetAllDanmuAsync(); | ||
return new WebResult<int> | ||
{ | ||
Code = 0, | ||
Data = count | ||
}; | ||
} | ||
|
||
/// <summary> | ||
/// 获取全部弹幕 | ||
/// </summary> | ||
/// <returns></returns> | ||
[HttpGet] | ||
public string Get() | ||
public async Task<WebResult<DanmuTable[]>> GetDanmuList(int page, int size, bool descending = true) | ||
{ | ||
return "11111"; | ||
var allDanmu = await DanmuDao.GetAllDanmuAsync(page, size, descending); | ||
return new WebResult<DanmuTable[]>(allDanmu); | ||
} | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
using System.Threading.Tasks; | ||
using Danmu.Controllers.Base; | ||
using Danmu.Model.DataTable; | ||
using Danmu.Model.WebResult; | ||
using Danmu.Utils.Dao; | ||
using Microsoft.AspNetCore.Mvc; | ||
|
||
namespace Danmu.Controllers.Admin | ||
{ | ||
[Route("/api/admin/danmuedit/")] | ||
public class DanmuEditController : AdminBaseController | ||
{ | ||
public DanmuEditController(DanmuDao danmuDao, VideoDao videoDao) : base(danmuDao, videoDao) { } | ||
|
||
[HttpGet("get")] | ||
public async Task<WebResult<DanmuTable>> Get(string id) | ||
{ | ||
var danmu = await DanmuDao.QueryDanmuByIdAsync(id); | ||
return new WebResult<DanmuTable>(danmu); | ||
} | ||
|
||
[HttpPost("edit")] | ||
public async Task<WebResult<DanmuTable>> EditDanmu(DanmuTable data) | ||
{ | ||
var result = await DanmuDao.EditDanmuAsync(data.Id, data.Data.Time, data.Data.Mode, data.Data.Color, | ||
data.Data.Text); | ||
return new WebResult<DanmuTable>(result); | ||
} | ||
|
||
[HttpGet("delete")] | ||
public async Task<WebResult> DeleteDanmu(string id) | ||
{ | ||
var result = await DanmuDao.DeleteDanmuAsync(id); | ||
return new WebResult(result ? 0 : 1); | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
using Danmu.Utils.Dao; | ||
using Microsoft.AspNetCore.Authorization; | ||
using Microsoft.AspNetCore.Cors; | ||
using Microsoft.AspNetCore.Mvc; | ||
using static Danmu.Utils.Global.VariableDictionary; | ||
|
||
namespace Danmu.Controllers.Base | ||
{ | ||
[ApiController] | ||
[EnableCors(AdminAllowSpecificOrigins)] | ||
[Authorize(Policy = AdminRolePolicy)] | ||
public class AdminBaseController : ControllerBase | ||
{ | ||
private protected DanmuDao DanmuDao; | ||
private protected VideoDao VideoDao; | ||
|
||
protected AdminBaseController(DanmuDao danmuDao, VideoDao videoDao) | ||
{ | ||
DanmuDao = danmuDao; | ||
VideoDao = videoDao; | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.