xxyy
2025-03-10 457b75b642a1fdaa7158e5b047cabc5d7ae16333
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
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using WIDESEA_Core.BaseRepository;
using WIDESEA_Core.BaseServices;
using WIDESEA_IRepository;
using WIDESEA_IServices;
using WIDESEA_Model.Models;
 
namespace WIDESEA_Services
{
    public class Sys_DictionaryService : ServiceBase<Sys_Dictionary, ISys_DictionaryRepository>, ISys_DictionaryService
    {
        private readonly IUnitOfWorkManage _unitOfWorkManage;
        public Sys_DictionaryService(ISys_DictionaryRepository BaseDal, IUnitOfWorkManage unitOfWorkManage) : base(BaseDal)
        {
            _unitOfWorkManage = unitOfWorkManage;
        }
 
        public object GetVueDictionary(string[] dicNos)
        {
            if (dicNos == null || dicNos.Count() == 0) return new string[] { };
 
            var dicConfig = BaseDal.GetDictionaries(dicNos, false).Select(s => new
            {
                dicNo = s.DicNo,
                config = s.Config,
                dbSql = s.DBSql,
                list = s.DicList.OrderByDescending(o => o.OrderNo).Select(list => new { key = list.DicValue, value = list.DicName })
            }).ToList();
 
            object GetSourceData(string dicNo, string dbSql, object data)
            {
                if (string.IsNullOrEmpty(dbSql))
                {
                    return data as object;
                }
                return BaseDal.QueryObjectDataBySql(dbSql, null);
            }
            return dicConfig.Select(item => new
            {
                item.dicNo,
                item.config,
                data = GetSourceData(item.dicNo, item.dbSql, item.list)
            }).ToList();
        }
    }
}