Exemplo n.º 1
0
        /// <summary>
        /// 修改菜单
        /// </summary>
        /// <param name="parm"></param>
        /// <returns></returns>
        public async Task <ApiResult <string> > ModifyAsync(SysMenu parm, List <string> btnfun)
        {
            var res = new ApiResult <string>
            {
                statusCode = 200
            };
            //判断别名是否存在,要不一样的
            var isCodeExis = SysMenuDb.GetSingle(m => m.NameCode == parm.NameCode && m.Guid != parm.Guid);

            if (isCodeExis != null)
            {
                res.statusCode = (int)ApiEnum.Error;
                res.message    = "别名已存在~";
                return(await Task.Run(() => res));
            }
            parm.EditTime = DateTime.Now;
            if (!string.IsNullOrEmpty(parm.ParentGuid))
            {
                // 说明有父级  根据父级,查询对应的模型
                var model = SysMenuDb.GetById(parm.ParentGuid);
                parm.ParentGuidList = model.ParentGuidList + parm.Guid + ",";
                parm.Layer          = model.Layer + 1;
            }
            else
            {
                parm.ParentGuidList = "," + parm.Guid + ",";
            }
            parm.BtnFunJson = JsonConvert.SerializeObject(btnfun);
            await Db.Updateable(parm).ExecuteCommandAsync();

            return(res);
        }
Exemplo n.º 2
0
        /// <summary>
        /// 添加部门信息
        /// </summary>
        /// <param name="parm"></param>
        /// <returns></returns>
        public async Task <ApiResult <string> > AddAsync(SysMenu parm)
        {
            parm.Guid     = Guid.NewGuid().ToString();
            parm.EditTime = DateTime.Now;
            parm.AddTIme  = DateTime.Now;
            SysMenuDb.Insert(parm);
            if (!string.IsNullOrEmpty(parm.ParentGuid))
            {
                // 说明有父级  根据父级,查询对应的模型
                var model = SysMenuDb.GetById(parm.ParentGuid);
                parm.ParentGuidList = model.ParentGuidList + parm.Guid + ",";
                parm.Layer          = model.Layer + 1;
            }
            else
            {
                parm.ParentGuidList = "," + parm.Guid + ",";
                parm.Layer          = 1;
            }
            //更新  新的对象
            SysMenuDb.Update(parm);
            var res = new ApiResult <string>
            {
                statusCode = 200,
                data       = "1"
            };

            return(await Task.Run(() => res));
        }
Exemplo n.º 3
0
        /// <summary>
        /// 根据唯一编号查询一条部门信息
        /// </summary>
        /// <param name="parm"></param>
        /// <returns></returns>
        public async Task <ApiResult <SysMenu> > GetByGuidAsync(string parm)
        {
            var model = SysMenuDb.GetById(parm);
            var res   = new ApiResult <SysMenu>
            {
                statusCode = 200
            };
            var pmdel = Db.Queryable <SysMenu>().OrderBy(m => m.Sort, OrderByType.Desc).First();

            res.data = model ?? new SysMenu()
            {
                Sort = pmdel?.Sort + 1 ?? 1, Status = true
            };
            return(await Task.Run(() => res));
        }
Exemplo n.º 4
0
        /// <summary>
        /// 修改菜单
        /// </summary>
        /// <param name="parm"></param>
        /// <returns></returns>
        public async Task <ApiResult <string> > ModifyAsync(SysMenu parm)
        {
            parm.EditTime = DateTime.Now;
            if (!string.IsNullOrEmpty(parm.ParentGuid))
            {
                // 说明有父级  根据父级,查询对应的模型
                var model = SysMenuDb.GetById(parm.ParentGuid);
                parm.ParentGuidList = model.ParentGuidList + parm.Guid + ",";
                parm.Layer          = model.Layer + 1;
            }
            else
            {
                parm.ParentGuidList = "," + parm.Guid + ",";
            }
            var res = new ApiResult <string>
            {
                statusCode = 200,
                data       = SysMenuDb.Update(parm) ? "1" : "0"
            };

            return(await Task.Run(() => res));
        }
Exemplo n.º 5
0
        /// <summary>
        /// 添加部门信息
        /// </summary>
        /// <param name="parm"></param>
        /// <returns></returns>
        public async Task <ApiResult <string> > AddAsync(SysMenu parm, List <string> btnfun)
        {
            var res = new ApiResult <string>
            {
                statusCode = 200,
                data       = "1"
            };
            //判断别名是否存在,要不一样的
            var isCodeExis = SysMenuDb.GetSingle(m => m.NameCode == parm.NameCode);

            if (isCodeExis != null)
            {
                res.statusCode = (int)ApiEnum.Error;
                res.message    = "别名已存在~";
                return(await Task.Run(() => res));
            }
            parm.Guid       = Guid.NewGuid().ToString();
            parm.EditTime   = DateTime.Now;
            parm.AddTIme    = DateTime.Now;
            parm.BtnFunJson = JsonConvert.SerializeObject(btnfun);
            SysMenuDb.Insert(parm);
            if (!string.IsNullOrEmpty(parm.ParentGuid))
            {
                // 说明有父级  根据父级,查询对应的模型
                var model = SysMenuDb.GetById(parm.ParentGuid);
                parm.ParentGuidList = model.ParentGuidList + parm.Guid + ",";
                parm.Layer          = model.Layer + 1;
            }
            else
            {
                parm.ParentGuidList = "," + parm.Guid + ",";
                parm.Layer          = 1;
            }

            //更新  新的对象
            SysMenuDb.Update(parm);

            return(await Task.Run(() => res));
        }