关注粉丝列表
This commit is contained in:
@@ -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<Author> getMine() {
|
||||
String authorId = String.valueOf(request.getAttribute("authorId"));
|
||||
Author author = authorService.getById(authorId);
|
||||
//关注我的列表
|
||||
List<FollowVo> followMes = followService.selectFollowList(new FollowDto().setAuthorId(author.getAuthorId()));
|
||||
List<FollowVo> 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<FollowVo> 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<FollowVo> 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<Author> 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<FollowVo> followMes = followService.selectFollowList(new FollowDto().setAuthorId(author.getAuthorId()));
|
||||
List<FollowVo> 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<IPage<NoteVo>> getAuthorNotes(String authorId) {
|
||||
String followId = String.valueOf(request.getAttribute("authorId"));
|
||||
NoteDto noteDto = new NoteDto();
|
||||
noteDto.setFollowId(followId);
|
||||
noteDto.setAuthorId(authorId);
|
||||
IPage<NoteVo> 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)
|
||||
|
@@ -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<FollowVo> followMes = new ArrayList<>();
|
||||
|
||||
@TableField(exist = false)
|
||||
List<FollowVo> myFollows = new ArrayList<>();
|
||||
|
||||
@TableField(exist = false)
|
||||
private Long upAndStarCount;
|
||||
}
|
||||
|
@@ -25,4 +25,6 @@ public interface AuthorMapper extends BaseMapper<Author> {
|
||||
IPage<AuthorVo> selectAuthorPage(Page<AuthorVo> page, @Param("authorDto") AuthorDto authorDto);
|
||||
|
||||
List<AuthorVo> selectAuthorList(@Param("authorDto") AuthorDto authorDto);
|
||||
|
||||
Long selectAuthorUpAndStarTotalCount(@Param("authorId") String authorId);
|
||||
}
|
||||
|
@@ -49,4 +49,15 @@
|
||||
*
|
||||
from business_author where 1 = 1
|
||||
</select>
|
||||
<select id="selectAuthorUpAndStarTotalCount" resultType="java.lang.Long">
|
||||
|
||||
SELECT IFNULL(SUM(subquery_counts.count_value), 0) AS total_count
|
||||
FROM (
|
||||
SELECT COUNT(*) AS count_value FROM business_up_notes WHERE AUTHOR_ID = #{authorId}
|
||||
UNION ALL
|
||||
SELECT COUNT(*) AS count_value FROM business_star_notes WHERE AUTHOR_ID = #{authorId}
|
||||
UNION ALL
|
||||
SELECT COUNT(*) AS count_value FROM business_up_replys WHERE AUTHOR_ID = #{authorId}
|
||||
) AS subquery_counts;
|
||||
</select>
|
||||
</mapper>
|
||||
|
@@ -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> {
|
||||
|
||||
Author createNewAuthor(String phoneNumber);
|
||||
|
||||
Long selectAuthorUpAndStarTotalCount(String authorId);
|
||||
|
||||
|
||||
}
|
||||
|
@@ -69,4 +69,9 @@ public class AuthorServiceImpl extends ServiceImpl<AuthorMapper, Author> impleme
|
||||
this.save(author);
|
||||
return author;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Long selectAuthorUpAndStarTotalCount(String authorId) {
|
||||
return baseMapper.selectAuthorUpAndStarTotalCount(authorId);
|
||||
}
|
||||
}
|
||||
|
@@ -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;
|
||||
|
||||
|
@@ -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;
|
||||
}
|
||||
|
@@ -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;
|
||||
|
||||
/**
|
||||
* <p>
|
||||
@@ -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;
|
||||
|
||||
|
@@ -25,4 +25,9 @@ public interface FollowMapper extends BaseMapper<Follow> {
|
||||
IPage<FollowVo> selectFollowPage(Page<FollowVo> page, @Param("followDto") FollowDto followDto);
|
||||
|
||||
List<FollowVo> selectFollowList(@Param("followDto") FollowDto followDto);
|
||||
|
||||
List<FollowVo> selectMyFollowList(@Param("authorId") String authorId);
|
||||
List<FollowVo> selectFollowMeList(@Param("authorId") String authorId);
|
||||
|
||||
|
||||
}
|
||||
|
@@ -23,9 +23,71 @@
|
||||
from business_follow where 1 = 1
|
||||
</select>
|
||||
|
||||
|
||||
|
||||
<select id="selectFollowList" resultType="com.dd.admin.business.follow.domain.FollowVo">
|
||||
select
|
||||
*
|
||||
from business_follow where 1 = 1
|
||||
<if test="followDto.authorId != null and followDto.authorId != ''">
|
||||
and AUTHOR_ID = #{followDto.authorId}
|
||||
</if>
|
||||
<if test="followDto.followId != null and followDto.followId != ''">
|
||||
and FOLLOW_ID = #{followDto.followId}
|
||||
</if>
|
||||
order by create_time desc
|
||||
</select>
|
||||
|
||||
<select id="selectMyFollowList" resultType="com.dd.admin.business.follow.domain.FollowVo">
|
||||
SELECT
|
||||
b.AUTHOR_ID,
|
||||
b.AUTHOR_NAME,
|
||||
b.AVATAR_URL,
|
||||
b.DESCRIPTION,
|
||||
(
|
||||
SELECT
|
||||
count(1)
|
||||
FROM
|
||||
business_follow
|
||||
WHERE
|
||||
follow_id = b.AUTHOR_ID
|
||||
AND author_id = #{authorId}
|
||||
) AS isFollowMe
|
||||
FROM
|
||||
business_follow a
|
||||
LEFT JOIN business_author b ON a.author_id = b.author_id
|
||||
WHERE
|
||||
1 = 1
|
||||
AND a.FOLLOW_ID = #{authorId}
|
||||
ORDER BY
|
||||
a.create_time DESC
|
||||
</select>
|
||||
|
||||
|
||||
<!-- 查询关注我的所有列表信息 并在查询的时候设置子查询 查询当前用户作为关注者的时候有没有关注对方-->
|
||||
<select id="selectFollowMeList" resultType="com.dd.admin.business.follow.domain.FollowVo">
|
||||
SELECT
|
||||
b.AUTHOR_ID,
|
||||
b.AUTHOR_NAME,
|
||||
b.AVATAR_URL,
|
||||
b.DESCRIPTION,
|
||||
(
|
||||
SELECT
|
||||
count(1)
|
||||
FROM
|
||||
business_follow
|
||||
WHERE
|
||||
follow_id = #{authorId}
|
||||
AND author_id = b.AUTHOR_ID
|
||||
) AS isFollow
|
||||
FROM
|
||||
business_follow a
|
||||
LEFT JOIN business_author b ON a.follow_id = b.author_id
|
||||
WHERE
|
||||
1 = 1
|
||||
AND a.AUTHOR_ID = #{authorId}
|
||||
ORDER BY
|
||||
a.create_time DESC
|
||||
</select>
|
||||
|
||||
</mapper>
|
||||
|
@@ -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<Follow> {
|
||||
|
||||
List<Follow> selectFollowListByFollowId(String followId);
|
||||
|
||||
Follow selectOneByFollowId(String authorId,String followId);
|
||||
|
||||
|
||||
List<FollowVo> selectMyFollowList( String authorId);
|
||||
List<FollowVo> selectFollowMeList(String authorId);
|
||||
|
||||
|
||||
}
|
||||
|
@@ -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<FollowMapper, Follow> impleme
|
||||
queryWrapper.eq(Follow::getFollowId,followId);
|
||||
return this.list(queryWrapper);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Follow selectOneByFollowId(String authorId, String followId) {
|
||||
LambdaQueryWrapper<Follow> queryWrapper = new LambdaQueryWrapper();
|
||||
queryWrapper.eq(Follow::getAuthorId,authorId);
|
||||
queryWrapper.eq(Follow::getFollowId,followId);
|
||||
return this.getOne(queryWrapper);
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<FollowVo> selectMyFollowList(String authorId) {
|
||||
return baseMapper.selectMyFollowList(authorId);
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<FollowVo> selectFollowMeList(String authorId) {
|
||||
return baseMapper.selectFollowMeList(authorId);
|
||||
}
|
||||
|
||||
}
|
||||
|
@@ -77,7 +77,7 @@
|
||||
AND a.AUTHOR_ID = #{noteDto.authorId}
|
||||
</if>
|
||||
<if test="noteDto.authorIds!= null and noteDto.authorIds!= ''">
|
||||
AND a.AUTHOR_ID IN ${noteDto.authorIds}
|
||||
AND a.AUTHOR_ID IN (${noteDto.authorIds})
|
||||
</if>
|
||||
<if test="noteDto.ipRealAddress!= null and noteDto.ipRealAddress!= ''">
|
||||
AND a.IP_REAL_ADDRESS = #{noteDto.ipRealAddress}
|
||||
|
@@ -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
|
||||
port: 8080
|
||||
|
Reference in New Issue
Block a user