public int RegisterRole([FromForm] RegisterRoleAndQuan model) { string time = DateTime.Now.ToString(); //分割获取到的权限ID,分为数组类型 var ids = model.Q_ids.Split(','); //实例化初始化器赋值 Base_Role role = new Base_Role() { Role_Name = model.Role_Name, Role_Desc = model.Role_Desc, CreateDate = time }; //添加角色,接收受影响行数 int flag = bll.AddRole(role); //判断是否添加成功 if (flag < 0) { return(0); } //获取所有的角色 List <Base_Role> list = bll.GetRoleList(); //通过时间判断刚才所添加的角色ID Base_Role rmodel = list.Where(s => s.CreateDate.Equals(time)).FirstOrDefault(); //赋值 int code = rmodel.ID; //循环添加角色权限表 for (int i = 0; i < ids.Length; i++) { flag += bll.AddRoleAndQuan(int.Parse(ids[i]), code); } //返回受影响行数 return(flag); }
public ActionResult Add(Base_Role model) { //权限检查 Helper.IsCheck(HttpContext, AdminModule.AdminRole.ToString(), SystemRight.Add.ToString(), true); ResultView <int> view = new ResultView <int>(); ResultView <bool> checkRight = new ResultView <bool>(); if (string.IsNullOrEmpty(model.RoleName)) { view.Flag = false; view.Message = "角色名不能为空"; return(Json(view)); } model.Belong = RoleType.Owner.ToString(); Result <int> result = new Result <int>(); using (AdminClientProxy proxy = new AdminClientProxy(ProxyEx(Request))) { result = proxy.AddRole(model); view = result.ToResultView(); } return(Json(view)); }
/// <summary> /// 角色列表 /// </summary> /// <returns></returns> public IEnumerable <RoleEntity> GetList() { var sql = PetaPoco.Sql.Builder.Append(@"select * from Base_Role where 1=1 and Category=@0 and EnabledMark=1 and DeleteMark=0", (int)QSDMS.Model.Enums.RoleCategoryEnum.角色); sql.Append(" order by CreateDate desc"); var list = Base_Role.Query(sql); return(EntityConvertTools.CopyToList <Base_Role, RoleEntity>(list.ToList())); }
public bool SaveOrUpdate(Base_Role data) { try { CommonDao.SaveOrUpdate(data); return true; } catch (Exception e) { Log.Error("角色数据编辑", e); return false; } }
/// <summary> /// 角色名称不能重复 /// </summary> /// <param name="fullName">名称</param> /// <param name="keyValue">主键</param> /// <returns></returns> public bool ExistFullName(string fullName, string keyValue) { var sql = PetaPoco.Sql.Builder.Append(@"select * from Base_Role where 1=1 and Category=@0", (int)QSDMS.Model.Enums.RoleCategoryEnum.角色); if (!string.IsNullOrEmpty(fullName)) { sql.Append(" and FullName=@0", fullName); } if (!string.IsNullOrEmpty(keyValue)) { sql.Append(" and RoleId!=@0", keyValue); } return(Base_Role.Query(sql).Count() == 0 ? true : false); }
public async Task SaveData(Base_Role theData, string actionsJson) { var actionList = actionsJson?.ToList <string>(); if (theData.Id.IsNullOrEmpty()) { theData.InitEntity(); await _roleBus.AddDataAsync(theData, actionList); } else { await _roleBus.UpdateDataAsync(theData, actionList); } }
/// <summary> /// 保存岗位表单(新增、修改) /// </summary> /// <param name="keyValue">主键值</param> /// <param name="postEntity">岗位实体</param> /// <returns></returns> public void SaveForm(string keyValue, RoleEntity postEntity) { if (!string.IsNullOrEmpty(keyValue)) { postEntity.Modify(keyValue); Base_Role role = Base_Role.SingleOrDefault("where RoleId=@0", keyValue); role = EntityConvertTools.CopyToModel <RoleEntity, Base_Role>(postEntity, role); role.RoleId = keyValue; role.Update(); } else { postEntity.Create(); postEntity.Category = (int)QSDMS.Model.Enums.RoleCategoryEnum.岗位; Base_Role role = EntityConvertTools.CopyToModel <RoleEntity, Base_Role>(postEntity, null); role.Insert(); } }
public ActionResult <AjaxResult> SaveData(Base_Role theData, string actionsJson) { AjaxResult res; var actionList = actionsJson?.ToList <string>(); if (theData.Id.IsNullOrEmpty()) { theData.InitEntity(); res = _roleBus.AddData(theData, actionList); } else { res = _roleBus.UpdateData(theData, actionList); } return(JsonContent(res.ToJson())); }
/// <summary> /// 职位列表 /// </summary> /// <param name="pagination">分页</param> /// <param name="queryJson">查询参数</param> /// <returns></returns> public IEnumerable <RoleEntity> GetPageList(Pagination pagination, string queryJson) { var sql = PetaPoco.Sql.Builder.Append(@"select * from Base_Role where 1=1 and Category=@0", (int)QSDMS.Model.Enums.RoleCategoryEnum.职位); var queryParam = queryJson.ToJObject(); //机构主键 if (!queryParam["organizeId"].IsEmpty()) { string organizeId = queryParam["organizeId"].ToString(); sql.Append(" and OrganizeId=@0", organizeId); } //查询条件 if (!queryParam["condition"].IsEmpty() && !queryParam["keyword"].IsEmpty()) { string condition = queryParam["condition"].ToString(); string keyword = queryParam["keyword"].ToString(); switch (condition) { case "EnCode": //职位编号 sql.Append(" and (charindex(@0,EnCode)>0)", keyword); break; case "FullName": //职位名称 sql.Append(" and (charindex(@0,FullName)>0)", keyword); break; default: break; } } if (!string.IsNullOrWhiteSpace(pagination.sidx)) { sql.OrderBy(new object[] { pagination.sidx + " " + pagination.sord }); } var currentpage = Base_Role.Page(pagination.page, pagination.rows, sql); //数据对象 var pageList = currentpage.Items; //分页对象 pagination.records = Converter.ParseInt32(currentpage.TotalItems); return(EntityConvertTools.CopyToList <Base_Role, RoleEntity>(pageList.ToList())); }
public ActionResult Edit(Base_Role model) { Result <int> result = new Result <int>(); ResultView <int> view = new ResultView <int>(); if (string.IsNullOrEmpty(model.RoleName)) { view.Flag = false; view.Message = "角色名不能为空"; return(Json(view)); } using (AdminClientProxy proxy = new AdminClientProxy(ProxyEx(Request))) { result = proxy.UpdateRole(model); view = result.ToResultView(); } return(Json(view)); }
public int AddRole(Base_Role model) { return(dal.AddRole(model)); }
public int AddRole(Base_Role model) { return(helper.AddData(model)); }
/// <summary> /// 修改角色 /// </summary> /// <param name="model"></param> /// <returns></returns> public Result <int> UpdateRole(Base_Role model) { return(base.Channel.UpdateRole(model)); }
/// <summary> /// 删除角色 /// </summary> /// <param name="keyValue">主键</param> public void RemoveForm(string keyValue) { Base_Role.Delete("where RoleId=@0", keyValue); }
/// <summary> /// 角色实体 /// </summary> /// <param name="keyValue">主键值</param> /// <returns></returns> public RoleEntity GetEntity(string keyValue) { var role = Base_Role.SingleOrDefault("where RoleId=@0", keyValue); return(EntityConvertTools.CopyToModel <Base_Role, RoleEntity>(role, null)); }
/// <summary> /// 添加角色 /// </summary> /// <param name="model"></param> /// <returns></returns> public Result <int> AddRole(Base_Role model) { return(base.Channel.AddRole(model)); }
public int DeleteRole(Base_Role user) { user.DeleteMark = 1; return(dbUtil._myDb.Update(user)); }
public int UpdateRole(Base_Role user) { return(dbUtil._myDb.Update(user)); }
public int AddRole(Base_Role user) { return(dbUtil._myDb.Insert(user)); }