Ejemplo n.º 1
0
        /// <summary>
        ///     保存权限信息
        /// </summary>
        /// <param name="input"></param>
        /// <returns></returns>
        public async Task <OperateStatus> SavePermission(SavePermissionInput input)
        {
            var operateStatus = new OperateStatus();

            try
            {
                IList <SystemPermission> systemPermissions = input.Permissiones.Select(per => new SystemPermission
                {
                    PrivilegeAccess      = (byte)input.PrivilegeAccess,
                    PrivilegeAccessValue = per,
                    PrivilegeMasterValue = input.PrivilegeMasterValue,
                    PrivilegeMaster      = (byte)input.PrivilegeMaster,
                    PrivilegeMenuId      = input.PrivilegeMenuId
                }).ToList();

                //删除该角色的权限信息
                await _permissionRepository.DeletePermissionByPrivilegeMasterValue(input.PrivilegeAccess, input.PrivilegeMasterValue, input.PrivilegeMenuId);

                if (input.PrivilegeMaster == EnumPrivilegeMaster.人员)
                {
                    //删除对应人员数据
                    await _permissionUsernRepository.DeletePermissionUser(input.PrivilegeMaster, input.PrivilegeMasterValue);

                    //判断是否具有权限
                    if (!systemPermissions.Any())
                    {
                        operateStatus.ResultSign = ResultSign.Successful;
                        operateStatus.Message    = Chs.Successful;
                        return(operateStatus);
                    }
                    //插入权限人员数据
                    var permissionUser = new SystemPermissionUser
                    {
                        PrivilegeMaster       = (byte)input.PrivilegeMaster,
                        PrivilegeMasterUserId = input.PrivilegeMasterValue,
                        PrivilegeMasterValue  = input.PrivilegeMasterValue
                    };
                    await _permissionUsernRepository.InsertAsync(permissionUser);
                }

                //是否具有权限数据
                if (!systemPermissions.Any())
                {
                    operateStatus.ResultSign = ResultSign.Successful;
                    operateStatus.Message    = Chs.Successful;
                    return(operateStatus);
                }
                //插入数据库
                await _permissionRepository.InsertMultipleAsync(systemPermissions);

                operateStatus.ResultSign = ResultSign.Successful;
                operateStatus.Message    = Chs.Successful;
                return(operateStatus);
            }
            catch (Exception)
            {
                return(operateStatus);
            }
        }
Ejemplo n.º 2
0
        public async Task <JsonResult> SavePermission(SavePermissionInput input)
        {
            if (input.MenuPermissions != null)
            {
                input.Permissiones = input.MenuPermissions.Split(',');
            }

            return(Json(await _permissionLogic.SavePermission(input)));
        }
Ejemplo n.º 3
0
 public async Task <JsonResult> SavePermission(SavePermissionInput input)
 {
     input.Permissiones = input.MenuPermissions.JsonStringToList <SystemPermissionViewModel>().Select(m => m.P).ToList();
     return(Json(await _permissionLogic.SavePermission(input)));
 }