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 UserRepository
|
{
|
/// <summary>
|
/// 获取个人用户查询
|
/// </summary>
|
/// <param name="rep"></param>
|
/// <param name="tracking"></param>
|
/// <param name="logier"></param>
|
/// <returns></returns>
|
public static IQueryable<User> GetPersonalQueryable(this IRepository<User> rep, bool tracking = true, CurrentLogier logier = null)
|
{
|
logier = logier ?? JwtUtils.GetCurrentLogier();
|
var q = rep.AsQueryable();
|
if (tracking)
|
{
|
q = q.AsNoTracking();
|
}
|
q = q.OrderBy(it => it.CreatedTime);
|
if (logier != null)
|
{
|
if (logier.Type == EnumUserType.Personal)
|
{
|
q = q.Where(it => it.Id == logier.Id);
|
}
|
}
|
return q;
|
}
|
}
|
}
|