/// <summary> /// 查看详细 /// </summary> /// <param name="id"></param> /// <returns></returns> //[SupportFilter] public JsonResult Details(int id) { var item = SMROLETBService.LoadEntities(r => r.ROLE_ID == id).Select(r => new { ROLE_NAME = r.ROLE_NAME, CREATION_TIME = r.CREATION_TIME, CreateUserName = r.SMUSERTB1 == null?string.Empty:r.SMUSERTB1.USER_NAME, UPDATE_TIME = r.UPDATE_TIME, UpdateUserName = r.SMUSERTB == null?string.Empty:r.SMUSERTB.USER_NAME, REMARK = r.REMARK, SysPersonId = r.SMUSERTB2.Select(u => u.USER_NAME), StatusName = r.STATUS }).FirstOrDefault(); string statusName = item.StatusName.GetStatusName(); string sysPersonId = item.SysPersonId.ToList().GetStringByList(); var result = new { ROLE_NAME = item.ROLE_NAME, CREATION_TIME = item.CREATION_TIME, UPDATE_TIME = item.UPDATE_TIME, CreateUserName = item.CreateUserName, UpdateUserName = item.UpdateUserName, REMARK = item.REMARK, SysPersonId = sysPersonId, StatusName = statusName }; return(Json(result, JsonRequestBehavior.AllowGet)); }
//[SupportFilter] public ActionResult Save(FormCollection collection) { string returnValue = string.Empty; string[] ids = collection["ids"].GetString().Split(','); int id = collection["id"].GetInt(); int userId = UserId; SMLOG OperLog = new SMLOG { OPERATION_TYPE = "U", FUNC_CODE = "900009", USER_ID = userId, CLASSNAME = this.GetType().ToString() + ": Save" }; try { if (SMROLETBService.SaveCollection(ids, id)) { OperLog.REMARK = "信息的Id为" + string.Join(",", ids) + Suggestion.InsertSucceed; SMLOGService.AddEntity(OperLog); return(Json("OK")); } else { OperLog.REMARK = "信息的Id为" + string.Join(",", ids) + Suggestion.InsertFail; SMLOGService.AddEntity(OperLog); } } catch (Exception ex) { throw new Exception(ex.Message); } return(Json(returnValue)); }
//[SupportFilter] public ActionResult Delete(FormCollection collection) { string returnValue = string.Empty; List <int> lists = collection["query"].GetString().ToIntList(); int[] deleteId = lists.ToArray(); if (deleteId != null && deleteId.Length > 0) { SMLOG OperLog = new SMLOG { OPERATION_TYPE = "D", FUNC_CODE = "010701", USER_ID = UserId, CLASSNAME = this.GetType().ToString() + strDelete }; if (deleteId.Length == 1) { int roleId = deleteId[0]; var role = SMROLETBService.LoadEntities(r => r.ROLE_ID == roleId).FirstOrDefault(); if (SMROLETBService.Delete(role)) { OperLog.REMARK = "角色Id:" + deleteId[0] + Suggestion.DeleteSucceed; SMLOGService.AddEntity(OperLog);//写入日志 return(Json("OK")); } else { OperLog.REMARK = "角色Id:" + deleteId[0] + Suggestion.DeleteFail; } SMLOGService.AddEntity(OperLog);//写入日志 } } return(Json(returnValue)); }
//[SupportFilter] public ActionResult Edit(int id, SMROLETB entity) { if (entity != null && ModelState.IsValid) { //数据校验 entity.UPDATE_USER = UserId; string returnValue = string.Empty; SMLOG OperLog = new SMLOG { OPERATION_TYPE = "U", FUNC_CODE = "010701", USER_ID = UserId, CLASSNAME = this.GetType().ToString() + strEdit }; if (SMROLETBService.Edit(entity)) { OperLog.REMARK = "角色:" + entity.ROLE_NAME + Suggestion.UpdateSucceed; SMLOGService.AddEntity(OperLog); //写入日志 return(Json(Suggestion.UpdateSucceed)); //提示更新成功 } else { OperLog.REMARK = "角色:" + entity.ROLE_NAME + Suggestion.UpdateFail + returnValue; return(Json(Suggestion.UpdateFail + returnValue)); //提示更新失败 } } return(Json(Suggestion.UpdateFail + "请核对输入的数据的格式")); //提示输入的数据的格式不对 }
//[SupportFilter] public ActionResult Create(SMROLETB entity) { if (entity != null && ModelState.IsValid) { entity.CREATION_TIME = DateTime.Now; entity.CREATION_USER = UserId; string returnValue = string.Empty; SMLOG OperLog = new SMLOG { OPERATION_TYPE = "N", FUNC_CODE = "010701", USER_ID = UserId, CLASSNAME = this.GetType().ToString() + strCreate }; var result = SMROLETBService.Create(entity); if (result != null) { OperLog.REMARK = "角色:" + entity.ROLE_NAME + Suggestion.InsertSucceed; SMLOGService.AddEntity(OperLog);//写入日志 return(Json(Suggestion.InsertSucceed)); } else { OperLog.REMARK = "角色:" + entity.ROLE_NAME + Suggestion.InsertFail; SMLOGService.AddEntity(OperLog); //写入日志 return(Json(Suggestion.InsertFail + returnValue)); //提示插入失败 } } return(Json(Suggestion.InsertFail + ",请核对输入的数据的格式")); //提示输入的数据的格式不对 }
//[SupportFilter] public ActionResult Delete(FormCollection collection) { string returnValue = string.Empty; int[] deleteId = collection["query"].GetString().ToIntList().ToArray <int>(); if (deleteId != null && deleteId.Length > 0) { SMLOG _SMLOG = new SMLOG { OPERATION_TYPE = "D", FUNC_CODE = "010000", USER_ID = UserId, CLASSNAME = this.GetType().ToString() + strDelete }; int userId = deleteId[0]; var userInfo = SMUSERTBService.LoadEntities(x => x.USER_ID == userId).FirstOrDefault(); List <int> roleIds = userInfo.SMROLETB.Select(x => x.ROLE_ID).ToList(); var userRoles = SMROLETBService.LoadEntities(x => roleIds.Contains(x.ROLE_ID)).ToList(); foreach (var v in userRoles) { userInfo.SMROLETB.Remove(v); } if (SMUSERTBService.DeleteEntity(userInfo)) { _SMLOG.REMARK = "用户:" + GetCurrentAccount().USER_NAME + Suggestion.DeleteSucceed; SMLOGService.AddEntity(_SMLOG);//删除成功,写入日志 return(Json("OK")); } else { _SMLOG.REMARK = "用户:" + GetCurrentAccount().USER_NAME + Suggestion.DeleteFail; SMLOGService.AddEntity(_SMLOG);//删除失败,写入日志 } returnValue = _SMLOG.REMARK; } return(Json(returnValue)); }
public SysRoleController(SMLOGService logService, SMROLETBService roleService, SMFUNCTBService funcService) { SMLOGService = logService; SMROLETBService = roleService; }
public SysUserController(SMLOGService logService, SMROLETBService roleService, SMUSERTBService userService) { SMLOGService = logService; SMROLETBService = roleService; SMUSERTBService = userService; }
/// <summary> /// 首次设置SysMenu /// </summary> /// <param name="id">主键</param> /// <returns></returns> //[SupportFilter] public ActionResult SetSysMenu(int id) { var entity = SMROLETBService.LoadEntities(x => x.ROLE_ID == id).FirstOrDefault(); ViewData["myname"] = entity.ROLE_NAME; ViewData["myid"] = id; return(View(entity)); }
//[SupportFilter] public JsonResult GetData(string id, RoleParam roleParam) { int total = 0; var queryData = SMROLETBService.LoadSearchEntities(roleParam); total = roleParam.TotalCount; var data = queryData.ToList().Select(m => new { ROLE_ID = m.ROLE_ID, ROLE_NAME = m.ROLE_NAME, CREATION_TIME = m.CREATION_TIME, REMARK = m.REMARK, STATUS = m.STATUS.GetStatusName() }); //构造成Json的格式传递 var result = new { total = total, rows = data }; return(Json(result, JsonRequestBehavior.AllowGet)); }
//[SupportFilter] public ActionResult Create(SMUSERTB entity) { if (entity != null && ModelState.IsValid) { entity.CREATION_TIME = DateTime.Now; entity.CREATION_USER = UserId; entity.U_PASSWORD = xEncrypt.EncryptText(entity.U_PASSWORD);//加密 string returnValue = string.Empty; if (SMUSERTBService.LoadEntities(x => x.U_ID == entity.U_ID).FirstOrDefault() != null) { returnValue = "登录名已存在!"; return(Json(Suggestion.InsertFail + returnValue)); } SMLOG _SMLOG = new SMLOG { OPERATION_TYPE = "N", FUNC_CODE = "010702", USER_ID = UserId, CLASSNAME = this.GetType().ToString() + strCreate }; List <int> roleIds = entity.SysRoleId.GetIdSort(); entity.SMROLETB = SMROLETBService.LoadEntities(x => roleIds.Contains(x.ROLE_ID)).ToList(); var result = SMUSERTBService.AddEntity(entity); if (result != null) { _SMLOG.REMARK = "用户:" + entity.USER_NAME + Suggestion.InsertSucceed; SMLOGService.AddEntity(_SMLOG);//写入日志 return(Json(Suggestion.InsertSucceed)); } else { _SMLOG.REMARK = "用户:" + entity.USER_NAME + Suggestion.InsertFail + "原因:" + returnValue; SMLOGService.AddEntity(_SMLOG);//写入日志 //提示插入失败 return(Json(Suggestion.InsertFail + returnValue)); } } return(Json(Suggestion.InsertFail + "请核对输入的数据的格式")); //提示输入的数据的格式不对 }
/// <summary> /// 首次编辑 /// </summary> /// <param name="id">主键</param> /// <returns></returns> //[SupportFilter] public ActionResult Edit(int id) { SMROLETB item = SMROLETBService.LoadEntities(r => r.ROLE_ID == id).FirstOrDefault(); return(View(item)); }