国产探花免费观看_亚洲丰满少妇自慰呻吟_97日韩有码在线_资源在线日韩欧美_一区二区精品毛片,辰东完美世界有声小说,欢乐颂第一季,yy玄幻小说排行榜完本

首頁(yè) > 學(xué)院 > 開(kāi)發(fā)設(shè)計(jì) > 正文

構(gòu)建ASP.NET MVC4+EF5+EasyUI+Unity2.x注入的后臺(tái)管理系統(tǒng)(23)-權(quán)限管理系統(tǒng)-角色組模塊

2019-11-15 02:26:32
字體:
來(lái)源:轉(zhuǎn)載
供稿:網(wǎng)友

構(gòu)建asp.net MVC4+EF5+EasyUI+Unity2.x注入的后臺(tái)管理系統(tǒng)(23)-權(quán)限管理系統(tǒng)-角色組模塊

系列目錄

距離上次發(fā)布22講已經(jīng)有少許日子了,真是太抱歉,最近年關(guān)項(xiàng)目比較急,時(shí)間太緊,沒(méi)有時(shí)間發(fā)布.請(qǐng)大家見(jiàn)諒

接下來(lái)我們的目標(biāo)是

  1. 角色組管理
  2. 角色組權(quán)限設(shè)置
  3. 用戶管理
  4. 把角色組授權(quán)給用戶
  5. 給用戶分配角色組

所以最少我們還要講多5講才能結(jié)束這個(gè)管理系統(tǒng),經(jīng)過(guò)之前的樣例程序,我們很熟悉這個(gè)套路了,如果你很喜歡這個(gè)系列,你可以為這種重復(fù)性的動(dòng)作寫(xiě)一個(gè)簡(jiǎn)單的代碼生成器,或者一套強(qiáng)大的T4模版,其實(shí)這2個(gè)我都有,而且也是剛寫(xiě)的,以后系統(tǒng)完善了,給發(fā)布出來(lái)。

是不是還可以呢,哈哈,T4我也寫(xiě)了一套,但畢竟還是沒(méi)有winfrom來(lái)得方便。

接下來(lái)我們?cè)谥白龊玫哪K管理,在22講中,添加角色組管理的記錄和操作碼,如圖

目前我是需要添加這么多個(gè)操作碼。回頭就機(jī)械性的創(chuàng)建DAL層,BLL層,Model層,還有注入

using System;using System.Collections.Generic;using System.Linq;using System.Text;using App.Models;namespace App.IDAL{    public interface ISysRoleRepository    {             IQueryable<SysRole> GetList(DBContainer db);        int Create(SysRole entity);        int Delete(string id);        int Edit(SysRole entity);        SysRole GetById(string id);        bool IsExist(string id);    }}
ISysRoleRepository
using System;using System.Collections.Generic;using System.Linq;using System.Text;using App.Models;using App.IDAL;using System.Data;namespace App.DAL{    public class SysRoleRepository : IDisposable,ISysRoleRepository    {        public IQueryable<SysRole> GetList(DBContainer db)        {            IQueryable<SysRole> list = db.SysRole.AsQueryable();            return list;        }        public int Create(SysRole entity)        {            using (DBContainer db = new DBContainer())            {                db.SysRole.AddObject(entity);                return db.SaveChanges();            }        }        public int Delete(string id)        {            using (DBContainer db = new DBContainer())            {                SysRole entity = db.SysRole.SingleOrDefault(a => a.Id == id);                if (entity != null)                {                    db.SysRole.DeleteObject(entity);                }                return db.SaveChanges();            }        }        public int Edit(SysRole entity)        {            using (DBContainer db = new DBContainer())            {                db.SysRole.Attach(entity);                db.ObjectStateManager.ChangeObjectState(entity, EntityState.Modified);                return db.SaveChanges();            }        }        public SysRole GetById(string id)        {            using (DBContainer db = new DBContainer())            {                return db.SysRole.SingleOrDefault(a => a.Id == id);            }        }        public bool IsExist(string id)        {            using (DBContainer db = new DBContainer())            {                SysRole entity = GetById(id);                if (entity != null)                    return true;                return false;            }        }        public void Dispose()        {        }    }}
SysRoleRepository
using System;using System.Collections.Generic;using System.Linq;using System.Text;using App.Models;using App.Common;using App.Models.Sys;namespace App.IBLL{    public interface ISysRoleBLL    {        List<SysRoleModel> GetList(ref GridPager pager, string queryStr);        bool Create(ref ValidationErrors errors, SysRoleModel model);        bool Delete(ref ValidationErrors errors, string id);        bool Edit(ref ValidationErrors errors, SysRoleModel model);        SysRoleModel GetById(string id);        bool IsExist(string id);    }}
ISysRoleBLL
using System;using System.Collections.Generic;using System.Linq;using Microsoft.PRactices.Unity;using App.Models;using App.Common;using System.Transactions;using App.Models.Sys;using App.IBLL;using App.IDAL;using App.BLL.Core;namespace App.BLL{    public class SysRoleBLL : BaseBLL, ISysRoleBLL    {        [Dependency]        public ISysRoleRepository m_Rep { get; set; }        public List<SysRoleModel> GetList(ref GridPager pager, string queryStr)        {            IQueryable<SysRole> queryData = null;            if (!string.IsNullOrWhiteSpace(queryStr))            {                queryData = m_Rep.GetList(db).Where(a => a.Name.Contains(queryStr));            }            else            {                queryData = m_Rep.GetList(db);            }            pager.totalRows = queryData.Count();            queryData = LinqHelper.SortingAndPaging(queryData, pager.sort, pager.order, pager.page, pager.rows);            return CreateModelList(ref queryData);        }        private List<SysRoleModel> CreateModelList(ref IQueryable<SysRole> queryData)        {            List<SysRoleModel> modelList = new List<SysRoleModel>();            foreach (var r in queryData)            {                modelList.Add(new SysRoleModel()                {                    Id = r.Id,                    Name = r.Name,                    Description = r.Description,                    CreateTime = r.CreateTime,                    CreatePerson = r.CreatePerson,                    UserName = ""                });            }            return modelList;        }        public bool Create(ref ValidationErrors errors, SysRoleModel model)        {            try            {                SysRole entity = m_Rep.GetById(model.Id);                if (entity != null)                {                    errors.Add(Suggestion.PrimaryRepeat);                    return false;                }                entity = new SysRole();                entity.Id = model.Id;                entity.Name = model.Name;                entity.Description = model.Description;                entity.CreateTime = model.CreateTime;                entity.CreatePerson = model.CreatePerson;                if (m_Rep.Create(entity) == 1)                {                    //分配給角色                    db.P_Sys_InsertSysRight();                    //清理無(wú)用的項(xiàng)                    db.P_Sys_ClearUnusedRightOperate();                    return true;                }                else                {                    errors.Add(Suggestion.InsertFail);                    return false;                }            }            catch (Exception ex)            {                errors.Add(ex.Message);                ExceptionHander.WriteException(ex);                return false;            }        }        public bool Delete(ref ValidationErrors errors, string id)        {            try            {                if (m_Rep.Delete(id) == 1)                {                    r
發(fā)表評(píng)論 共有條評(píng)論
用戶名: 密碼:
驗(yàn)證碼: 匿名發(fā)表
主站蜘蛛池模板: 广元市| 自贡市| 龙海市| 滁州市| 夏津县| 阳山县| 深州市| 泉州市| 湄潭县| 绿春县| 嘉黎县| 和林格尔县| 溧水县| 梁河县| 梨树县| 荔波县| 林口县| 雷州市| 南川市| 上犹县| 龙岩市| 锡林郭勒盟| 沙洋县| 德兴市| 公主岭市| 河北区| 冕宁县| 宜章县| 安化县| 沙田区| 延寿县| 广灵县| 澜沧| 梁平县| 无极县| 北票市| 桦甸市| 和政县| 娄烦县| 宁明县| 潜江市|