mirror of
https://gitee.com/dotnetchina/OpenAuth.Net.git
synced 2025-04-05 17:38:01 +08:00
完成外部数据源CRUD
This commit is contained in:
parent
ee396146d3
commit
32e0ae1a6b
@ -1,4 +1,6 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Threading.Tasks;
|
||||
using Infrastructure;
|
||||
using OpenAuth.App.Interface;
|
||||
@ -38,6 +40,22 @@ namespace OpenAuth.App
|
||||
return result;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 获取数据库类型
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
public TableData GetDbTypes()
|
||||
{
|
||||
var result = new TableData();
|
||||
// 创建包含键值对的列表
|
||||
var dbTypeList = Enum.GetValues(typeof(DbType))
|
||||
.Cast<DbType>()
|
||||
.Select(item => new { label = item.ToString(), value = (int)item })
|
||||
.ToList();
|
||||
result.data = dbTypeList;
|
||||
return result;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 测试数据源连接
|
||||
/// </summary>
|
||||
@ -53,7 +71,7 @@ namespace OpenAuth.App
|
||||
var conn = new SqlSugarClient(new ConnectionConfig()
|
||||
{
|
||||
ConnectionString = obj.Connectionstring,
|
||||
DbType = (DbType)Enum.Parse(typeof(DbType), obj.Dbtype),
|
||||
DbType = (DbType)Enum.Parse(typeof(DbType), obj.Dbtype.ToString()),
|
||||
IsAutoCloseConnection = true,
|
||||
});
|
||||
conn.Open();
|
||||
@ -62,6 +80,7 @@ namespace OpenAuth.App
|
||||
public void Add(AddOrUpdateExternalDataSourceReq req)
|
||||
{
|
||||
var obj = req.MapTo<ExternalDataSource>();
|
||||
obj.Id = Guid.NewGuid().ToString();
|
||||
obj.Createtime = DateTime.Now;
|
||||
var user = _auth.GetCurrentUser().User;
|
||||
obj.Createuserid = user.Id;
|
||||
|
@ -101,7 +101,7 @@ namespace OpenAuth.App.Request
|
||||
/// <summary>
|
||||
///数据库类型
|
||||
/// </summary>
|
||||
public string Dbtype { get; set; }
|
||||
public int Dbtype { get; set; }
|
||||
|
||||
/// <summary>
|
||||
///数据源名称
|
||||
|
@ -25,10 +25,10 @@ namespace OpenAuth.Repository.Domain
|
||||
this.Description = "";
|
||||
this.Password = "";
|
||||
this.Username = "";
|
||||
this.Port = 0;
|
||||
this.Port = null;
|
||||
this.Server = "";
|
||||
this.Databasename = "";
|
||||
this.Dbtype = "";
|
||||
this.Dbtype = 0;
|
||||
this.Name = "";
|
||||
|
||||
}
|
||||
@ -126,7 +126,7 @@ namespace OpenAuth.Repository.Domain
|
||||
///数据库类型
|
||||
/// </summary>
|
||||
[Description("数据库类型")]
|
||||
public string Dbtype { get; set; }
|
||||
public int Dbtype { get; set; }
|
||||
|
||||
/// <summary>
|
||||
///数据源名称
|
||||
|
@ -84,6 +84,17 @@ namespace OpenAuth.WebApi.Controllers
|
||||
return await _app.Load(request);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 获取数据库类型
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
[HttpGet]
|
||||
public TableData GetDbTypes()
|
||||
{
|
||||
|
||||
return _app.GetDbTypes();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 批量删除
|
||||
/// </summary>
|
||||
|
Loading…
Reference in New Issue
Block a user