修复页面加载不出的问题
This commit is contained in:
@@ -1,4 +1,5 @@
|
||||
using Microsoft.AspNetCore.Authorization;
|
||||
using AutoMapper;
|
||||
using Microsoft.AspNetCore.Authorization;
|
||||
using Microsoft.AspNetCore.Mvc;
|
||||
using Microsoft.Extensions.Logging;
|
||||
using System;
|
||||
@@ -6,6 +7,7 @@ using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Threading.Tasks;
|
||||
using Yi.Framework.Common.Models;
|
||||
using Yi.Framework.DTOModel;
|
||||
using Yi.Framework.Interface;
|
||||
using Yi.Framework.Model.Models;
|
||||
using Yi.Framework.Repository;
|
||||
@@ -20,9 +22,11 @@ namespace Yi.Framework.ApiMicroservice.Controllers
|
||||
public class ArticleController : BaseSimpleCrudController<ArticleEntity>
|
||||
{
|
||||
private IArticleService _iArticleService;
|
||||
public ArticleController(ILogger<ArticleEntity> logger, IArticleService iArticleService) : base(logger, iArticleService)
|
||||
private IMapper _mapper;
|
||||
public ArticleController(ILogger<ArticleEntity> logger, IArticleService iArticleService, IMapper mapper) : base(logger, iArticleService)
|
||||
{
|
||||
_iArticleService = iArticleService;
|
||||
_mapper = mapper;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@@ -34,7 +38,8 @@ namespace Yi.Framework.ApiMicroservice.Controllers
|
||||
[HttpGet]
|
||||
public async Task<Result> PageList([FromQuery] ArticleEntity entity, [FromQuery] PageParModel page)
|
||||
{
|
||||
return Result.Success().SetData(await _iArticleService.SelctPageList(entity, page));
|
||||
var pageData= await _iArticleService.SelctPageList(entity, page);
|
||||
return Result.Success().SetData(new PageModel() { Data = _mapper.Map<List<ArticleVo>>(pageData.Data), Total = pageData.Total }) ;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@@ -44,7 +49,7 @@ namespace Yi.Framework.ApiMicroservice.Controllers
|
||||
/// <returns></returns>
|
||||
public override Task<Result> Add(ArticleEntity entity)
|
||||
{
|
||||
entity.UserId=HttpContext.GetUserIdInfo();
|
||||
entity.UserId = HttpContext.GetUserIdInfo();
|
||||
return base.Add(entity);
|
||||
}
|
||||
}
|
||||
|
||||
Binary file not shown.
|
After Width: | Height: | Size: 30 KiB |
Binary file not shown.
|
After Width: | Height: | Size: 1.3 MiB |
Binary file not shown.
|
After Width: | Height: | Size: 320 KiB |
Binary file not shown.
|
After Width: | Height: | Size: 460 KiB |
Binary file not shown.
38
Yi.Framework.Net6/Yi.Framework.DTOModel/ArticleVo.cs
Normal file
38
Yi.Framework.Net6/Yi.Framework.DTOModel/ArticleVo.cs
Normal file
@@ -0,0 +1,38 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace Yi.Framework.DTOModel
|
||||
{
|
||||
public class ArticleVo
|
||||
{
|
||||
public long Id { get; set; }
|
||||
|
||||
public string Title { get; set; }
|
||||
|
||||
public string Content { get; set; }
|
||||
|
||||
public long? UserId { get; set; }
|
||||
|
||||
public long? CreateUser { get; set; }
|
||||
|
||||
public DateTime? CreateTime { get; set; }
|
||||
|
||||
public long? ModifyUser { get; set; }
|
||||
|
||||
public DateTime? ModifyTime { get; set; }
|
||||
|
||||
public bool? IsDeleted { get; set; }
|
||||
|
||||
public long? TenantId { get; set; }
|
||||
|
||||
public int? OrderNum { get; set; }
|
||||
|
||||
public string Remark { get; set; }
|
||||
public List<string> Images { get; set; }
|
||||
|
||||
public UserVo User { get; set; }
|
||||
}
|
||||
}
|
||||
37
Yi.Framework.Net6/Yi.Framework.DTOModel/UserVo.cs
Normal file
37
Yi.Framework.Net6/Yi.Framework.DTOModel/UserVo.cs
Normal file
@@ -0,0 +1,37 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace Yi.Framework.DTOModel
|
||||
{
|
||||
/// <summary>
|
||||
/// 前端只需要这些数据即可
|
||||
/// </summary>
|
||||
public class UserVo
|
||||
{
|
||||
public string Name { get; set; }
|
||||
|
||||
public int? Age { get; set; }
|
||||
|
||||
public string UserName { get; set; }
|
||||
|
||||
public string Icon { get; set; }
|
||||
|
||||
public string Nick { get; set; }
|
||||
|
||||
//public string Email { get; set; }
|
||||
|
||||
//public string Ip { get; set; }
|
||||
|
||||
|
||||
//public string Address { get; set; }
|
||||
|
||||
//public string Phone { get; set; }
|
||||
|
||||
public string Introduction { get; set; }
|
||||
|
||||
public int? Sex { get; set; }
|
||||
}
|
||||
}
|
||||
13
Yi.Framework.Net6/Yi.Framework.Model/ArticleEntity.cs
Normal file
13
Yi.Framework.Net6/Yi.Framework.Model/ArticleEntity.cs
Normal file
@@ -0,0 +1,13 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text.Json.Serialization;
|
||||
using SqlSugar;
|
||||
namespace Yi.Framework.Model.Models
|
||||
{
|
||||
public partial class ArticleEntity:IBaseModelEntity
|
||||
{
|
||||
[Navigate(NavigateType.OneToOne,nameof(UserId))]
|
||||
public UserEntity User { get; set; }
|
||||
}
|
||||
}
|
||||
@@ -14,6 +14,7 @@ namespace Yi.Framework.Service
|
||||
{
|
||||
RefAsync<int> total = 0;
|
||||
var data = await _repository._DbQueryable
|
||||
.Includes(x => x.User)
|
||||
//.WhereIF(!string.IsNullOrEmpty(config.ConfigName), u => u.ConfigName.Contains(config.ConfigName))
|
||||
//.WhereIF(!string.IsNullOrEmpty(config.ConfigKey), u => u.ConfigKey.Contains(config.ConfigKey))
|
||||
.WhereIF(page.StartTime is not null && page.EndTime is not null, u => u.CreateTime >= page.StartTime && u.CreateTime <= page.EndTime)
|
||||
|
||||
@@ -4,6 +4,8 @@ using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using Yi.Framework.DTOModel;
|
||||
using Yi.Framework.Model.Models;
|
||||
|
||||
namespace Yi.Framework.WebCore.Mapper
|
||||
{
|
||||
@@ -12,7 +14,8 @@ namespace Yi.Framework.WebCore.Mapper
|
||||
// 添加你的实体映射关系.
|
||||
public AutoMapperProfile()
|
||||
{
|
||||
//CreateMap<DBPoundSheet, PoundSheetViewModel>();
|
||||
CreateMap<ArticleEntity, ArticleVo > ();
|
||||
CreateMap<UserEntity, UserVo>();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user