diff --git a/content/aspnetcore/host/CompanyName.ProjectName.HttpApi.Host/CompanyNameProjectNameHttpApiHostModule.cs b/content/aspnetcore/host/CompanyName.ProjectName.HttpApi.Host/CompanyNameProjectNameHttpApiHostModule.cs index e41e705b..bc940c9b 100644 --- a/content/aspnetcore/host/CompanyName.ProjectName.HttpApi.Host/CompanyNameProjectNameHttpApiHostModule.cs +++ b/content/aspnetcore/host/CompanyName.ProjectName.HttpApi.Host/CompanyNameProjectNameHttpApiHostModule.cs @@ -108,18 +108,11 @@ namespace CompanyNameProjectName } app.UseCorrelationId(); - app.UseVirtualFiles(); + app.UseStaticFiles(); app.UseRouting(); app.UseCors(DefaultCorsPolicyName); app.UseAuthentication(); app.UseJwtTokenMiddleware(); - - //if (MultiTenancyConsts.IsEnabled) - //{ - // app.UseMultiTenancy(); - //} - - //app.UseIdentityServer(); app.UseAuthorization(); app.UseSwagger(); @@ -161,6 +154,7 @@ namespace CompanyNameProjectName { options.IsEnabled = true; options.EntityHistorySelectors.AddAllEntities(); + options.ApplicationName = "CompanyName.ProjectName"; }); } diff --git a/content/aspnetcore/host/CompanyName.ProjectName.HttpApi.Host/Extensions/Filters/DefaultHttpExceptionStatusCodeFinder.cs b/content/aspnetcore/host/CompanyName.ProjectName.HttpApi.Host/Extensions/Filters/DefaultHttpExceptionStatusCodeFinder.cs new file mode 100644 index 00000000..35ce7b50 --- /dev/null +++ b/content/aspnetcore/host/CompanyName.ProjectName.HttpApi.Host/Extensions/Filters/DefaultHttpExceptionStatusCodeFinder.cs @@ -0,0 +1,73 @@ +using Microsoft.AspNetCore.Http; +using Microsoft.Extensions.Options; +using System; +using System.Net; +using Volo.Abp; +using Volo.Abp.AspNetCore.ExceptionHandling; +using Volo.Abp.Authorization; +using Volo.Abp.DependencyInjection; +using Volo.Abp.Domain.Entities; +using Volo.Abp.ExceptionHandling; +using Volo.Abp.Validation; + + namespace CompanyNameProjectName.Extensions.Filters +{ + [Dependency(ReplaceServices = true)] + public class DefaultHttpExceptionStatusCodeFinder : IHttpExceptionStatusCodeFinder, ITransientDependency + { + protected AbpExceptionHttpStatusCodeOptions Options { get; } + + public DefaultHttpExceptionStatusCodeFinder( + IOptions options) + { + Options = options.Value; + } + + public HttpStatusCode GetStatusCode(HttpContext httpContext, Exception exception) + { + if (exception is IHasHttpStatusCode exceptionWithHttpStatusCode && + exceptionWithHttpStatusCode.HttpStatusCode > 0) + { + return (HttpStatusCode)exceptionWithHttpStatusCode.HttpStatusCode; + } + + if (exception is IHasErrorCode exceptionWithErrorCode && + !exceptionWithErrorCode.Code.IsNullOrWhiteSpace()) + { + if (Options.ErrorCodeToHttpStatusCodeMappings.TryGetValue(exceptionWithErrorCode.Code, out var status)) + { + return status; + } + } + + if (exception is AbpAuthorizationException) + { + return HttpStatusCode.Forbidden; + } + + //TODO: Handle SecurityException..? + + if (exception is AbpValidationException) + { + return HttpStatusCode.BadRequest; + } + + if (exception is EntityNotFoundException) + { + return HttpStatusCode.NotFound; + } + + if (exception is NotImplementedException) + { + return HttpStatusCode.NotImplemented; + } + + if (exception is IBusinessException) + { + return HttpStatusCode.InternalServerError; + } + + return HttpStatusCode.InternalServerError; + } + } +} diff --git a/content/aspnetcore/host/CompanyName.ProjectName.HttpApi.Host/Properties/launchSettings.json b/content/aspnetcore/host/CompanyName.ProjectName.HttpApi.Host/Properties/launchSettings.json index 3a553ed9..2e29ce65 100644 --- a/content/aspnetcore/host/CompanyName.ProjectName.HttpApi.Host/Properties/launchSettings.json +++ b/content/aspnetcore/host/CompanyName.ProjectName.HttpApi.Host/Properties/launchSettings.json @@ -7,7 +7,7 @@ "environmentVariables": { "ASPNETCORE_ENVIRONMENT": "Development" }, - "applicationUrl": "http://localhost:50010/" + "applicationUrl": "http://localhost:50010" } } } \ No newline at end of file diff --git a/content/aspnetcore/host/CompanyName.ProjectName.HttpApi.Host/appsettings.json b/content/aspnetcore/host/CompanyName.ProjectName.HttpApi.Host/appsettings.json index 2350b5cf..12a31825 100644 --- a/content/aspnetcore/host/CompanyName.ProjectName.HttpApi.Host/appsettings.json +++ b/content/aspnetcore/host/CompanyName.ProjectName.HttpApi.Host/appsettings.json @@ -31,12 +31,12 @@ } }, "ConnectionStrings": { - "Default": "Data Source=mysql.platform.development.cn;Database=CompanyNameProjectName;uid=root;pwd=mysql@dmin;charset=utf8mb4;Allow User Variables=true;AllowLoadLocalInfile=true" + "Default": "Data Source=localhost;Database=CompanyNameProjectName;uid=root;pwd=mypassword;charset=utf8mb4;Allow User Variables=true;AllowLoadLocalInfile=true" }, "Cache": { "Redis": { - "ConnectionString": "redis.platform.development.cn,password=OD5VbzIuAWsHOZV5ncYx9xaDsAMsKXn7", - "DatabaseId": 234 + "ConnectionString": "localhost,password=mypassword", + "DatabaseId": 1 } }, "AuthServer": { diff --git a/content/aspnetcore/src/CompanyName.ProjectName.Application.Contracts/Users/Dtos/LoginInputDto.cs b/content/aspnetcore/src/CompanyName.ProjectName.Application.Contracts/Users/Dtos/LoginInputDto.cs index d5784fc8..befd9ca7 100644 --- a/content/aspnetcore/src/CompanyName.ProjectName.Application.Contracts/Users/Dtos/LoginInputDto.cs +++ b/content/aspnetcore/src/CompanyName.ProjectName.Application.Contracts/Users/Dtos/LoginInputDto.cs @@ -1,6 +1,7 @@ using System; using System.Collections.Generic; using System.ComponentModel.DataAnnotations; +using Volo.Abp.Auditing; namespace CompanyNameProjectName.Dtos.Users { @@ -17,6 +18,7 @@ namespace CompanyNameProjectName.Dtos.Users /// /// 密码 /// + [DisableAuditing] public string Password { get; set; } public IEnumerable Validate(ValidationContext validationContext) diff --git a/content/aspnetcore/src/CompanyName.ProjectName.Application/Users/LoginAppService.cs b/content/aspnetcore/src/CompanyName.ProjectName.Application/Users/LoginAppService.cs index fa3b36da..2bad84d8 100644 --- a/content/aspnetcore/src/CompanyName.ProjectName.Application/Users/LoginAppService.cs +++ b/content/aspnetcore/src/CompanyName.ProjectName.Application/Users/LoginAppService.cs @@ -14,6 +14,7 @@ using System.Threading.Tasks; using Volo.Abp; using Volo.Abp.Application.Services; using Volo.Abp.Identity; +using Volo.Abp.Security.Claims; namespace CompanyNameProjectName.Users { @@ -72,12 +73,13 @@ namespace CompanyNameProjectName.Users var key = Encoding.ASCII.GetBytes(_jwtOptions.SecurityKey); var claims = new List { - new Claim(JwtClaimTypes.Audience, _jwtOptions.Audience), - new Claim(JwtClaimTypes.Issuer, _jwtOptions.Issuer), - new Claim(JwtClaimTypes.Subject, user.Id.ToString()), - new Claim(JwtClaimTypes.Name, user.Name), - new Claim(JwtClaimTypes.Email, user.Email), - new Claim("TenantId", user.TenantId.ToString()) + new Claim(JwtClaimTypes.Audience, _jwtOptions.Audience), + new Claim(JwtClaimTypes.Issuer, _jwtOptions.Issuer), + new Claim(AbpClaimTypes.UserId, user.Id.ToString()), + new Claim(AbpClaimTypes.Name, user.Name), + new Claim(AbpClaimTypes.UserName, user.UserName), + new Claim(AbpClaimTypes.Email, user.Email), + new Claim(AbpClaimTypes.TenantId, user.TenantId.ToString()) }; foreach (var item in roles) diff --git a/content/aspnetcore/tools/CompanyName.ProjectName.DbMigrator/appsettings.json b/content/aspnetcore/tools/CompanyName.ProjectName.DbMigrator/appsettings.json index 7b9922c4..f01664e6 100644 --- a/content/aspnetcore/tools/CompanyName.ProjectName.DbMigrator/appsettings.json +++ b/content/aspnetcore/tools/CompanyName.ProjectName.DbMigrator/appsettings.json @@ -1,5 +1,5 @@ { "ConnectionStrings": { - "Default": "Data Source=mysql.platform.development.cn;Database=CompanyNameProjectName;uid=root;pwd=mysql@dmin;charset=utf8mb4;Allow User Variables=true;AllowLoadLocalInfile=true" + "Default": "Data Source=localhost;Database=CompanyNameProjectName;uid=root;pwd=mypassword;charset=utf8mb4;Allow User Variables=true;AllowLoadLocalInfile=true" } } diff --git a/content/vue/.husky/.gitignore b/content/vue/.husky/.gitignore deleted file mode 100644 index 31354ec1..00000000 --- a/content/vue/.husky/.gitignore +++ /dev/null @@ -1 +0,0 @@ -_ diff --git a/content/vue/package.json b/content/vue/package.json index 185b2798..f7104957 100644 --- a/content/vue/package.json +++ b/content/vue/package.json @@ -23,14 +23,12 @@ "lint:eslint": "eslint \"{src,mock}/**/*.{vue,ts,tsx}\" --fix", "lint:prettier": "prettier --write --loglevel warn \"src/**/*.{js,json,tsx,css,less,scss,vue,html,md}\"", "lint:stylelint": "stylelint --fix \"**/*.{vue,less,postcss,css,scss}\" --cache --cache-location node_modules/.cache/stylelint/", - "lint:lint-staged": "lint-staged -c ./.husky/lintstagedrc.js", "lint:pretty": "pretty-quick --staged", "test:gzip": "http-server dist --cors --gzip -c-1", "test:br": "http-server dist --cors --brotli -c-1", "reinstall": "rimraf yarn.lock && rimraf package.lock.json && rimraf node_modules && npm run bootstrap", - "install:husky": "is-ci || husky install", - "gen:icon": "esno ./build/generate/icon/index.ts", - "postinstall": "npm run install:husky" + "gen:icon": "esno ./build/generate/icon/index.ts" + }, "dependencies": { "@iconify/iconify": "^2.0.0-rc.6", @@ -90,7 +88,6 @@ "esno": "^0.5.0", "fs-extra": "^9.1.0", "http-server": "^0.12.3", - "husky": "^6.0.0", "inquirer": "^8.0.0", "is-ci": "^3.0.0", "less": "^4.1.1", diff --git a/content/vue/src/layouts/default/header/index.vue b/content/vue/src/layouts/default/header/index.vue index 7ff143fa..fce782d0 100644 --- a/content/vue/src/layouts/default/header/index.vue +++ b/content/vue/src/layouts/default/header/index.vue @@ -55,7 +55,7 @@