//TODO: 添加上下级,阻止无限递归 public static long SetCate(AtomCateConfig acc, bool isAdd) { lock (locker) { var exist = SonFact.Cur.Top <AtomCateConfig>(t => t.CateCode == acc.CateCode); if (exist != null && isAdd) { throw new Exception("cate code 已经存在"); } if (exist != null && !isAdd) { acc.ConfigCateId = exist.ConfigCateId; var result = SonFact.Cur.Update(acc); return(Convert.ToInt64(result)); } return(SonFact.Cur.Insert(acc)); } }
/// <summary> /// 添加配置字段 /// </summary> /// <param name="name">字段名</param> /// <param name="code">字段编码</param> /// <param name="pCode">上级编码</param> /// <param name="extCode">扩展编码</param> /// <param name="isAdd">是否添加操作</param> /// <returns></returns> public static long SetCate(string name, string code, string pCode = null, string extCode = null, bool isAdd = false) { if (string.IsNullOrWhiteSpace(name)) { throw new Exception("名称不可为空"); } if (string.IsNullOrWhiteSpace(code)) { throw new Exception("配置值不可为空"); } var acc = new AtomCateConfig { CateName = name, CateCode = code, ParentCateCode = pCode, AddTime = DateTime.Now, ExtCateCode = extCode, Enable = true }; return(AtomConfigCenterManage.SetCate(acc, isAdd)); }