zhengyiming
4 天以前 844ef8147c4e61c22d5aa40deab4b026638e1781
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
using Furion.DatabaseAccessor;
using Microsoft.EntityFrameworkCore;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading;
using System.Threading.Tasks;
 
namespace FlexJobApi.Core
{
    /// <summary>
    /// 任务仓库
    /// </summary>
    public static class TaskInfoRepository
    {
        /// <summary>
        /// 获取任务查询
        /// </summary>
        /// <param name="rep"></param>
        /// <param name="tracking"></param>
        /// <param name="logier"></param>
        /// <returns></returns>
        public static IQueryable<TaskInfo> GetQueryable(this IRepository<TaskInfo> rep, bool tracking = true, CurrentLogier logier = null)
        {
            logier = logier ?? JwtUtils.GetCurrentLogier();
            var q = rep.AsQueryable();
            if (tracking)
            {
                q = q.AsNoTracking();
            }
            q = q.OrderByDescending(it => it.CreatedTime);
            if (logier != null && logier.Type == EnumUserType.Enterprise)
            {
                q = q.Where(it => it.EnterpriseId == logier.EnterpriseId);
            }
            return q;
        }
    }
}