Commit a8f0381f by ruyun.zhang@suvalue.com

Merge branch 'v2020morge-graphql' into develop 职称补贴系统代码合并

parents ebc7135c 7ebf9871
...@@ -28,42 +28,93 @@ public class SubsidyController : ControllerBase ...@@ -28,42 +28,93 @@ public class SubsidyController : ControllerBase
public async Task<ApiResponse> GetAllot() public async Task<ApiResponse> GetAllot()
{ {
var allots = await _service.GetAllot(); var allots = await _service.GetAllot();
return new ApiResponse(Status.Ok, allots); return new ApiResponse(Status.Ok, allots);
} }
// 职称查询 /// <summary>
[HttpGet("{allotId}/jobtitle")] /// 职称查询
public async Task<ApiResponse> GetJobTitle(int allotId) /// </summary>
/// <param name="allotId"></param>
/// <param name="hospitalId"></param>
/// <returns></returns>
[HttpGet("{allotId}/jobtitle/{hospitalId}")]
public ApiResponse GetJobTitle(int allotId, int hospitalId)
{ {
throw new NotImplementedException(); _service.GetHrpJobTitle(allotId, hospitalId, false);
var jobTitle = _service.GetJobTitle(allotId, hospitalId);
return new ApiResponse(Status.Ok, jobTitle);
} }
// 重新查询职称 /// <summary>
[HttpPost("{allotId}/reset-jobtitle")] /// 重新查询职称
public async Task ResetJobTitle(int allotId) /// </summary>
/// <param name="allotId"></param>
/// <param name="hospitalId"></param>
/// <returns></returns>
[HttpPost("{allotId}/reset-jobtitle/{hospitalId}")]
public ApiResponse ResetJobTitle(int allotId, int hospitalId)
{ {
throw new NotImplementedException(); // 调取配置的SQL语句
// 执行SQL 获取结果
// 将结果存储到sub_subsidy中
// 查询sub_subsidy表职称去重
// 将去重数据插入sub_jobtitle
_service.GetHrpJobTitle(allotId, hospitalId, true);
var jobTitle = _service.GetJobTitle(allotId, hospitalId);
return new ApiResponse(Status.Ok, jobTitle);
} }
// 职称标准保存 /// <summary>
/// 职称标准保存
/// </summary>
/// <param name="allotId"></param>
/// <param name="sub_Jobtitle"></param>
/// <returns></returns>
[HttpPost("{allotId}/jobtitle")] [HttpPost("{allotId}/jobtitle")]
public async Task SaveJobTitle(int allotId) public ApiResponse SaveJobTitle(int allotId, [FromBody] List<sub_jobtitle> sub_Jobtitle)
{ {
throw new NotImplementedException(); bool result = _service.SaveJobTitle(allotId, sub_Jobtitle);
return new ApiResponse(Status.Ok, result);
} }
// 个人职称补贴结果查询 /// <summary>
/// 个人职称补贴结果查询
/// </summary>
/// <param name="allotId"></param>
/// <returns></returns>
[HttpGet("{allotId}/jobtitle/subsidy")] [HttpGet("{allotId}/jobtitle/subsidy")]
public Task<ApiResponse> GetJobTitleSubsidy(int allotId) public ApiResponse GetJobTitleSubsidy(int allotId)
{ {
throw new NotImplementedException(); List<sub_subsidy> subsidies = _service.GetJobTitleSubsidy(allotId);
return new ApiResponse(Status.Ok, subsidies);
} }
// 个人职称补贴结果保存 /// <summary>
/// 个人职称补贴结果保存
/// </summary>
/// <param name="allotId"></param>
/// <param name="subsidys"></param>
/// <returns></returns>
[HttpPost("{allotId}/jobtitle/subsidy")] [HttpPost("{allotId}/jobtitle/subsidy")]
public async Task SaveJobTitleSubsidy(int allotId) public ApiResponse SaveJobTitleSubsidy(int allotId, [FromBody] List<sub_subsidy> subsidys)
{
bool result = _service.SaveJobTitleSubsidy(allotId, subsidys);
return new ApiResponse(Status.Ok, result);
}
/// <summary>
/// 保存个人职称补贴结果
/// </summary>
/// <param name="allotId"></param>
/// <param name="subsidies"></param>
/// <returns></returns>
[HttpPost("{allotId}/savesubsidy")]
public ApiResponse SaveSubsidy(int allotId,[FromBody] List<sub_subsidy> subsidies)
{ {
throw new NotImplementedException(); var result = _service.SaveSubsidy(allotId, subsidies);
return new ApiResponse(Status.Ok, result);
} }
} }
} }
using Microsoft.AspNetCore.Mvc;
using Microsoft.AspNetCore.Mvc.Filters;
using Microsoft.Extensions.Logging;
using Newtonsoft.Json;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;
namespace Performance.Subsidy.Api.Filters
{
public class ExceptionsFilter : IAsyncExceptionFilter
{
private readonly ILogger<ExceptionsFilter> _logger;
public ExceptionsFilter(ILogger<ExceptionsFilter> logger)
{
this._logger = logger;
}
public Task OnExceptionAsync(ExceptionContext context)
{
if(context.Exception is Exception)
{
_logger.LogError($"接口异常:{context.Exception.ToString()}");
var response = new ApiResponse(Status.Error, "接口内部异常", context.Exception.Message);
context.Result = new ObjectResult(response);
_logger.LogError("接口内部异常" + JsonConvert.SerializeObject(response, Formatting.None));
}
return Task.CompletedTask;
}
}
}
...@@ -5,6 +5,13 @@ ...@@ -5,6 +5,13 @@
</PropertyGroup> </PropertyGroup>
<ItemGroup> <ItemGroup>
<None Include="..\.editorconfig" Link=".editorconfig" />
</ItemGroup>
<ItemGroup>
<PackageReference Include="NLog" Version="4.7.9" />
<PackageReference Include="NLog.Extensions.Logging" Version="1.4.0" />
<PackageReference Include="NLog.Web.AspNetCore" Version="4.8.0" />
<PackageReference Include="Swashbuckle.AspNetCore" Version="5.6.3" /> <PackageReference Include="Swashbuckle.AspNetCore" Version="5.6.3" />
<PackageReference Include="Autofac" Version="6.2.0" /> <PackageReference Include="Autofac" Version="6.2.0" />
<PackageReference Include="Autofac.Extensions.DependencyInjection" Version="7.1.0" /> <PackageReference Include="Autofac.Extensions.DependencyInjection" Version="7.1.0" />
......
...@@ -3,6 +3,7 @@ ...@@ -3,6 +3,7 @@
using Microsoft.Extensions.Configuration; using Microsoft.Extensions.Configuration;
using Microsoft.Extensions.Hosting; using Microsoft.Extensions.Hosting;
using Microsoft.Extensions.Logging; using Microsoft.Extensions.Logging;
using NLog.Web;
using System; using System;
using System.Collections.Generic; using System.Collections.Generic;
using System.Linq; using System.Linq;
...@@ -14,8 +15,20 @@ public class Program ...@@ -14,8 +15,20 @@ public class Program
{ {
public static void Main(string[] args) public static void Main(string[] args)
{ {
var logger = NLogBuilder.ConfigureNLog("nlog.config").GetCurrentClassLogger();
try
{
CreateHostBuilder(args).Build().Run(); CreateHostBuilder(args).Build().Run();
} }
catch (Exception ex)
{
logger.Error(ex, "Stopped program because of exception");
}
finally
{
NLog.LogManager.Shutdown();
}
}
public static IHostBuilder CreateHostBuilder(string[] args) => public static IHostBuilder CreateHostBuilder(string[] args) =>
Host.CreateDefaultBuilder(args) Host.CreateDefaultBuilder(args)
...@@ -23,6 +36,12 @@ public static void Main(string[] args) ...@@ -23,6 +36,12 @@ public static void Main(string[] args)
.ConfigureWebHostDefaults(webBuilder => .ConfigureWebHostDefaults(webBuilder =>
{ {
webBuilder.UseStartup<Startup>(); webBuilder.UseStartup<Startup>();
}); })
.ConfigureLogging(logging =>
{
logging.ClearProviders();
logging.SetMinimumLevel(LogLevel.Trace);
})
.UseNLog();
} }
} }
<?xml version="1.0" encoding="utf-8"?>
<!--
https://go.microsoft.com/fwlink/?LinkID=208121.
-->
<Project ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<PropertyGroup>
<DeleteExistingFiles>False</DeleteExistingFiles>
<ExcludeApp_Data>False</ExcludeApp_Data>
<LaunchSiteAfterPublish>True</LaunchSiteAfterPublish>
<LastUsedBuildConfiguration>Release</LastUsedBuildConfiguration>
<LastUsedPlatform>Any CPU</LastUsedPlatform>
<PublishProvider>FileSystem</PublishProvider>
<PublishUrl>D:\publish\Subsidy</PublishUrl>
<WebPublishMethod>FileSystem</WebPublishMethod>
</PropertyGroup>
</Project>
\ No newline at end of file
...@@ -5,6 +5,7 @@ ...@@ -5,6 +5,7 @@
using Microsoft.Extensions.DependencyInjection; using Microsoft.Extensions.DependencyInjection;
using Microsoft.Extensions.Hosting; using Microsoft.Extensions.Hosting;
using Microsoft.OpenApi.Models; using Microsoft.OpenApi.Models;
using Performance.Subsidy.Api.Filters;
using Performance.Subsidy.Services; using Performance.Subsidy.Services;
using Performance.Subsidy.Services.Models; using Performance.Subsidy.Services.Models;
using Performance.Subsidy.Services.Repository; using Performance.Subsidy.Services.Repository;
...@@ -38,18 +39,23 @@ public void ConfigureServices(IServiceCollection services) ...@@ -38,18 +39,23 @@ public void ConfigureServices(IServiceCollection services)
c.SwaggerDoc("v1", new OpenApiInfo { Title = "Performance.Subsidy.Api", Version = "v1" }); c.SwaggerDoc("v1", new OpenApiInfo { Title = "Performance.Subsidy.Api", Version = "v1" });
}); });
services.Configure<ConnectionStringTemplates>(Configuration.GetSection("ConnectionStringTemplates")); services.Configure<ConnectionStringTemplates>(Configuration.GetSection("ConnectionStringTemplates"));
services.AddMvc(option => { option.Filters.Add<ExceptionsFilter>(); });
} }
// This method gets called by the runtime. Use this method to configure the HTTP request pipeline. // This method gets called by the runtime. Use this method to configure the HTTP request pipeline.
public void Configure(IApplicationBuilder app, IWebHostEnvironment env) public void Configure(IApplicationBuilder app, IWebHostEnvironment env)
{ {
string swaggerJson = "/api/swagger/v1/swagger.json";
if (env.IsDevelopment()) if (env.IsDevelopment())
{ {
app.UseDeveloperExceptionPage(); app.UseDeveloperExceptionPage();
app.UseSwagger(); swaggerJson = swaggerJson.Replace("/api", "");
app.UseSwaggerUI(c => c.SwaggerEndpoint("/swagger/v1/swagger.json", "Performance.Subsidy.Api v1"));
} }
app.UseSwagger();
app.UseSwaggerUI(c => c.SwaggerEndpoint(swaggerJson, "Performance.Subsidy.Api v1"));
app.UseRouting(); app.UseRouting();
app.UseAuthorization(); app.UseAuthorization();
......
<?xml version="1.0" encoding="utf-8"?>
<nlog xmlns="http://www.nlog-project.org/schemas/NLog.xsd"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
autoReload="true"
internalLogLevel="info"
internalLogFile="c:\Temp\GrapefruitVuCore\internal-nlog.txt">
<!-- enable asp.net core and mongodb layout renderers -->
<extensions>
<add assembly="NLog.Web.AspNetCore"/>
<add assembly="NLog.Mongo"/>
</extensions>
<!--internal-nlog:NLog启动及加载config信息-->
<!--nlog-all:所有日志记录信息-->
<!--nlog-own:自定义日志记录信息-->
<!-- the targets to write to -->
<targets>
<!-- write logs to file -->
<target xsi:type="File" name="allfile" fileName="${basedir}/Logs/${shortdate}/${level}.log"
layout="日志记录时间:${longdate}${newline}日志级别:${uppercase:${level}}${newline}日志来源:${logger}${newline}日志信息:${message}${newline}错误信息:${exception:format=tostring}${newline}==============================================================${newline}" />
<!-- another file log, only own logs. Uses some ASP.NET core renderers -->
<target xsi:type="File" name="ownFile-web" fileName="${basedir}/Logs/${shortdate}/${level}.log"
layout="日志记录时间:${longdate}${newline}日志级别:${uppercase:${level}}${newline}日志来源:${logger}${newline}日志信息:${message}${newline}错误信息:${exception:format=tostring}${newline}url: ${aspnet-request-url}${newline}action: ${aspnet-mvc-action}${newline}==============================================================${newline}" />
</targets>
<!-- rules to map from logger name to target -->
<rules>
<!--All logs, including from Microsoft-->
<logger name="*" minlevel="Trace" writeTo="allfile" />
<!--Skip non-critical Microsoft logs and so log only own logs-->
<logger name="Microsoft.*" maxLevel="Info" final="true" />
<!-- BlackHole without writeTo -->
<logger name="*" minlevel="Trace" writeTo="ownFile-web" />
<!--Add logs to mongodb-->
<!--<logger name="*" minlevel="Trace" writeTo="mongo"/>-->
</rules>
</nlog>
\ No newline at end of file
...@@ -13,8 +13,8 @@ public enum Status ...@@ -13,8 +13,8 @@ public enum Status
public enum DatabaseType public enum DatabaseType
{ {
MySQL, MySQL=1,
SqlServer, SqlServer=2,
Oracle, Oracle=3,
} }
} }
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace Performance.Subsidy.Services
{
public class ex_config
{
public int Id { get; set; }
public int HospitalId { get; set; }
public string DbSource { get; set; }
public string DbName { get; set; }
public string DbUser { get; set; }
public string DbPassword { get; set; }
public int DataBaseType { get; set; }
public string Remark { get; set; }
}
}
namespace Performance.Subsidy.Services namespace Performance.Subsidy.Services
{ {
public class ex_script { } public class ex_script
{
public int Id { get; set; }
public string ExecScript { get; set; }
public int ConfigId { get; set; }
public int IsEnable { get; set; }
public string Remark { get; set; }
}
} }
...@@ -6,8 +6,12 @@ ...@@ -6,8 +6,12 @@
<ItemGroup> <ItemGroup>
<PackageReference Include="Dapper" Version="2.0.90" /> <PackageReference Include="Dapper" Version="2.0.90" />
<PackageReference Include="Microsoft.AspNet.WebApi.Core" Version="5.2.7" />
<PackageReference Include="Microsoft.Extensions.Configuration.Abstractions" Version="5.0.0" /> <PackageReference Include="Microsoft.Extensions.Configuration.Abstractions" Version="5.0.0" />
<PackageReference Include="Microsoft.Extensions.Logging.Abstractions" Version="5.0.0" />
<PackageReference Include="Microsoft.Extensions.Options" Version="5.0.0" />
<PackageReference Include="MySql.Data" Version="8.0.24" /> <PackageReference Include="MySql.Data" Version="8.0.24" />
<PackageReference Include="NLog" Version="4.7.9" />
<PackageReference Include="Oracle.ManagedDataAccess.Core" Version="3.21.1" /> <PackageReference Include="Oracle.ManagedDataAccess.Core" Version="3.21.1" />
<PackageReference Include="System.Data.SqlClient" Version="4.8.2" /> <PackageReference Include="System.Data.SqlClient" Version="4.8.2" />
</ItemGroup> </ItemGroup>
......
using Dapper; using Dapper;
using Microsoft.Extensions.Configuration; using Microsoft.Extensions.Logging;
using Performance.Subsidy.Services.Repository; using Performance.Subsidy.Services.Repository;
using System; using System;
using System.Collections.Generic; using System.Collections.Generic;
using System.Data;
using System.Linq;
using System.Threading.Tasks; using System.Threading.Tasks;
namespace Performance.Subsidy.Services namespace Performance.Subsidy.Services
...@@ -10,23 +12,194 @@ namespace Performance.Subsidy.Services ...@@ -10,23 +12,194 @@ namespace Performance.Subsidy.Services
public class SubsidyService public class SubsidyService
{ {
private readonly ConnectionFactory _factory; private readonly ConnectionFactory _factory;
private readonly ConnectionStringBuilder builder;
private readonly int _commandTimeout; private readonly int _commandTimeout;
private readonly IDbConnection _dbConnection;
private readonly ILogger<SubsidyService> logger;
public SubsidyService( public SubsidyService(
ConnectionFactory factory) ConnectionFactory factory,
ConnectionStringBuilder builder,
ILogger<SubsidyService> logger)
{ {
_factory = factory; _factory = factory;
this.builder = builder;
_commandTimeout = 60 * 5; _commandTimeout = 60 * 5;
_dbConnection = _factory.CreateDefault();
this.logger = logger;
} }
//绩效列表
public async Task<IEnumerable<view_allot>> GetAllot() public async Task<IEnumerable<view_allot>> GetAllot()
{ {
return await _factory.CreateDefault().QueryAsync<view_allot>("SELECT * FROM view_allot"); return await _dbConnection.QueryAsync<view_allot>("SELECT * FROM view_allot;");
} }
public async Task<IEnumerable<sub_jobtitle>> GetJobTitle(int allotId) //allot查询
public view_allot GetAllot(int allotId)
{ {
return await _factory.CreateDefault().QueryAsync<sub_jobtitle>("SELECT * FROM sub_jobtitle WHERE AllotID=@allotId", new { allotId }); return _dbConnection.QueryFirst<view_allot>($@"select * from view_allot where AllotID=@allotId;", new { allotId });
}
//职称查询
public IEnumerable<sub_jobtitle> GetJobTitle(int allotId, int hospitalId)
{
try
{
var jobTitleSql = $@"select * from sub_jobtitle where AllotID=@allotId ";
var jobTitles = _dbConnection.Query<sub_jobtitle>(jobTitleSql, new { allotId });
if (jobTitles?.Count() > 0) return jobTitles;
jobTitles = _dbConnection.Query<sub_jobtitle>($@"SELECT DISTINCT JobTitle FROM db_performance_subsidy.sub_subsidy where AllotID=@allotId ", new { allotId }).Select(t => new sub_jobtitle { JobTitle = t.JobTitle, BasicPerforFee = t.BasicPerforFee ?? 0 });
var allotOder = _dbConnection.Query<view_allot>($@"SELECT * from view_allot a WHERE a.HospitalId=@HospitalId ORDER BY a.`Year`,a.`Month`;", new { hospitalId }).ToList();
if (!allotOder.Any()) return jobTitles;
var allot = allotOder.FirstOrDefault(t => t.AllotId == allotId);
if (allot == null) throw new Exception("有问题");
var index = allotOder.IndexOf(allot);
if (index == 0) return jobTitles;
var prevAllot = allotOder[index - 1];
var jobTitle = _dbConnection.Query<sub_jobtitle>(jobTitleSql, new { prevAllot.AllotId });
return jobTitle.Select(t => new sub_jobtitle { JobTitle = t.JobTitle, BasicPerforFee = t.BasicPerforFee ?? 0 }) ?? jobTitles;
}
catch (Exception e)
{
logger.LogError(e.Message);
throw e;
}
}
//重新查询职称
public void GetHrpJobTitle(int allotId, int hospitalId, bool isRefresh)
{
try
{
var allot = GetAllot(allotId);
if (allot == null) throw new Exception("AllotId无效");
var subsidies = _dbConnection.Query<sub_subsidy>("select * from sub_subsidy where AllotID=@allotId ", new { allotId });
if (subsidies.Any() && isRefresh == false) return;
var config = _dbConnection.QueryFirst<ex_config>("select * from ex_config where hospitalId=@hospitalId", new { hospitalId });
var connectionString = builder.GetConnectionString(config.DataBaseType, config.DbSource, config.DbName, config.DbUser, config.DbPassword);
var connection = _factory.Create(config.DataBaseType, connectionString);
var hrp = _dbConnection.QueryFirst<ex_script>("select * from ex_script;");
var res = connection.Query<sub_subsidy>(hrp?.ExecScript, new { allotId }, commandTimeout: _commandTimeout);
var subsidy = _dbConnection.Query<sub_jobtitle>("select * from sub_jobtitle where AllotID=@allotId ;", new { allotId }).Select(t => new { t.JobTitle, t.BasicPerforFee }).Distinct();
//删除:在点击重新加载时删除记录重新插入
_dbConnection.Execute("delete from sub_subsidy where AllotID=@allotId;delete from sub_jobtitle where AllotID=@allotId;", new { allotId });
var jobtitle = res.Where(w=>!string.IsNullOrWhiteSpace(w.JobTitle)).Select(t => new
{
allotId,
t.JobTitle,
BasicPerforFee = subsidy.Where(w => w.JobTitle == t.JobTitle)?.Select(t => t.BasicPerforFee).FirstOrDefault()
}).Distinct();
var sql = $@"insert into sub_jobtitle(AllotID,JobTitle,BasicPerforFee) values (@allotId,@JobTitle,@BasicPerforFee);";
_dbConnection.Execute(sql, jobtitle);
sql = $@"insert into sub_subsidy (AllotID,Department,PersonnelNumber,PersonnelName,JobTitle,Attendance) values (@allotId,@Department,@PersonnelNumber,@PersonnelName,@JobTitle,@Attendance);";
var exmper = res.ToList().Select(t => new
{
AllotID = allotId,
t.Department,
t.PersonnelNumber,
t.PersonnelName,
t.JobTitle,
t.Attendance
});
var i = _dbConnection.Execute(sql, exmper);
}
catch (Exception e)
{
logger.LogError(e.Message);
throw e;
}
}
//职称标准保存
public bool SaveJobTitle(int allotId, List<sub_jobtitle> jobtitle)
{
try
{
var allot = GetAllot(allotId);
if (allot == null) throw new Exception("AllotId无效");
var result = jobtitle.Select(t => new { AllotID = allotId, t.BasicPerforFee, t.JobTitle });
var modify = _dbConnection.Execute($" update `sub_jobtitle` set BasicPerforFee =@BasicPerforFee WHERE AllotID=@allotId and JobTitle=@JobTitle; ", result);
_dbConnection.Execute("call proc_performance_subsidy(@allotId) ;", new { allotId });
return modify > 0;
}
catch (Exception e)
{
logger.LogError(e.Message);
throw e;
}
}
//个人职称补贴结果查询
public List<sub_subsidy> GetJobTitleSubsidy(int allotId)
{
try
{
var allot = GetAllot(allotId);
if (allot == null) throw new Exception("AllotId无效");
IEnumerable<sub_subsidy> _Subsidies = _dbConnection.Query<sub_subsidy>(@"select * from sub_subsidy where AllotID=@allotId ;", new { allotId });
return _Subsidies?.ToList();
}
catch (Exception e)
{
logger.LogError(e.Message);
throw e;
}
}
//个人职称补贴结果保存
public bool SaveJobTitleSubsidy(int allotId, List<sub_subsidy> subsidys)
{
try
{
var allot = GetAllot(allotId);
if (allot == null) throw new Exception("AllotId无效");
var result = subsidys.Select(t => new { t.RealAmount, AllotID = allotId, t.PersonnelNumber });
_dbConnection.Execute(@$"update sub_subsidy set GiveAmount = Attendance * BasicPerforFee, RealAmount = @RealAmount where AllotID=@allotId and PersonnelNumber=@PersonnelNumber;", result);
_dbConnection.Execute($@"call proc_performance_sync(@allotId);", new { allotId });
return true;
}
catch (Exception e)
{
logger.LogError(e.Message);
throw e;
}
}
public bool SaveSubsidy(int allotId, List<sub_subsidy> subsidys)
{
try
{
var allot = GetAllot(allotId);
if (allot == null) throw new Exception("AllotId无效");
var result = subsidys.Select(t => new { t.RealAmount, AllotID = allotId, t.PersonnelNumber });
_dbConnection.Execute(@$"update sub_subsidy set GiveAmount = Attendance * BasicPerforFee, RealAmount = @RealAmount where AllotID=@allotId and PersonnelNumber=@PersonnelNumber;", result);
return true;
}
catch (Exception e)
{
logger.LogError(e.Message);
throw e;
}
} }
} }
} }
...@@ -23,17 +23,17 @@ public IDbConnection CreateDefault() ...@@ -23,17 +23,17 @@ public IDbConnection CreateDefault()
return new MySqlConnection(_connectionString); return new MySqlConnection(_connectionString);
} }
public IDbConnection Create(DatabaseType type, string connectionString) public IDbConnection Create(int type, string connectionString)
{ {
try try
{ {
switch (type) switch (type)
{ {
case DatabaseType.MySQL: case (int)DatabaseType.MySQL:
return new MySqlConnection(connectionString); return new MySqlConnection(connectionString);
case DatabaseType.SqlServer: case (int)DatabaseType.SqlServer:
return new SqlConnection(connectionString); return new SqlConnection(connectionString);
case DatabaseType.Oracle: case (int)DatabaseType.Oracle:
return new OracleConnection(connectionString); return new OracleConnection(connectionString);
default: default:
throw new ArgumentException("DatabaseType类型不支持"); throw new ArgumentException("DatabaseType类型不支持");
......
...@@ -17,18 +17,18 @@ public ConnectionStringBuilder(IOptions<ConnectionStringTemplates> options) ...@@ -17,18 +17,18 @@ public ConnectionStringBuilder(IOptions<ConnectionStringTemplates> options)
_options = options; _options = options;
} }
public string GetConnectionString(DatabaseType type, string ip, string database, string uid, string pwd) public string GetConnectionString(int type, string ip, string database, string uid, string pwd)
{ {
switch (type) switch (type)
{ {
case DatabaseType.MySQL: case (int)DatabaseType.MySQL:
return string.Format(_options.Value.MySQLTemplates, ip, database, uid, pwd); return string.Format(_options.Value.MySQLTemplates, ip, database, uid, pwd);
case DatabaseType.SqlServer: case (int)DatabaseType.SqlServer:
return string.Format(_options.Value.MySQLTemplates, ip, database, uid, pwd); return string.Format(_options.Value.SqlServerTemplates, ip, database, uid, pwd);
case DatabaseType.Oracle: case (int)DatabaseType.Oracle:
return string.Format(_options.Value.MySQLTemplates, ip, database, uid, pwd); return string.Format(_options.Value.OracleTemplates, ip, database, uid, pwd);
default: default:
throw new ArgumentException("DatabaseType类型不支持"); throw new ArgumentException("DatabaseType类型不支持");
......
...@@ -3,9 +3,9 @@ Microsoft Visual Studio Solution File, Format Version 12.00 ...@@ -3,9 +3,9 @@ Microsoft Visual Studio Solution File, Format Version 12.00
# Visual Studio Version 16 # Visual Studio Version 16
VisualStudioVersion = 16.0.31112.23 VisualStudioVersion = 16.0.31112.23
MinimumVisualStudioVersion = 10.0.40219.1 MinimumVisualStudioVersion = 10.0.40219.1
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Performance.Subsidy.Api", "Performance.Subsidy.Api\Performance.Subsidy.Api.csproj", "{B1560D0E-69D5-44DA-9C7E-AB548C709EE7}" Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Performance.Subsidy.Api", "Performance.Subsidy.Api\Performance.Subsidy.Api.csproj", "{B1560D0E-69D5-44DA-9C7E-AB548C709EE7}"
EndProject EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Performance.Subsidy.Services", "Performance.Subsidy.Services\Performance.Subsidy.Services.csproj", "{75937D89-4F57-4D95-A03E-DD64D782C700}" Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Performance.Subsidy.Services", "Performance.Subsidy.Services\Performance.Subsidy.Services.csproj", "{75937D89-4F57-4D95-A03E-DD64D782C700}"
EndProject EndProject
Global Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution GlobalSection(SolutionConfigurationPlatforms) = preSolution
......
...@@ -369,5 +369,18 @@ public ApiResponse DeleteUser([CustomizeValidator(RuleSet = "Delete"), FromBody] ...@@ -369,5 +369,18 @@ public ApiResponse DeleteUser([CustomizeValidator(RuleSet = "Delete"), FromBody]
} }
#endregion #endregion
/// <summary>
/// 批量新增用户
/// </summary>
/// <param name="request"></param>
/// <returns></returns>
[Route("BatchSaveUser")]
[HttpPost]
public ApiResponse BatchSaveUser()
{
return new ApiResponse(ResponseType.OK);
}
} }
} }
\ No newline at end of file
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment