123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437 |
- 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
- {
- /// <summary>
- /// 创 建 人:王海洋
- /// 创建日期:2018-12-10
- /// 功能描述:系统用户控制器
- /// </summary>
- public class SystemUserController : BaseController
- {
- IXTJSModel xtjs_model = InterfaceFactory.CreateBusinessInstance<IXTJSModel>();
- IXTZHModel xtzh_model = InterfaceFactory.CreateBusinessInstance<IXTZHModel>();
- IRoleAuthModel roleauth_model = InterfaceFactory.CreateBusinessInstance<IRoleAuthModel>();
- #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<account_authdata_model> models)
- {
- //保存授权数据
- bool r = account_obj.SaveAuthDataToAccount(models);
- if (r)
- {
- return this.ResponseJson(System.Net.HttpStatusCode.OK, "授权成功");
- }
- return this.ResponseJson(System.Net.HttpStatusCode.Forbidden, "授权失败");
- }
- /// <summary>
- /// 批量授权
- /// </summary>
- /// <param name="id"></param>
- /// <returns></returns>
- [HttpPost]
- public int BatchAuth(string id, IEnumerable<account_authdata_model> models)
- {
- //保存授权数据
- return account_obj.BatchAuth(id,models);
- }
- //GET:根据账户ID,获取该账户的数据授的授权列表
- [HttpGet]
- public ActionResult GetUserDataAuth(int id)
- {
- List<account_authdata_model> 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();
- }
- /// <summary>
- /// 根据id查找用户信息
- /// </summary>
- /// <param name="ID"></param>
- /// <returns></returns>
- public ActionResult GetSystemUserInfo(int ID)
- {
- return this.ResponseJson(System.Net.HttpStatusCode.OK, "完成读取", xtzh_model.GetSystemUserInfo(ID));
- }
- /// <summary>
- /// 获取系统账户类型
- /// </summary>
- /// <returns></returns>
- public ActionResult XtZHLx()
- {
- string result = xtzh_model.XtZHLx();
- return Content(result, "text/json");
- }
- /// <summary>
- /// 获取系统账户公司
- /// </summary>
- /// <returns></returns>
- public ActionResult XtZHGs()
- {
- return Content(xtzh_model.XtZHGs(),"text/json");
- }
- /// <summary>
- /// 新增修改系统账户
- /// </summary>
- /// <param name="XtzhModel"></param>
- /// <returns></returns>
- 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]);
- }
- }
- /// <summary>
- /// 系统账户查询 return Content(dt, "application/json");
- /// </summary>
- /// <param name="search">条件</param>
- /// <param name="page">当前页码</param>
- /// <param name="rows">每页显示得行数</param>
- /// <returns></returns>
- public ActionResult XtZHSelect(string search, int page, int rows)
- {
- string result = xtzh_model.XtZHSelect(search, page, rows);
- return Content(result, "application/json");
- }
- /// <summary>
- /// 删除记录
- /// </summary>
- /// <returns></returns>
- public ActionResult XtZHDel(int id)
- {
- xtzh_model.XtZHDel(id);
- return this.ResponseJson(System.Net.HttpStatusCode.OK, "删除成功");
- }
- /// <summary>
- /// 设置账户可以访问渠道下面所有项目
- /// </summary>
- /// <param name="id"></param>
- /// <param name="authorize">1是,0否</param>
- /// <returns></returns>
- 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, "操作成功");
- }
- /// <summary>
- /// 重置密码
- /// ID: 4
- // XM: "冉利"
- //ZH: "18315119271"
- /// </summary>
- /// <param name="ID">id</param>
- /// <param name="ZH">账户</param>
- /// <param name="XM">姓名</param>
- /// <returns></returns>
- 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, "重置成功");
- }
- /// <summary>
- /// 获取公司下的人员
- /// </summary>
- /// <param name="GSID"></param>
- /// <returns></returns>
- 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");
- }
- /// <summary>
- /// 判断是否是管理员
- /// </summary>
- /// <returns></returns>
- 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]);
- }
- /// <summary>
- /// 判断输入的系统角色名是否重复
- /// 并给与提示
- /// </summary>
- /// <param name="Name"></param>
- /// <returns></returns>
- public string RoleNameCheck(string Name)
- {
- string result = xtjs_model.RoleNameCheck(Name);
- string[] re = result.Split('|');
- if (re[0] == "1")
- {
- return "true";
- }
- return "false";
- }
- /// <summary>
- /// 系统账户名称重复测试有问题
- /// </summary>
- /// <param name="name"></param>
- /// <returns></returns>
- 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
- /// <summary>
- /// 系统角色权限的保存(暂时不能用)
- /// </summary>
- /// <param name="ids"></param>
- /// <returns></returns>
- 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");
- }
- }
- }
|