mirror of
https://github.com/Ombi-app/Ombi.git
synced 2025-08-14 18:47:15 -07:00
This commit is contained in:
parent
1f4ece8b5b
commit
4feb3cd462
33 changed files with 526 additions and 119 deletions
43
Ombi.Store/Models/Emby/EmbyUsers.cs
Normal file
43
Ombi.Store/Models/Emby/EmbyUsers.cs
Normal file
|
@ -0,0 +1,43 @@
|
|||
#region Copyright
|
||||
// /************************************************************************
|
||||
// Copyright (c) 2016 Jamie Rees
|
||||
// File: PlexUsers.cs
|
||||
// Created By: Jamie Rees
|
||||
//
|
||||
// Permission is hereby granted, free of charge, to any person obtaining
|
||||
// a copy of this software and associated documentation files (the
|
||||
// "Software"), to deal in the Software without restriction, including
|
||||
// without limitation the rights to use, copy, modify, merge, publish,
|
||||
// distribute, sublicense, and/or sell copies of the Software, and to
|
||||
// permit persons to whom the Software is furnished to do so, subject to
|
||||
// the following conditions:
|
||||
//
|
||||
// The above copyright notice and this permission notice shall be
|
||||
// included in all copies or substantial portions of the Software.
|
||||
//
|
||||
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
||||
// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
||||
// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
||||
// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
||||
// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
||||
// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
||||
// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
// ************************************************************************/
|
||||
#endregion
|
||||
|
||||
using Dapper.Contrib.Extensions;
|
||||
|
||||
namespace Ombi.Store.Models.Emby
|
||||
{
|
||||
[Table(nameof(EmbyUsers))]
|
||||
public class EmbyUsers : Entity
|
||||
{
|
||||
public string PlexUserId { get; set; }
|
||||
public string UserAlias { get; set; }
|
||||
public int Permissions { get; set; }
|
||||
public int Features { get; set; }
|
||||
public string Username { get; set; }
|
||||
public string EmailAddress { get; set; }
|
||||
public string LoginId { get; set; }
|
||||
}
|
||||
}
|
|
@ -27,7 +27,7 @@
|
|||
|
||||
using Dapper.Contrib.Extensions;
|
||||
|
||||
namespace Ombi.Store.Models
|
||||
namespace Ombi.Store.Models.Plex
|
||||
{
|
||||
[Table("PlexEpisodes")]
|
||||
public class PlexEpisodes : Entity
|
|
@ -26,9 +26,8 @@
|
|||
#endregion
|
||||
|
||||
using Dapper.Contrib.Extensions;
|
||||
using Newtonsoft.Json;
|
||||
|
||||
namespace Ombi.Store.Models
|
||||
namespace Ombi.Store.Models.Plex
|
||||
{
|
||||
[Table(nameof(PlexUsers))]
|
||||
public class PlexUsers : Entity
|
|
@ -68,8 +68,9 @@
|
|||
<Compile Include="Models\Emby\EmbyContent.cs" />
|
||||
<Compile Include="Models\Emby\EmbyEpisodes.cs" />
|
||||
<Compile Include="Models\IssueBlobs.cs" />
|
||||
<Compile Include="Models\PlexEpisodes.cs" />
|
||||
<Compile Include="Models\PlexUsers.cs" />
|
||||
<Compile Include="Models\Plex\PlexEpisodes.cs" />
|
||||
<Compile Include="Models\Emby\EmbyUsers.cs" />
|
||||
<Compile Include="Models\Plex\PlexUsers.cs" />
|
||||
<Compile Include="Models\Plex\MetadataItems.cs" />
|
||||
<Compile Include="Models\Plex\PlexContent.cs" />
|
||||
<Compile Include="Models\Emby\EmbyMediaType.cs" />
|
||||
|
@ -80,6 +81,8 @@
|
|||
<Compile Include="Models\UsersToNotify.cs" />
|
||||
<Compile Include="PlexDatabase.cs" />
|
||||
<Compile Include="Repository\BaseGenericRepository.cs" />
|
||||
<Compile Include="Repository\BaseExternalUserRepository.cs" />
|
||||
<Compile Include="Repository\IExternalUserRepository.cs" />
|
||||
<Compile Include="Repository\IRequestRepository.cs" />
|
||||
<Compile Include="Repository\ISettingsRepository.cs" />
|
||||
<Compile Include="ISqliteConfiguration.cs" />
|
||||
|
@ -91,7 +94,6 @@
|
|||
<Compile Include="Repository\SettingsJsonRepository.cs" />
|
||||
<Compile Include="Repository\RequestJsonRepository.cs" />
|
||||
<Compile Include="Repository\GenericRepository.cs" />
|
||||
<Compile Include="Repository\PlexUserRepository.cs" />
|
||||
<Compile Include="Repository\UserRepository.cs" />
|
||||
<Compile Include="RequestedModel.cs" />
|
||||
<Compile Include="UserEntity.cs" />
|
||||
|
|
|
@ -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);
|
||||
}
|
||||
}
|
|
@ -124,6 +124,20 @@ CREATE TABLE IF NOT EXISTS PlexUsers
|
|||
);
|
||||
CREATE UNIQUE INDEX IF NOT EXISTS PlexUsers_Id ON PlexUsers (Id);
|
||||
|
||||
|
||||
CREATE TABLE IF NOT EXISTS EmbyUsers
|
||||
(
|
||||
Id INTEGER PRIMARY KEY AUTOINCREMENT,
|
||||
PlexUserId varchar(100) NOT NULL,
|
||||
UserAlias varchar(100) NOT NULL,
|
||||
Permissions INTEGER,
|
||||
Features INTEGER,
|
||||
Username VARCHAR(100),
|
||||
EmailAddress VARCHAR(100),
|
||||
LoginId VARCHAR(100)
|
||||
);
|
||||
CREATE UNIQUE INDEX IF NOT EXISTS EmbyUsers_Id ON EmbyUsers (Id);
|
||||
|
||||
BEGIN;
|
||||
CREATE TABLE IF NOT EXISTS PlexEpisodes
|
||||
(
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue