+
Skip to content

Fix migration data #483

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Aug 16, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -0,0 +1,67 @@
// Licensed to the Mixcore Foundation under one or more agreements.
// The Mixcore Foundation licenses this file to you under the MIT license.
// See the LICENSE file in the project root for more information.

using Microsoft.AspNetCore.Mvc;
using Microsoft.EntityFrameworkCore;
using Mix.Cms.Lib.Constants;
using Mix.Cms.Lib.Controllers;
using Mix.Cms.Lib.Enums;
using Mix.Cms.Lib.Models.Cms;
using Mix.Cms.Lib.Models.Common;
using Mix.Cms.Lib.ViewModels.MixPages;
using Mix.Heart.Infrastructure.Repositories;
using Mix.Heart.Models;
using System;
using System.Linq.Expressions;
using System.Threading.Tasks;
using Mix.Heart.Extensions;

namespace Mix.Cms.Api.RestFul.Controllers.v1
{
[Produces("application/json")]
[Route("api/v1/rest/{culture}/mix-page/mvc")]
public class ApiPageMvcController :
BaseReadOnlyApiController<MixCmsContext, MixPage, ReadMvcViewModel>
{
public ApiPageMvcController(DefaultRepository<MixCmsContext, MixPage, ReadMvcViewModel> repo)
: base(repo)
{
}

[HttpGet]
public override async Task<ActionResult<PaginationModel<ReadMvcViewModel>>> Get()
{
bool isStatus = Enum.TryParse(Request.Query[MixRequestQueryKeywords.Status], out MixContentStatus status);
bool isFromDate = DateTime.TryParse(Request.Query[MixRequestQueryKeywords.FromDate], out DateTime fromDate);
bool isToDate = DateTime.TryParse(Request.Query[MixRequestQueryKeywords.ToDate], out DateTime toDate);
string type = Request.Query["type"];
string keyword = Request.Query[MixRequestQueryKeywords.Keyword];
Expression<Func<MixPage, bool>> predicate = model => model.Specificulture == _lang;
predicate = predicate.AndAlsoIf(isStatus, model => model.Status == status);
predicate = predicate.AndAlsoIf(isFromDate, model => model.CreatedDateTime >= fromDate);
predicate = predicate.AndAlsoIf(isToDate, model => model.CreatedDateTime <= toDate);
predicate = predicate.AndAlsoIf(!string.IsNullOrEmpty(keyword), model => (EF.Functions.Like(model.Title, $"%{keyword}%"))
|| (EF.Functions.Like(model.Excerpt, $"%{keyword}%"))
|| (EF.Functions.Like(model.Content, $"%{keyword}%")));
var getData = await base.GetListAsync(predicate);
if (getData.IsSucceed)
{
return getData.Data;
}
else
{
return BadRequest(getData.Errors);
}
}

protected override async Task<RepositoryResponse<ReadMvcViewModel>> GetSingleAsync(string id)
{
int.TryParse(Request.Query[MixRequestQueryKeywords.PageSize], out int pageSize);
int.TryParse(Request.Query[MixRequestQueryKeywords.PageIndex], out int pageIndex);
var result = await base.GetSingleAsync(id);
result.Data.LoadData(pageSize, pageIndex);
return result;
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
namespace Mix.Cms.Api.RestFul.Controllers.v1
{
[Produces("application/json")]
[Route("api/v1/rest/{culture}/post/mvc")]
[Route("api/v1/rest/{culture}/mix-post/mvc")]
public class ApiPostMvcController :
BaseReadOnlyApiController<MixCmsContext, MixPost, ReadMvcViewModel>
{
Expand Down
4 changes: 2 additions & 2 deletions src/Mix.Cms.Lib/Controllers/BaseReadOnlyApiController.cs
Original file line number Diff line number Diff line change
Expand Up @@ -168,7 +168,7 @@ protected void GetLanguage()

#region Helpers

protected async Task<RepositoryResponse<T>> GetSingleAsync<T>(string id)
protected virtual async Task<RepositoryResponse<T>> GetSingleAsync<T>(string id)
where T : Mix.Heart.Infrastructure.ViewModels.ViewModelBase<TDbContext, TModel, T>
{
Expression<Func<TModel, bool>> predicate = ReflectionHelper.GetExpression<TModel>(MixQueryColumnName.Id, id, Heart.Enums.ExpressionMethod.Eq);
Expand All @@ -181,7 +181,7 @@ protected async Task<RepositoryResponse<T>> GetSingleAsync<T>(string id)
return await GetSingleAsync<T>(predicate);
}

protected async Task<RepositoryResponse<TView>> GetSingleAsync(string id)
protected virtual async Task<RepositoryResponse<TView>> GetSingleAsync(string id)
{
Expression<Func<TModel, bool>> predicate = ReflectionHelper.GetExpression<TModel>(MixQueryColumnName.Id, id, Heart.Enums.ExpressionMethod.Eq);
if (!string.IsNullOrEmpty(_lang))
Expand Down
1 change: 0 additions & 1 deletion src/Mix.Cms.Lib/ViewModels/MixPages/ReadMvcViewModel.cs
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@

namespace Mix.Cms.Lib.ViewModels.MixPages
{
[GeneratedController("api/v1/rest/{culture}/mix-page/mvc")]
public class ReadMvcViewModel : ViewModelBase<MixCmsContext, MixPage, ReadMvcViewModel>, IMvcViewModel
{
#region Properties
Expand Down
7 changes: 0 additions & 7 deletions src/Mix.Rest.Api.Client/Startup.cs
Original file line number Diff line number Diff line change
@@ -1,17 +1,10 @@
using Microsoft.AspNetCore.Builder;
using Microsoft.AspNetCore.Hosting;
using Microsoft.AspNetCore.HttpsPolicy;
using Microsoft.AspNetCore.Mvc;
using Microsoft.Extensions.Configuration;
using Microsoft.Extensions.DependencyInjection;
using Microsoft.Extensions.Hosting;
using Microsoft.Extensions.Logging;
using Microsoft.OpenApi.Models;
using Mix.Cms.Lib.Extensions;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;

namespace Mix.Rest.Api.Client
{
Expand Down
点击 这是indexloc提供的php浏览器服务,不要输入任何密码和下载