新建职称补贴系统

parent 4c8ac279
using Microsoft.AspNetCore.Mvc;
using Performance.Subsidy.Services;
using System;
using System.Threading.Tasks;
namespace Performance.Subsidy.Api.Controllers
{
[ApiController]
[Route("[controller]")]
public class SubsidyController : ControllerBase
{
private readonly SubsidyService _service;
public SubsidyController(
SubsidyService service)
{
_service = service;
}
// 绩效列表
[HttpGet]
public async Task<ApiResponse> GetAllot()
{
var allots = await _service.GetAllot();
return new ApiResponse(ResponseType.OK, allots);
}
// 职称查询
[HttpGet("{allotId}/jobtitle")]
public async Task<ApiResponse> GetJobTitle(int allotId)
{
throw new NotImplementedException();
}
// 重新查询职称
[HttpPost("{allotId}/reset-jobtitle")]
public async Task ResetJobTitle(int allotId)
{
throw new NotImplementedException();
}
// 职称标准保存
[HttpPost("{allotId}/jobtitle")]
public async Task SaveJobTitle(int allotId)
{
throw new NotImplementedException();
}
// 个人职称补贴结果查询
[HttpGet("{allotId}/jobtitle/subsidy")]
public Task<ApiResponse> GetJobTitleSubsidy(int allotId)
{
throw new NotImplementedException();
}
// 个人职称补贴结果保存
[HttpPost("{allotId}/jobtitle/subsidy")]
public async Task SaveJobTitleSubsidy(int allotId)
{
throw new NotImplementedException();
}
}
}
<Project Sdk="Microsoft.NET.Sdk.Web">
<PropertyGroup>
<TargetFramework>net5.0</TargetFramework>
</PropertyGroup>
<ItemGroup>
<PackageReference Include="Swashbuckle.AspNetCore" Version="5.6.3" />
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\Performance.Subsidy.Services\Performance.Subsidy.Services.csproj" />
</ItemGroup>
</Project>
using Microsoft.AspNetCore.Hosting;
using Microsoft.Extensions.Configuration;
using Microsoft.Extensions.Hosting;
using Microsoft.Extensions.Logging;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;
namespace Performance.Subsidy.Api
{
public class Program
{
public static void Main(string[] args)
{
CreateHostBuilder(args).Build().Run();
}
public static IHostBuilder CreateHostBuilder(string[] args) =>
Host.CreateDefaultBuilder(args)
.ConfigureWebHostDefaults(webBuilder =>
{
webBuilder.UseStartup<Startup>();
});
}
}
{
"$schema": "http://json.schemastore.org/launchsettings.json",
"iisSettings": {
"windowsAuthentication": false,
"anonymousAuthentication": true,
"iisExpress": {
"applicationUrl": "http://localhost:29135",
"sslPort": 0
}
},
"profiles": {
"IIS Express": {
"commandName": "IISExpress",
"launchBrowser": true,
"launchUrl": "swagger",
"environmentVariables": {
"ASPNETCORE_ENVIRONMENT": "Development"
}
},
"Performance.Subsidy.Api": {
"commandName": "Project",
"dotnetRunMessages": "true",
"launchBrowser": true,
"launchUrl": "swagger",
"applicationUrl": "http://localhost:5000",
"environmentVariables": {
"ASPNETCORE_ENVIRONMENT": "Development"
}
}
}
}
using Microsoft.AspNetCore.Builder;
using Microsoft.AspNetCore.Hosting;
using Microsoft.Extensions.Configuration;
using Microsoft.Extensions.DependencyInjection;
using Microsoft.Extensions.Hosting;
using Microsoft.OpenApi.Models;
using Performance.Subsidy.Services;
using Performance.Subsidy.Services.Repository;
namespace Performance.Subsidy.Api
{
public class Startup
{
public Startup(IConfiguration configuration)
{
Configuration = configuration;
}
public IConfiguration Configuration { get; }
// This method gets called by the runtime. Use this method to add services to the container.
public void ConfigureServices(IServiceCollection services)
{
services.AddControllers();
services.AddSwaggerGen(c =>
{
c.SwaggerDoc("v1", new OpenApiInfo { Title = "Performance.Subsidy.Api", Version = "v1" });
});
services.AddScoped<SubsidyService>();
services.AddSingleton<ConnectionFactory>();
}
// This method gets called by the runtime. Use this method to configure the HTTP request pipeline.
public void Configure(IApplicationBuilder app, IWebHostEnvironment env)
{
if (env.IsDevelopment())
{
app.UseDeveloperExceptionPage();
app.UseSwagger();
app.UseSwaggerUI(c => c.SwaggerEndpoint("/swagger/v1/swagger.json", "Performance.Subsidy.Api v1"));
}
app.UseRouting();
app.UseAuthorization();
app.UseEndpoints(endpoints =>
{
endpoints.MapControllers();
});
}
}
}
{
"Logging": {
"LogLevel": {
"Default": "Information",
"Microsoft": "Warning",
"Microsoft.Hosting.Lifetime": "Information"
}
}
}
{
"Logging": {
"LogLevel": {
"Default": "Information",
"Microsoft": "Warning",
"Microsoft.Hosting.Lifetime": "Information"
}
},
"DefaultConnectionString": "server=192.168.18.166;database=db_test_liutie;uid=root;pwd=1234qwer;pooling=true;charset=utf8;convert zero datetime=true;port=3306;connection timeout=120;max pool size=512;allow user variables=true;"
}
using System;
using System.Collections.Generic;
using System.Text;
namespace Performance.Subsidy
{
public class ApiResponse<TEntity>
where TEntity : class, new()
{
public ResponseType State { get; set; }
/// <summary>
/// 消息内容。
/// </summary>
public string Message { get; set; }
/// <summary>
/// 返回数据。
/// </summary>
public TEntity Data { get; set; }
public ApiResponse()
: this(ResponseType.Fail, "", null)
{
}
public ApiResponse(ResponseType type)
: this(type, type.ToString(), null)
{
}
public ApiResponse(ResponseType type, string message)
: this(type, message, null)
{
}
public ApiResponse(ResponseType type, TEntity entity)
: this(type, type.ToString(), entity)
{
}
public ApiResponse(ResponseType type, string message, TEntity entity)
{
State = type;
Message = message;
Data = entity;
}
}
public sealed class ApiResponse : ApiResponse<Object>
{
public ApiResponse()
{
}
public ApiResponse(ResponseType type) : base(type)
{
}
public ApiResponse(ResponseType type, string message) : base(type, message)
{
}
public ApiResponse(ResponseType type, object entity) : base(type, entity)
{
}
public ApiResponse(ResponseType type, string message, object entity) : base(type, message, entity)
{
}
}
}
namespace Performance.Subsidy
{
public enum DbType
{
MySQL,
MSSQL,
Oracle,
}
}
using System;
using System.Collections.Generic;
using System.Text;
namespace Performance.Subsidy
{
public enum ResponseType
{
OK = 1,
Fail = 2,
Error = 3,
TokenError = 4,
NotFound = 5,
ParameterError = 6,
Disable = 7,
}
}
namespace Performance.Subsidy.Services
{
public class sub_jobtitle { }
}
namespace Performance.Subsidy.Services
{
public class sub_subsidy { }
}
namespace Performance.Subsidy.Services
{
public class view_allot { }
}
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<TargetFramework>net5.0</TargetFramework>
</PropertyGroup>
<ItemGroup>
<PackageReference Include="Dapper" Version="2.0.90" />
<PackageReference Include="Microsoft.Extensions.Configuration.Abstractions" Version="5.0.0" />
<PackageReference Include="MySql.Data" Version="8.0.24" />
<PackageReference Include="Oracle.ManagedDataAccess" Version="19.11.0" />
<PackageReference Include="System.Data.SqlClient" Version="4.8.2" />
</ItemGroup>
</Project>
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace Performance.Subsidy.Services.Repository
{
public class BasicRepository
{
}
}
using MySql.Data.MySqlClient;
using Oracle.ManagedDataAccess.Client;
using System;
using System.Collections.Generic;
using System.Data;
using System.Data.SqlClient;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace Performance.Subsidy.Services.Repository
{
public class ConnectionFactory
{
public IDbConnection Create(DbType type, string connectionString)
{
switch (type)
{
case DbType.MySQL:
return new MySqlConnection(connectionString);
case DbType.MSSQL:
return new SqlConnection(connectionString);
case DbType.Oracle:
return new OracleConnection(connectionString);
default:
throw new ArgumentException("DbType类型不支持");
}
}
}
}
using Dapper;
using Microsoft.Extensions.Configuration;
using Performance.Subsidy.Services.Repository;
using System;
using System.Collections.Generic;
using System.Threading.Tasks;
namespace Performance.Subsidy.Services
{
public class SubsidyService
{
private readonly ConnectionFactory _factory;
private readonly IConfiguration _configuration;
private readonly int _commandTimeout;
public SubsidyService(
ConnectionFactory factory,
IConfiguration configuration)
{
_factory = factory;
_configuration = configuration;
_commandTimeout = 60 * 5;
}
public async Task<IEnumerable<view_allot>> GetAllot()
{
var connectionString = _configuration.GetConnectionString("DefaultConnectionString");
return await _factory.Create(DbType.MySQL, connectionString).QueryAsync<view_allot>("SELECT * FROM view_allot");
}
public async Task<IEnumerable<sub_jobtitle>> GetJobTitle(int allotId)
{
var connectionString = _configuration.GetConnectionString("DefaultConnectionString");
return await _factory.Create(DbType.MySQL, connectionString).QueryAsync<sub_jobtitle>
("SELECT * FROM sub_jobtitle WHERE AllotID=@allotId",
new { allotId },
commandTimeout: _commandTimeout);
}
}
}

Microsoft Visual Studio Solution File, Format Version 12.00
# Visual Studio Version 16
VisualStudioVersion = 16.0.31112.23
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}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Performance.Subsidy.Services", "Performance.Subsidy.Services\Performance.Subsidy.Services.csproj", "{75937D89-4F57-4D95-A03E-DD64D782C700}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
Release|Any CPU = Release|Any CPU
EndGlobalSection
GlobalSection(ProjectConfigurationPlatforms) = postSolution
{B1560D0E-69D5-44DA-9C7E-AB548C709EE7}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{B1560D0E-69D5-44DA-9C7E-AB548C709EE7}.Debug|Any CPU.Build.0 = Debug|Any CPU
{B1560D0E-69D5-44DA-9C7E-AB548C709EE7}.Release|Any CPU.ActiveCfg = Release|Any CPU
{B1560D0E-69D5-44DA-9C7E-AB548C709EE7}.Release|Any CPU.Build.0 = Release|Any CPU
{75937D89-4F57-4D95-A03E-DD64D782C700}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{75937D89-4F57-4D95-A03E-DD64D782C700}.Debug|Any CPU.Build.0 = Debug|Any CPU
{75937D89-4F57-4D95-A03E-DD64D782C700}.Release|Any CPU.ActiveCfg = Release|Any CPU
{75937D89-4F57-4D95-A03E-DD64D782C700}.Release|Any CPU.Build.0 = Release|Any CPU
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
EndGlobalSection
GlobalSection(ExtensibilityGlobals) = postSolution
SolutionGuid = {DF4E84C3-E4BA-40EF-8B82-41EEDA53BE8B}
EndGlobalSection
EndGlobal
...@@ -8,7 +8,7 @@ ...@@ -8,7 +8,7 @@
}, },
"AppConnection": { "AppConnection": {
//"PerformanceConnectionString": "server=112.124.13.17;database=db_performance;uid=suvalue;pwd=suvalue2016;pooling=true;charset=utf8;convert zero datetime=true;port=3306;connection timeout=120;max pool size=512;allow user variables=true;", //"PerformanceConnectionString": "server=112.124.13.17;database=db_performance;uid=suvalue;pwd=suvalue2016;pooling=true;charset=utf8;convert zero datetime=true;port=3306;connection timeout=120;max pool size=512;allow user variables=true;",
"PerformanceConnectionString": "server=192.168.18.166;database=db_performance_screen;uid=root;pwd=1234qwer;pooling=true;charset=utf8;convert zero datetime=true;port=3306;connection timeout=120;max pool size=512;allow user variables=true;", "PerformanceConnectionString": "server=192.168.18.166;database=db_test_liutie;uid=root;pwd=1234qwer;pooling=true;charset=utf8;convert zero datetime=true;port=3306;connection timeout=120;max pool size=512;allow user variables=true;",
"HangfireConnectionString": "server=192.168.18.166;database=db_hangfire;uid=root;pwd=1234qwer;port=3306;allow user variables=true;", "HangfireConnectionString": "server=192.168.18.166;database=db_hangfire;uid=root;pwd=1234qwer;port=3306;allow user variables=true;",
"RedisConnectionString": "116.62.245.55:6379,defaultDatabase=2" "RedisConnectionString": "116.62.245.55:6379,defaultDatabase=2"
}, },
......
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