| | |
| | | using System; |
| | | using Furion.FriendlyException; |
| | | using System; |
| | | using System.Collections.Generic; |
| | | using System.ComponentModel.DataAnnotations; |
| | | using System.Linq; |
| | | using System.Net.Http; |
| | | using System.Text; |
| | | using System.Threading.Tasks; |
| | | |
| | |
| | | /// 是否已过期 |
| | | /// </summary> |
| | | public bool IsExpired { get; set; } |
| | | |
| | | public HttpMethod GetHttpMethod() |
| | | { |
| | | switch (Method) |
| | | { |
| | | case EnumResourceMethod.Get: |
| | | return HttpMethod.Get; |
| | | case EnumResourceMethod.Post: |
| | | return HttpMethod.Post; |
| | | case EnumResourceMethod.Put: |
| | | return HttpMethod.Put; |
| | | case EnumResourceMethod.Delete: |
| | | return HttpMethod.Delete; |
| | | default: |
| | | throw Oops.Oh(EnumErrorCodeType.s400, "不支持的请求类型"); |
| | | } |
| | | } |
| | | } |
| | | } |
| | |
| | | 任务地点详细地址 |
| | | </summary> |
| | | </member> |
| | | <member name="P:FlexJobApi.Core.GetTaskInfoQueryResult.Longitude"> |
| | | <summary> |
| | | 经度 |
| | | </summary> |
| | | </member> |
| | | <member name="P:FlexJobApi.Core.GetTaskInfoQueryResult.Latitude"> |
| | | <summary> |
| | | 纬度 |
| | | </summary> |
| | | </member> |
| | | <member name="P:FlexJobApi.Core.GetTaskInfoQueryResult.BeginTime"> |
| | | <summary> |
| | | 任务开始时间 |
| | |
| | | 关键字(任务名称) |
| | | </summary> |
| | | </member> |
| | | <member name="P:FlexJobApi.Core.GetTaskInfosQuery.Time"> |
| | | <member name="P:FlexJobApi.Core.GetTaskInfosQuery.BeginTime"> |
| | | <summary> |
| | | 发布时间 |
| | | 发布时间-开始 |
| | | </summary> |
| | | </member> |
| | | <member name="P:FlexJobApi.Core.GetTaskInfosQuery.EndTime"> |
| | | <summary> |
| | | 发布时间-结束 |
| | | </summary> |
| | | </member> |
| | | <member name="P:FlexJobApi.Core.GetTaskInfosQuery.CityCode"> |
| | |
| | | 是否选中 |
| | | </summary> |
| | | </member> |
| | | <member name="T:FlexJobApi.Core.GetUserResumeQuery"> |
| | | <summary> |
| | | 查询用户简历 |
| | | </summary> |
| | | </member> |
| | | <member name="P:FlexJobApi.Core.GetUserResumeQuery.UserId"> |
| | | <summary> |
| | | 用户Id |
| | | </summary> |
| | | </member> |
| | | <member name="T:FlexJobApi.Core.GetUserResumeQueryResult"> |
| | | <summary> |
| | | 查询用户简历-结果 |
| | | </summary> |
| | | </member> |
| | | <member name="T:FlexJobApi.Core.AliyunOptions"> |
| | | <summary> |
| | | 阿里云配置 |
| | |
| | | 资源工具 |
| | | </summary> |
| | | </member> |
| | | <member name="M:FlexJobApi.Core.ResourceUtils.SendHttpAsync``2(``0)"> |
| | | <member name="M:FlexJobApi.Core.ResourceUtils.SendHttpAsync``2(``0,FlexJobApi.Core.IResourceHttpProvider)"> |
| | | <summary> |
| | | 发送HTTP请求 |
| | | </summary> |
| | | <typeparam name="TRequest"></typeparam> |
| | | <typeparam name="TResponse"></typeparam> |
| | | <param name="request"></param> |
| | | <param name="provider"></param> |
| | | <returns></returns> |
| | | </member> |
| | | <member name="M:FlexJobApi.Core.ResourceUtils.GetHealthyServiceDomain(FlexJobApi.Core.Resource)"> |
| | |
| | | public string AddressDetail { get; set; } |
| | | |
| | | /// <summary> |
| | | /// 经度 |
| | | /// </summary> |
| | | public decimal? Longitude { get; set; } |
| | | |
| | | /// <summary> |
| | | /// 纬度 |
| | | /// </summary> |
| | | public decimal? Latitude { get; set; } |
| | | |
| | | /// <summary> |
| | | /// 任务开始时间 |
| | | /// </summary> |
| | | public DateTime BeginTime { get; set; } |
| | |
| | | public string Keywords { get; set; } |
| | | |
| | | /// <summary> |
| | | /// 发布时间 |
| | | /// 发布时间-开始 |
| | | /// </summary> |
| | | public DateTime? Time { get; set; } |
| | | public DateTime? BeginTime { get; set; } |
| | | |
| | | /// <summary> |
| | | /// 发布时间-结束 |
| | | /// </summary> |
| | | public DateTime? EndTime { get; set; } |
| | | |
| | | /// <summary> |
| | | /// 任务地点所属城市编号 |
New file |
| | |
| | | using MediatR; |
| | | using System; |
| | | using System.Collections.Generic; |
| | | using System.Linq; |
| | | using System.Text; |
| | | using System.Threading.Tasks; |
| | | |
| | | namespace FlexJobApi.Core |
| | | { |
| | | /// <summary> |
| | | /// 查询用户简历 |
| | | /// </summary> |
| | | [Resource([EnumResourceController.User])] |
| | | public class GetUserResumeQuery : IRequest<GetUserResumeQueryResult> |
| | | { |
| | | /// <summary> |
| | | /// 用户Id |
| | | /// </summary> |
| | | public Guid? UserId { get; set; } |
| | | } |
| | | |
| | | /// <summary> |
| | | /// 查询用户简历-结果 |
| | | /// </summary> |
| | | public class GetUserResumeQueryResult |
| | | { |
| | | |
| | | } |
| | | } |
New file |
| | |
| | | using Furion; |
| | | using Furion.FriendlyException; |
| | | using Furion.HttpRemote; |
| | | using Furion.Shapeless; |
| | | using System; |
| | | using System.Collections.Generic; |
| | | using System.Linq; |
| | | using System.Net.Http.Headers; |
| | | using System.Text; |
| | | using System.Threading.Tasks; |
| | | |
| | | namespace FlexJobApi.Core |
| | | { |
| | | public interface IResourceHttpProvider |
| | | { |
| | | HttpRequestBuilder AddAuthentication(HttpRequestBuilder builder); |
| | | Task<TResponse> SendAsAsync<TResponse>(IHttpRemoteService httpRemoteService, HttpRequestBuilder builder); |
| | | } |
| | | |
| | | public class DefaultResourceHttpProvider : IResourceHttpProvider |
| | | { |
| | | public HttpRequestBuilder AddAuthentication(HttpRequestBuilder builder) |
| | | { |
| | | var token = App.HttpContext.Request.Headers["Authorization"].ToString(); |
| | | var refreshToken = App.HttpContext.Request.Headers["X-Authorization"].ToString(); |
| | | return builder |
| | | .AddAuthentication(new AuthenticationHeaderValue("Authorization", token)) |
| | | .AddAuthentication(new AuthenticationHeaderValue("X-Authorization", refreshToken)); |
| | | } |
| | | |
| | | public async Task<TResponse> SendAsAsync<TResponse>(IHttpRemoteService httpRemoteService, HttpRequestBuilder builder) |
| | | { |
| | | var response = await httpRemoteService.SendAsAsync<TResponse>(builder); |
| | | dynamic clay = Clay.Parse(response); |
| | | if (clay.Code == 401) |
| | | { |
| | | Console.WriteLine(); |
| | | throw new Exception(); |
| | | } |
| | | else |
| | | { |
| | | return response; |
| | | } |
| | | } |
| | | } |
| | | } |
| | |
| | | /// <typeparam name="TRequest"></typeparam> |
| | | /// <typeparam name="TResponse"></typeparam> |
| | | /// <param name="request"></param> |
| | | /// <param name="provider"></param> |
| | | /// <returns></returns> |
| | | public static async Task<TResponse> SendHttpAsync<TRequest, TResponse>(TRequest request) |
| | | public static async Task<TResponse> SendHttpAsync<TRequest, TResponse>( |
| | | TRequest request, |
| | | IResourceHttpProvider provider = null) |
| | | where TRequest : class, new() |
| | | { |
| | | var requestTypeFullName = typeof(TRequest).FullName; |
| | |
| | | .FirstOrDefaultAsync(); |
| | | var domain = await GetHealthyServiceDomain(resource); |
| | | var httpRemoteService = App.GetRequiredService<IHttpRemoteService>(); |
| | | var token = App.HttpContext.Request.Headers["Authorization"].ToString(); |
| | | var refreshToken = App.HttpContext.Request.Headers["X-Authorization"].ToString(); |
| | | TResponse response; |
| | | switch (resource.Method) |
| | | { |
| | | case EnumResourceMethod.Get: |
| | | response = await httpRemoteService.GetAsAsync<TResponse>( |
| | | $"{domain}{resource.Route}", |
| | | it => |
| | | it.WithQueryParameters(request) |
| | | .AddAuthentication(new AuthenticationHeaderValue("Authorization", token)) |
| | | .AddAuthentication(new AuthenticationHeaderValue("X-Authorization", refreshToken))); |
| | | break; |
| | | case EnumResourceMethod.Post: |
| | | response = await httpRemoteService.PostAsAsync<TResponse>( |
| | | $"{domain}{resource.Route}", |
| | | it => |
| | | it.SetJsonContent(request) |
| | | .WithHeader("Authorization", token) |
| | | .WithHeader("X-Authorization", refreshToken)); |
| | | break; |
| | | case EnumResourceMethod.Put: |
| | | response = await httpRemoteService.PutAsAsync<TResponse>( |
| | | $"{domain}{resource.Route}", |
| | | it => |
| | | it.SetJsonContent(request) |
| | | .AddAuthentication(new AuthenticationHeaderValue("Authorization", token)) |
| | | .AddAuthentication(new AuthenticationHeaderValue("X-Authorization", refreshToken))); |
| | | break; |
| | | case EnumResourceMethod.Delete: |
| | | response = await httpRemoteService.DeleteAsAsync<TResponse>( |
| | | $"{domain}{resource.Route}", |
| | | it => |
| | | it.SetJsonContent(request) |
| | | .AddAuthentication(new AuthenticationHeaderValue("Authorization", token)) |
| | | .AddAuthentication(new AuthenticationHeaderValue("X-Authorization", refreshToken))); |
| | | break; |
| | | default: |
| | | throw Oops.Oh(EnumErrorCodeType.s400, $"不支持请求方式{resource.Method}"); |
| | | } |
| | | var builder = HttpRequestBuilder.Create(resource.GetHttpMethod(), $"{domain}{resource.Route}"); |
| | | if (resource.Method == EnumResourceMethod.Get) |
| | | builder = builder.WithQueryParameters(request); |
| | | else |
| | | builder = builder.SetJsonContent(request); |
| | | provider = provider ?? new DefaultResourceHttpProvider(); |
| | | builder = provider.AddAuthentication(builder); |
| | | var response = await provider.SendAsAsync<TResponse>(httpRemoteService, builder); |
| | | return response; |
| | | } |
| | | |
| | |
| | | { |
| | | q = q.Where(it => it.Name.Contains(request.Keywords)); |
| | | } |
| | | if (request.Time.HasValue) |
| | | if (request.BeginTime.HasValue && request.EndTime.HasValue) |
| | | { |
| | | q = q.Where(it => it.BeginTime <= request.Time && request.Time <= it.EndTime); |
| | | q = q.Where(it => request.BeginTime <= it.BeginTime && it.BeginTime <= request.EndTime); |
| | | } |
| | | if (request.CityCode.IsNotNull()) |
| | | { |
New file |
| | |
| | | <Project Sdk="Microsoft.NET.Sdk"> |
| | | |
| | | <PropertyGroup> |
| | | <TargetFramework>net9.0</TargetFramework> |
| | | <ImplicitUsings>enable</ImplicitUsings> |
| | | <Nullable>enable</Nullable> |
| | | <IsPackable>false</IsPackable> |
| | | </PropertyGroup> |
| | | |
| | | <ItemGroup> |
| | | <Content Include="appsettings.json"> |
| | | <CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory> |
| | | <ExcludeFromSingleFile>true</ExcludeFromSingleFile> |
| | | <CopyToPublishDirectory>PreserveNewest</CopyToPublishDirectory> |
| | | </Content> |
| | | </ItemGroup> |
| | | |
| | | <ItemGroup> |
| | | <PackageReference Include="coverlet.collector" Version="6.0.2" /> |
| | | <PackageReference Include="Microsoft.NET.Test.Sdk" Version="17.12.0" /> |
| | | <PackageReference Include="xunit" Version="2.9.2" /> |
| | | <PackageReference Include="xunit.runner.visualstudio" Version="2.8.2" /> |
| | | </ItemGroup> |
| | | |
| | | <ItemGroup> |
| | | <ProjectReference Include="..\FlexJobApi.Core\FlexJobApi.Core.csproj" /> |
| | | </ItemGroup> |
| | | |
| | | <ItemGroup> |
| | | <Using Include="Xunit" /> |
| | | </ItemGroup> |
| | | |
| | | </Project> |
New file |
| | |
| | | using FlexJobApi.Core; |
| | | using System.Threading.Tasks; |
| | | |
| | | namespace FlexJobApi.FlexJobServer.Test |
| | | { |
| | | public class TaskUnitTest |
| | | { |
| | | [Fact] |
| | | public async Task Test1() |
| | | { |
| | | var categories = await ResourceUtils.SendHttpAsync< |
| | | GetDictionaryCategorySelectQuery, |
| | | FriendlyResult<SelectOption<Guid, GetDictionaryCategorySelectQueryOption>>>( |
| | | new GetDictionaryCategorySelectQuery()); |
| | | Console.WriteLine(); |
| | | var result = await ResourceUtils.SendHttpAsync<SaveTaskInfoCommand, Guid>(new SaveTaskInfoCommand |
| | | { |
| | | Name = "测试任务", |
| | | BillingMethod = EnumBillingMethod.Month, |
| | | ServiceFee = 100, |
| | | SettlementCycle = EnumSettlementCycle.Month, |
| | | Benefits = new List<string> |
| | | { |
| | | |
| | | } |
| | | }); |
| | | } |
| | | } |
| | | } |
New file |
| | |
| | | { |
| | | "$schema": "https://gitee.com/dotnetchina/Furion/raw/v4/schemas/v4/furion-schema.json", |
| | | "ConnectionStrings": { |
| | | "FlexJobApi": "Server=120.26.58.240; Database=Dev_FlexJobApi; User=bole;Password=Bole1472589;Encrypt=false;", |
| | | "FlexJobApiLog": "Server=120.26.58.240; Database=Dev_FlexJobApiLog; User=bole;Password=Bole1472589;Encrypt=false;", |
| | | "HumanResources": "Server=120.26.58.240; Database=Dev_12333; User=bole;Password=Bole1472589;Encrypt=false;" |
| | | }, |
| | | "Consul": { |
| | | "Address": "http://localhost:8500/", |
| | | "ServiceName": "Local_FlexJobApi", |
| | | "ServiceIP": "localhost", |
| | | "ServicePort": 53780, |
| | | "ServiceHealthCheck": "/healthz" |
| | | }, |
| | | "DistributedCache": { |
| | | "Access": "Redis", |
| | | "Configuration": "118.178.252.28:5390,password=Bole123!" |
| | | }, |
| | | "Aliyun": { |
| | | "OSS": { |
| | | "AccessKeyId": "LTAI4GAdJ88mUMMFBHHiyDmS", |
| | | "AccessSecret": "NX3AmjOcGkJ8bncQfIVxqmifBWkI0E", |
| | | "RegionId": "cn-hangzhou", |
| | | "Endpoint": "http://oss-cn-hangzhou.aliyuncs.com", |
| | | "BucketName": "waterdroptest2", |
| | | "Url": "https://waterdroptest2.oss-cn-hangzhou.aliyuncs.com/", |
| | | "RoleArn": "acs:ram::1483797030072898:role/boleoss", |
| | | "RoleSessionName": "SessionTest", |
| | | "Policy": "{\"Version\":\"1\",\"Statement\":[{\"Effect\":\"Allow\",\"Action\":\"oss:PutObject\",\"Resource\":[\"acs:oss:*:*:waterdroptest2/*\",\"acs:oss:*:*:parkmanagement/*\",\"acs:oss:*:*:jurenlian/*\"]}]}", |
| | | "DurationSeconds": 3600 |
| | | } |
| | | } |
| | | } |
| | |
| | | EndProject |
| | | Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "FlexJobApi.FlexJobServer.Application", "FlexJobApi.FlexJobServer.Application\FlexJobApi.FlexJobServer.Application.csproj", "{6D8B1CA5-5859-491D-8E16-027ED8E44BDE}" |
| | | EndProject |
| | | Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "FlexJobApi.FlexJobServer.Test", "FlexJobApi.FlexJobServer.Test\FlexJobApi.FlexJobServer.Test.csproj", "{1D9D054D-B5D4-4F5B-B1D1-0354CD0F322F}" |
| | | EndProject |
| | | Global |
| | | GlobalSection(SolutionConfigurationPlatforms) = preSolution |
| | | Debug|Any CPU = Debug|Any CPU |
| | |
| | | {6D8B1CA5-5859-491D-8E16-027ED8E44BDE}.Debug|Any CPU.Build.0 = Debug|Any CPU |
| | | {6D8B1CA5-5859-491D-8E16-027ED8E44BDE}.Release|Any CPU.ActiveCfg = Release|Any CPU |
| | | {6D8B1CA5-5859-491D-8E16-027ED8E44BDE}.Release|Any CPU.Build.0 = Release|Any CPU |
| | | {1D9D054D-B5D4-4F5B-B1D1-0354CD0F322F}.Debug|Any CPU.ActiveCfg = Debug|Any CPU |
| | | {1D9D054D-B5D4-4F5B-B1D1-0354CD0F322F}.Debug|Any CPU.Build.0 = Debug|Any CPU |
| | | {1D9D054D-B5D4-4F5B-B1D1-0354CD0F322F}.Release|Any CPU.ActiveCfg = Release|Any CPU |
| | | {1D9D054D-B5D4-4F5B-B1D1-0354CD0F322F}.Release|Any CPU.Build.0 = Release|Any CPU |
| | | EndGlobalSection |
| | | GlobalSection(SolutionProperties) = preSolution |
| | | HideSolutionNode = FALSE |
| | |
| | | GlobalSection(NestedProjects) = preSolution |
| | | {BAC3E134-8D84-4F6D-8C25-AD6FD8A95697} = {02EA681E-C7D8-13C7-8484-4AC65E1B71E8} |
| | | {6D8B1CA5-5859-491D-8E16-027ED8E44BDE} = {39E37108-90DA-4908-B04C-B5A06591326D} |
| | | {1D9D054D-B5D4-4F5B-B1D1-0354CD0F322F} = {39E37108-90DA-4908-B04C-B5A06591326D} |
| | | EndGlobalSection |
| | | GlobalSection(ExtensibilityGlobals) = postSolution |
| | | SolutionGuid = {B2073C2C-0FD3-452B-8047-8134D68E12CE} |