diff --git a/Yi.Framework.Net6/Yi.Framework.ApiMicroservice/Controllers/ArticleController.cs b/Yi.Framework.Net6/Yi.Framework.ApiMicroservice/Controllers/ArticleController.cs index 04f6de14..96ebf38c 100644 --- a/Yi.Framework.Net6/Yi.Framework.ApiMicroservice/Controllers/ArticleController.cs +++ b/Yi.Framework.Net6/Yi.Framework.ApiMicroservice/Controllers/ArticleController.cs @@ -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 { private IArticleService _iArticleService; - public ArticleController(ILogger logger, IArticleService iArticleService) : base(logger, iArticleService) + private IMapper _mapper; + public ArticleController(ILogger logger, IArticleService iArticleService, IMapper mapper) : base(logger, iArticleService) { _iArticleService = iArticleService; + _mapper = mapper; } /// @@ -34,7 +38,8 @@ namespace Yi.Framework.ApiMicroservice.Controllers [HttpGet] public async Task 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>(pageData.Data), Total = pageData.Total }) ; } /// @@ -44,7 +49,7 @@ namespace Yi.Framework.ApiMicroservice.Controllers /// public override Task Add(ArticleEntity entity) { - entity.UserId=HttpContext.GetUserIdInfo(); + entity.UserId = HttpContext.GetUserIdInfo(); return base.Add(entity); } } diff --git a/Yi.Framework.Net6/Yi.Framework.ApiMicroservice/wwwroot/Image/0.jpg b/Yi.Framework.Net6/Yi.Framework.ApiMicroservice/wwwroot/Image/0.jpg new file mode 100644 index 00000000..57c1f446 Binary files /dev/null and b/Yi.Framework.Net6/Yi.Framework.ApiMicroservice/wwwroot/Image/0.jpg differ diff --git a/Yi.Framework.Net6/Yi.Framework.ApiMicroservice/wwwroot/Image/1580406572306272256.jpg b/Yi.Framework.Net6/Yi.Framework.ApiMicroservice/wwwroot/Image/1580406572306272256.jpg new file mode 100644 index 00000000..fbeee125 Binary files /dev/null and b/Yi.Framework.Net6/Yi.Framework.ApiMicroservice/wwwroot/Image/1580406572306272256.jpg differ diff --git a/Yi.Framework.Net6/Yi.Framework.ApiMicroservice/wwwroot/Image/1580406585744822272.png b/Yi.Framework.Net6/Yi.Framework.ApiMicroservice/wwwroot/Image/1580406585744822272.png new file mode 100644 index 00000000..dc4b7124 Binary files /dev/null and b/Yi.Framework.Net6/Yi.Framework.ApiMicroservice/wwwroot/Image/1580406585744822272.png differ diff --git a/Yi.Framework.Net6/Yi.Framework.ApiMicroservice/wwwroot/Image/1580406585753210880.gif b/Yi.Framework.Net6/Yi.Framework.ApiMicroservice/wwwroot/Image/1580406585753210880.gif new file mode 100644 index 00000000..d916a66d Binary files /dev/null and b/Yi.Framework.Net6/Yi.Framework.ApiMicroservice/wwwroot/Image/1580406585753210880.gif differ diff --git a/Yi.Framework.Net6/Yi.Framework.ApiMicroservice/yi-sqlsugar-dev.db b/Yi.Framework.Net6/Yi.Framework.ApiMicroservice/yi-sqlsugar-dev.db index 7db5d9d9..cb071cce 100644 Binary files a/Yi.Framework.Net6/Yi.Framework.ApiMicroservice/yi-sqlsugar-dev.db and b/Yi.Framework.Net6/Yi.Framework.ApiMicroservice/yi-sqlsugar-dev.db differ diff --git a/Yi.Framework.Net6/Yi.Framework.DTOModel/ArticleVo.cs b/Yi.Framework.Net6/Yi.Framework.DTOModel/ArticleVo.cs new file mode 100644 index 00000000..c862535e --- /dev/null +++ b/Yi.Framework.Net6/Yi.Framework.DTOModel/ArticleVo.cs @@ -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 Images { get; set; } + + public UserVo User { get; set; } + } +} diff --git a/Yi.Framework.Net6/Yi.Framework.DTOModel/UserVo.cs b/Yi.Framework.Net6/Yi.Framework.DTOModel/UserVo.cs new file mode 100644 index 00000000..fb183e36 --- /dev/null +++ b/Yi.Framework.Net6/Yi.Framework.DTOModel/UserVo.cs @@ -0,0 +1,37 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace Yi.Framework.DTOModel +{ + /// + /// 前端只需要这些数据即可 + /// + 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; } + } +} diff --git a/Yi.Framework.Net6/Yi.Framework.Model/ArticleEntity.cs b/Yi.Framework.Net6/Yi.Framework.Model/ArticleEntity.cs new file mode 100644 index 00000000..fc9ad6b0 --- /dev/null +++ b/Yi.Framework.Net6/Yi.Framework.Model/ArticleEntity.cs @@ -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; } + } +} diff --git a/Yi.Framework.Net6/Yi.Framework.Service/ArticleService.cs b/Yi.Framework.Net6/Yi.Framework.Service/ArticleService.cs index f2970ee0..0b039004 100644 --- a/Yi.Framework.Net6/Yi.Framework.Service/ArticleService.cs +++ b/Yi.Framework.Net6/Yi.Framework.Service/ArticleService.cs @@ -14,6 +14,7 @@ namespace Yi.Framework.Service { RefAsync 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) diff --git a/Yi.Framework.Net6/Yi.Framework.WebCore/Mapper/Profile/AutoMapperProfile.cs b/Yi.Framework.Net6/Yi.Framework.WebCore/Mapper/Profile/AutoMapperProfile.cs index a8e2a78c..da65a8c3 100644 --- a/Yi.Framework.Net6/Yi.Framework.WebCore/Mapper/Profile/AutoMapperProfile.cs +++ b/Yi.Framework.Net6/Yi.Framework.WebCore/Mapper/Profile/AutoMapperProfile.cs @@ -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(); + CreateMap (); + CreateMap(); } } diff --git a/Yi.Vue3.X.RuoYi/src/views/index.vue b/Yi.Vue3.X.RuoYi/src/views/index.vue index 2cf6a0c3..346d475a 100644 --- a/Yi.Vue3.X.RuoYi/src/views/index.vue +++ b/Yi.Vue3.X.RuoYi/src/views/index.vue @@ -856,7 +856,7 @@