Browse Source

根据姓名+身份证号或者姓名+证书编码进行查询

wangyuhan 1 year ago
commit
0e7d993049

+ 365 - 0
.gitignore

@@ -0,0 +1,365 @@
+## Ignore Visual Studio temporary files, build results, and
+## files generated by popular Visual Studio add-ons.
+##
+## Get latest from https://github.com/github/gitignore/blob/master/VisualStudio.gitignore
+
+# User-specific files
+*.rsuser
+*.suo
+*.user
+*.userosscache
+*.sln.docstates
+
+# User-specific files (MonoDevelop/Xamarin Studio)
+*.userprefs
+
+# Mono auto generated files
+mono_crash.*
+
+# Build results
+[Dd]ebug/
+[Dd]ebugPublic/
+[Rr]elease/
+[Rr]eleases/
+x64/
+x86/
+[Ww][Ii][Nn]32/
+[Aa][Rr][Mm]/
+[Aa][Rr][Mm]64/
+bld/
+[Bb]in/
+[Oo]bj/
+[Ll]og/
+[Ll]ogs/
+
+# Visual Studio 2015/2017 cache/options directory
+.vs/
+# Uncomment if you have tasks that create the project's static files in wwwroot
+#wwwroot/
+
+# Visual Studio 2017 auto generated files
+Generated\ Files/
+
+# MSTest test Results
+[Tt]est[Rr]esult*/
+[Bb]uild[Ll]og.*
+
+# NUnit
+*.VisualState.xml
+TestResult.xml
+nunit-*.xml
+
+# Build Results of an ATL Project
+[Dd]ebugPS/
+[Rr]eleasePS/
+dlldata.c
+
+# Benchmark Results
+BenchmarkDotNet.Artifacts/
+
+# .NET Core
+project.lock.json
+project.fragment.lock.json
+artifacts/
+
+# ASP.NET Scaffolding
+ScaffoldingReadMe.txt
+
+# StyleCop
+StyleCopReport.xml
+
+# Files built by Visual Studio
+*_i.c
+*_p.c
+*_h.h
+*.ilk
+*.meta
+*.obj
+*.iobj
+*.pch
+*.pdb
+*.ipdb
+*.pgc
+*.pgd
+*.rsp
+*.sbr
+*.tlb
+*.tli
+*.tlh
+*.tmp
+*.tmp_proj
+*_wpftmp.csproj
+*.log
+*.vspscc
+*.vssscc
+.builds
+*.pidb
+*.svclog
+*.scc
+
+# Chutzpah Test files
+_Chutzpah*
+
+# Visual C++ cache files
+ipch/
+*.aps
+*.ncb
+*.opendb
+*.opensdf
+*.sdf
+*.cachefile
+*.VC.db
+*.VC.VC.opendb
+
+# Visual Studio profiler
+*.psess
+*.vsp
+*.vspx
+*.sap
+
+# Visual Studio Trace Files
+*.e2e
+
+# TFS 2012 Local Workspace
+$tf/
+
+# Guidance Automation Toolkit
+*.gpState
+
+# ReSharper is a .NET coding add-in
+_ReSharper*/
+*.[Rr]e[Ss]harper
+*.DotSettings.user
+
+# TeamCity is a build add-in
+_TeamCity*
+
+# DotCover is a Code Coverage Tool
+*.dotCover
+
+# AxoCover is a Code Coverage Tool
+.axoCover/*
+!.axoCover/settings.json
+
+# Coverlet is a free, cross platform Code Coverage Tool
+coverage*[.json, .xml, .info]
+
+# Visual Studio code coverage results
+*.coverage
+*.coveragexml
+
+# NCrunch
+_NCrunch_*
+.*crunch*.local.xml
+nCrunchTemp_*
+
+# MightyMoose
+*.mm.*
+AutoTest.Net/
+
+# Web workbench (sass)
+.sass-cache/
+
+# Installshield output folder
+[Ee]xpress/
+
+# DocProject is a documentation generator add-in
+DocProject/buildhelp/
+DocProject/Help/*.HxT
+DocProject/Help/*.HxC
+DocProject/Help/*.hhc
+DocProject/Help/*.hhk
+DocProject/Help/*.hhp
+DocProject/Help/Html2
+DocProject/Help/html
+
+# Click-Once directory
+publish/
+
+# Publish Web Output
+*.[Pp]ublish.xml
+*.azurePubxml
+# Note: Comment the next line if you want to checkin your web deploy settings,
+# but database connection strings (with potential passwords) will be unencrypted
+*.pubxml
+*.publishproj
+
+# Microsoft Azure Web App publish settings. Comment the next line if you want to
+# checkin your Azure Web App publish settings, but sensitive information contained
+# in these scripts will be unencrypted
+PublishScripts/
+
+# NuGet Packages
+*.nupkg
+# NuGet Symbol Packages
+*.snupkg
+# The packages folder can be ignored because of Package Restore
+**/[Pp]ackages/*
+# except build/, which is used as an MSBuild target.
+!**/[Pp]ackages/build/
+# Uncomment if necessary however generally it will be regenerated when needed
+#!**/[Pp]ackages/repositories.config
+# NuGet v3's project.json files produces more ignorable files
+*.nuget.props
+*.nuget.targets
+
+# Microsoft Azure Build Output
+csx/
+*.build.csdef
+
+# Microsoft Azure Emulator
+ecf/
+rcf/
+
+# Windows Store app package directories and files
+AppPackages/
+BundleArtifacts/
+Package.StoreAssociation.xml
+_pkginfo.txt
+*.appx
+*.appxbundle
+*.appxupload
+
+# Visual Studio cache files
+# files ending in .cache can be ignored
+*.[Cc]ache
+# but keep track of directories ending in .cache
+!?*.[Cc]ache/
+
+# Others
+ClientBin/
+~$*
+*~
+*.dbmdl
+*.dbproj.schemaview
+*.jfm
+*.pfx
+*.publishsettings
+orleans.codegen.cs
+
+# Including strong name files can present a security risk
+# (https://github.com/github/gitignore/pull/2483#issue-259490424)
+#*.snk
+
+# Since there are multiple workflows, uncomment next line to ignore bower_components
+# (https://github.com/github/gitignore/pull/1529#issuecomment-104372622)
+#bower_components/
+
+# RIA/Silverlight projects
+Generated_Code/
+
+# Backup & report files from converting an old project file
+# to a newer Visual Studio version. Backup files are not needed,
+# because we have git ;-)
+_UpgradeReport_Files/
+Backup*/
+UpgradeLog*.XML
+UpgradeLog*.htm
+ServiceFabricBackup/
+*.rptproj.bak
+
+# SQL Server files
+*.mdf
+*.ldf
+*.ndf
+
+# Business Intelligence projects
+*.rdl.data
+*.bim.layout
+*.bim_*.settings
+*.rptproj.rsuser
+*- [Bb]ackup.rdl
+*- [Bb]ackup ([0-9]).rdl
+*- [Bb]ackup ([0-9][0-9]).rdl
+
+# Microsoft Fakes
+FakesAssemblies/
+
+# GhostDoc plugin setting file
+*.GhostDoc.xml
+
+# Node.js Tools for Visual Studio
+.ntvs_analysis.dat
+node_modules/
+
+# Visual Studio 6 build log
+*.plg
+
+# Visual Studio 6 workspace options file
+*.opt
+
+# Visual Studio 6 auto-generated workspace file (contains which files were open etc.)
+*.vbw
+
+# Visual Studio LightSwitch build output
+**/*.HTMLClient/GeneratedArtifacts
+**/*.DesktopClient/GeneratedArtifacts
+**/*.DesktopClient/ModelManifest.xml
+**/*.Server/GeneratedArtifacts
+**/*.Server/ModelManifest.xml
+_Pvt_Extensions
+
+# Paket dependency manager
+.paket/paket.exe
+paket-files/
+
+# FAKE - F# Make
+.fake/
+
+# CodeRush personal settings
+.cr/personal
+
+# Python Tools for Visual Studio (PTVS)
+__pycache__/
+*.pyc
+
+# Cake - Uncomment if you are using it
+# tools/**
+# !tools/packages.config
+
+# Tabs Studio
+*.tss
+
+# Telerik's JustMock configuration file
+*.jmconfig
+
+# BizTalk build output
+*.btp.cs
+*.btm.cs
+*.odx.cs
+*.xsd.cs
+
+# OpenCover UI analysis results
+OpenCover/
+
+# Azure Stream Analytics local run output
+ASALocalRun/
+
+# MSBuild Binary and Structured Log
+*.binlog
+
+# NVidia Nsight GPU debugger configuration file
+*.nvuser
+
+# MFractors (Xamarin productivity tool) working folder
+.mfractor/
+
+# Local History for Visual Studio
+.localhistory/
+
+# BeatPulse healthcheck temp database
+healthchecksdb
+
+# Backup folder for Package Reference Convert tool in Visual Studio 2017
+MigrationBackup/
+
+# Ionide (cross platform F# VS Code tools) working folder
+.ionide/
+
+# Fody - auto-generated XML schema
+FodyWeavers.xsd
+/ProjectManageSystem/.idea/.idea.ProjectManageSystem/.idea
+YH.PhotoAlbum.Picszen/.vs/YH.PhotoAlbum.Picszen/v17/.suo
+bin
+obj
+.vs

+ 1 - 0
readme.md

@@ -0,0 +1 @@
+# 职称证书查询

+ 4 - 0
src/PTCMS.API/.editorconfig

@@ -0,0 +1,4 @@
+[*.cs]
+
+# CS1591: 缺少对公共可见类型或成员的 XML 注释
+dotnet_diagnostic.CS1591.severity = none

+ 30 - 0
src/PTCMS.API/PTCMS.API.sln

@@ -0,0 +1,30 @@
+
+Microsoft Visual Studio Solution File, Format Version 12.00
+# Visual Studio Version 17
+VisualStudioVersion = 17.6.33829.357
+MinimumVisualStudioVersion = 10.0.40219.1
+Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "PTCMS.API", "PTCMS.API\PTCMS.API.csproj", "{17D616E2-8AC5-458F-8B87-0CB277CF5C61}"
+EndProject
+Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Solution Items", "Solution Items", "{9726C822-BA34-4782-BD0F-5DF686A13B5E}"
+	ProjectSection(SolutionItems) = preProject
+		.editorconfig = .editorconfig
+	EndProjectSection
+EndProject
+Global
+	GlobalSection(SolutionConfigurationPlatforms) = preSolution
+		Debug|Any CPU = Debug|Any CPU
+		Release|Any CPU = Release|Any CPU
+	EndGlobalSection
+	GlobalSection(ProjectConfigurationPlatforms) = postSolution
+		{17D616E2-8AC5-458F-8B87-0CB277CF5C61}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
+		{17D616E2-8AC5-458F-8B87-0CB277CF5C61}.Debug|Any CPU.Build.0 = Debug|Any CPU
+		{17D616E2-8AC5-458F-8B87-0CB277CF5C61}.Release|Any CPU.ActiveCfg = Release|Any CPU
+		{17D616E2-8AC5-458F-8B87-0CB277CF5C61}.Release|Any CPU.Build.0 = Release|Any CPU
+	EndGlobalSection
+	GlobalSection(SolutionProperties) = preSolution
+		HideSolutionNode = FALSE
+	EndGlobalSection
+	GlobalSection(ExtensibilityGlobals) = postSolution
+		SolutionGuid = {EEE9E532-1AE7-4BBD-8D0B-BC87BC5BDCFC}
+	EndGlobalSection
+EndGlobal

+ 40 - 0
src/PTCMS.API/PTCMS.API/Controllers/CertificateController.cs

@@ -0,0 +1,40 @@
+using Microsoft.AspNetCore.Http;
+using Microsoft.AspNetCore.Mvc;
+
+using PTCMS.API.Domain.Repositories;
+using PTCMS.API.Infrastructure.Dtos;
+
+namespace PTCMS.API.Controllers
+{
+    /// <summary>
+    /// 证书查询服务接口
+    /// </summary>
+    [Route("api/[controller]/[action]")]
+    [ApiController]
+    public class CertificateController : ControllerBase
+    {
+        private readonly ICertificateRepository _certificateRepository;
+
+        /// <summary>
+        /// 注入服务
+        /// </summary>
+        /// <param name="certificateRepository"></param>
+        public CertificateController(ICertificateRepository certificateRepository)
+        {
+            _certificateRepository = certificateRepository;
+        }
+
+        /// <summary>
+        /// 根据姓名+身份证号或者姓名+证书编码进行查询
+        /// </summary>
+        /// <param name="input"></param>
+        /// <returns></returns>
+        [HttpPost]
+        public async Task<IActionResult> GetCertificateAsync(CertificateSearchDto input)
+        {
+            var data = await _certificateRepository.GetCertificateAsync(input);
+
+            return Ok(data);
+        }
+    }
+}

+ 101 - 0
src/PTCMS.API/PTCMS.API/Domain/Entities/Certificate.cs

@@ -0,0 +1,101 @@
+using FreeSql.DataAnnotations;
+
+namespace PTCMS.API.Domain.Entities
+{
+    /// <summary>
+    /// 证书信息
+    /// </summary>
+    [Table(Name = "certificate")]
+    public class Certificate
+    {
+        /// <summary>
+        /// id
+        /// </summary>
+        [Column(Name = "id", IsIdentity = true, IsPrimary = true)]
+        public int Id { get; set; }
+
+        /// <summary>
+        /// 名称
+        /// </summary>
+        [Column(Name = "name")]
+        public string Name { get; set; }
+
+        /// <summary>
+        /// 证件类型
+        /// </summary>
+        [Column(Name = "id_type")]
+        public int IdType { get; set; }
+
+        /// <summary>
+        /// 证件号码
+        /// </summary>
+        [Column(Name = "id_number", StringLength = 20)]
+        public string IdNumber { get; set; }
+
+        /// <summary>
+        /// 证件编号
+        /// </summary>
+        [Column(Name = "id_code", StringLength = 50)]
+        public string IdCode { get; set; }
+
+        /// <summary>
+        /// 职称系列
+        /// </summary>
+        [Column(Name = "professional_title_series", StringLength = 50)]
+        public int ProfessionalTitleSeries { get; set; }
+
+        /// <summary>
+        /// 职称专业
+        /// </summary>
+        [Column(Name = "Professional_title", StringLength = 50)]
+        public string ProfessionalTitle { get; set; }
+
+        /// <summary>
+        /// 任职资格
+        /// </summary>
+        [Column(Name = "qualification", StringLength = 50)]
+        public string Qualification { get; set; }
+
+        /// <summary>
+        /// 职称级别
+        /// </summary>
+        [Column(Name = "level")]
+        public int Level { get; set; }
+
+        /// <summary>
+        /// 任职资格时间
+        /// </summary>
+        [Column(Name = "qualification_time")]
+        public DateTime? QualificationTime { get; set; }
+
+        /// <summary>
+        /// 发证时间
+        /// </summary>
+        [Column(Name = "issue_time")]
+        public DateTime? IssueTime { get; set; }
+
+        /// <summary>
+        /// 评审组织
+        /// </summary>
+        [Column(Name = "review_organization", StringLength = 80)]
+        public string ReviewOrganization { get; set; }
+
+        /// <summary>
+        /// 发证单位
+        /// </summary>
+        [Column(Name = "issuing_authority", StringLength = 50)]
+        public string IssuingAuthority { get; set; }
+
+        /// <summary>
+        /// 申报单位
+        /// </summary>
+        [Column(Name = "declaration_unit", StringLength = 50)]
+        public string DeclarationUnit { get; set; }
+
+        /// <summary>
+        /// 备注
+        /// </summary>
+        [Column(Name = "remark", StringLength = 200)]
+        public string Remark { get; set; }
+    }
+}

+ 18 - 0
src/PTCMS.API/PTCMS.API/Domain/Repositories/ICertificateRepository.cs

@@ -0,0 +1,18 @@
+using PTCMS.API.Domain.Entities;
+using PTCMS.API.Infrastructure.Dtos;
+
+namespace PTCMS.API.Domain.Repositories
+{
+    /// <summary>
+    /// 证书信息仓储接口
+    /// </summary>
+    public interface ICertificateRepository
+    {
+        /// <summary>
+        /// 根据姓名+身份证号或者姓名+证书编码进行查询
+        /// </summary>
+        /// <param name="input"></param>
+        /// <returns></returns>
+        Task<Certificate> GetCertificateAsync(CertificateSearchDto input);
+    }
+}

+ 20 - 0
src/PTCMS.API/PTCMS.API/Infrastructure/Dtos/CertificateSearchDto.cs

@@ -0,0 +1,20 @@
+namespace PTCMS.API.Infrastructure.Dtos
+{
+    public class CertificateSearchDto
+    {
+        /// <summary>
+        /// 姓名
+        /// </summary>
+        public string Name { get; set; }
+
+        /// <summary>
+        /// 证件号码
+        /// </summary>
+        public string IdNumber { get; set; }
+
+        /// <summary>
+        /// 证件编号
+        /// </summary>
+        public string IdCode { get; set; }
+    }
+}

+ 62 - 0
src/PTCMS.API/PTCMS.API/Infrastructure/Repositories/CertificateRepository.cs

@@ -0,0 +1,62 @@
+using System.Diagnostics.Eventing.Reader;
+using System.Linq.Expressions;
+
+using PTCMS.API.Domain.Entities;
+using PTCMS.API.Domain.Repositories;
+using PTCMS.API.Infrastructure.Dtos;
+
+namespace PTCMS.API.Infrastructure.Repositories
+{
+    /// <summary>
+    /// 证书信息仓储实现
+    /// </summary>
+    public class CertificateRepository : ICertificateRepository
+    {
+        private readonly IFreeSql _freeSql;
+
+        /// <summary>
+        /// 注入服务
+        /// </summary>
+        /// <param name="freeSql"></param>
+        public CertificateRepository(IFreeSql freeSql)
+        {
+            _freeSql = freeSql;
+        }
+
+        /// <summary>
+        /// 根据姓名+身份证号或者姓名+证书编码进行查询
+        /// </summary>
+        /// <param name="input"></param>
+        /// <returns></returns>
+        public async Task<Certificate> GetCertificateAsync(CertificateSearchDto input)
+        {
+            Expression<Func<Certificate, bool>> expression = null;
+
+            if (!string.IsNullOrWhiteSpace(input.Name) && !string.IsNullOrWhiteSpace(input.IdNumber) && !string.IsNullOrWhiteSpace(input.IdCode))
+            {
+                expression = expression.And(x => x.Name == input.Name && x.IdNumber == input.IdNumber && x.IdCode == input.IdCode);
+            }
+            else if (!string.IsNullOrWhiteSpace(input.Name) && !string.IsNullOrWhiteSpace(input.IdNumber))
+            {
+                expression = expression.And(x => x.Name == input.Name && x.IdNumber == input.IdNumber);
+            }
+            else if (!string.IsNullOrWhiteSpace(input.Name) && !string.IsNullOrWhiteSpace(input.IdCode))
+            {
+                expression = expression.And(x => x.Name == input.Name && x.IdCode == input.IdCode);
+            }
+            else
+            {
+                return null;
+            }
+
+            if (expression == null)
+            {
+                return null;
+            }
+
+            var data = await _freeSql.Select<Certificate>().Where(expression).FirstAsync();
+
+            return data;
+        }
+    }
+}

+ 99 - 0
src/PTCMS.API/PTCMS.API/Infrastructure/Utils/AppSettingHelper.cs

@@ -0,0 +1,99 @@
+namespace PTCMS.API.Infrastructure.Utils
+{
+    /// <summary>
+    /// 读取配置文件帮助类
+    /// </summary>
+    public class AppSettingHelper
+    {
+        #region 注入参数
+        /// <summary>
+        /// 配置文件
+        /// </summary>
+        private static IConfiguration? _config;
+        #endregion
+
+        #region 构造函数
+        /// <summary>
+        /// 构造函数
+        /// </summary>
+        /// <param name="configuration">配置文件</param>
+        public AppSettingHelper()
+        {
+            _config = new ConfigurationBuilder()
+                    .AddJsonFile("appsettings.json", true, reloadOnChange: true)
+                    .Build();
+        }
+        #endregion
+
+        #region 静态方法
+        /// <summary>
+        /// 读取指定节点信息
+        /// </summary>
+        /// <param name="sessions">节点名称</param>
+        /// <returns></returns>
+        public static string ReadString(params string[] sessions)
+        {
+            try
+            {
+                if (_config != null && sessions.Any())
+                {
+                    string? str = _config[string.Join(":", sessions)];
+                    if (!string.IsNullOrEmpty(str))
+                    {
+                        return str;
+                    }
+                }
+            }
+            catch
+            {
+                return string.Empty;
+            }
+            return string.Empty;
+        }
+
+        /// <summary>
+        /// 读取实体信息
+        /// </summary>
+        /// <param name="sessions">节点名称</param>
+        /// <returns></returns>
+        public static T ReadObject<T>(params string[] sessions) where T : class, new()
+        {
+            T data = new();
+            try
+            {
+                if (_config != null && sessions.Any())
+                {
+                    _config.Bind(string.Join(":", sessions), data);
+                }
+            }
+            catch
+            {
+                return data;
+            }
+            return data;
+        }
+
+        /// <summary>
+        /// 读取实体数组信息
+        /// </summary>
+        /// <param name="sessions">节点名称</param>
+        /// <returns></returns>
+        public static List<T> ReadList<T>(params string[] sessions) where T : class
+        {
+            List<T> list = new();
+            try
+            {
+                if (_config != null && sessions.Any())
+                {
+                    _config.Bind(string.Join(":", sessions), list);
+                }
+            }
+            catch
+            {
+                return list;
+            }
+            return list;
+        }
+        #endregion
+    }
+}

+ 73 - 0
src/PTCMS.API/PTCMS.API/Infrastructure/Utils/Extensions/ServiceExtensions.cs

@@ -0,0 +1,73 @@
+using System.Reflection;
+
+using PTCMS.API.Domain.Repositories;
+using PTCMS.API.Infrastructure.Repositories;
+
+namespace PTCMS.API.Infrastructure.Utils.Extensions
+{
+    /// <summary>
+    /// 服务扩展
+    /// </summary>
+    public static class ServiceExtensions
+    {
+        /// <summary>
+        /// 注册freesql
+        /// </summary>
+        /// <param name="services"></param>
+        public static void AddFreeSql(this IServiceCollection services)
+        {
+            var connStr = AppSettingHelper.ReadString("DbConn:MySQL");
+
+            IFreeSql fsql = new FreeSql.FreeSqlBuilder()
+#if DEBUG
+                    .UseNoneCommandParameter(true)
+                    .UseAutoSyncStructure(true)
+#else
+
+                    .UseGenerateCommandParameterWithLambda(true)
+#endif
+
+                    .UseConnectionString(FreeSql.DataType.MySql, connStr)
+                    .Build();
+
+            fsql.Aop.CommandBefore += (s, e) =>
+            {
+                Console.WriteLine($"--------------Start:{DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss")}--------------");
+                Console.WriteLine($"CommandBefore->监视线程:{Thread.CurrentThread.ManagedThreadId};");
+                Console.WriteLine("CommandBefore-->Identifier:" + e.Identifier + "");
+            };
+
+            fsql.Aop.CommandAfter += (s, e) =>
+            {
+                Console.WriteLine($"CommandAfter->监视线程:{Thread.CurrentThread.ManagedThreadId};");
+                Console.WriteLine("CommandAfter-->Identifier:" + e.Identifier + "");
+                Console.WriteLine($"CommandAfter->监视SQL:{e.Command.CommandText}");
+                Console.WriteLine("CommandAfter-->耗时:" + e.ElapsedMilliseconds + ":毫秒");
+                Console.WriteLine($"--------------End:{DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss")}--------------");
+            };
+
+            fsql.Aop.CurdAfter += (s, e) =>
+            {
+                Console.WriteLine($"CurdAfter->监视线程:{Thread.CurrentThread.ManagedThreadId};");
+                Console.WriteLine("Identifier:" + e.Identifier + "");
+                Console.WriteLine($"CurdAfter->监视实体:{e.EntityType.Name}");
+                Console.WriteLine($"CurdAfter->监视执行时间:{e.ElapsedMilliseconds}" + ":毫秒");
+                Console.WriteLine($"CurdAfter->监视SQL:{e.Sql}");
+                Console.WriteLine($"CurdAfter->监视参数:{string.Join(',', e.DbParms.AsEnumerable())}");
+                Console.WriteLine($"--------------End:{DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss")}--------------");
+            };
+
+            services.AddFreeRepository(null, nameof(ServiceExtensions).GetType().Assembly);
+            services.AddSingleton<IFreeSql>(fsql);
+        }
+
+        /// <summary>
+        /// 注册自定义服务以及仓储
+        /// </summary>
+        /// <param name="services"></param>
+        public static void AddCustomServices(this IServiceCollection services)
+        {
+            services.AddScoped<ICertificateRepository, CertificateRepository>();
+        }
+    }
+}

+ 27 - 0
src/PTCMS.API/PTCMS.API/PTCMS.API.csproj

@@ -0,0 +1,27 @@
+<Project Sdk="Microsoft.NET.Sdk.Web">
+
+  <PropertyGroup>
+    <TargetFramework>net6.0</TargetFramework>
+    <Nullable>disable</Nullable>
+    <ImplicitUsings>enable</ImplicitUsings>
+    <GenerateDocumentationFile>True</GenerateDocumentationFile>
+  </PropertyGroup>
+
+  <ItemGroup>
+    <PackageReference Include="FreeSql.Provider.MySql" Version="3.2.700" />
+    <PackageReference Include="Swashbuckle.AspNetCore" Version="6.5.0" />
+      <PackageReference Include="FreeSql" Version="3.2.800" />
+      <PackageReference Include="FreeSql.Extensions.JsonMap" Version="3.2.800" />
+      <PackageReference Include="FreeSql.Provider.PostgreSQL" Version="3.2.800" />
+      <PackageReference Include="FreeSql.Repository" Version="3.2.800" />
+  </ItemGroup>
+
+  <ItemGroup>
+    <Folder Include="Infrastructure\Utils\Helpers\" />
+  </ItemGroup>
+
+  <ItemGroup>
+    <None Include="..\.editorconfig" Link=".editorconfig" />
+  </ItemGroup>
+
+</Project>

+ 30 - 0
src/PTCMS.API/PTCMS.API/Program.cs

@@ -0,0 +1,30 @@
+using PTCMS.API.Infrastructure.Utils;
+using PTCMS.API.Infrastructure.Utils.Extensions;
+
+var builder = WebApplication.CreateBuilder(args);
+
+builder.Services.AddSingleton(new AppSettingHelper());
+
+builder.Services.AddControllers();
+// Learn more about configuring Swagger/OpenAPI at https://aka.ms/aspnetcore/swashbuckle
+builder.Services.AddEndpointsApiExplorer();
+builder.Services.AddSwaggerGen();
+
+builder.Services.AddFreeSql();
+builder.Services.AddCustomServices();
+
+var app = builder.Build();
+
+// Configure the HTTP request pipeline.
+if (app.Environment.IsDevelopment())
+{
+    app.UseSwagger();
+    app.UseSwaggerUI();
+}
+
+app.UseAuthentication();
+app.UseAuthorization();
+
+app.MapControllers();
+
+app.Run();

+ 31 - 0
src/PTCMS.API/PTCMS.API/Properties/launchSettings.json

@@ -0,0 +1,31 @@
+{
+  "$schema": "https://json.schemastore.org/launchsettings.json",
+  "iisSettings": {
+    "windowsAuthentication": false,
+    "anonymousAuthentication": true,
+    "iisExpress": {
+      "applicationUrl": "http://localhost:4611",
+      "sslPort": 0
+    }
+  },
+  "profiles": {
+    "PTCMS.API": {
+      "commandName": "Project",
+      "dotnetRunMessages": true,
+      "launchBrowser": true,
+      "launchUrl": "swagger",
+      "applicationUrl": "http://localhost:5271",
+      "environmentVariables": {
+        "ASPNETCORE_ENVIRONMENT": "Development"
+      }
+    },
+    "IIS Express": {
+      "commandName": "IISExpress",
+      "launchBrowser": true,
+      "launchUrl": "swagger",
+      "environmentVariables": {
+        "ASPNETCORE_ENVIRONMENT": "Development"
+      }
+    }
+  }
+}

+ 8 - 0
src/PTCMS.API/PTCMS.API/appsettings.Development.json

@@ -0,0 +1,8 @@
+{
+  "Logging": {
+    "LogLevel": {
+      "Default": "Information",
+      "Microsoft.AspNetCore": "Warning"
+    }
+  }
+}

+ 13 - 0
src/PTCMS.API/PTCMS.API/appsettings.json

@@ -0,0 +1,13 @@
+{
+  "Logging": {
+    "LogLevel": {
+      "Default": "Information",
+      "Microsoft.AspNetCore": "Warning"
+    }
+  },
+  "DbConn": {
+    "PostgreSQL": "Host=124.220.187.142;Port=5432;Username=postgres;Password=wyh_232321; Database=ptcms;Pooling=true;Minimum Pool Size=1",
+    "MySQL": "server=localhost;Port=3306;User ID=root;Password=Hello1703; database=ptcms;Charset=utf8; SslMode=none;Min pool size=1"
+  },
+  "AllowedHosts": "*"
+}