diff --git a/Yi.BBS.Vue3/src/apis/commentApi.js b/Yi.BBS.Vue3/src/apis/commentApi.js new file mode 100644 index 00000000..78e2a034 --- /dev/null +++ b/Yi.BBS.Vue3/src/apis/commentApi.js @@ -0,0 +1,15 @@ +import myaxios from '@/utils/request' +export function getListByDiscussId(discussId,data){ + return myaxios({ + url: `/comment/discuss-id/${discussId}`, + method: 'get', + params:data + }) +}; +export function add(data){ + return myaxios({ + url: `/comment`, + method: 'post', + data:data + }) +}; \ No newline at end of file diff --git a/Yi.BBS.Vue3/src/components/CommentInfo.vue b/Yi.BBS.Vue3/src/components/CommentInfo.vue new file mode 100644 index 00000000..47069b3c --- /dev/null +++ b/Yi.BBS.Vue3/src/components/CommentInfo.vue @@ -0,0 +1,46 @@ + + + 第一级:{{ item.content }},id{{ item.id }} 回复 + + -->> 第二级 {{ children.content }}, 评论者{{ children.createUser.nick }}, + 被回复者{{ children.commentedUser.nick }},id{{ children.id }} + 回复 + + + + 发布 + + diff --git a/Yi.BBS.Vue3/src/views/Article.vue b/Yi.BBS.Vue3/src/views/Article.vue index fe903a45..0b01afe1 100644 --- a/Yi.BBS.Vue3/src/views/Article.vue +++ b/Yi.BBS.Vue3/src/views/Article.vue @@ -53,7 +53,11 @@ - 文章评论 + + + + + @@ -121,6 +125,7 @@ import { h, ref, onMounted } from "vue"; import AvatarInfo from "@/components/AvatarInfo.vue"; import InfoCard from "@/components/InfoCard.vue"; import ArticleContentInfo from "@/components/ArticleContentInfo.vue"; +import CommentInfo from "@/components/CommentInfo.vue"; import TreeArticleInfo from "@/components/TreeArticleInfo.vue"; import { useRoute, useRouter } from "vue-router"; diff --git a/Yi.BBS.Vue3/src/views/Index.vue b/Yi.BBS.Vue3/src/views/Index.vue index 17fadff4..e36bb610 100644 --- a/Yi.BBS.Vue3/src/views/Index.vue +++ b/Yi.BBS.Vue3/src/views/Index.vue @@ -40,7 +40,7 @@ - 没有什么能够阻挡,人类对代码优雅的最求 + 没有什么能够阻挡,人类对代码优雅的追求 diff --git a/Yi.Framework.Net6/src/project/BBS/Yi.BBS.Web/yi-sqlsugar-dev.db b/Yi.Framework.Net6/src/project/BBS/Yi.BBS.Web/yi-sqlsugar-dev.db index bfc403bb..c27c8cee 100644 Binary files a/Yi.Framework.Net6/src/project/BBS/Yi.BBS.Web/yi-sqlsugar-dev.db and b/Yi.Framework.Net6/src/project/BBS/Yi.BBS.Web/yi-sqlsugar-dev.db differ diff --git a/Yi.Framework.Net6/src/project/bbs/Yi.BBS.Application.Contracts/Exhibition/Dtos/Argee/ArgeeDto.cs b/Yi.Framework.Net6/src/project/bbs/Yi.BBS.Application.Contracts/Exhibition/Dtos/Argee/ArgeeDto.cs new file mode 100644 index 00000000..25391e8f --- /dev/null +++ b/Yi.Framework.Net6/src/project/bbs/Yi.BBS.Application.Contracts/Exhibition/Dtos/Argee/ArgeeDto.cs @@ -0,0 +1,30 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace Yi.BBS.Application.Contracts.Exhibition.Dtos.Argee +{ + public class ArgeeDto + { + public ArgeeDto(bool isArgee) + { + IsArgee = isArgee; + if (isArgee) + { + + Message = "点赞成功,点赞+1"; + } + else + { + + Message = "取消点赞,点赞-1"; + } + + } + + public bool IsArgee { get; set; } + public string Message { get; set; } + } +} diff --git a/Yi.Framework.Net6/src/project/bbs/Yi.BBS.Application/Exhibition/AgreeService.cs b/Yi.Framework.Net6/src/project/bbs/Yi.BBS.Application/Exhibition/AgreeService.cs new file mode 100644 index 00000000..75f4fa5f --- /dev/null +++ b/Yi.Framework.Net6/src/project/bbs/Yi.BBS.Application/Exhibition/AgreeService.cs @@ -0,0 +1,82 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using Cike.AutoWebApi.Setting; +using Yi.BBS.Application.Contracts.Exhibition.Dtos.Argee; +using Yi.BBS.Domain.Exhibition.Entities; +using Yi.BBS.Domain.Forum.Entities; +using Yi.Framework.Core.CurrentUsers; +using Yi.Framework.Ddd.Repositories; +using Yi.Framework.Ddd.Services; +using Yi.Framework.Ddd.Services.Abstract; +using Yi.Framework.Uow; + +namespace Yi.BBS.Application.Exhibition +{ + /// + /// 点赞功能 + /// + [AppService] + public class AgreeService : ApplicationService, IApplicationService, IAutoApiService + { + + [Autowired] + private IRepository _repository { get; set; } + + [Autowired] + private IRepository _discssRepository { get; set; } + [Autowired] + private ICurrentUser _currentUser { get; set; } + + [Autowired] + private IUnitOfWorkManager _unitOfWorkManager { get; set; } + + /// + /// 点赞,返回true为点赞+1,返回false为点赞-1 + /// + /// + public async Task PostOperateAsync(long discussId) + { + var entity = await _repository.GetFirstAsync(x => x.DiscussId == discussId && x.CreatorId == _currentUser.Id); + //判断是否已经点赞过 + if (entity is null) + { + using (var uow = _unitOfWorkManager.CreateContext()) + { + //没点赞过,添加记录即可,,修改总点赞数量 + await _repository.InsertAsync(new AgreeEntity(discussId)); + var discussEntity = await _discssRepository.GetByIdAsync(discussId); + if (discussEntity is null) + { + throw new UserFriendlyException("主题为空"); + } + discussEntity.AgreeNum += 1; + await _discssRepository.UpdateAsync(discussEntity); + uow.Commit(); + } + return new ArgeeDto(true); + + } + else + { + using (var uow = _unitOfWorkManager.CreateContext()) + { + //点赞过,删除即可,修改总点赞数量 + await _repository.DeleteByIdAsync(entity.Id); + var discussEntity = await _discssRepository.GetByIdAsync(discussId); + if (discussEntity is null) + { + throw new UserFriendlyException("主题为空"); + } + discussEntity.AgreeNum -= 1; + await _discssRepository.UpdateAsync(discussEntity); + uow.Commit(); + } + + return new ArgeeDto(false); + } + } + } +} diff --git a/Yi.Framework.Net6/src/project/bbs/Yi.BBS.Domain/Exhibition/Entities/AgreeEntity .cs b/Yi.Framework.Net6/src/project/bbs/Yi.BBS.Domain/Exhibition/Entities/AgreeEntity .cs new file mode 100644 index 00000000..37ab217f --- /dev/null +++ b/Yi.Framework.Net6/src/project/bbs/Yi.BBS.Domain/Exhibition/Entities/AgreeEntity .cs @@ -0,0 +1,39 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using SqlSugar; +using Yi.Framework.Data.Auditing; +using Yi.Framework.Data.Entities; +using Yi.Framework.Ddd.Entities; + +namespace Yi.BBS.Domain.Exhibition.Entities +{ + [SugarTable("Agree")] + public class AgreeEntity : IEntity, ICreationAuditedObject + { + public AgreeEntity() + { + } + + public AgreeEntity(long discussId) + { + DiscussId = discussId; + } + + [SugarColumn(IsPrimaryKey = true)] + public long Id { get; set; } = SnowflakeHelper.NextId; + public DateTime CreationTime { get; set; } + + /// + /// 主题id + /// + public long DiscussId { get; set; } + + /// + /// 创建者 + /// + public long? CreatorId { get; set; } + } +} diff --git a/Yi.Framework.Net6/src/project/bbs/Yi.BBS.Web/wwwroot/File/1637844443115687936.ico b/Yi.Framework.Net6/src/project/bbs/Yi.BBS.Web/wwwroot/File/1637844443115687936.ico new file mode 100644 index 00000000..7650ebd0 Binary files /dev/null and b/Yi.Framework.Net6/src/project/bbs/Yi.BBS.Web/wwwroot/File/1637844443115687936.ico differ diff --git a/Yi.Framework.Net6/src/project/bbs/Yi.BBS.Web/wwwroot/File/1637844496261713920.mp4 b/Yi.Framework.Net6/src/project/bbs/Yi.BBS.Web/wwwroot/File/1637844496261713920.mp4 new file mode 100644 index 00000000..e995a0d7 Binary files /dev/null and b/Yi.Framework.Net6/src/project/bbs/Yi.BBS.Web/wwwroot/File/1637844496261713920.mp4 differ diff --git a/Yi.Framework.Net6/src/project/bbs/Yi.BBS.Web/wwwroot/File/1637844543116283904.ico b/Yi.Framework.Net6/src/project/bbs/Yi.BBS.Web/wwwroot/File/1637844543116283904.ico new file mode 100644 index 00000000..7650ebd0 Binary files /dev/null and b/Yi.Framework.Net6/src/project/bbs/Yi.BBS.Web/wwwroot/File/1637844543116283904.ico differ diff --git a/Yi.Framework.Net6/src/project/bbs/Yi.BBS.Web/wwwroot/File/1637844777053589504.ico b/Yi.Framework.Net6/src/project/bbs/Yi.BBS.Web/wwwroot/File/1637844777053589504.ico new file mode 100644 index 00000000..7650ebd0 Binary files /dev/null and b/Yi.Framework.Net6/src/project/bbs/Yi.BBS.Web/wwwroot/File/1637844777053589504.ico differ diff --git a/Yi.Framework.Net6/src/project/bbs/Yi.BBS.Web/wwwroot/File/1637844907274145792.ico b/Yi.Framework.Net6/src/project/bbs/Yi.BBS.Web/wwwroot/File/1637844907274145792.ico new file mode 100644 index 00000000..7650ebd0 Binary files /dev/null and b/Yi.Framework.Net6/src/project/bbs/Yi.BBS.Web/wwwroot/File/1637844907274145792.ico differ diff --git a/Yi.Framework.Net6/src/project/bbs/Yi.BBS.Web/wwwroot/File/1637845098337275904.mp4 b/Yi.Framework.Net6/src/project/bbs/Yi.BBS.Web/wwwroot/File/1637845098337275904.mp4 new file mode 100644 index 00000000..e995a0d7 Binary files /dev/null and b/Yi.Framework.Net6/src/project/bbs/Yi.BBS.Web/wwwroot/File/1637845098337275904.mp4 differ diff --git a/Yi.Framework.Net6/src/project/bbs/Yi.BBS.Web/wwwroot/File/1637845229551882240.mp4 b/Yi.Framework.Net6/src/project/bbs/Yi.BBS.Web/wwwroot/File/1637845229551882240.mp4 new file mode 100644 index 00000000..e995a0d7 Binary files /dev/null and b/Yi.Framework.Net6/src/project/bbs/Yi.BBS.Web/wwwroot/File/1637845229551882240.mp4 differ diff --git a/Yi.Framework.Net6/src/project/bbs/Yi.BBS.Web/wwwroot/File/1637845321692352512.mp4 b/Yi.Framework.Net6/src/project/bbs/Yi.BBS.Web/wwwroot/File/1637845321692352512.mp4 new file mode 100644 index 00000000..e995a0d7 Binary files /dev/null and b/Yi.Framework.Net6/src/project/bbs/Yi.BBS.Web/wwwroot/File/1637845321692352512.mp4 differ diff --git a/Yi.Framework.Net6/src/project/bbs/Yi.BBS.Web/wwwroot/File/1637845338704449536.ico b/Yi.Framework.Net6/src/project/bbs/Yi.BBS.Web/wwwroot/File/1637845338704449536.ico new file mode 100644 index 00000000..7650ebd0 Binary files /dev/null and b/Yi.Framework.Net6/src/project/bbs/Yi.BBS.Web/wwwroot/File/1637845338704449536.ico differ diff --git a/Yi.Framework.Net6/src/project/bbs/Yi.BBS.Web/wwwroot/File/1637845338872221696.mp4 b/Yi.Framework.Net6/src/project/bbs/Yi.BBS.Web/wwwroot/File/1637845338872221696.mp4 new file mode 100644 index 00000000..e995a0d7 Binary files /dev/null and b/Yi.Framework.Net6/src/project/bbs/Yi.BBS.Web/wwwroot/File/1637845338872221696.mp4 differ diff --git a/Yi.Framework.Net6/src/project/bbs/Yi.BBS.Web/wwwroot/File/1637845461018742784.ico b/Yi.Framework.Net6/src/project/bbs/Yi.BBS.Web/wwwroot/File/1637845461018742784.ico new file mode 100644 index 00000000..7650ebd0 Binary files /dev/null and b/Yi.Framework.Net6/src/project/bbs/Yi.BBS.Web/wwwroot/File/1637845461018742784.ico differ diff --git a/Yi.Framework.Net6/src/project/bbs/Yi.BBS.Web/wwwroot/File/1638182203487817728 b/Yi.Framework.Net6/src/project/bbs/Yi.BBS.Web/wwwroot/File/1638182203487817728 new file mode 100644 index 00000000..f8211c62 Binary files /dev/null and b/Yi.Framework.Net6/src/project/bbs/Yi.BBS.Web/wwwroot/File/1638182203487817728 differ diff --git a/Yi.Framework.Net6/src/project/bbs/Yi.BBS.Web/wwwroot/File/1638182254972899328 b/Yi.Framework.Net6/src/project/bbs/Yi.BBS.Web/wwwroot/File/1638182254972899328 new file mode 100644 index 00000000..be0cd913 Binary files /dev/null and b/Yi.Framework.Net6/src/project/bbs/Yi.BBS.Web/wwwroot/File/1638182254972899328 differ diff --git a/Yi.Framework.Net6/src/project/bbs/Yi.BBS.Web/wwwroot/Image/1637845338872221697.png b/Yi.Framework.Net6/src/project/bbs/Yi.BBS.Web/wwwroot/Image/1637845338872221697.png new file mode 100644 index 00000000..a07294e8 Binary files /dev/null and b/Yi.Framework.Net6/src/project/bbs/Yi.BBS.Web/wwwroot/Image/1637845338872221697.png differ diff --git a/Yi.Framework.Net6/src/project/bbs/Yi.BBS.Web/wwwroot/Thumbnail/1637845338872221697.png b/Yi.Framework.Net6/src/project/bbs/Yi.BBS.Web/wwwroot/Thumbnail/1637845338872221697.png new file mode 100644 index 00000000..703bb487 Binary files /dev/null and b/Yi.Framework.Net6/src/project/bbs/Yi.BBS.Web/wwwroot/Thumbnail/1637845338872221697.png differ diff --git a/Yi.Framework.Net6/src/project/bbs/Yi.BBS.Web/yi-sqlsugar-dev.db b/Yi.Framework.Net6/src/project/bbs/Yi.BBS.Web/yi-sqlsugar-dev.db index bfc403bb..c27c8cee 100644 Binary files a/Yi.Framework.Net6/src/project/bbs/Yi.BBS.Web/yi-sqlsugar-dev.db and b/Yi.Framework.Net6/src/project/bbs/Yi.BBS.Web/yi-sqlsugar-dev.db differ