From 305bc4eb86b7fbf6bae53d822ed2b511cfa035b3 Mon Sep 17 00:00:00 2001 From: wangxulei <727869402@qq.com> Date: Fri, 27 Dec 2024 17:22:59 +0800 Subject: [PATCH] =?UTF-8?q?=E5=85=B3=E6=B3=A8=E7=B2=89=E4=B8=9D=E5=88=97?= =?UTF-8?q?=E8=A1=A8?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../com/dd/admin/business/api/AuthApi.java | 139 ++++++- .../admin/business/author/entity/Author.java | 21 + .../business/author/mapper/AuthorMapper.java | 2 + .../author/mapper/xml/AuthorMapper.xml | 11 + .../author/service/AuthorService.java | 5 + .../service/impl/AuthorServiceImpl.java | 5 + .../business/follow/domain/FollowDto.java | 3 +- .../business/follow/domain/FollowVo.java | 9 +- .../admin/business/follow/entity/Follow.java | 6 +- .../business/follow/mapper/FollowMapper.java | 5 + .../follow/mapper/xml/FollowMapper.xml | 62 +++ .../follow/service/FollowService.java | 9 + .../service/impl/FollowServiceImpl.java | 20 + .../business/note/mapper/xml/NoteMapper.xml | 2 +- src/main/resources/application.yml | 5 +- web/src/api/business/reply/reply.js | 41 ++ web/src/views/business/reply/addReply.vue | 171 ++++++++ web/src/views/business/reply/editReply.vue | 172 ++++++++ web/src/views/business/reply/replyList.vue | 373 ++++++++++++++++++ 19 files changed, 1055 insertions(+), 6 deletions(-) create mode 100644 web/src/api/business/reply/reply.js create mode 100644 web/src/views/business/reply/addReply.vue create mode 100644 web/src/views/business/reply/editReply.vue create mode 100644 web/src/views/business/reply/replyList.vue diff --git a/src/main/java/com/dd/admin/business/api/AuthApi.java b/src/main/java/com/dd/admin/business/api/AuthApi.java index ad73adb..279b987 100644 --- a/src/main/java/com/dd/admin/business/api/AuthApi.java +++ b/src/main/java/com/dd/admin/business/api/AuthApi.java @@ -8,6 +8,8 @@ import com.dd.admin.business.author.entity.Author; import com.dd.admin.business.author.service.AuthorService; import com.dd.admin.business.file.entity.File; import com.dd.admin.business.file.service.FileService; +import com.dd.admin.business.follow.domain.FollowDto; +import com.dd.admin.business.follow.domain.FollowVo; import com.dd.admin.business.follow.entity.Follow; import com.dd.admin.business.follow.service.FollowService; import com.dd.admin.business.note.domain.NoteDto; @@ -32,6 +34,7 @@ import com.dd.admin.business.upReplys.entity.UpReplys; import com.dd.admin.business.upReplys.service.UpReplysService; import com.dd.admin.common.aop.operationLog.aop.OperLog; import com.dd.admin.common.aop.operationLog.aop.OperType; +import com.dd.admin.common.exception.ApiException; import com.dd.admin.common.model.result.ResultBean; import com.dd.admin.common.utils.AddressUtils; import com.dd.admin.common.utils.CommonUtil; @@ -154,7 +157,6 @@ public class AuthApi { } - @ApiOperation(value = "获取所有点赞笔记") @ApiOperationSupport(order = 1) @GetMapping("/api/auth/getUpNotes") @@ -190,9 +192,90 @@ public class AuthApi { public ResultBean getMine() { String authorId = String.valueOf(request.getAttribute("authorId")); Author author = authorService.getById(authorId); + //关注我的列表 + List followMes = followService.selectFollowList(new FollowDto().setAuthorId(author.getAuthorId())); + List myFollows = followService.selectFollowList(new FollowDto().setFollowId(author.getAuthorId())); + + author.setFollow(Long.valueOf(myFollows.size())); + author.setFans(Long.valueOf(followMes.size())); + author.setFollowMes(followMes); + author.setMyFollows(myFollows); + Long upAndStarTotalCount = authorService.selectAuthorUpAndStarTotalCount(authorId); + author.setUpAndStarCount(upAndStarTotalCount); return ResultBean.success(author); } + @ApiOperation(value = "获取关注目标作者的所有粉丝") + @ApiOperationSupport(order = 1) + @GetMapping("/api/auth/getFollowMes") + @OperLog(operModule = "获取关注目标作者的所有粉丝",operType = OperType.QUERY,operDesc = "获取关注目标作者的所有粉丝") + public ResultBean getFollowMes(String authorId) { + //关注我的列表 + List followMes = followService.selectFollowMeList(authorId); + followMes.stream().forEach(followVo -> { + followVo.setIsFollowMe(Boolean.TRUE); + }); + return ResultBean.success(followMes); + } + + @ApiOperation(value = "获取关注目标作者的关注的所有博主") + @ApiOperationSupport(order = 1) + @GetMapping("/api/auth/getMyFollows") + @OperLog(operModule = "getMyFollows",operType = OperType.QUERY,operDesc = "获取关注目标作者的所有粉丝") + public ResultBean getMyFollows(String authorId) { + //关注我的列表 + List myFollows = followService.selectMyFollowList(authorId); + return ResultBean.success(myFollows); + } + + + + @ApiOperation(value = "获取作者信息") + @ApiOperationSupport(order = 1) + @GetMapping("/api/auth/getAuthor") + @OperLog(operModule = "获取作者信息",operType = OperType.QUERY,operDesc = "获取作者信息") + public ResultBean getAuthor(String authorId) { + String followId = String.valueOf(request.getAttribute("authorId")); + + Author author = authorService.getById(authorId); + //我是否关注过 + Follow isFollow= followService.selectOneByFollowId(authorId, followId); + if(isFollow!=null){ + author.setIsFollow(Boolean.TRUE); + } + //是否关注过我 + Follow isFollowMe= followService.selectOneByFollowId(followId, authorId); + if(isFollowMe!=null){ + author.setIsFollowMe(Boolean.TRUE); + } + + //关注我的列表 + List followMes = followService.selectFollowList(new FollowDto().setAuthorId(author.getAuthorId())); + List myFollows = followService.selectFollowList(new FollowDto().setFollowId(author.getAuthorId())); + + author.setFollow(Long.valueOf(myFollows.size())); + author.setFans(Long.valueOf(followMes.size())); + author.setFollowMes(followMes); + author.setMyFollows(myFollows); + Long upAndStarTotalCount = authorService.selectAuthorUpAndStarTotalCount(authorId); + author.setUpAndStarCount(upAndStarTotalCount); + return ResultBean.success(author); + } + + + @ApiOperation(value = "获取目标博主笔记") + @ApiOperationSupport(order = 1) + @GetMapping("/api/auth/getAuthorNotes") + @OperLog(operModule = "获取目标博主笔记",operType = OperType.QUERY,operDesc = "获取目标博主笔记") + public ResultBean> getAuthorNotes(String authorId) { + String followId = String.valueOf(request.getAttribute("authorId")); + NoteDto noteDto = new NoteDto(); + noteDto.setFollowId(followId); + noteDto.setAuthorId(authorId); + IPage pageInfo = noteService.selectNotePage(noteDto); + return ResultBean.success(pageInfo); + } + @ApiOperation(value = "获取当前博主笔记") @ApiOperationSupport(order = 1) @@ -207,6 +290,60 @@ public class AuthApi { return ResultBean.success(pageInfo); } + @ApiOperation(value = "关注博主") + @ApiOperationSupport(order = 1) + @PostMapping("/api/auth/followAuthor") + @OperLog(operModule = "关注博主",operType = OperType.ADD,operDesc = "关注博主") + public ResultBean followAuthor(@RequestBody FollowDto followDto) { + String followId = String.valueOf(request.getAttribute("authorId")); + Author follow = authorService.getById(followId); + //查看在不在点赞列表 + Follow oneByFollow= followService.selectOneByFollowId(followDto.getAuthorId(), followId); + //不在证明是点赞 + if(oneByFollow==null){ + String authorId = followDto.getAuthorId(); + Author author = authorService.getById(authorId); + + oneByFollow = new Follow(); + oneByFollow.setAuthorId(author.getAuthorId()); + oneByFollow.setAuthorName(author.getAuthorName()); + oneByFollow.setFollowId(follow.getAuthorId()); + oneByFollow.setFollowName(follow.getAuthorName()); + followService.save(oneByFollow); + }else{ + throw new ApiException("已经关注过了~"); + } + return ResultBean.success(); + }; + + + @ApiOperation(value = "取消关注博主") + @ApiOperationSupport(order = 1) + @PostMapping("/api/auth/cancelfollowAuthor") + @OperLog(operModule = "取消关注博主",operType = OperType.ADD,operDesc = "取消关注博主") + public ResultBean cancelfollowAuthor(@RequestBody FollowDto followDto) { + String followId = String.valueOf(request.getAttribute("authorId")); + Author follow = authorService.getById(followId); + //查看在不在关注列表 + Follow oneByFollow= followService.selectOneByFollowId(followDto.getAuthorId(), followId); + //不为空证明关注过 + if(oneByFollow!=null){ + String authorId = followDto.getAuthorId(); + Author author = authorService.getById(authorId); + + oneByFollow.setAuthorId(author.getAuthorId()); + oneByFollow.setAuthorName(author.getAuthorName()); + oneByFollow.setFollowId(follow.getAuthorId()); + oneByFollow.setFollowName(follow.getAuthorName()); + followService.removeById(oneByFollow); + }else{ + throw new ApiException("你还未关注博主~"); + } + return ResultBean.success(); + }; + + + @ApiOperation(value = "点赞笔记") @ApiOperationSupport(order = 1) diff --git a/src/main/java/com/dd/admin/business/author/entity/Author.java b/src/main/java/com/dd/admin/business/author/entity/Author.java index 66ef5c4..92293cc 100644 --- a/src/main/java/com/dd/admin/business/author/entity/Author.java +++ b/src/main/java/com/dd/admin/business/author/entity/Author.java @@ -2,6 +2,8 @@ package com.dd.admin.business.author.entity; import com.baomidou.mybatisplus.annotation.TableName; import com.baomidou.mybatisplus.annotation.IdType; + +import java.util.ArrayList; import java.util.Date; import com.baomidou.mybatisplus.annotation.Version; import com.baomidou.mybatisplus.annotation.TableId; @@ -9,6 +11,10 @@ import com.baomidou.mybatisplus.annotation.FieldFill; import com.baomidou.mybatisplus.annotation.TableLogic; import com.baomidou.mybatisplus.annotation.TableField; import java.io.Serializable; +import java.util.List; + +import com.dd.admin.business.follow.domain.FollowDto; +import com.dd.admin.business.follow.domain.FollowVo; import io.swagger.annotations.ApiModel; import io.swagger.annotations.ApiModelProperty; import lombok.Data; @@ -142,4 +148,19 @@ public class Author implements Serializable { @TableField(exist = false) private String token; + + @TableField(exist = false) + private Boolean isFollow = Boolean.FALSE; + + @TableField(exist = false) + private Boolean isFollowMe = Boolean.FALSE; + + @TableField(exist = false) + List followMes = new ArrayList<>(); + + @TableField(exist = false) + List myFollows = new ArrayList<>(); + + @TableField(exist = false) + private Long upAndStarCount; } diff --git a/src/main/java/com/dd/admin/business/author/mapper/AuthorMapper.java b/src/main/java/com/dd/admin/business/author/mapper/AuthorMapper.java index 168ef3e..2ea45ca 100644 --- a/src/main/java/com/dd/admin/business/author/mapper/AuthorMapper.java +++ b/src/main/java/com/dd/admin/business/author/mapper/AuthorMapper.java @@ -25,4 +25,6 @@ public interface AuthorMapper extends BaseMapper { IPage selectAuthorPage(Page page, @Param("authorDto") AuthorDto authorDto); List selectAuthorList(@Param("authorDto") AuthorDto authorDto); + + Long selectAuthorUpAndStarTotalCount(@Param("authorId") String authorId); } diff --git a/src/main/java/com/dd/admin/business/author/mapper/xml/AuthorMapper.xml b/src/main/java/com/dd/admin/business/author/mapper/xml/AuthorMapper.xml index b73db56..6465958 100644 --- a/src/main/java/com/dd/admin/business/author/mapper/xml/AuthorMapper.xml +++ b/src/main/java/com/dd/admin/business/author/mapper/xml/AuthorMapper.xml @@ -49,4 +49,15 @@ * from business_author where 1 = 1 + diff --git a/src/main/java/com/dd/admin/business/author/service/AuthorService.java b/src/main/java/com/dd/admin/business/author/service/AuthorService.java index b89854c..8652562 100644 --- a/src/main/java/com/dd/admin/business/author/service/AuthorService.java +++ b/src/main/java/com/dd/admin/business/author/service/AuthorService.java @@ -5,6 +5,8 @@ import com.dd.admin.business.author.entity.Author; import com.baomidou.mybatisplus.extension.service.IService; import com.dd.admin.business.author.domain.AuthorVo; import com.dd.admin.business.author.domain.AuthorDto; +import org.apache.ibatis.annotations.Param; + import java.util.List; /** @@ -27,4 +29,7 @@ public interface AuthorService extends IService { Author createNewAuthor(String phoneNumber); + Long selectAuthorUpAndStarTotalCount(String authorId); + + } diff --git a/src/main/java/com/dd/admin/business/author/service/impl/AuthorServiceImpl.java b/src/main/java/com/dd/admin/business/author/service/impl/AuthorServiceImpl.java index e5776f7..b6b8fcd 100644 --- a/src/main/java/com/dd/admin/business/author/service/impl/AuthorServiceImpl.java +++ b/src/main/java/com/dd/admin/business/author/service/impl/AuthorServiceImpl.java @@ -69,4 +69,9 @@ public class AuthorServiceImpl extends ServiceImpl impleme this.save(author); return author; } + + @Override + public Long selectAuthorUpAndStarTotalCount(String authorId) { + return baseMapper.selectAuthorUpAndStarTotalCount(authorId); + } } diff --git a/src/main/java/com/dd/admin/business/follow/domain/FollowDto.java b/src/main/java/com/dd/admin/business/follow/domain/FollowDto.java index 265d6e1..5399948 100644 --- a/src/main/java/com/dd/admin/business/follow/domain/FollowDto.java +++ b/src/main/java/com/dd/admin/business/follow/domain/FollowDto.java @@ -14,6 +14,7 @@ import lombok.Data; import lombok.EqualsAndHashCode; import javax.validation.constraints.NotBlank; import com.dd.admin.common.model.UpdateGroup; +import lombok.experimental.Accessors; /** @@ -26,9 +27,9 @@ import com.dd.admin.common.model.UpdateGroup; */ @Data @ApiModel(value="关注表接收对象") +@Accessors(chain = true) public class FollowDto { - @NotBlank(message = "关注表id不能为空",groups = UpdateGroup.class) private String id; diff --git a/src/main/java/com/dd/admin/business/follow/domain/FollowVo.java b/src/main/java/com/dd/admin/business/follow/domain/FollowVo.java index 4eef382..73126c2 100644 --- a/src/main/java/com/dd/admin/business/follow/domain/FollowVo.java +++ b/src/main/java/com/dd/admin/business/follow/domain/FollowVo.java @@ -34,6 +34,12 @@ public class FollowVo { @ApiModelProperty(value = "被关注名字") private String authorName; + @ApiModelProperty(value = "头像地址") + private String avatarUrl; + + @ApiModelProperty(value = "简介") + private String description; + @ApiModelProperty(value = "关注者") private String followId; @@ -43,5 +49,6 @@ public class FollowVo { @ApiModelProperty(value = "创建时间") private Date createTime; - + private Boolean isFollowMe = Boolean.FALSE; + private Boolean isFollow = Boolean.FALSE; } diff --git a/src/main/java/com/dd/admin/business/follow/entity/Follow.java b/src/main/java/com/dd/admin/business/follow/entity/Follow.java index 7fbc3de..1528b7c 100644 --- a/src/main/java/com/dd/admin/business/follow/entity/Follow.java +++ b/src/main/java/com/dd/admin/business/follow/entity/Follow.java @@ -8,10 +8,13 @@ import com.baomidou.mybatisplus.annotation.TableId; import com.baomidou.mybatisplus.annotation.FieldFill; import com.baomidou.mybatisplus.annotation.TableField; import java.io.Serializable; + +import com.dd.admin.business.upNotes.entity.UpNotes; import io.swagger.annotations.ApiModel; import io.swagger.annotations.ApiModelProperty; import lombok.Data; import lombok.EqualsAndHashCode; +import lombok.experimental.Accessors; /** *

@@ -25,7 +28,8 @@ import lombok.EqualsAndHashCode; @EqualsAndHashCode(callSuper = false) @TableName("business_follow") @ApiModel(value="Follow对象", description="关注表") -public class Follow implements Serializable { +@Accessors(chain = true) +public class Follow implements Serializable { private static final long serialVersionUID = 1L; diff --git a/src/main/java/com/dd/admin/business/follow/mapper/FollowMapper.java b/src/main/java/com/dd/admin/business/follow/mapper/FollowMapper.java index 07c0b7e..85e8588 100644 --- a/src/main/java/com/dd/admin/business/follow/mapper/FollowMapper.java +++ b/src/main/java/com/dd/admin/business/follow/mapper/FollowMapper.java @@ -25,4 +25,9 @@ public interface FollowMapper extends BaseMapper { IPage selectFollowPage(Page page, @Param("followDto") FollowDto followDto); List selectFollowList(@Param("followDto") FollowDto followDto); + + List selectMyFollowList(@Param("authorId") String authorId); + List selectFollowMeList(@Param("authorId") String authorId); + + } diff --git a/src/main/java/com/dd/admin/business/follow/mapper/xml/FollowMapper.xml b/src/main/java/com/dd/admin/business/follow/mapper/xml/FollowMapper.xml index 191a514..85de44d 100644 --- a/src/main/java/com/dd/admin/business/follow/mapper/xml/FollowMapper.xml +++ b/src/main/java/com/dd/admin/business/follow/mapper/xml/FollowMapper.xml @@ -23,9 +23,71 @@ from business_follow where 1 = 1 + + + + + + + + + diff --git a/src/main/java/com/dd/admin/business/follow/service/FollowService.java b/src/main/java/com/dd/admin/business/follow/service/FollowService.java index 6946a96..7485e17 100644 --- a/src/main/java/com/dd/admin/business/follow/service/FollowService.java +++ b/src/main/java/com/dd/admin/business/follow/service/FollowService.java @@ -5,6 +5,8 @@ import com.dd.admin.business.follow.entity.Follow; import com.baomidou.mybatisplus.extension.service.IService; import com.dd.admin.business.follow.domain.FollowVo; import com.dd.admin.business.follow.domain.FollowDto; +import org.apache.ibatis.annotations.Param; + import java.util.List; /** @@ -25,4 +27,11 @@ public interface FollowService extends IService { List selectFollowListByFollowId(String followId); + Follow selectOneByFollowId(String authorId,String followId); + + + List selectMyFollowList( String authorId); + List selectFollowMeList(String authorId); + + } diff --git a/src/main/java/com/dd/admin/business/follow/service/impl/FollowServiceImpl.java b/src/main/java/com/dd/admin/business/follow/service/impl/FollowServiceImpl.java index 29d76e0..d083989 100644 --- a/src/main/java/com/dd/admin/business/follow/service/impl/FollowServiceImpl.java +++ b/src/main/java/com/dd/admin/business/follow/service/impl/FollowServiceImpl.java @@ -3,6 +3,7 @@ package com.dd.admin.business.follow.service.impl; import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; import com.baomidou.mybatisplus.core.metadata.IPage; import com.baomidou.mybatisplus.extension.plugins.pagination.Page; +import com.dd.admin.business.upNotes.entity.UpNotes; import com.dd.admin.common.model.PageFactory; import com.dd.admin.business.follow.entity.Follow; import com.dd.admin.business.follow.mapper.FollowMapper; @@ -41,4 +42,23 @@ public class FollowServiceImpl extends ServiceImpl impleme queryWrapper.eq(Follow::getFollowId,followId); return this.list(queryWrapper); } + + @Override + public Follow selectOneByFollowId(String authorId, String followId) { + LambdaQueryWrapper queryWrapper = new LambdaQueryWrapper(); + queryWrapper.eq(Follow::getAuthorId,authorId); + queryWrapper.eq(Follow::getFollowId,followId); + return this.getOne(queryWrapper); + } + + @Override + public List selectMyFollowList(String authorId) { + return baseMapper.selectMyFollowList(authorId); + } + + @Override + public List selectFollowMeList(String authorId) { + return baseMapper.selectFollowMeList(authorId); + } + } diff --git a/src/main/java/com/dd/admin/business/note/mapper/xml/NoteMapper.xml b/src/main/java/com/dd/admin/business/note/mapper/xml/NoteMapper.xml index f2ce450..7486d59 100644 --- a/src/main/java/com/dd/admin/business/note/mapper/xml/NoteMapper.xml +++ b/src/main/java/com/dd/admin/business/note/mapper/xml/NoteMapper.xml @@ -77,7 +77,7 @@ AND a.AUTHOR_ID = #{noteDto.authorId} - AND a.AUTHOR_ID IN ${noteDto.authorIds} + AND a.AUTHOR_ID IN (${noteDto.authorIds}) AND a.IP_REAL_ADDRESS = #{noteDto.ipRealAddress} diff --git a/src/main/resources/application.yml b/src/main/resources/application.yml index 54ce6cf..d8d1c0e 100644 --- a/src/main/resources/application.yml +++ b/src/main/resources/application.yml @@ -10,6 +10,9 @@ spring: url: jdbc:p6spy:mysql://127.0.0.1:3306/ddxhs?useSSL=false&autoReconnect=true&useUnicode=true&characterEncoding=utf-8&serverTimezone=GMT%2B8 username: root password: admin +# url: jdbc:p6spy:mysql://8.146.211.120:3306/ddxhs?useSSL=false&autoReconnect=true&useUnicode=true&characterEncoding=utf-8&serverTimezone=GMT%2B8 +# username: root +# password: wxlwxl12 jackson: #配置日期返回格式 @@ -54,4 +57,4 @@ mybatis-plus: #================================================= mybatis-plus end =================================================== server: - port: 8080 \ No newline at end of file + port: 8080 diff --git a/web/src/api/business/reply/reply.js b/web/src/api/business/reply/reply.js new file mode 100644 index 0000000..e446449 --- /dev/null +++ b/web/src/api/business/reply/reply.js @@ -0,0 +1,41 @@ +import request from '@/utils/request' + +export function getReplyPage(params) { + return request({ + url: '/admin/reply/page', + method: 'get', + params + }) +} + +export function getReplyList(params) { + return request({ + url: '/admin/reply/list', + method: 'get', + params + }) +} + +export function addReply(data) { + return request({ + url: '/admin/reply/add', + method: 'post', + data: data + }) +} + +export function editReply(data) { + return request({ + url: '/admin/reply/update', + method: 'post', + data: data + }) +} + +export function deleteReply(replyId) { + return request({ + url: '/admin/reply/delete/' + replyId, + method: 'get' + }) +} + diff --git a/web/src/views/business/reply/addReply.vue b/web/src/views/business/reply/addReply.vue new file mode 100644 index 0000000..2ec563b --- /dev/null +++ b/web/src/views/business/reply/addReply.vue @@ -0,0 +1,171 @@ + + + + + diff --git a/web/src/views/business/reply/editReply.vue b/web/src/views/business/reply/editReply.vue new file mode 100644 index 0000000..a7fee85 --- /dev/null +++ b/web/src/views/business/reply/editReply.vue @@ -0,0 +1,172 @@ + + + + + diff --git a/web/src/views/business/reply/replyList.vue b/web/src/views/business/reply/replyList.vue new file mode 100644 index 0000000..fd10835 --- /dev/null +++ b/web/src/views/business/reply/replyList.vue @@ -0,0 +1,373 @@ + + + + +