Skip to content

Commit

Permalink
Merge branch 'master' into dev
Browse files Browse the repository at this point in the history
  • Loading branch information
nnhy committed May 12, 2023
2 parents 0ca7b4b + 88aff7f commit dd25135
Show file tree
Hide file tree
Showing 295 changed files with 9,286 additions and 6,893 deletions.
4 changes: 1 addition & 3 deletions .github/workflows/publish-beta.yml
Original file line number Diff line number Diff line change
Expand Up @@ -36,10 +36,8 @@ jobs:
dotnet build -c Release --version-suffix ${{ env.VERSION }}
- name: Pack
run: |
dotnet pack --no-build --version-suffix ${{ env.VERSION }} -c Release -o out NewLife.Cube/NewLife.Cube.csproj
dotnet pack --no-build --version-suffix ${{ env.VERSION }} -c Release -o out NewLife.CubeNC/NewLife.CubeNC.csproj
dotnet pack --no-build --version-suffix ${{ env.VERSION }} -c Release -o out NewLife.Cube.LayuiAdmin/NewLife.Cube.LayuiAdmin.csproj
dotnet pack --no-build --version-suffix ${{ env.VERSION }} -c Release -o out NewLife.Cube.Metronic/NewLife.Cube.Metronic.csproj
dotnet pack --no-build --version-suffix ${{ env.VERSION }} -c Release -o out NewLife.Cube.Metronic8/NewLife.Cube.Metronic8.csproj
- name: Publish
run: |
Expand Down
9 changes: 5 additions & 4 deletions .github/workflows/publish.yml
Original file line number Diff line number Diff line change
Expand Up @@ -22,13 +22,14 @@ jobs:
dotnet build -c Release --version-suffix ${{ env.VERSION }}
- name: Pack
run: |
dotnet pack --no-build --version-suffix ${{ env.VERSION }} -c Release -o out NewLife.Cube/NewLife.Cube.csproj
dotnet pack --no-build --version-suffix ${{ env.VERSION }} -c Release -o out NewLife.CubeNC/NewLife.CubeNC.csproj
dotnet pack --no-build --version-suffix ${{ env.VERSION }} -c Release -o out NewLife.Cube.AdminLTE/NewLife.Cube.AdminLTE.csproj
dotnet pack --no-build --version-suffix ${{ env.VERSION }} -c Release -o out NewLife.Cube.ElementUI/NewLife.Cube.ElementUI.csproj
dotnet pack --no-build --version-suffix ${{ env.VERSION }} -c Release -o out NewLife.Cube.LayuiAdmin/NewLife.Cube.LayuiAdmin.csproj
#dotnet pack --no-build --version-suffix ${{ env.VERSION }} -c Release -o out NewLife.Cube.AdminLTE/NewLife.Cube.AdminLTE.csproj
#dotnet pack --no-build --version-suffix ${{ env.VERSION }} -c Release -o out NewLife.Cube.ElementUI/NewLife.Cube.ElementUI.csproj
#dotnet pack --no-build --version-suffix ${{ env.VERSION }} -c Release -o out NewLife.Cube.LayuiAdmin/NewLife.Cube.LayuiAdmin.csproj
dotnet pack --no-build --version-suffix ${{ env.VERSION }} -c Release -o out NewLife.Cube.Metronic/NewLife.Cube.Metronic.csproj
dotnet pack --no-build --version-suffix ${{ env.VERSION }} -c Release -o out NewLife.Cube.Metronic8/NewLife.Cube.Metronic8.csproj
dotnet pack --no-build --version-suffix ${{ env.VERSION }} -c Release -o out NewLife.Cube.Tabler/NewLife.Cube.Tabler.csproj
#dotnet pack --no-build --version-suffix ${{ env.VERSION }} -c Release -o out NewLife.Cube.Tabler/NewLife.Cube.Tabler.csproj
- name: Publish
run: |
Expand Down
33 changes: 0 additions & 33 deletions CubeDemo/Controllers/WeatherForecastController.cs

This file was deleted.

13 changes: 9 additions & 4 deletions CubeDemo/CubeDemo.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,8 @@
<FileVersion>$(Version)</FileVersion>
<AssemblyVersion>$(VersionPrefix).*</AssemblyVersion>
<Deterministic>false</Deterministic>
<OutputPath>..\Bin3</OutputPath>
<OutputPath>..\Bin\CubeDemo</OutputPath>
<AppendTargetFrameworkToOutputPath>false</AppendTargetFrameworkToOutputPath>
<Nullable>enable</Nullable>
<ImplicitUsings>enable</ImplicitUsings>
<LangVersion>latest</LangVersion>
Expand All @@ -22,13 +23,17 @@
</PropertyGroup>

<ItemGroup>
<PackageReference Include="Microsoft.AspNetCore.OpenApi" Version="7.0.3" />
<PackageReference Include="NewLife.Stardust.Extensions" Version="2.6.2023.225-beta0127" />
<PackageReference Include="Swashbuckle.AspNetCore" Version="6.4.0" />
<PackageReference Include="Microsoft.AspNetCore.OpenApi" Version="7.0.5" />
<PackageReference Include="NewLife.Stardust.Extensions" Version="2.8.2023.510-beta2330" />
<PackageReference Include="Swashbuckle.AspNetCore" Version="6.5.0" />
</ItemGroup>

<ItemGroup>
<ProjectReference Include="..\NewLife.Cube\NewLife.Cube.csproj" />
</ItemGroup>

<ItemGroup>
<Folder Include="Controllers\" />
</ItemGroup>

</Project>
44 changes: 41 additions & 3 deletions CubeDemo/Program.cs
Original file line number Diff line number Diff line change
@@ -1,6 +1,12 @@
using NewLife.Cube;
using CubeDemo;
using Microsoft.AspNetCore.Mvc.ApiExplorer;
using Microsoft.AspNetCore.Mvc.Controllers;
using Microsoft.Extensions.Options;
using Microsoft.OpenApi.Models;
using NewLife.Cube;
using NewLife.Cube.WebMiddleware;
using NewLife.Log;
using Swashbuckle.AspNetCore.SwaggerGen;

XTrace.UseConsole();

Expand All @@ -16,21 +22,53 @@
builder.Services.AddControllers();
// Learn more about configuring Swagger/OpenAPI at https://aka.ms/aspnetcore/swashbuckle
builder.Services.AddEndpointsApiExplorer();
builder.Services.AddTransient<IConfigureOptions<SwaggerGenOptions>, SwaggerConfigureOptions>();
builder.Services.AddSwaggerGen(options =>
{
// 解决 NewLife.Setting 与 XCode.Setting 冲突的问题
options.CustomSchemaIds(type => type.FullName);
options.IncludeXmlComments("NewLife.Cube.xml".GetFullPath());
options.SwaggerDoc("v1", new OpenApiInfo { Version = "v1", Title = "第三代魔方", Description = "第三代魔方WebApi接口,用于前后端分离。" });
//options.SwaggerDoc("Basic", new OpenApiInfo { Version = "basic", Title = "基础模块" });
//options.SwaggerDoc("Admin", new OpenApiInfo { Version = "admin", Title = "系统管理" });
//options.SwaggerDoc("Cube", new OpenApiInfo { Version = "cube", Title = "魔方管理" });
options.DocInclusionPredicate((docName, apiDesc) =>
{
if (apiDesc.ActionDescriptor is not ControllerActionDescriptor controller) return false;
var groups = controller.ControllerTypeInfo.GetCustomAttributes(true).OfType<IApiDescriptionGroupNameProvider>().Select(e => e.GroupName).ToList();
if (docName == "v1" && (groups == null || groups.Count == 0)) return true;
return groups != null && groups.Any(e => e == docName);
});
});

services.AddCube();

var app = builder.Build();

// Configure the HTTP request pipeline.
if (app.Environment.IsDevelopment())
//if (app.Environment.IsDevelopment())
{
app.UseSwagger();
app.UseSwaggerUI();
//app.UseSwaggerUI();
app.UseSwaggerUI(options =>
{
//options.SwaggerEndpoint("/swagger/Basic/swagger.json", "Basic");
//options.SwaggerEndpoint("/swagger/Admin/swagger.json", "Admin");
//options.SwaggerEndpoint("/swagger/Cube/swagger.json", "Cube");
//options.SwaggerEndpoint("/swagger/v1/swagger.json", "v1");
options.RoutePrefix = String.Empty;
var groups = app.Services.GetRequiredService<IApiDescriptionGroupCollectionProvider>().ApiDescriptionGroups.Items;
foreach (var description in groups)
{
var group = description.GroupName ?? "v1";
options.SwaggerEndpoint($"/swagger/{group}/swagger.json", group);
}
});
}

app.UseCube(builder.Environment);
Expand Down
2 changes: 1 addition & 1 deletion CubeDemo/Properties/launchSettings.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
"commandName": "Project",
"dotnetRunMessages": true,
"launchBrowser": true,
"launchUrl": "swagger",
"launchUrl": "",
"applicationUrl": "http://localhost:5000",
"environmentVariables": {
"ASPNETCORE_ENVIRONMENT": "Development"
Expand Down
20 changes: 20 additions & 0 deletions CubeDemo/SwaggerConfigureOptions.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
using Microsoft.AspNetCore.Mvc.ApiExplorer;
using Microsoft.Extensions.Options;
using Swashbuckle.AspNetCore.SwaggerGen;

namespace CubeDemo;

public class SwaggerConfigureOptions : IConfigureOptions<SwaggerGenOptions>
{
private readonly IApiDescriptionGroupCollectionProvider provider;

public SwaggerConfigureOptions(IApiDescriptionGroupCollectionProvider provider) => this.provider = provider;

public void Configure(SwaggerGenOptions options)
{
foreach (var description in provider.ApiDescriptionGroups.Items)
{
options.SwaggerDoc(description.GroupName ?? "v1", null);
}
}
}
13 changes: 0 additions & 13 deletions CubeDemo/WeatherForecast.cs

This file was deleted.

4 changes: 2 additions & 2 deletions CubeDemoNC/Areas/School/Controllers/ClassController.cs
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ namespace CubeDemo.Areas.School.Controllers
{
[SchoolArea]
[DisplayName("班级")]
public class ClassController : EntityController<Class>
public class ClassController : EntityController<Class, ClassModel>
{
private readonly ITracer _tracer;

Expand All @@ -30,7 +30,7 @@ protected override IEnumerable<Class> Search(Pager p)
var id = p["Id"].ToInt(-1);
if (id > 0)
{
var entity = Class.FindByID(id);
var entity = Class.FindById(id);
return entity == null ? new List<Class>() : new List<Class> { entity };
}

Expand Down
51 changes: 24 additions & 27 deletions CubeDemoNC/Areas/School/Controllers/StudentController.cs
Original file line number Diff line number Diff line change
@@ -1,39 +1,36 @@
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.ComponentModel;
using Microsoft.AspNetCore.Mvc;
using NewLife.Cube;
using NewLife.School.Entity;
using NewLife.Web;

namespace CubeDemo.Areas.School.Controllers
namespace CubeDemo.Areas.School.Controllers;

[SchoolArea]
[DisplayName("学生")]
public class StudentController : EntityController<Student, StudentModel>
{
[SchoolArea]
[DisplayName("学生")]
public class StudentController : EntityController<Student>
static StudentController()
{
static StudentController()
{
ListFields.RemoveField("CreateUserID");
ListFields.RemoveField("UpdateUserID");
//FormFields
}
ListFields.RemoveField("CreateUserID");
ListFields.RemoveField("UpdateUserID");
//FormFields
}

protected override Student Find(Object key)
{
return base.Find(key);
}
protected override Student Find(Object key)
{
return base.Find(key);
}

protected override IEnumerable<Student> Search(Pager p)
{
return base.Search(p);
var classid = p["classid"].ToInt();
return Student.Search(null,p);
}
protected override IEnumerable<Student> Search(Pager p)
{
return base.Search(p);
//var classid = p["classid"].ToInt();
//return Student.Search(null,p);
}

public override ActionResult Index(Pager p = null)
{
return base.Index(p);
}
public override ActionResult Index(Pager p = null)
{
return base.Index(p);
}
}
50 changes: 50 additions & 0 deletions CubeDemoNC/Areas/School/Models/Entity/Interfaces/IClass.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Runtime.Serialization;
using System.Web.Script.Serialization;
using System.Xml.Serialization;

namespace NewLife.School.Entity;

/// <summary>班级</summary>
public partial interface IClass
{
#region 属性
/// <summary>编号</summary>
Int32 Id { get; set; }

/// <summary>租户</summary>
Int32 TenantId { get; set; }

/// <summary>名称</summary>
String Name { get; set; }

/// <summary>启用</summary>
Boolean Enable { get; set; }

/// <summary>毕业时间</summary>
DateTime GraduationDate { get; set; }

/// <summary>创建者</summary>
Int32 CreateUserID { get; set; }

/// <summary>创建时间</summary>
DateTime CreateTime { get; set; }

/// <summary>创建地址</summary>
String CreateIP { get; set; }

/// <summary>更新者</summary>
Int32 UpdateUserID { get; set; }

/// <summary>更新时间</summary>
DateTime UpdateTime { get; set; }

/// <summary>更新地址</summary>
String UpdateIP { get; set; }

/// <summary>备注</summary>
String Remark { get; set; }
#endregion
}
Loading

0 comments on commit dd25135

Please sign in to comment.