94 lines
2.8 KiB
C#
94 lines
2.8 KiB
C#
|
|
using LangGuan.Command.Model;
|
|||
|
|
using LangGuan.Command.Model.EntityModel;
|
|||
|
|
using LangGuan.Services;
|
|||
|
|
using Microsoft.AspNetCore.Http;
|
|||
|
|
using Microsoft.AspNetCore.Mvc;
|
|||
|
|
using System;
|
|||
|
|
using System.Collections.Generic;
|
|||
|
|
using System.IO;
|
|||
|
|
using System.Linq;
|
|||
|
|
using System.Net;
|
|||
|
|
using System.Threading.Tasks;
|
|||
|
|
|
|||
|
|
namespace LangGuan.Controllers
|
|||
|
|
{
|
|||
|
|
[ApiVersion("1.0")]
|
|||
|
|
[Route("api/[controller]/v{version:apiVersion}")]
|
|||
|
|
[ApiController]
|
|||
|
|
public class VideoController : ControllerBase
|
|||
|
|
{
|
|||
|
|
private VideoService _videoService;
|
|||
|
|
/// <summary>
|
|||
|
|
///
|
|||
|
|
/// </summary>
|
|||
|
|
/// <param name="videoService"></param>
|
|||
|
|
public VideoController(VideoService videoService)
|
|||
|
|
{
|
|||
|
|
_videoService = videoService;
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
//[HttpPost]
|
|||
|
|
//public async Task<IActionResult> SaveRecoredFile()
|
|||
|
|
//{
|
|||
|
|
// if (Request.Form.Files.Any())
|
|||
|
|
// {
|
|||
|
|
// var file = Request.Form.Files["video-blob"];
|
|||
|
|
|
|||
|
|
// string UploadFolder = Path.Combine(Directory.GetCurrentDirectory(), "wwwroot", "UploadedFiles");
|
|||
|
|
// string UniqueFileName = Guid.NewGuid().ToString() + "_" + file.FileName + ".webm";
|
|||
|
|
// string UploadPath = Path.Combine(UploadFolder, UniqueFileName);
|
|||
|
|
// await file.CopyToAsync(new FileStream(UploadPath, FileMode.Create));
|
|||
|
|
// }
|
|||
|
|
// return Ok(HttpStatusCode.OK);
|
|||
|
|
//}
|
|||
|
|
/// <summary>
|
|||
|
|
/// 列表
|
|||
|
|
/// </summary>
|
|||
|
|
/// <returns></returns>
|
|||
|
|
[HttpGet("list")]
|
|||
|
|
public async Task<IActionResult> list([FromQuery] RqeustPaging request)
|
|||
|
|
{
|
|||
|
|
var result = await _videoService.GetList(request);
|
|||
|
|
return Ok(result);
|
|||
|
|
}
|
|||
|
|
/// <summary>
|
|||
|
|
/// 新加
|
|||
|
|
/// </summary>
|
|||
|
|
/// <param name="request"></param>
|
|||
|
|
/// <returns></returns>
|
|||
|
|
[HttpPost("add")]
|
|||
|
|
public async Task<IActionResult> Add(Video request)
|
|||
|
|
{
|
|||
|
|
var result = await _videoService.Add(request);
|
|||
|
|
return Ok(result);
|
|||
|
|
}
|
|||
|
|
/// <summary>
|
|||
|
|
/// /更新
|
|||
|
|
/// </summary>
|
|||
|
|
/// <returns></returns>
|
|||
|
|
[HttpPost("update")]
|
|||
|
|
public async Task<IActionResult> update(Video video)
|
|||
|
|
{
|
|||
|
|
var result = await _videoService.Update(video);
|
|||
|
|
return Ok(result);
|
|||
|
|
}
|
|||
|
|
/// <summary>
|
|||
|
|
/// 批量删除,传数组
|
|||
|
|
/// </summary>
|
|||
|
|
/// <param name="ids"></param>
|
|||
|
|
/// <returns></returns>
|
|||
|
|
[HttpDelete("remove")]
|
|||
|
|
public async Task<IActionResult> removoe(IEnumerable<string> ids)
|
|||
|
|
{
|
|||
|
|
if (ids.Any())
|
|||
|
|
{
|
|||
|
|
foreach (var item in ids)
|
|||
|
|
{
|
|||
|
|
await _videoService.RemoveAsync(item);
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
return Ok(new ApiResult() { code = 0 });
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
}
|