username@email.com
2024-04-12 5f4384bdab4697cc0a678fb17e55603a91a4750b
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
using CoreCms.Net.Configuration;
using CoreCms.Net.IRepository.UnitOfWork;
using CoreCms.Net.IServices;
using CoreCms.Net.IServices.baifenbingfa;
using CoreCms.Net.Model.Entities;
using CoreCms.Net.Utility.Helper;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
 
namespace CoreCms.Net.Services.baifenbingfa
{
    /// <summary>
    /// 
    /// </summary>
    public class BfbfComAPIService : IBfbfComAPIService
    {
        
        private readonly ICoreCmsUserServices _userServices;
        private readonly IUnitOfWork _unitOfWork;
        private readonly ICoreCmsSettingServices _coreCmsSettingServices;
        public   BfbfComAPIService(ICoreCmsUserServices userServices,IUnitOfWork unitOfWork,   ICoreCmsSettingServices coreCmsSettingServices)
        {
            _userServices = userServices;
            _unitOfWork = unitOfWork;
            _coreCmsSettingServices = coreCmsSettingServices;
        }
        public async Task<List<SearchUserData>> SearchUserData(string s)
        {
           var ListData= await  _unitOfWork.GetDbClient().Queryable<CoreCmsUser>().Where(x => x.isDelete == false).Select(x => new SearchUserData
            {
                Id = x.id,
                name = x.mobile + "|" + x.userName + "|" + x.nickName,
 
            }).WithCache(50).ToListAsync();
            if (string.IsNullOrEmpty(s))
            {
               return ListData;
            }
            return ListData.Where(x => x.name.Contains(s)).ToList();
        }
 
        public async Task<bool> IsDictionary(int UserId)
        {
            if (UserId == 0)
                return false;
           var user=await  _unitOfWork.GetDbClient().Queryable<CoreCmsUser>().Includes(x=>x.gradeInfo).Where(x=>x.id== UserId).WithCache(10).SingleAsync();
            if (user == null)
                return false;
            if(user.gradeInfo==null)
                return false;
            var allConfigs = await _coreCmsSettingServices.GetConfigDictionaries();
            var kc = CommonHelper.GetConfigDictionary(allConfigs, SystemSettingConstVars.DictionaryUserGroupKey);
            if (user.gradeInfo.valueKey == kc)
                return true;
            return false;
 
        }
    }
}