179 lines
6.4 KiB
C#
179 lines
6.4 KiB
C#
using APT.BaseData.Domain.Entities;
|
|
using APT.BaseData.Domain.IServices;
|
|
using APT.Infrastructure.Core;
|
|
using Microsoft.AspNetCore.Mvc;
|
|
using System;
|
|
using System.Collections.Generic;
|
|
using System.Linq;
|
|
using APT.Utility;
|
|
using APT.Infrastructure.Api;
|
|
using APT.Migrations;
|
|
using APT.BaseData.Domain.Entities.OP;
|
|
using APT.BaseData.Domain.Enums.OP;
|
|
using APT.BaseData.Domain.Enums.PF;
|
|
using APT.BaseData.Domain.IServices.OP;
|
|
using Microsoft.Data.SqlClient;
|
|
|
|
namespace APT.PF.WebApiControllers.Api.PF
|
|
{
|
|
/// <summary>
|
|
///
|
|
/// </summary>
|
|
[Route("api/PF/PFBivideoimg")]
|
|
public class PFBivideoimgController : AuthorizeApiController<T_PF_BIVIDEOIMG>
|
|
{
|
|
IOPTenantDBConnService OPTenantDBConnService { get; set; }
|
|
/// <summary>
|
|
///
|
|
/// </summary>
|
|
/// <param name="opTenantDBConnService"></param>
|
|
public PFBivideoimgController(IOPTenantDBConnService opTenantDBConnService)
|
|
{
|
|
OPTenantDBConnService = opTenantDBConnService;
|
|
}
|
|
|
|
/// <summary>
|
|
/// 更新或新增数据
|
|
/// </summary>
|
|
/// <param name="entity">对象实体</param>
|
|
/// <returns></returns>
|
|
[HttpPost, Route("FullUpdate")]
|
|
public JsonActionResult<bool> FullUpdate([FromBody] T_PF_BIVIDEOIMG entity)
|
|
{
|
|
return SafeExecute(() =>
|
|
{
|
|
T_PF_BIVIDEOIMG check = null;
|
|
var Nav_Files = entity.Nav_Files;
|
|
entity.Nav_Files = null;
|
|
var Nav_FilesImg = entity.Nav_FilesImg;
|
|
entity.Nav_FilesImg = null;
|
|
if (string.IsNullOrEmpty(entity.TITLE))
|
|
{
|
|
throw new Exception("请输入标题后再操作!");
|
|
}
|
|
if ((Nav_Files == null || Nav_Files.Count() < 1) && (Nav_FilesImg == null || Nav_FilesImg.Count() < 1))
|
|
{
|
|
throw new Exception("请上传" + (entity.TYPE == FILETYPEEnum.VIDEO ? "视频" : "图片") + "后再操作!");
|
|
}
|
|
if (entity.TYPE == FILETYPEEnum.VIDEO && Nav_Files.Where(e => !e.IS_DELETED).Count() > 1)
|
|
{
|
|
throw new Exception("只能上传一个视频!");
|
|
}
|
|
if (Nav_Files != null && Nav_Files.Count() > 0)
|
|
{
|
|
foreach (var item in Nav_Files)
|
|
{
|
|
item.TYPE = entity.TYPE;
|
|
}
|
|
}
|
|
if (Nav_FilesImg != null && Nav_FilesImg.Count() > 0)
|
|
{
|
|
foreach (var item in Nav_FilesImg)
|
|
{
|
|
item.TYPE = entity.TYPE;
|
|
}
|
|
}
|
|
if (entity.STATUS == STATEEnum.release)
|
|
{
|
|
check = GetEntity<T_PF_BIVIDEOIMG>(e => e.STATUS == STATEEnum.release);
|
|
if (check != null)
|
|
{
|
|
if (check.ID == entity.ID)
|
|
{
|
|
|
|
}
|
|
else
|
|
{
|
|
throw new Exception("只能有一条已发布的标语!如需发布本本条,请撤回已发布的标语!");
|
|
}
|
|
}
|
|
}
|
|
else if (entity.STATUS == STATEEnum.Delete)
|
|
{
|
|
entity.IS_DELETED = true;
|
|
}
|
|
else if (entity.STATUS == STATEEnum.Draft)
|
|
{
|
|
check = GetEntity<T_PF_BIVIDEOIMG>(entity.ID);
|
|
if (check != null && (check.STATUS == STATEEnum.release))
|
|
{
|
|
throw new Exception("请先撤回后再修改!");
|
|
}
|
|
}
|
|
if (entity.USER_ID_CREATER == Guid.Empty)
|
|
{
|
|
entity.USER_ID_CREATER = APT.Infrastructure.Api.AppContext.CurrentSession.UserID.Value;
|
|
}
|
|
|
|
entity.MODIFY_TIME = DateTime.Now;
|
|
this.UnifiedCommit(() =>
|
|
{
|
|
UpdateEntityNoCommit(entity);
|
|
if (Nav_Files != null && Nav_Files.Count() > 0)
|
|
BantchSaveEntityNoCommit(Nav_Files);
|
|
if (Nav_FilesImg != null && Nav_FilesImg.Count() > 0)
|
|
BantchSaveEntityNoCommit(Nav_FilesImg);
|
|
});
|
|
return true;
|
|
});
|
|
}
|
|
|
|
|
|
/// <summary>
|
|
/// 获得单条实体数据
|
|
/// </summary>
|
|
/// <param name="filter">过滤实体</param>
|
|
/// <returns></returns>
|
|
[HttpPost, Route("GetSuit")]
|
|
public JsonActionResult<T_PF_BIVIDEOIMG> GetSuit([FromBody] KeywordFilter filter)
|
|
{
|
|
return SafeExecute(() =>
|
|
{
|
|
var Include = filter.Include;
|
|
if (Include != null && Include.Count() > 0)
|
|
{
|
|
foreach (var item in Include)
|
|
{
|
|
if (item.StartsWith("Nav_FilesImg"))
|
|
{
|
|
filter.Include.Remove(item);
|
|
break;
|
|
}
|
|
}
|
|
}
|
|
var model = GetEntity<T_PF_BIVIDEOIMG>(null, filter, null);
|
|
if (model.TYPE == FILETYPEEnum.IMG)
|
|
{
|
|
model.Nav_FilesImg = model.Nav_Files;
|
|
model.Nav_Files = null;
|
|
}
|
|
return model;
|
|
});
|
|
}
|
|
|
|
/// <summary>
|
|
/// 更新或新增数据
|
|
/// </summary>
|
|
/// <param name="entity">对象实体</param>
|
|
/// <returns></returns>
|
|
[HttpPost, Route("UpdatePlaySet")]
|
|
public JsonActionResult<bool> UpdatePlaySet([FromBody] T_PF_BIPLAY_SET entity)
|
|
{
|
|
return SafeExecute(() =>
|
|
{
|
|
if (entity.V_ISAUTO && !entity.V_ISSILENT)
|
|
{
|
|
throw new Exception("自动播放必须静音!");
|
|
}
|
|
if (!entity.V_ISSHOWCONTROL && !entity.V_ISAUTO)
|
|
{
|
|
throw new Exception("不自动播放必须显示控制器!");
|
|
}
|
|
bool result = UpdateEntity(entity);
|
|
return result;
|
|
});
|
|
}
|
|
|
|
}
|
|
}
|