颐和api

Sys_Post_SystemRepository.cs 1.8KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849
  1. using ConfigurationApi.IRepositories;
  2. using MadRunFabric.Common;
  3. using MadRunFabric.Common.Options;
  4. using MadRunFabric.Model;
  5. using Microsoft.Extensions.Logging;
  6. using Microsoft.Extensions.Options;
  7. using MongoDB.Driver;
  8. using System;
  9. using System.Collections.Generic;
  10. using System.Text;
  11. using System.Linq;
  12. namespace ConfigurationApi.Repositories
  13. {
  14. public class Sys_Post_SystemRepository : BaseRepository<Sys_Post_System, string>, ISys_Post_SystemRepository
  15. {
  16. protected readonly ILogger<BaseRepository<Sys_Post_System, string>> _logger;
  17. protected readonly IMongoCollection<Sys_DictionaryValue> _collection_sys_dictionaryvalue;
  18. public Sys_Post_SystemRepository(IOptions<MongodbOptions> settings, ILogger<BaseRepository<Sys_Post_System, string>> logger) : base(settings, logger)
  19. {
  20. _collection_sys_dictionaryvalue = _context.GetCollection<Sys_DictionaryValue>();
  21. _logger = logger;
  22. }
  23. /// <summary>
  24. /// 获取岗位系统树形结构
  25. /// </summary>
  26. /// <returns></returns>
  27. public IEnumerable<object> GetPostSystemAsync(string postid)
  28. {
  29. var query = from p in _collection.AsQueryable()
  30. where p.postid == postid && p.isdelete == 0
  31. select p;
  32. var systemlist = from p in _collection_sys_dictionaryvalue.AsQueryable()
  33. where p.dictionarycode == "XTMC" && p.statetype == true
  34. select p;
  35. var list = systemlist.ToList().Select(p => new
  36. {
  37. p.id,
  38. pid = "-1",
  39. name = p.name,
  40. ischecked = query.Where(q => q.systemid == p.id).FirstOrDefault() != null ? true : false
  41. });
  42. return list;
  43. }
  44. }
  45. }