Exemplo n.º 1
0
        /// <summary>
        /// 修改
        /// </summary>
        /// <param name="model"></param>
        /// <returns></returns>
        public async Task <ApiResult <string> > Modify(SysMenuParam model)
        {
            var result = new ApiResult <string>();

            try
            {
                var menuModel = model.MapTo <SysMenuParam, SysMenu>(m => m.Id);
                if (model.Parent.Any())
                {
                    menuModel.ParentId      = model.Parent[model.Parent.Count - 1];
                    menuModel.ParentGroupId = string.Join(",", model.Parent.ToArray()) + "," + menuModel.Id;
                    //查询,上级的层级
                    var paramModel = await _thisRepository.GetModelAsync(m => m.Id == menuModel.ParentId);

                    if (paramModel != null && !string.IsNullOrEmpty(paramModel.Id))
                    {
                        menuModel.Layer = paramModel.Layer + 1;
                    }
                }
                await _thisRepository.UpdateAsync(menuModel, m => new { m.CreateUser, m.CreateTime, m.IsDel });
            }
            catch (Exception ex)
            {
                result.StatusCode = (int)HttpStatusCode.InternalServerError;
                result.Message    = ex.Message;
            }
            return(result);
        }
Exemplo n.º 2
0
 public async Task <ApiResult <string> > Modify([FromBody] SysMenuParam model) => await _sysMenuService.Modify(model);