OpenAuth.Net/OpenAuth.App/AppManager/AppManager.cs

52 lines
1.3 KiB
C#
Raw Normal View History

2018-04-13 17:25:49 +08:00
using System;
using System.Collections.Generic;
using System.Linq;
2020-12-17 23:04:04 +08:00
using System.Threading.Tasks;
using Microsoft.EntityFrameworkCore;
using OpenAuth.App.Interface;
2018-04-13 17:25:49 +08:00
using OpenAuth.App.Request;
using OpenAuth.Repository;
2018-04-13 17:25:49 +08:00
using OpenAuth.Repository.Domain;
using OpenAuth.Repository.Interface;
2023-08-27 00:23:45 +08:00
using SqlSugar;
2018-04-13 17:25:49 +08:00
namespace OpenAuth.App
{
/// <summary>
2023-08-27 00:23:45 +08:00
/// 应用管理
2018-04-13 17:25:49 +08:00
/// </summary>
2023-08-27 00:23:45 +08:00
public class AppManager : SqlSugarBaseApp<Application>
2018-04-13 17:25:49 +08:00
{
2023-08-27 00:23:45 +08:00
public AppManager(ISqlSugarClient client) : base(client, null)
{
}
2023-08-27 00:23:45 +08:00
public void Add(Application application)
2018-04-13 17:25:49 +08:00
{
2023-08-27 00:23:45 +08:00
if (string.IsNullOrEmpty(application.Id))
2018-04-13 17:25:49 +08:00
{
2023-08-27 00:23:45 +08:00
application.Id = Guid.NewGuid().ToString();
2018-04-13 17:25:49 +08:00
}
2023-08-27 00:23:45 +08:00
Repository.Insert(application);
2018-04-13 17:25:49 +08:00
}
2023-08-27 00:23:45 +08:00
public void Update(Application application)
2018-04-13 17:25:49 +08:00
{
2023-08-27 00:23:45 +08:00
Repository.Update(application);
2018-04-13 17:25:49 +08:00
}
2023-08-27 00:23:45 +08:00
2020-12-17 23:04:04 +08:00
public async Task<List<Application>> GetList(QueryAppListReq request)
2018-04-13 17:25:49 +08:00
{
2023-08-27 00:23:45 +08:00
var applications = Repository.GetListAsync();
2023-08-27 00:23:45 +08:00
return await applications;
2018-04-13 17:25:49 +08:00
}
public Application GetByAppKey(string modelAppKey)
{
2023-08-27 00:23:45 +08:00
return Repository.GetFirst(u => u.AppSecret == modelAppKey);
}
2018-04-13 17:25:49 +08:00
}
}