using System; using System.Collections.Generic; using System.Linq; using System.Web; using System.Web.Mvc; using PMS.BusinessModels.SysManager; using PMS.Interface; using PMS.Interface.SysManager; using QWPlatform.SystemLibrary; using PMS.EntityModels.SysManager; using System.Data; using PMS.BusinessModels.Account; namespace PMS.WebUI.Controllers { /// /// 创 建 人:王海洋 /// 创建日期:2018-12-10 /// 功能描述:系统用户控制器 /// public class SystemUserController : BaseController { IXTJSModel xtjs_model = InterfaceFactory.CreateBusinessInstance(); IXTZHModel xtzh_model = InterfaceFactory.CreateBusinessInstance(); IRoleAuthModel roleauth_model = InterfaceFactory.CreateBusinessInstance(); #region 人员账户 // GET: SystemUser public ActionResult Index() { return View(); } //Get 获取所有机构 [HttpGet] public ActionResult GetOrgs() { //获取组织机构的JSOn var json = account_obj.GetOrgsDataGridJson(); return Content(json, "application/json"); } //Get:根据机构ID获取该机构下所有账户目录json [HttpGet] public ActionResult GetUserListByOrgId(string id, int page, int rows) { var json = account_obj.GetUserListByOrgId(id, page, rows); return Content(json, "application/json"); } //将账户进行授权 public ActionResult AuthRoleToAccount(int? id) { ViewBag.id = id; return View(); } //POST:将用户授权相关角色ID [HttpPost] public ActionResult PostSaveAuthRoleToAccount(int? uid, string rids) { if (uid > 0) { bool r = account_obj.SaveAuthRoleToAccount(uid, rids); if (r) { return this.ResponseJson(System.Net.HttpStatusCode.OK, "授权成功", null); } } return this.ResponseJson(System.Net.HttpStatusCode.Forbidden, "没有用户ID", null); } //GET:根据人员账户获取已授权的角色 [HttpGet] public ActionResult GetAccountRolesGridJson(int id) { var dt = account_obj.GetAccountRoles(id); var json = dt.ToEasyUIGridJson(0, null); return Content(json, "text/json"); } //GET:返回数据权限的授权界面 public ActionResult AuthDataToUser(int id) { ViewBag.id = id; return View(); } //GET:获取所有渠道下的项目(数据授权时使用) [HttpGet] public ActionResult GetOrgProjects() { var treeJson = account_obj.GetOrgProjecgTree(); return Content(treeJson, "text/json"); } //POST 保存数据(用户数据授权) [HttpPost] public ActionResult PostSaveUserDataAuth(IEnumerable models) { //保存授权数据 bool r = account_obj.SaveAuthDataToAccount(models); if (r) { return this.ResponseJson(System.Net.HttpStatusCode.OK, "授权成功"); } return this.ResponseJson(System.Net.HttpStatusCode.Forbidden, "授权失败"); } /// /// 批量授权 /// /// /// [HttpPost] public int BatchAuth(string id, IEnumerable models) { //保存授权数据 return account_obj.BatchAuth(id,models); } //GET:根据账户ID,获取该账户的数据授的授权列表 [HttpGet] public ActionResult GetUserDataAuth(int id) { List list = account_obj.GetAccountDataAuth(id); return this.ResponseJson(System.Net.HttpStatusCode.OK, "完成读取", list); } //系统账户弹出框 XtZHPopWindows(string id) public ActionResult XtZHPopWindows(int id) { ViewBag.id = id; return View(); } /// /// 根据id查找用户信息 /// /// /// public ActionResult GetSystemUserInfo(int ID) { return this.ResponseJson(System.Net.HttpStatusCode.OK, "完成读取", xtzh_model.GetSystemUserInfo(ID)); } /// /// 获取系统账户类型 /// /// public ActionResult XtZHLx() { string result = xtzh_model.XtZHLx(); return Content(result, "text/json"); } /// /// 获取系统账户公司 /// /// public ActionResult XtZHGs() { return Content(xtzh_model.XtZHGs(),"text/json"); } /// /// 新增修改系统账户 /// /// /// public ActionResult XtZHEdit(XTZHModel XtzhModel) { int EditType=0; if (XtzhModel.ID!=null) { EditType = 1; } string result = xtzh_model.XtZHEdit(XtzhModel,EditType); string [] re= result.Split('|'); if (re[0] == "1") { return this.ResponseJson(System.Net.HttpStatusCode.OK, re[1]); } else { return this.ResponseJson(System.Net.HttpStatusCode.Forbidden, re[1]); } } /// /// 系统账户查询 return Content(dt, "application/json"); /// /// 条件 /// 当前页码 /// 每页显示得行数 /// public ActionResult XtZHSelect(string search, int page, int rows) { string result = xtzh_model.XtZHSelect(search, page, rows); return Content(result, "application/json"); } /// /// 删除记录 /// /// public ActionResult XtZHDel(int id) { xtzh_model.XtZHDel(id); return this.ResponseJson(System.Net.HttpStatusCode.OK, "删除成功"); } /// /// 设置账户可以访问渠道下面所有项目 /// /// /// 1是,0否 /// public ActionResult UpdataAuthorize(int id,int authorize) { var state= xtzh_model.UpdataAuthorize(id, authorize); return this.ResponseJson(state? System.Net.HttpStatusCode.OK : System.Net.HttpStatusCode.InternalServerError, "操作成功"); } /// /// 重置密码 /// ID: 4 // XM: "冉利" //ZH: "18315119271" /// /// id /// 账户 /// 姓名 /// public ActionResult XtZHMMPopWindows(int ID,string XM,string ZH) { ViewBag.id = ID; ViewBag.ZH = ZH; ViewBag.XM = XM; return View(); } //保存修改得密码 public ActionResult XGMm(int id,string MM, string ZH, string XM) { xtzh_model.XGMm(id, MM); return this.ResponseJson(System.Net.HttpStatusCode.OK, "重置成功"); } /// /// 获取公司下的人员 /// /// /// public ActionResult XtZHRY(string GSID) { return Content(xtzh_model.XtZHRY(GSID), "application/json"); } #endregion #region 人员角色 //获取人员角色主页 public ActionResult RolesIndex() { return View(); } //获取角色列表的json [HttpGet] public ActionResult GetRoleList(int page, int rows) { var json = account_obj.GetRolesList(page, rows); return Content(json, "application/json"); } //获取角色列表的json [HttpGet] public ActionResult GetRolesForActiveList(int page, int rows) { var json = account_obj.GetRolesForActiveList(page, rows); return Content(json, "application/json"); } //角色授权页面(传递角色ID) [HttpGet] public ActionResult RoleAuthorize(int id) { ViewBag.id = id; return View(); } //POST,针对某个角色的授权信息 //模块ID的最后一个节点为功能授权节点 [HttpPost] public ActionResult PostRoleAuthorzie(int rid, string mids, string bids) { var r = account_obj.SaveRoleAuthorzie(rid, mids, bids); if (r) { return this.ResponseJson(System.Net.HttpStatusCode.OK, "授权成功"); } return this.ResponseJson(System.Net.HttpStatusCode.Forbidden, "授权失败"); } //GET:获取角色的权限信息(获取角色的模块信息,角色ID) [HttpGet] public ActionResult GetRoleAuthorzie(int id) { var json = account_obj.GetRoleAuthJson(id); return Content(json, "text/json"); } //G用:根据角色ID及模块ID获取功能目录 [HttpGet] public ActionResult GetRoleAuthorzieFuns(int roleid, int moduleid) { var json = account_obj.GetRoleAuthFunGridJson(roleid, moduleid); return Content(json, "text/json"); } /// /// 判断是否是管理员 /// /// public ActionResult IsSuperAdmin() { UserInfo userinfo = this.GetCurrentUser(); bool IsSuperAdmin = userinfo.IsSuperAdmin; if (IsSuperAdmin == true) { return this.ResponseJson(System.Net.HttpStatusCode.OK, "1"); } else { return this.ResponseJson(System.Net.HttpStatusCode.Forbidden, "0"); } } ///SystemUser/RolePopWindows 新增系统角色 //修改系统角色/SystemUser/RolePopWindows?id= public ActionResult RolePopWindows(int id) { ViewBag.id = id; return View(); } ////删除系统角色/SystemUser/RoleDel { 'id': row.ID, 'type': 0 }; public ActionResult RoleDel(int id) { xtjs_model.RoleDel(id); return this.ResponseJson(System.Net.HttpStatusCode.OK, "删除成功"); } ///参数id查询系统角色信息SystemUser/GetSystemRoleInfo?id=' + ID, public ActionResult GetSystemRoleInfo(int id) { DataTable result = xtjs_model.GetSystemRoleInfo(id); return this.ResponseJson(System.Net.HttpStatusCode.OK, "读取成功", result); } // 提交表单信息到具体得页面 SystemUser/SaveRoleInfo public ActionResult SaveRoleInfo(XTJSModel model) { int type_in = 0; if (model.ID!=null) { type_in = 1; } string Result = xtjs_model.SaveRoleInfo(model, type_in); string[] Resultstring = Result.Split('1'); return this.ResponseJson(System.Net.HttpStatusCode.OK, Resultstring[1]); } /// /// 判断输入的系统角色名是否重复 /// 并给与提示 /// /// /// public string RoleNameCheck(string Name) { string result = xtjs_model.RoleNameCheck(Name); string[] re = result.Split('|'); if (re[0] == "1") { return "true"; } return "false"; } /// /// 系统账户名称重复测试有问题 /// /// /// public string UserNameCheck(string name) { string result= xtzh_model.UserNameCheck(name); string[] re = result.Split('|'); if (re[0] == "1") { return "true"; } return "false"; } //where rownum = 1 public ActionResult RoleXh() { string result = xtjs_model.RoleXh(); return Content(result, "text/json"); } //根据角色查询用户列表 public ActionResult GetUserByRoleId(int rid,int rows,int page) { var json = account_obj.GetUserByRoleId(rid, rows, page); return Content(json, "text/json"); } #endregion /// /// 系统角色权限的保存(暂时不能用) /// /// /// public ActionResult SaveXtjsQx(string ids) { string result= roleauth_model.SaveXtjsQx(ids); string[] result1 = result.Split('|'); if (result1[0] == "1") { return this.ResponseJson(System.Net.HttpStatusCode.OK, "成功"); } else { return this.ResponseJson(System.Net.HttpStatusCode.InternalServerError, "失败"); } } public ActionResult SelectPersonInfo(string Zh) { string result= xtzh_model.SelectPersonInfo(Zh); if (result=="") { return Content("", "text/json"); } return Content(result, "text/json"); } } }