1
yanjinhui
2025-06-12 10c497ad3b1802e1c8feed8df0a290a407ec72bc
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
using Microsoft.AspNetCore.DataProtection.KeyManagement;
using SqlSugar;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using WIDESEAWCS_Core.BaseRepository;
using WIDESEAWCS_ISystemRepository;
using WIDESEAWCS_Model.Models;
 
namespace WIDESEAWCS_SystemRepository
{
    public class Sys_DictionaryRepository : RepositoryBase<Sys_Dictionary>, ISys_DictionaryRepository
    {
        public Sys_DictionaryRepository(IUnitOfWorkManage unitOfWorkManage) : base(unitOfWorkManage)
        {
        }
 
        /// <summary>
        /// 
        /// </summary>
        /// <param name="dicNos"></param>
        /// <param name="executeSql">是否执行自定义sql</param>
        /// <returns></returns>
        public IEnumerable<Sys_Dictionary> GetDictionaries(IEnumerable<string> dicNos, bool executeSql = false)
        {
            List<Sys_Dictionary> Dictionaries = GetAllDictionary(dicNos);
 
            //foreach (var item in Dictionaries.Where(x => dicNos.Contains(x.DicNo)))
            //{
            //    if (executeSql)
            //    {
            //        //  2020.05.01增加根据用户信息加载字典数据源sql
            //        string sql = item.DBSql;
            //        if (!string.IsNullOrEmpty(sql))
            //        {
            //            item.DicList = Query(sql);
            //        }
            //    }
            //}
 
            return Dictionaries;
        }
 
        List<Sys_DictionaryList> Query(string sql)
        {
            try
            {
                return base.QueryDynamicDataBySql(sql, null).Select(s => new Sys_DictionaryList()
                {
                    DicName = s.Value,
                    DicValue = s.Key.ToString()
                }).ToList();
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }
 
        private List<Sys_Dictionary> GetAllDictionary(IEnumerable<string> dicNos)
        {
            //base.QueryData().ToList();
            List<Sys_Dictionary> _dictionaries = Db.Queryable<Sys_Dictionary>().Includes(x => x.DicList).Where(x => x.Enable == 1 && dicNos.Contains(x.DicNo)).ToList();
            return _dictionaries;
        }
    }
 
    public class SourceKeyVaule
    {
        public object Key { get; set; }
        public string Value { get; set; }
    }
}