mirror of
https://github.com/Ombi-app/Ombi.git
synced 2025-08-21 05:43:19 -07:00
This commit is contained in:
parent
1f4ece8b5b
commit
4feb3cd462
33 changed files with 526 additions and 119 deletions
|
@ -26,18 +26,16 @@
|
|||
#endregion
|
||||
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Data;
|
||||
using System.Threading.Tasks;
|
||||
using Dapper;
|
||||
using Ombi.Helpers;
|
||||
using Ombi.Store.Models;
|
||||
|
||||
namespace Ombi.Store.Repository
|
||||
{
|
||||
public class PlexUserRepository : BaseGenericRepository<PlexUsers>, IPlexUserRepository
|
||||
public class BaseExternalUserRepository<T> : BaseGenericRepository<T>, IExternalUserRepository<T> where T : class
|
||||
{
|
||||
public PlexUserRepository(ISqliteConfiguration config, ICacheProvider cache) : base(config,cache)
|
||||
public BaseExternalUserRepository(ISqliteConfiguration config, ICacheProvider cache) : base(config,cache)
|
||||
{
|
||||
DbConfig = config;
|
||||
}
|
||||
|
@ -45,53 +43,53 @@ namespace Ombi.Store.Repository
|
|||
private ISqliteConfiguration DbConfig { get; }
|
||||
private IDbConnection Db => DbConfig.DbConnection();
|
||||
|
||||
public PlexUsers GetUser(string userGuid)
|
||||
public T GetUser(string userGuid)
|
||||
{
|
||||
var sql = @"SELECT * FROM PlexUsers
|
||||
WHERE PlexUserId = @UserGuid
|
||||
COLLATE NOCASE";
|
||||
return Db.QueryFirstOrDefault<PlexUsers>(sql, new {UserGuid = userGuid});
|
||||
return Db.QueryFirstOrDefault<T>(sql, new {UserGuid = userGuid});
|
||||
}
|
||||
|
||||
public PlexUsers GetUserByUsername(string username)
|
||||
public T GetUserByUsername(string username)
|
||||
{
|
||||
var sql = @"SELECT * FROM PlexUsers
|
||||
WHERE Username = @UserName
|
||||
COLLATE NOCASE";
|
||||
return Db.QueryFirstOrDefault<PlexUsers>(sql, new {UserName = username});
|
||||
return Db.QueryFirstOrDefault<T>(sql, new {UserName = username});
|
||||
}
|
||||
|
||||
public async Task<PlexUsers> GetUserAsync(string userguid)
|
||||
public async Task<T> GetUserAsync(string userguid)
|
||||
{
|
||||
var sql = @"SELECT * FROM PlexUsers
|
||||
WHERE PlexUserId = @UserGuid
|
||||
COLLATE NOCASE";
|
||||
return await Db.QueryFirstOrDefaultAsync<PlexUsers>(sql, new {UserGuid = userguid});
|
||||
return await Db.QueryFirstOrDefaultAsync<T>(sql, new {UserGuid = userguid});
|
||||
}
|
||||
|
||||
#region abstract implementation
|
||||
|
||||
#pragma warning disable CS0809 // Obsolete member overrides non-obsolete member
|
||||
[Obsolete]
|
||||
public override PlexUsers Get(string id)
|
||||
public override T Get(string id)
|
||||
{
|
||||
throw new System.NotImplementedException();
|
||||
}
|
||||
|
||||
[Obsolete]
|
||||
public override Task<PlexUsers> GetAsync(int id)
|
||||
public override Task<T> GetAsync(int id)
|
||||
{
|
||||
throw new System.NotImplementedException();
|
||||
}
|
||||
|
||||
[Obsolete]
|
||||
public override PlexUsers Get(int id)
|
||||
public override T Get(int id)
|
||||
{
|
||||
throw new System.NotImplementedException();
|
||||
}
|
||||
|
||||
[Obsolete]
|
||||
public override Task<PlexUsers> GetAsync(string id)
|
||||
public override Task<T> GetAsync(string id)
|
||||
{
|
||||
throw new System.NotImplementedException();
|
||||
}
|
||||
|
@ -99,22 +97,5 @@ namespace Ombi.Store.Repository
|
|||
#pragma warning restore CS0809 // Obsolete member overrides non-obsolete member
|
||||
#endregion
|
||||
}
|
||||
|
||||
|
||||
public interface IPlexUserRepository
|
||||
{
|
||||
PlexUsers GetUser(string userGuid);
|
||||
PlexUsers GetUserByUsername(string username);
|
||||
Task<PlexUsers> GetUserAsync(string userguid);
|
||||
IEnumerable<PlexUsers> Custom(Func<IDbConnection, IEnumerable<PlexUsers>> func);
|
||||
long Insert(PlexUsers entity);
|
||||
void Delete(PlexUsers entity);
|
||||
IEnumerable<PlexUsers> GetAll();
|
||||
bool UpdateAll(IEnumerable<PlexUsers> entity);
|
||||
bool Update(PlexUsers entity);
|
||||
Task<IEnumerable<PlexUsers>> GetAllAsync();
|
||||
Task<bool> UpdateAsync(PlexUsers users);
|
||||
Task<int> InsertAsync(PlexUsers users);
|
||||
}
|
||||
}
|
||||
|
28
Ombi.Store/Repository/IExternalUserRepository.cs
Normal file
28
Ombi.Store/Repository/IExternalUserRepository.cs
Normal file
|
@ -0,0 +1,28 @@
|
|||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Data;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace Ombi.Store.Repository
|
||||
{
|
||||
public interface IExternalUserRepository<T> where T : class
|
||||
{
|
||||
T Get(string id);
|
||||
T Get(int id);
|
||||
Task<T> GetAsync(string id);
|
||||
Task<T> GetAsync(int id);
|
||||
T GetUser(string userGuid);
|
||||
Task<T> GetUserAsync(string userguid);
|
||||
T GetUserByUsername(string username);
|
||||
|
||||
IEnumerable<T> Custom(Func<IDbConnection, IEnumerable<T>> func);
|
||||
long Insert(T entity);
|
||||
void Delete(T entity);
|
||||
IEnumerable<T> GetAll();
|
||||
bool UpdateAll(IEnumerable<T> entity);
|
||||
bool Update(T entity);
|
||||
Task<IEnumerable<T>> GetAllAsync();
|
||||
Task<bool> UpdateAsync(T users);
|
||||
Task<int> InsertAsync(T users);
|
||||
}
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue