예제 #1
0
 /// <summary>
 /// 纯净删除模块
 /// </summary>
 /// <param name="module"></param>
 public virtual void DeleteModule(TsResource module)
 {
     using (var db = new Db())
     {
         db.Delete(module);
     }
 }
예제 #2
0
 /// <summary>
 /// 纯净新增模块
 /// </summary>
 /// <param name="module"></param>
 public virtual void InsertModule(TsResource module)
 {
     using (var db = new Db())
     {
         db.Insert(module);
     }
 }
예제 #3
0
 /// <summary>
 /// 纯净删除模块
 /// </summary>
 /// <param name="module"></param>
 public virtual int DeleteModule(TsResource module)
 {
     using (var db = GetDbContext())
     {
         return(db.Delete(module));
     }
 }
예제 #4
0
 /// <summary>
 /// 纯净新增模块
 /// </summary>
 /// <param name="module"></param>
 public virtual int InsertModule(TsResource module)
 {
     using (var db = GetDbContext())
     {
         module.Id = SequenceService.Proxy.GenerateLocalId();
         return(db.Insert(module));
     }
 }
예제 #5
0
파일: MenuItemDto.cs 프로젝트: lsYinyue/Z17
 public static MenuItemDto Map(TsResource rsc)
 {
     return(new MenuItemDto
     {
         Id = rsc.Id,
         PId = rsc.CPId,
         Code = rsc.CCode,
         Name = rsc.CName,
         Order = rsc.COrder,
         Path = rsc.CResourcePath,
         SubPath = rsc.CResourceSubPath,
         Url = rsc.CUrl,
         QueryString = rsc.CQueryString,
         Timestamp = rsc.TimeStamp.GetValueOrDefault()
     });
 }
예제 #6
0
        public virtual List <TreeDto> QueryRestrictData(TsResource item, string roleId)
        {
            if (item.CType != 16)
            {
                return(new List <TreeDto>());
            }

            using (var db = GetDbContext())
            {
                if (item.CCode.StartsWith("KV_"))
                {
                    var kvId     = item.CCode.Substring(3);
                    var parentKv = db.GetTable <TsKeyValue>()
                                   .FirstOrDefault(x => x.Id.Equals(kvId));
                    var result = db.GetTable <TsKeyValue>()
                                 .Where(x => x.CPCode.Equals(parentKv.CCode))
                                 .OrderBy(x => x.COrder)
                                 .ToList()
                                 .Select(x => new TreeDto
                    {
                        Id   = x.Id,
                        Name = x.CCode,
                        Tag  = x.CName
                    })
                                 .ToList();
                    return(result);
                }
                else
                {
                    var listRole = db.GetTable <TsRolePermission>()
                                   .Where(x => x.CRoleId.Equals(roleId) && x.CResourceId.StartsWith(item.Id) && x.CResourceType.Equals(16))
                                   .ToList();
                    string sql    = string.Format("select {0} Id,{1} Name ", item.CResourcePath, item.CResourceSubPath) + string.Format("from {0} order by {1}", item.CCode, item.CResourcePath);
                    var    result = db.Query <TreeDto>(sql)
                                    .Select(x => new TreeDto
                    {
                        Id   = x.Id,
                        Name = string.Format("[{0}]-{1}", x.Id, x.Name),
                        Tag  = listRole.Any(w => w.CResourceId == string.Format("{0}##{1}", item.Id, x.Id))
                    }).ToList();
                    return(result);
                }
            }
        }