104 lines
3.7 KiB
C#
104 lines
3.7 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;
|
|
if (string.IsNullOrEmpty(entity.TITLE))
|
|
{
|
|
throw new Exception("请输入标题后再操作!");
|
|
}
|
|
if (Nav_Files == null || Nav_Files.Count() < 1)
|
|
{
|
|
throw new Exception("请上传图片或附件再操作!");
|
|
}
|
|
if (entity.TYPE == FILETYPEEnum.VIDEO && Nav_Files.Where(e => !e.IS_DELETED).Count() > 1)
|
|
{
|
|
throw new Exception("只能上传一个视频!");
|
|
}
|
|
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);
|
|
});
|
|
return true;
|
|
});
|
|
}
|
|
}
|
|
}
|