//配置管理
        public static List <NAtomCateConfigModel> SearchDict(NAtomCateConfigModel request, int domid = 0)
        {
            var list = new List <NAtomCateConfigModel>();
            //var doms =SonFact.Cur.FindMany<Domain>(t => t.IsValid==true);
            var oldlisttmp = SonFact.Cur.FindMany <AtomCateConfig>(t => t.IsValid == true && t.MainConfigCode == "dict").OrderBy(t => t.Sort).ToList();

            if (domid != 0)
            {
                oldlisttmp = oldlisttmp.Where(t => t.DomainId == 0 || t.DomainId == domid).ToList();
            }

            var firsts = oldlisttmp.Where(t => t.ParentCateCode == null || t.ParentCateCode == "").ToList();

            if (!firsts.Any())
            {
                return(list);
            }

            //if (request.ExpceptCustom == true)
            //    firsts = firsts.Where(t => t.CateCode != "custom_dict").ToList();

            foreach (var first in firsts)
            {
                var firstModel = EntityMapper.Mapper <AtomCateConfig, NAtomCateConfigModel>(first);
                firstModel.DomainName = firstModel.DomainId == 0 ? "全平台" : domid + "";
                list.Add(firstModel);
                SearchDictChildren(firstModel, 0, oldlisttmp, domid);
            }

            return(list);
        }
Exemple #2
0
        public Br <string> EditDict([FromBody] NAtomCateConfigModel request)
        {
            var result = config.EditDict(request);

            return(new Br <string> {
                Data = result + ""
            });
        }
        private static void SearchDictChildren(NAtomCateConfigModel model, int level, List <AtomCateConfig> oldlist, int domid)
        {
            model.Level = level;
            var childrenlist = oldlist.Where(o => o.ParentCateCode == model.CateCode).OrderBy(t => t.Sort).ToList();
            var newlist      = new List <NAtomCateConfigModel>();

            childrenlist.ForEach(o =>
            {
                var cd        = EntityMapper.Mapper <AtomCateConfig, NAtomCateConfigModel>(o);
                cd.DomainName = cd.DomainId == 0 ? "全平台" : domid + "";
                newlist.Add(cd);
            });
            model.Children = newlist;
            level         += 1;
            foreach (var item in newlist)
            {
                SearchDictChildren(item, level, oldlist, domid);
            }
        }
        public static bool AddDict(NAtomCateConfigModel model, int domid = 0)
        {
            var exist = SonFact.Cur.Top <AtomCateConfig>(t => t.CateCode == model.CateCode);

            if (exist != null)
            {
                throw new Exception("呵呵!配置代码重复,请修改");
            }

            var newPer = EntityMapper.Mapper <NAtomCateConfigModel, AtomCateConfig>(model);

            newPer.AddTime        = DateTime.Now;
            newPer.EditTime       = DateTime.Now;
            newPer.AddUserId      = 0;
            newPer.EditUserId     = 0;
            newPer.MainConfigCode = "dict";
            newPer.DomainId       = domid == 0 ? model.DomainId : domid;

            var result = SonFact.Cur.Insert(newPer);

            return(result > 0);
        }
        public static bool EditDict(NAtomCateConfigModel model)
        {
            var existCode = SonFact.Cur.Top <AtomCateConfig>(t => t.CateCode == model.CateCode && t.ConfigCateId != model.ConfigCateId);

            if (existCode != null)
            {
                throw new Exception("呵呵!字典代码重复,请修改");
            }

            if (!model.IsValid.HasValue)
            {
                return(DelDict(model.ConfigCateId));
            }

            var exist = SonFact.Cur.Top <AtomCateConfig>(t => t.ConfigCateId == model.ConfigCateId);

            exist.IsValid        = model.IsValid.Value;
            exist.CateName       = model.CateName;
            exist.CateCode       = model.CateCode;
            exist.ExtCateCode    = model.ExtCateCode;
            exist.MainConfigCode = "dict";
            exist.ParentCateCode = model.ParentCateCode;
            exist.Level          = model.Level;
            exist.Value          = model.Value;
            exist.ScdValue       = model.ScdValue;
            exist.ThdValue       = model.ThdValue;
            exist.Sort           = model.Sort;
            exist.DomainId       = model.DomainId;
            exist.EditTime       = DateTime.Now;
            exist.EditUserId     = 0;
            exist.EditTime       = DateTime.Now;
            exist.EditUserId     = 0;

            var result = SonFact.Cur.Update(exist);

            return(result > 0);
        }
Exemple #6
0
 public bool EditDict(NAtomCateConfigModel model)
 {
     return(AtomConfigCenterDataCore.EditDict(model));
 }
Exemple #7
0
 public bool AddDict(NAtomCateConfigModel model, int domid = 0)
 {
     return(AtomConfigCenterDataCore.AddDict(model, domid));
 }
Exemple #8
0
 public List <NAtomCateConfigModel> SearchDict(NAtomCateConfigModel request, int domid = 0)
 {
     return(AtomConfigCenterDataCore.SearchDict(request, domid));
 }