|
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435 |
- using Learun.Application.Organization;
- using Learun.Util;
- using System.Collections.Generic;
- using System.Web.Mvc;
- using Learun.Application.Base.AuthorizeModule;
- using System.Linq;
- using System;
- using Learun.Application.Base.SystemModule;
- using Learun.Application.TwoDevelopment.EducationalAdministration;
- using System.Configuration;
-
- namespace Learun.Application.Web.Areas.LR_OrganizationModule.Controllers
- {
- /// <summary>
- /// 版 本 Learun-ADMS-Ultimate V7.0.0 数字化智慧校园
- /// Copyright (c) 2013-2018 北京泉江科技有限公司
- /// 创建人:陈彬彬
- /// 日 期:2017.03.09
- /// 描 述:用户管理控制器
- /// </summary>
- public class UserController : MvcControllerBase
- {
- private UserIBLL userIBLL = new UserBLL();
- private DepartmentIBLL departmentIBLL = new DepartmentBLL();
- private UserRelationIBLL userRelationIBLL = new UserRelationBLL();
- private RoleIBLL roleIBLL = new RoleBLL();
- private Sys_DefaultPwdConfigIBLL sys_DefaultPwdConfigIBLL = new Sys_DefaultPwdConfigBLL();
-
-
- #region 获取视图
-
- [HttpGet]
- public ActionResult StudentIndex()
- {
- return View();
- }
-
- /// <summary>
- /// 用户管理主页
- /// </summary>
- /// <returns></returns>
- [HttpGet]
- public ActionResult Index()
- {
- return View();
- }
- /// <summary>
- /// 用户管理表单
- /// </summary>
- /// <returns></returns>
- [HttpGet]
- public ActionResult Form()
- {
- return View();
- }
-
- /// <summary>
- /// 人员选择
- /// </summary>
- /// <returns></returns>
- [HttpGet]
- public ActionResult SelectForm()
- {
- return View();
- }
- [HttpGet]
- public ActionResult LookForm()
- {
- return View();
- }
- /// <summary>
- /// 人员选择
- /// </summary>
- /// <returns></returns>
- [HttpGet]
- public ActionResult SelectOnlyForm()
- {
- return View();
- }
-
-
- #endregion
-
- #region 获取数据
- /// <summary>
- /// 获取分页数据
- /// </summary>
- /// <param name="pagination">分页参数</param>
- /// <param name="keyword">关键字</param>
- /// <param name="companyId">公司主键</param>
- /// <param name="departmentId">部门主键</param>
- /// <param name="tp">0 教师 1学生</param>
- /// <returns></returns>
- [HttpGet]
- [AjaxOnly]
- public ActionResult GetPageList(string pagination, string keyword, string companyId, string departmentId, string tp)
- {
- Pagination paginationobj = pagination.ToObject<Pagination>();
- var data = userIBLL.GetPageList(companyId, departmentId, paginationobj, keyword, tp);
- var jsonData = new
- {
- rows = data,
- total = paginationobj.total,
- page = paginationobj.page,
- records = paginationobj.records,
- };
- return JsonResult(jsonData);
- }
- /// <summary>
- /// 获取用户列表
- /// </summary>
- /// <param name="companyId">公司主键</param>
- /// <param name="departmentId">部门主键</param>
- /// <param name="keyword">查询关键词</param>
- /// <returns></returns>
- [HttpGet]
- [AjaxOnly]
- public ActionResult GetList(string companyId, string departmentId, string keyword)
- {
- if (string.IsNullOrEmpty(companyId))
- {
- var department = departmentIBLL.GetEntity(departmentId);
- if (department != null)
- {
- var data = userIBLL.GetList(department.F_CompanyId, departmentId, keyword);
- return JsonResult(data);
- }
- else
- {
- return JsonResult(new List<string>());
- }
- }
- else
- {
- var data = userIBLL.GetList(companyId, departmentId, keyword);
- return JsonResult(data);
- }
- }
- /// <summary>
- /// 根据部门获取用户
- /// </summary>
- /// <param name="departmentId">部门主键</param>
- /// <returns></returns>
- [HttpGet]
- [AjaxOnly]
- public ActionResult GetListByDepartmentId(string departmentId)
- {
- var data = userIBLL.GetListByDepartmentId(departmentId);
- return JsonResult(data);
- }
- /// <summary>
- /// 根据部门获取用户
- /// </summary>
- /// <param name="departmentId">部门主键</param>
- /// <returns></returns>
- [HttpGet]
- [AjaxOnly]
- public ActionResult GetListByDepartmentIds(string departmentId)
- {
- var data = userIBLL.GetListByDepartmentIds(departmentId);
- return JsonResult(data);
- }
- /// <summary>
- /// 获取本部门的人员
- /// </summary>
- /// <param name="companyId">公司主键</param>
- /// <param name="departmentId">部门主键</param>
- /// <param name="keyword">查询关键词</param>
- /// <returns></returns>
- [HttpGet]
- [AjaxOnly]
- public ActionResult GetMyDepartmentList()
- {
- UserInfo userinfo = LoginUserInfo.Get();
- var data = userIBLL.GetList(userinfo.companyId, userinfo.departmentId, "");
- return JsonResult(data);
- }
- /// <summary>
- /// 获取用户信息列表
- /// </summary>
- /// <param name="userIds">用户主键串</param>
- /// <returns></returns>
- [HttpGet]
- [AjaxOnly]
- public ActionResult GetListByUserIds(string keyValue)
- {
- var list = userIBLL.GetListByUserIds(keyValue);
- string text = "";
- if (list != null)
- {
- foreach (var item in list)
- {
- if (!string.IsNullOrEmpty(text))
- {
- text += ",";
- }
- text += item.F_RealName;
- }
- }
- return SuccessString(text);
- }
- /// <summary>
- /// 获取用户信息列表
- /// </summary>
- /// <param name="userIds">用户主键串</param>
- /// <returns></returns>
- [HttpGet]
- [AjaxOnly]
- public ActionResult GetEntityListByUserIds(string keyValue)
- {
- var list = userIBLL.GetListByUserIds(keyValue);
- return JsonResult(list);
- }
-
- /// <summary>
- /// 获取用户信息
- /// </summary>
- /// <param name="userIds">用户主键</param>
- /// <returns></returns>
- [HttpGet]
- [AjaxOnly]
- public ActionResult GetUserEntity(string userId)
- {
- var data = userIBLL.GetEntityByUserId(userId);
- return JsonResult(data);
- }
-
- /// <summary>
- /// 获取映射数据
- /// </summary>
- /// <returns></returns>
- [HttpGet]
- [AjaxOnly]
- public ActionResult GetMap(string ver)
- {
- var data = userIBLL.GetModelMap();
- string md5 = Md5Helper.Encrypt(data.ToJson(), 32);
- if (md5 == ver)
- {
- return Success("no update");
- }
- else
- {
- var jsondata = new
- {
- data = data,
- ver = md5
- };
- return JsonResult(jsondata);
- }
- }
- /// <summary>
- /// 获取头像
- /// </summary>
- /// <param name="userId">用户主键</param>
- /// <returns></returns>
- [HttpGet]
- public ActionResult GetImg(string userId)
- {
- userIBLL.GetImg(userId);
- return Success("获取成功。");
- }
- /// <summary>
- /// 获取头像For大厂
- /// </summary>
- /// <param name="userId"></param>
- /// <returns></returns>
- [HttpGet]
- public ActionResult GetImgForDC(string userId)
- {
- userIBLL.GetImgForDC(userId);
- return Success("获取成功。");
- }
- [HttpGet]
- public ActionResult GetRoleList(string objectId)
- {
- var roleList = userRelationIBLL.GetRoleListByUserId(objectId);
- var jsonResult = new { roleInfoList = roleList };
- return Success(jsonResult);
- }
-
- [HttpGet]
- [AjaxOnly]
- public ActionResult GetLastLoginTime(string userId)
- {
- return Success(LogBLL.GetUserLogList(userId)?.F_OperateTime);
- }
-
- #endregion
-
- #region 提交数据
- /// <summary>
- /// 保存表单数据
- /// </summary>
- /// <param name="keyValue">主键</param>
- /// <param name="entity">实体</param>
- /// <returns></returns>
- [HttpPost]
- [ValidateAntiForgeryToken]
- [AjaxOnly]
- public ActionResult SaveForm(string keyValue, UserEntity entity)
- {
- userIBLL.SaveEntity(keyValue, entity);
- return Success("保存成功!");
- }
- /// <summary>
- /// 删除表单数据
- /// </summary>
- /// <param name="keyValue">主键</param>
- /// <returns></returns>
- [HttpPost]
- [AjaxOnly]
- public ActionResult DeleteForm(string keyValue)
- {
- //userIBLL.VirtualDelete(keyValue);
- userIBLL.VirtualDeleteBatch(keyValue);
- return Success("删除成功!");
- }
- /// <summary>
- /// 启用禁用账号
- /// </summary>
- /// <param name="keyValue">主键</param>
- /// <returns></returns>
- [HttpPost]
- [AjaxOnly]
- public ActionResult UpdateState(string keyValue, int state)
- {
- userIBLL.UpdateState(keyValue, state);
- return Success("操作成功!");
- }
- /// <summary>
- /// 重置用户账号密码
- /// </summary>
- /// <param name="keyValue">主键</param>
- /// <returns></returns>
- [HttpPost]
- [AjaxOnly]
- public ActionResult ResetPassword(string keyValue)
- {
- string defpwd = ConfigurationManager.AppSettings["defaultpwd"];
- //读取默认密码配置中已启用的密码
- if (sys_DefaultPwdConfigIBLL.GetEnabledEntity() != null)
- {
- defpwd = sys_DefaultPwdConfigIBLL.GetEnabledEntity().Pwd;
- }
- userIBLL.ResetPassword(keyValue, defpwd);
- return Success("操作成功!");
- }
- /// <summary>
- /// 重置用户账号密码(八位)
- /// </summary>
- /// <param name="keyValue">主键</param>
- /// <returns></returns>
- [HttpPost]
- [AjaxOnly]
- public ActionResult ResetPasswordEight(string keyValue)
- {
- string defpwd = ConfigurationManager.AppSettings["defaultpwdeight"];
- //读取默认密码配置中已启用的密码
- if (sys_DefaultPwdConfigIBLL.GetEnabledEntity() != null)
- {
- defpwd = sys_DefaultPwdConfigIBLL.GetEnabledEntity().Pwd;
- }
- userIBLL.ResetPasswordEight(keyValue, defpwd);
- return Success("操作成功!");
- }
-
-
- [HttpGet]
- [AjaxOnly]
- public ActionResult ResetStudentRelation()
- {
- var allStudents = userIBLL.GetStudents();
- var studentRoleId = roleIBLL.GetIdByRoleName("学生");
-
- var hasStudentsRolePeople = userRelationIBLL.GetUserIdList(studentRoleId).Select(a => a.F_UserId);
- var studentList = allStudents.Where(a => !hasStudentsRolePeople.Contains(a.F_UserId));
- var relationList = new List<UserRelationEntity>();
- var userIds = "";
- foreach (var item in allStudents)
- {
- if (userIds != "")
- {
- userIds += ",";
- }
- userIds += item.F_UserId;
-
- }
- userRelationIBLL.SaveEntityList(studentRoleId, 1, userIds);
- return Success("操作成功");
-
-
- }
- #endregion
-
- #region 数据导出
- /// <summary>
- /// 导出用户列表
- /// </summary>
- /// <returns></returns>
- [HttpGet]
- public ActionResult ExportUserList()
- {
- userIBLL.GetExportList();
- return Success("导出成功。");
- }
- /// <summary>
- /// 导出用户列表【学生】
- /// </summary>
- /// <returns></returns>
- [HttpGet]
- public ActionResult ExportUserListOfStudent()
- {
- userIBLL.GetExportListOfStudent();
- return Success("导出成功。");
- }
- #endregion
-
- #region 验证数据
- /// <summary>
- /// 账号不能重复
- /// </summary>
- /// <param name="keyValue">主键</param>
- /// <param name="F_Account">账号</param>
- /// <returns></returns>
- [HttpGet]
- [AjaxOnly]
- public ActionResult ExistAccount(string keyValue, string F_Account)
- {
- bool res = userIBLL.ExistAccount(F_Account, keyValue);
- return JsonResult(res);
- }
- #endregion
- }
- }
|