/// <summary>
        ///
        /// </summary>
        /// <param name="data"></param>
        /// <returns></returns>
        public async Task <dynamic> UpdateRole(DTOAPIReq_Role data)
        {
            Role role = this.accesser.Get(data.key);

            if (role != null)
            {
                var cmd = new UpdateRoleCommand
                {
                    key         = data.key,
                    name        = data.name,
                    displayName = data.displayName,
                    description = data.description,
                    routes      = data.routes.Select(x => new DTOIn_PageRouteId {
                        PageRouteID = x
                    }).ToArray()
                };

                await this.publishEndpoint.Publish(cmd);

                return(1);
            }
            else
            {
                throw new NullReferenceException("角色不存在..请刷新页面重试");
            }
        }
        /// <summary>
        ///
        /// </summary>
        /// <param name="data"></param>
        /// <returns></returns>
        public async Task <dynamic> AddRole(DTOAPIReq_Role data)
        {
            if (data.routes != null && data.routes.Count > 0)
            {
                //ensure pageRoutes is exist
                if (this.accesser.db.RoutePages.Where(x => data.routes.Contains(x.Id)).Count() != data.routes.Count)
                {
                    return(-1);
                }
            }


            var routes = data.routes.Select(x => new DTOIn_PageRouteId {
                PageRouteID = x
            }).ToArray();

            long NewID = this.IDGenerator.GetNewID <Role>();
            var  cmd   = new AddRoleCommand
            {
                key         = NewID,
                description = data.description,
                name        = data.name,
                routes      = routes
            };

            await this.publishEndpoint.Publish(cmd);

            return(NewID);
        }