using APT.BaseData.Domain.Entities; using APT.BaseData.Domain.Entities.BD; using APT.BaseData.Domain.Enums; using APT.BaseData.Domain.IServices.BD; using APT.Infrastructure.Core; using APT.Utility; using Microsoft.AspNetCore.Mvc; using System; using System.Collections.Generic; using System.ComponentModel; using System.Linq; using System.Reflection; using System.Threading.Tasks; using APT.Infrastructure.Api; namespace APT.BD.WebApi.Controllers.Api { /// /// 国标行业信息 /// [Route("api/BD/BDWordTemplate")] public partial class BDWordTemplateController : CommonApiController { /// /// 获取word模板属性 /// /// 模板id /// 模板id /// [HttpGet, Route("Props")] public JsonActionResult> Props(string id, string type) { return SafeExecute>(() => { var retProps = new List(); Type entityType = null; if (!string.IsNullOrEmpty(type)) { entityType = APT.Infrastructure.Core.Refctor.ReflectHelper.FindTypeInCurrentDomain(type); } else { var template = this.GetEntity(id); if (template == null) return retProps; entityType = APT.Infrastructure.Core.Refctor.ReflectHelper.FindTypeInCurrentDomain(template.RET_ENTITY_TYPE); } if (entityType == null) return retProps; var fields = entityType.GetProperties(); List attrs = new List(); foreach (var fi in fields) { dynamic obj = new System.Dynamic.ExpandoObject(); obj.IS_LEAF = true;//不是导航属性 if (fi.Name.Contains("ID")) continue; if (fi.Name.StartsWith("Nav_")) { //1-对多的不导航 if (typeof(System.Collections.IEnumerable).IsAssignableFrom(fi.PropertyType)) { continue; } else { obj.IS_LEAF = false; } } obj.CODE = fi.Name; obj.ID = fi.Name; obj.TYPE = fi.PropertyType.Name; var descAtrr = fi.GetAttribute(); if (descAtrr != null) { obj.NAME = descAtrr.Description; } else { obj.NAME = ""; } attrs.Add(obj); } return attrs; }); } [HttpPost, Route("GetTemplate")] public JsonActionResult GetTemplate([FromBody] KeywordFilter filter) { return SafeExecute(() => { var retProps = new List(); var template = this.GetEntityByRedis(filter.Keyword, filter.GetOrgId()); return template; }); } } }