Esempio n. 1
0
        /// <summary>
        /// 从应用移除权限
        /// </summary>
        /// <param name="id"></param>
        /// <param name="pids"></param>
        /// <returns></returns>
        public ActionResult RemovePermissions(int id, string pids)
        {
            string[]  ids = pids.Split(',');
            ClientApp app = ClientAppBll.GetById(id);

            if (app is null)
            {
                return(ResultData(null, false, "未找到应用!"));
            }

            List <Permission> permissions = PermissionBll.LoadEntities(u => ids.Contains(u.Id.ToString())).ToList();

            permissions.ForEach(u => { app.Permissions.Remove(u); });
            bool b = ClientAppBll.UpdateEntitySaved(app);

            return(ResultData(null, b, b ? "移除权限成功!" : "移除权限失败!"));
        }
Esempio n. 2
0
        /// <summary>
        /// 从应用移除角色
        /// </summary>
        /// <param name="id"></param>
        /// <param name="rids"></param>
        /// <returns></returns>
        public ActionResult RemoveRoles(int id, string rids)
        {
            string[]  ids = rids.Split(',');
            ClientApp app = ClientAppBll.GetById(id);

            if (app is null)
            {
                return(ResultData(null, false, "未找到应用!"));
            }

            List <Role> roles = RoleBll.LoadEntities(u => ids.Contains(u.Id.ToString())).ToList();

            roles.ForEach(u => { app.Roles.Remove(u); });
            bool b = ClientAppBll.UpdateEntitySaved(app);

            return(ResultData(null, b, b ? "移除角色成功!" : "移除角色失败!"));
        }
Esempio n. 3
0
        /// <summary>
        /// 从应用移除用户组
        /// </summary>
        /// <param name="id"></param>
        /// <param name="gids"></param>
        /// <returns></returns>
        public ActionResult RemoveUserGroups(int id, string gids)
        {
            string[]  ids = gids.Split(',');
            ClientApp app = ClientAppBll.GetById(id);

            if (app is null)
            {
                return(ResultData(null, false, "未找到应用!"));
            }

            List <UserGroup> groups = UserGroupBll.LoadEntities(u => ids.Contains(u.Id.ToString())).ToList();

            groups.ForEach(u => { app.UserGroup.Remove(u); });
            bool b = ClientAppBll.UpdateEntitySaved(app);

            return(ResultData(null, b, b ? "移除用户组成功!" : "移除用户组失败!"));
        }
Esempio n. 4
0
        /// <summary>
        /// 添加用户
        /// </summary>
        /// <returns></returns>
        public ActionResult AddUsers(int id, string uids)
        {
            string[]  ids = uids.Split(',');
            ClientApp app = ClientAppBll.GetById(id);

            if (app is null)
            {
                return(ResultData(null, false, "未找到应用!"));
            }

            List <UserInfo> users = UserInfoBll.LoadEntities(u => ids.Contains(u.Id.ToString())).ToList();

            users.ForEach(u => { app.UserInfo.Add(u); });
            bool b = ClientAppBll.UpdateEntitySaved(app);

            return(ResultData(null, b, b ? "添加用户成功!" : "添加用户失败"));
        }
Esempio n. 5
0
        /// <summary>
        /// 删除应用程序
        /// </summary>
        /// <param name="id"></param>
        /// <returns></returns>
        public ActionResult Delete(int id)
        {
            ClientApp app = ClientAppBll.GetById(id);

            if (app is null)
            {
                return(ResultData(null, false, "应用不存在!"));
            }

            if (app.Preset)
            {
                return(ResultData(null, false, "预置应用不能被删除!"));
            }

            bool b = ClientAppBll.DeleteEntitySaved(a => a.Id.Equals(id) && !a.Preset) > 0;

            return(ResultData(null, b, b ? "应用删除成功!" : "应用删除失败!"));
        }
Esempio n. 6
0
        /// <summary>
        /// 修改子系统信息
        /// </summary>
        /// <param name="id"></param>
        /// <param name="name">新名字</param>
        /// <returns></returns>
        public ActionResult Update(int id, string name)
        {
            ClientApp app = ClientAppBll.GetById(id);

            if (app != null)
            {
                if (ClientAppBll.Any(a => a.AppName.Equals(name) && !a.AppName.Equals(app.AppName)))
                {
                    return(ResultData(null, false, $"{name} 应用已经存在!"));
                }

                app.AppName = name;
                bool b = ClientAppBll.UpdateEntitySaved(app);
                return(ResultData(null, b, b ? "修改成功" : "修改失败!"));
            }

            return(ResultData(null, false, "未找到该应用程序!"));
        }
Esempio n. 7
0
        /// <summary>
        /// 切换应用的可用状态
        /// </summary>
        /// <param name="id">应用id</param>
        /// <param name="state">可用状态</param>
        /// <returns></returns>
        public ActionResult ToggleState(int id, bool state)
        {
            ClientApp app = ClientAppBll.GetById(id);

            if (app is null)
            {
                return(ResultData(null, false, "应用不存在!"));
            }

            if (app.Preset)
            {
                return(ResultData(null, false, "预置应用的状态不能修改!"));
            }

            app.Available = !state;
            bool b = ClientAppBll.UpdateEntitySaved(app);

            return(ResultData(null, b, b ? "状态切换成功!" : "状态切换失败!"));
        }
Esempio n. 8
0
        /// <summary>
        /// 获取应用详情
        /// </summary>
        /// <param name="id"></param>
        /// <returns></returns>
        public ActionResult Get(int id)
        {
            ClientAppOutputDto app = ClientAppBll.GetById(id).Mapper <ClientAppOutputDto>();

            return(ResultData(app));
        }