Skip to content

Commit

Permalink
添加Like 支持
Browse files Browse the repository at this point in the history
  • Loading branch information
yunzheng888 committed May 5, 2020
1 parent deca440 commit 6ef9863
Show file tree
Hide file tree
Showing 9 changed files with 109 additions and 17 deletions.
25 changes: 25 additions & 0 deletions .dockerignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
**/.classpath
**/.dockerignore
**/.env
**/.git
**/.gitignore
**/.project
**/.settings
**/.toolstarget
**/.vs
**/.vscode
**/*.*proj.user
**/*.dbmdl
**/*.jfm
**/azds.yaml
**/bin
**/charts
**/docker-compose*
**/Dockerfile*
**/node_modules
**/npm-debug.log
**/obj
**/secrets.dev.yaml
**/values.dev.yaml
LICENSE
README.md
23 changes: 18 additions & 5 deletions src/Destiny.Core.Flow.API/Controllers/DefaultController.cs
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,16 @@
using System.ComponentModel;
using System.Linq;
using System.Threading.Tasks;
using Destiny.Core.Flow.Enums;
using Destiny.Core.Flow.ExpressionUtil;
using Destiny.Core.Flow.Filter;
using Destiny.Core.Flow.Model.Entities.Identity;
using Microsoft.AspNetCore.Http;
using Microsoft.AspNetCore.Identity;
using Microsoft.AspNetCore.Mvc;
using Microsoft.EntityFrameworkCore;
using System.Linq.Dynamic.Core;
using System.Linq.Dynamic.Core.CustomTypeProviders;

namespace Destiny.Core.Flow.API.Controllers
{
Expand All @@ -26,12 +31,20 @@ public DefaultController(UserManager<User> userManager)

// GET: api/Default1
[HttpGet]
public async Task<IEnumerable<User>> Get()
public async Task Get()
{
var list = await _userManager.Users.ToListAsync();
return list.AsEnumerable();

FilterInfo[] filterInfos = new FilterInfo[] { new FilterInfo() { Value= "Test",Key="UserName" ,Operator=FilterOperator.Like} };




await Task.CompletedTask;

}

}
}




}
3 changes: 3 additions & 0 deletions src/Destiny.Core.Flow.API/Destiny.Core.Flow.API.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@

<PropertyGroup>
<TargetFramework>netcoreapp3.1</TargetFramework>
<DockerDefaultTargetOS>Linux</DockerDefaultTargetOS>
<DockerfileContext>..\..</DockerfileContext>
</PropertyGroup>

<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|AnyCPU'">
Expand All @@ -21,6 +23,7 @@
</PackageReference>
<PackageReference Include="Microsoft.Extensions.Configuration.Abstractions" Version="3.1.3" />
<PackageReference Include="Microsoft.Extensions.DependencyInjection" Version="3.1.3" />
<PackageReference Include="Microsoft.VisualStudio.Azure.Containers.Tools.Targets" Version="1.10.8" />
<PackageReference Include="Microsoft.VisualStudio.Web.CodeGeneration.Design" Version="3.1.1" />
<PackageReference Include="Pomelo.EntityFrameworkCore.MySql" Version="3.1.1" />
<PackageReference Include="Serilog" Version="2.9.0" />
Expand Down
34 changes: 34 additions & 0 deletions src/Destiny.Core.Flow.API/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
#See https://aka.ms/containerfastmode to understand how Visual Studio uses this Dockerfile to build your images for faster debugging.

FROM mcr.microsoft.com/dotnet/core/aspnet:3.1 AS base
WORKDIR /app
EXPOSE 80

#FROM mcr.microsoft.com/dotnet/core/sdk:3.1-buster AS build
#WORKDIR /src
#COPY ["src/Destiny.Core.Flow.API/Destiny.Core.Flow.API.csproj", "src/Destiny.Core.Flow.API/"]
#COPY ["src/Destiny.Core.Flow.AutoMapper/Destiny.Core.Flow.AutoMapper.csproj", "src/Destiny.Core.Flow.AutoMapper/"]
#COPY ["src/Destiny.Core.Flow/Destiny.Core.Flow.csproj", "src/Destiny.Core.Flow/"]
#COPY ["src/Destiny.Core.Flow.Model/Destiny.Core.Flow.Model.csproj", "src/Destiny.Core.Flow.Model/"]
#COPY ["src/Destiny.Core.Flow.Identity/Destiny.Core.Flow.Identitys.csproj", "src/Destiny.Core.Flow.Identity/"]
#COPY ["src/Destiny.Core.Flow.EntityFrameworkCore/Destiny.Core.Flow.EntityFrameworkCore.csproj", "src/Destiny.Core.Flow.EntityFrameworkCore/"]
#COPY ["src/Destiny.Core.Flow.Swagger/Destiny.Core.Flow.Swagger.csproj", "src/Destiny.Core.Flow.Swagger/"]
#COPY ["src/Destiny.Core.Aop/Destiny.Core.Aop.csproj", "src/Destiny.Core.Aop/"]
#COPY ["src/Destiny.Core.Flow.IServices/Destiny.Core.Flow.IServices.csproj", "src/Destiny.Core.Flow.IServices/"]
#COPY ["src/Destiny.Core.Flow.Dtos/Destiny.Core.Flow.Dtos.csproj", "src/Destiny.Core.Flow.Dtos/"]
#COPY ["src/Destiny.Core.Flow.FluentValidation/Destiny.Core.Flow.FluentValidation.csproj", "src/Destiny.Core.Flow.FluentValidation/"]
#COPY ["src/Destiny.Core.Flow.AspNetCore/Destiny.Core.Flow.AspNetCore.csproj", "src/Destiny.Core.Flow.AspNetCore/"]
#COPY ["src/Destiny.Core.Flow.Services/Destiny.Core.Flow.Services.csproj", "src/Destiny.Core.Flow.Services/"]
#COPY ["src/Destiny.Core.Flow.Repository/Destiny.Core.Flow.Repository.csproj", "src/Destiny.Core.Flow.Repository/"]
#RUN dotnet restore "src/Destiny.Core.Flow.API/Destiny.Core.Flow.API.csproj"
#COPY . .
#WORKDIR "/src/src/Destiny.Core.Flow.API"
#RUN dotnet build "Destiny.Core.Flow.API.csproj" -c Release -o /app/build
#
#FROM build AS publish
#RUN dotnet publish "Destiny.Core.Flow.API.csproj" -c Release -o /app/publish
#
#FROM base AS final
#WORKDIR /app
#COPY --from=publish /app/publish .
ENTRYPOINT ["dotnet", "Destiny.Core.Flow.API.dll"]
15 changes: 10 additions & 5 deletions src/Destiny.Core.Flow.API/Properties/launchSettings.json
Original file line number Diff line number Diff line change
@@ -1,13 +1,18 @@
{

{
"profiles": {
"Destiny.Core.Flow.API": {
"commandName": "Project",
"launchBrowser": true,
"applicationUrl": "http://localhost:50003",
"environmentVariables": {
"ASPNETCORE_ENVIRONMENT": "Development"
}
},
"applicationUrl": "http://localhost:50003"
},
"Docker": {
"commandName": "Docker",
"launchBrowser": true,
"launchUrl": "{Scheme}://{ServiceHost}:{ServicePort}",
"publishAllPorts": true
}
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,5 @@ public DefaultDbContext(DbContextOptions<DefaultDbContext> options, IServiceProv

}



}
}
2 changes: 1 addition & 1 deletion src/Destiny.Core.Flow/Destiny.Core.Flow.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
<PackageReference Include="JetBrains.Annotations" Version="2019.1.3" />
<PackageReference Include="Microsoft.AspNetCore.Http.Abstractions" Version="2.2.0" />
<PackageReference Include="Microsoft.EntityFrameworkCore" Version="3.1.3" />
<PackageReference Include="Microsoft.EntityFrameworkCore.DynamicLinq" Version="1.1.0" />
<PackageReference Include="Microsoft.Extensions.Configuration.Abstractions" Version="3.1.3" />
<PackageReference Include="Microsoft.Extensions.DependencyInjection" Version="3.1.3" />
<PackageReference Include="Microsoft.Extensions.DependencyModel" Version="3.1.3" />
Expand All @@ -23,7 +24,6 @@
<PackageReference Include="Newtonsoft.Json" Version="12.0.3" />
<PackageReference Include="System.ComponentModel.Annotations" Version="4.7.0" />
<PackageReference Include="System.IdentityModel.Tokens.Jwt" Version="6.5.0" />
<PackageReference Include="System.Linq.Dynamic.Core" Version="1.0.23" />
<PackageReference Include="System.Runtime.Loader" Version="4.3.0" />
</ItemGroup>

Expand Down
4 changes: 4 additions & 0 deletions src/Destiny.Core.Flow/Enums/Enums.cs
Original file line number Diff line number Diff line change
Expand Up @@ -128,6 +128,10 @@ public enum FilterOperator
[FilterCode("Contains")]
[Description("包含")]
In,

[FilterCode("Contains")]
[Description("模糊查询")]
Like,
}

[Description("过滤连接器")]
Expand Down
18 changes: 14 additions & 4 deletions src/Destiny.Core.Flow/ExpressionUtil/FilterHelp.cs
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
using System.Text;

using Destiny.Core.Flow.Helpers;
using Microsoft.EntityFrameworkCore.DynamicLinq;

namespace Destiny.Core.Flow.ExpressionUtil
{
Expand Down Expand Up @@ -71,16 +72,25 @@ private static string GetFilterExpression(FilterInfo[] filters)
{
var index = count + 1;
//"City == @0 and Orders.Count >= @1"
if (index != filters.Length)
//var index1 = filters.IndexOf(this);
if (filterInfo.Operator == FilterOperator.Like)
{


strWhere.Append($"{filterInfo.Key}.{filterInfo.Operator.ToDescription<FilterCodeAttribute>()}(@{count}) ");

strWhere.Append($"{filterInfo.Key} {filterInfo.Operator.ToDescription<FilterCodeAttribute>()} @{count} {filterInfo.Connect.ToDescription<FilterCodeAttribute>()} ");
}
else
{
strWhere.Append($"{filterInfo.Key} {filterInfo.Operator.ToDescription<FilterCodeAttribute>()} @{count}");
strWhere.Append($"{filterInfo.Key} {filterInfo.Operator.ToDescription<FilterCodeAttribute>()} ");
}

if (index != filters.Length)
{
strWhere.Append($"{filterInfo.Connect.ToDescription<FilterCodeAttribute>()} ");
}
count++;

count++;
}
return strWhere?.ToString();
}
Expand Down

0 comments on commit 6ef9863

Please sign in to comment.