96 lines
3.5 KiB
C#
96 lines
3.5 KiB
C#
using APT.Infrastructure.Core;
|
|
using APT.MS.Domain.Entities.SC.PR;
|
|
using APT.Utility;
|
|
using Microsoft.AspNetCore.Mvc;
|
|
using System;
|
|
using System.Collections.Generic;
|
|
using System.Linq;
|
|
|
|
namespace APT.SC.WebApi.Controllers.Api.PRController
|
|
{
|
|
/// <summary>
|
|
/// 岗位表单关联表
|
|
/// </summary>
|
|
[Route("api/PR/PRPostFormLink")]
|
|
public partial class PostFormLinkController : AuthorizeApiController<T_PR_POST_FORM_LINK>
|
|
{
|
|
/// <summary>
|
|
/// 新增/编辑
|
|
/// </summary>
|
|
/// <param name="entity"></param>
|
|
/// <returns></returns>
|
|
[HttpPost, Route("FullUpdate")]
|
|
public JsonActionResult<bool> FullUpdate([FromBody] T_PR_POST_FORM_LINK entity)
|
|
{
|
|
return SafeExecute(() =>
|
|
{
|
|
var codes = entity.Nav_Codes;
|
|
if (codes != null && codes.Any())
|
|
{
|
|
codes.ForEach(t =>
|
|
{
|
|
t.ORG_ID = entity.ORG_ID; t.POST_POST_ID = entity.ID;
|
|
t.Nav_Form = null;
|
|
});
|
|
}
|
|
entity.Nav_Codes = null;
|
|
var departments = entity.Nav_Departments;
|
|
if (departments != null && departments.Any())
|
|
{
|
|
departments.ForEach(t =>
|
|
{
|
|
t.ORG_ID = entity.ORG_ID; t.POST_POST_ID = entity.ID;
|
|
t.Nav_Department = null;
|
|
});
|
|
}
|
|
entity.Nav_Departments = null;
|
|
UnifiedCommit(() =>
|
|
{
|
|
if (entity != null)
|
|
this.UpdateEntityNoCommit(entity);
|
|
if (codes != null && codes.Any())
|
|
this.BantchSaveEntityNoCommit(codes);
|
|
if (departments != null && departments.Any())
|
|
this.BantchSaveEntityNoCommit(departments);
|
|
});
|
|
return true;
|
|
});
|
|
}
|
|
/// <summary>
|
|
/// 单条删除
|
|
/// </summary>
|
|
/// <param name="id"></param>
|
|
/// <returns></returns>
|
|
[HttpGet, Route("FullDelete")]
|
|
public JsonActionResult<bool> FullDelete(string id)
|
|
{
|
|
return SafeExecute<bool>(() =>
|
|
{
|
|
T_PR_POST_FORM_LINK entity = GetEntity<T_PR_POST_FORM_LINK>(t => t.ID.ToString() == id, false, "Nav_Codes", "Nav_Departments");
|
|
List<Guid> codeIds = new List<Guid>();
|
|
List<Guid> departIds = new List<Guid>();
|
|
if (entity.Nav_Codes != null && entity.Nav_Codes.Any())
|
|
{
|
|
var idList = entity.Nav_Codes.Select(t => t.ID).ToList();
|
|
codeIds.AddRange(idList);
|
|
}
|
|
if (entity.Nav_Departments != null && entity.Nav_Departments.Any())
|
|
{
|
|
var idList = entity.Nav_Departments.Select(t => t.ID).ToList();
|
|
departIds.AddRange(idList);
|
|
}
|
|
UnifiedCommit(() =>
|
|
{
|
|
if (codeIds.Any())
|
|
this.BantchDeleteEntityNoCommit<T_PR_POST_FORM_LINK_CODE>(codeIds);
|
|
if (departIds.Any())
|
|
this.BantchDeleteEntityNoCommit<T_PR_POST_FORM_LINK_DEPARTMENT>(departIds);
|
|
if (entity != null)
|
|
this.DeleteEntityNoCommit(entity);
|
|
});
|
|
return true;
|
|
});
|
|
}
|
|
}
|
|
}
|