You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
252 lines
9.2 KiB
252 lines
9.2 KiB
using Elight.Entity; |
|
using Elight.Logic; |
|
using Elight.Utility; |
|
using Elight.Utility.Code; |
|
using Elight.Utility.Extensions; |
|
using javax.xml.crypto; |
|
using Microsoft.AspNetCore.Authorization; |
|
using Microsoft.AspNetCore.Mvc; |
|
using Newtonsoft.Json; |
|
using SqlSugar; |
|
|
|
namespace _24Hour.Controllers.Common |
|
{ |
|
/// <summary> |
|
/// 视频举报 |
|
/// </summary> |
|
[Authorize] |
|
[ApiController] |
|
[Route("api/Video")] |
|
public class VideoController : Controller |
|
{ |
|
#region Identity |
|
private readonly SqlSugarClient _db;//数据库 |
|
private readonly WriteSysLog _logs;//操作日志 |
|
App_Sys_UserModel _userdata = new App_Sys_UserModel();//当前用户 |
|
private readonly ILogger<LoginController> _logger;//日志 |
|
Result result = new Result(); |
|
public VideoController(ILogger<LoginController> logger, SqlSugarClient db, WriteSysLog logs, User user) |
|
{ |
|
_logger = logger; |
|
_db = db; |
|
_logs = logs; |
|
_userdata = user.Userdata(); |
|
} |
|
|
|
#endregion |
|
|
|
#region 视频举报增删改查 |
|
/// <summary> |
|
/// 系统--视频举报分页查询 |
|
/// </summary> |
|
/// <param name="info"></param> |
|
/// <returns></returns> |
|
[HttpPost] |
|
[Route("QueryVideolist")] |
|
public async Task<Result> QueryVideolist(App_VideoInput Videodata) |
|
{ |
|
RefAsync<int> totalNumber = 0;//总数据 |
|
var Videolist = new List<dynamic>(); |
|
//查询视频举报记录 |
|
var list = await _db.Queryable<App_VideoModel>() |
|
.WhereIF(Videodata.reporting.NotNull(), q => q.reporting.Contains(Videodata.reporting)) |
|
.WhereIF(Videodata.state != null, q => q.state == Videodata.state) |
|
.WhereIF(Videodata.StartTime != null && Videodata.EndTime != null, q => q.creationtime >= Videodata.StartTime && q.creationtime < Videodata.EndTime.Value.AddDays(1)) |
|
.Where(q => q.IsDeleted == 0 && q.unitCode == _userdata.unitCode).ToPageListAsync(Videodata.PageIndex, Videodata.PageSize, totalNumber); |
|
Videodata.RowsCount = totalNumber; |
|
list.OrderByDescending(q => q.creationtime).ToList().ForEach(q => |
|
{ |
|
Videolist.Add(new |
|
{ |
|
Id = q.Id, |
|
name = q.anonymous == 0 ? "匿名" : q.createusername, |
|
reporting = q.reporting, |
|
videofile = q.videofile, |
|
creationtime = q.creationtime, |
|
state = q.state, |
|
notes = q.notes, |
|
annexurl = JsonConvert.DeserializeObject<string[]>(q.annexurl), |
|
contact = q.anonymous == 0 ? "" : q.contact |
|
}); |
|
}); |
|
result.IsSucceed = true; |
|
result.result =new { Paging = Videodata, Data = Videolist }; |
|
return result; |
|
} |
|
/// <summary> |
|
/// app--视频举报分页查询 |
|
/// </summary> |
|
/// <param name="info"></param> |
|
/// <returns></returns> |
|
[HttpPost] |
|
[Route("QueryVideo")] |
|
public async Task<Result> QueryVideo(App_VideoInput Videodata) |
|
{ |
|
var Videolist = new List<dynamic>(); |
|
//查询远程会见记录 |
|
var list = await _db.Queryable<App_VideoModel>() |
|
.WhereIF(Videodata.reporting.NotNull(), q => q.reporting.Contains(Videodata.reporting)) |
|
.WhereIF(Videodata.state != null, q => q.state == Videodata.state) |
|
.WhereIF(Videodata.unitId.NotNull(), q => q.unitCode.Contains(Videodata.unitId)) |
|
.Where(q => q.IsDeleted == 0 && q.createuserId == _userdata.Id).ToPageListAsync(Videodata.PageIndex, Videodata.PageSize); |
|
list.OrderByDescending(q => q.creationtime).ToList().ForEach(q => |
|
{ |
|
Videolist.Add(new |
|
{ |
|
name = q.anonymous == 0 ? "匿名" : q.createusername, |
|
reporting = q.reporting, |
|
videofile = q.videofile, |
|
creationtime = q.creationtime, |
|
notes = q.notes, |
|
annexurl =JsonConvert.DeserializeObject<string[]>(q.annexurl), |
|
contact = q.anonymous == 0 ? "" : q.contact |
|
}); |
|
}); |
|
result.IsSucceed = true; |
|
result.result = Videolist; |
|
return result; |
|
} |
|
/// <summary> |
|
/// 添加视频举报 |
|
/// </summary> |
|
/// <param name="Videodata">视频举报对象</param> |
|
/// <returns></returns> |
|
[HttpPost] |
|
[Route("AddVideo")] |
|
public async Task<Result> AddVideo(App_VideoModel Videodata) |
|
{ |
|
try |
|
{ |
|
_db.BeginTran(); |
|
Videodata.Id = Guid.NewGuid().ToString(); |
|
Videodata.createuserId = _userdata.Id.ToString(); |
|
Videodata.createusername = _userdata.name; |
|
Videodata.state = 0; |
|
var num = await _db.Insertable(Videodata).ExecuteCommandAsync(); |
|
_db.CommitTran(); |
|
if (num > 0) |
|
{ |
|
result.IsSucceed = true; |
|
result.result = "添加成功"; |
|
} |
|
} |
|
catch (System.Exception ex) |
|
{ |
|
_db.RollbackTran(); |
|
result.IsSucceed = false; |
|
result.Message = ex.Message; |
|
} |
|
_logs.WriteSysLogadd("视频举报管理", "添加视频举报", result, _db); |
|
return result; |
|
} |
|
|
|
/// <summary> |
|
/// 修改视频举报 |
|
/// </summary> |
|
/// <param name="info"></param> |
|
/// <returns></returns> |
|
[HttpPost] |
|
[Route("UpdateVideo")] |
|
public async Task<Result> UpdateVideo(App_VideoModel Videodata) |
|
{ |
|
try |
|
{ |
|
_db.BeginTran(); |
|
var num = await _db.Updateable(Videodata).IgnoreColumns(ignoreAllNullColumns: true).ExecuteCommandAsync(); |
|
_db.CommitTran(); |
|
if (num > 0) |
|
{ |
|
result.IsSucceed = true; |
|
result.result = "修改成功"; |
|
} |
|
} |
|
catch (System.Exception ex) |
|
{ |
|
_db.RollbackTran(); |
|
result.IsSucceed = false; |
|
result.Message = ex.Message; |
|
} |
|
_logs.WriteSysLogadd("视频举报管理", "修改视频举报", result, _db); |
|
return result; |
|
} |
|
|
|
/// <summary> |
|
/// 删除视频举报 |
|
/// </summary> |
|
/// <param name="info"></param> |
|
/// <returns></returns> |
|
[HttpPost] |
|
[Route("DeleteVideo")] |
|
public async Task<Result> DeleteVideo(CurrencyDelete Currency) |
|
{ |
|
try |
|
{ |
|
_db.BeginTran(); |
|
var Videodatalist = await _db.Queryable<App_VideoModel>().In(q => q.Id, Currency.id).ToListAsync(); |
|
Videodatalist.ForEach(q => |
|
{ |
|
q.IsDeleted = 1; |
|
}); |
|
var num = await _db.Updateable(Videodatalist).ExecuteCommandAsync(); |
|
_db.CommitTran(); |
|
if (num > 0) |
|
{ |
|
result.IsSucceed = true; |
|
result.result = "删除成功"; |
|
} |
|
} |
|
catch (System.Exception ex) |
|
{ |
|
_db.RollbackTran(); |
|
result.IsSucceed = false; |
|
result.Message = ex.Message; |
|
} |
|
_logs.WriteSysLogadd("视频举报管理", "删除视频举报", result, _db); |
|
return result; |
|
} |
|
|
|
|
|
/// <summary> |
|
/// 更改视频举报状态 |
|
/// </summary> |
|
/// <param name="Id">视频举报ID</param> |
|
/// <param name="state">视频举报状态</param> |
|
/// <returns></returns> |
|
[HttpGet] |
|
[Route("UpdateVideostate")] |
|
public async Task<Result> UpdateVideostate(string? Id, int state) |
|
{ |
|
try |
|
{ |
|
var Video = await _db.Queryable<App_VideoModel>().Where(q => q.Id == Id).ToArrayAsync(); |
|
if (Video.Any()) |
|
{ |
|
Video.FirstOrDefault().state = state; |
|
_db.BeginTran(); |
|
var num = await _db.Updateable(Video.FirstOrDefault()).UpdateColumns(it => new { it.state}).ExecuteCommandAsync(); |
|
_db.CommitTran(); |
|
if (num > 0) |
|
{ |
|
result.IsSucceed = true; |
|
result.result = "修改成功"; |
|
} |
|
} |
|
else |
|
{ |
|
result.IsSucceed = false; |
|
result.result = "未找到举报信息!"; |
|
|
|
} |
|
} |
|
catch (System.Exception ex) |
|
{ |
|
_db.RollbackTran(); |
|
result.IsSucceed = false; |
|
result.Message = ex.Message; |
|
} |
|
_logs.WriteSysLogadd("视频举报管理", "修改视频举报", result, _db); |
|
return result; |
|
} |
|
#endregion |
|
} |
|
}
|
|
|