156 lines
		
	
	
		
			5.4 KiB
		
	
	
	
		
			C#
		
	
	
	
	
	
			
		
		
	
	
			156 lines
		
	
	
		
			5.4 KiB
		
	
	
	
		
			C#
		
	
	
	
	
	
using APT.BaseData.Domain.Entities;
 | 
						|
using APT.BaseData.Domain.Enums;
 | 
						|
using APT.BaseData.Domain.IServices;
 | 
						|
using APT.Infrastructure.Core;
 | 
						|
using APT.BaseData.Domain.Entities.FM;
 | 
						|
using APT.Utility;
 | 
						|
using Microsoft.AspNetCore.Mvc;
 | 
						|
using System;
 | 
						|
using System.Collections.Generic;
 | 
						|
using System.Linq;
 | 
						|
 | 
						|
using APT.Utility;namespace APT.PF.WebApiControllers.Api.PF
 | 
						|
{
 | 
						|
	[Route("api/PF/Column")]
 | 
						|
    [APT.Infrastructure.Api.RootOrg]
 | 
						|
    public class ColumnController : AuthorizeApiController<T_PF_COLUMN>
 | 
						|
    {
 | 
						|
        /// <summary>
 | 
						|
        /// 查询
 | 
						|
        /// </summary>
 | 
						|
        /// <param name="pageFilter"></param>
 | 
						|
        /// <returns></returns>
 | 
						|
        [HttpPost, Route("Entities")]
 | 
						|
        public JsonActionResult<IEnumerable<T_PF_COLUMN>> Entities([FromBody]KeywordFilter filter)
 | 
						|
        {
 | 
						|
            return WitEntities(null, filter);
 | 
						|
        }
 | 
						|
        /// <summary>
 | 
						|
        /// 查询
 | 
						|
        /// </summary>
 | 
						|
        /// <param name="pageFilter"></param>
 | 
						|
        /// <returns></returns>
 | 
						|
        [HttpPost, Route("OrderEntities")]
 | 
						|
        public JsonActionResult<IEnumerable<T_PF_COLUMN>> OrderEntities([FromBody]KeywordFilter filter)
 | 
						|
        {
 | 
						|
            return SafeExecute<IEnumerable<T_PF_COLUMN>>(() =>
 | 
						|
          {
 | 
						|
              var data = this.GetOrderEntities<T_PF_COLUMN>(null, filter); ;
 | 
						|
              data.Where(i => !string.IsNullOrEmpty(i.ENUM))
 | 
						|
                    .ForEach(i => i.ENUM = DataHelper.EnumToString(i.ENUM));
 | 
						|
              return data;
 | 
						|
          });
 | 
						|
        }
 | 
						|
        /// <summary>
 | 
						|
        /// 查询
 | 
						|
        /// </summary>
 | 
						|
        /// <param name="pageFilter"></param>
 | 
						|
        /// <returns></returns>
 | 
						|
        [HttpPost, Route("Paged")]
 | 
						|
        public PagedActionResult<T_PF_COLUMN> Paged([FromBody]KeywordPageFilter pageFilter)
 | 
						|
        {
 | 
						|
            return WitPaged(null, pageFilter);
 | 
						|
        }
 | 
						|
        /// <summary>
 | 
						|
        /// 查询
 | 
						|
        /// </summary>
 | 
						|
        /// <param name="pageFilter"></param>
 | 
						|
        /// <returns></returns>
 | 
						|
        [HttpPost, Route("OrderPaged")]
 | 
						|
        public PagedActionResult<T_PF_COLUMN> OrderPaged([FromBody]KeywordPageFilter pageFilter)
 | 
						|
        {
 | 
						|
            return WitOrderPaged(null, pageFilter);
 | 
						|
        }
 | 
						|
        [HttpPost, Route("Update")]
 | 
						|
        public JsonActionResult<bool> Update([FromBody]T_PF_COLUMN entity)
 | 
						|
        {
 | 
						|
			return SafeExecute<bool>(() =>
 | 
						|
			{
 | 
						|
				this.UpdateEntity(entity);
 | 
						|
				var formService = APT.Infrastructure.Api.ServiceLocator.Instance.GetService<IPFFormService>();
 | 
						|
				formService.CreateFormConfigVersion(PFFormConfigVersionEnum.Column, entity.ID.ToString());
 | 
						|
				return true;
 | 
						|
			});
 | 
						|
		}
 | 
						|
        /// <summary>
 | 
						|
        /// 删除
 | 
						|
        /// </summary>
 | 
						|
        /// <param name="id"></param>
 | 
						|
        /// <returns></returns>
 | 
						|
        [HttpGet, Route("Delete")]
 | 
						|
        public JsonActionResult<bool> Delete(string id)
 | 
						|
        {
 | 
						|
			return SafeExecute<bool>(() =>
 | 
						|
			{
 | 
						|
				var formService = APT.Infrastructure.Api.ServiceLocator.Instance.GetService<IPFFormService>();
 | 
						|
				formService.CreateFormConfigVersion(PFFormConfigVersionEnum.Column, id);
 | 
						|
				List<Guid> ids = new List<Guid>();
 | 
						|
				ids.Add(new Guid(id));
 | 
						|
				this.DoDelete(ids);
 | 
						|
				return true;
 | 
						|
			});
 | 
						|
		}
 | 
						|
		private void DoDelete(List<Guid> ids)
 | 
						|
		{
 | 
						|
			this.DeleteEntity<T_PF_COLUMN_FILTER>(t => ids.Contains(t.COLUMN_ID));
 | 
						|
			this.DeleteEntity<T_FM_USER_CUSTOM_CONFIG_H_COL>(t => ids.Contains(t.COLUMN_ID));
 | 
						|
			this.DeleteEntity<T_FM_USER_C_C_TABLE_COL>(t => ids.Contains(t.COLUMN_ID));
 | 
						|
			this.DeleteEntity<T_FM_ROLE_MENU_PERM_COL>(t => ids.Contains(t.COLUMN_ID));
 | 
						|
			this.DeleteEntity<T_PF_COLUMN>(t => ids.Contains(t.ID));
 | 
						|
		}
 | 
						|
		/// <summary>
 | 
						|
		/// 批量删除
 | 
						|
		/// </summary>
 | 
						|
		/// <param name="ids"></param>
 | 
						|
		/// <returns></returns>
 | 
						|
		[HttpGet, Route("BatchDelete")]
 | 
						|
        public JsonActionResult<bool> BatchDelete(string ids)
 | 
						|
        {
 | 
						|
			return SafeExecute<bool>(() =>
 | 
						|
			{
 | 
						|
				var formService = APT.Infrastructure.Api.ServiceLocator.Instance.GetService<IPFFormService>();
 | 
						|
				formService.CreateFormConfigVersion(PFFormConfigVersionEnum.Column, ids);
 | 
						|
				var arrays = string.IsNullOrEmpty(ids) ? null : ids.Split(new char[] { ',' }, StringSplitOptions.RemoveEmptyEntries)
 | 
						|
						.Select(t => new Guid(t)).ToList();
 | 
						|
				if (arrays != null && arrays.Count > 0)
 | 
						|
					this.DoDelete(arrays);
 | 
						|
				return true;
 | 
						|
			});
 | 
						|
		}
 | 
						|
        /// <summary>
 | 
						|
        /// 根据ID获得实体数据
 | 
						|
        /// </summary>
 | 
						|
        /// <param name="id"></param>
 | 
						|
        /// <returns></returns>
 | 
						|
        [HttpPost, Route("Get")]
 | 
						|
        public JsonActionResult<T_PF_COLUMN> Get([FromBody] KeywordFilter filter)
 | 
						|
        {
 | 
						|
            return WitEntity(null, filter);
 | 
						|
        }
 | 
						|
 | 
						|
 | 
						|
        [HttpPost, Route("ChangeNum")]
 | 
						|
        public JsonActionResult<bool> ChangeNum([FromBody] KeywordFilter filter)
 | 
						|
        {
 | 
						|
            return SafeExecute<bool>(() =>
 | 
						|
            {
 | 
						|
                if (string.IsNullOrEmpty(filter.Parameter1) || string.IsNullOrEmpty(filter.Parameter2))
 | 
						|
                    this.ThrowError("020005");
 | 
						|
                string param1 = filter.Parameter1;
 | 
						|
                string param2 = filter.Parameter2;
 | 
						|
                var col1 = this.GetEntity<T_PF_COLUMN>(param1);
 | 
						|
                var col2 = this.GetEntity<T_PF_COLUMN>(param2);
 | 
						|
                var tmpNum = col2.NUM;
 | 
						|
                col2.NUM = col1.NUM;
 | 
						|
                col1.NUM = tmpNum;
 | 
						|
                this.UnifiedCommit(() => {
 | 
						|
                    this.UpdateEntity(col1, "NUM");
 | 
						|
                    this.UpdateEntity(col2, "NUM");
 | 
						|
                });
 | 
						|
                return true;
 | 
						|
            });
 | 
						|
        }
 | 
						|
 | 
						|
    }
 | 
						|
}
 |