Commit 5f86daad authored by 刘基明's avatar 刘基明

接口调整

parent 82501221
package com.tanpu.community.api.beans;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
@Data
@ApiModel(value = "讨论多图存储对象,等同于newsFeedRes")
public class ImagesDTO {
private Integer productType;
@ApiModelProperty("关联id")
private String relIdl;
@ApiModelProperty("关联类型 产品:88 直播:3 短视频:6 图片:122")
private Integer relType;
private String remark;
}
package com.tanpu.community.api.beans.req;
package com.tanpu.community.api.beans.req.theme;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
......@@ -22,7 +22,7 @@ public class CreateThemeReq {
@NotEmpty(message = "内容不能为空")
@ApiModelProperty(value = "文本内容")
private String content;
private ThemeContentReq content;
@ApiModelProperty(value = "所属的话题id")
private String topicId;
......
package com.tanpu.community.api.beans.req.theme;
import com.tanpu.community.api.beans.ImagesDTO;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import java.util.List;
@Data
@ApiModel(value = "主题内容")
public class ThemeContentReq {
......@@ -14,6 +17,6 @@ public class ThemeContentReq {
@ApiModelProperty(value = "文本的值是内容,附件的值为id")
private String value;
@ApiModelProperty(value = "类型为6时,传入图片列表")
private String[] imgList;
@ApiModelProperty(value = "图片列表,类型为6时此项有值")
private List<ImagesDTO> images;
}
......@@ -4,12 +4,16 @@ package com.tanpu.community.api.beans.req.theme;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import javax.validation.constraints.NotEmpty;
@Data
public class ThemeListReq {
@ApiModelProperty(value = "当前浏览的最后一个themeId")
@ApiModelProperty(value = "当前浏览的最后一个themeId,可以为空")
private String lastId;
@NotEmpty(message = "PageSize不能为空")
@ApiModelProperty(value = "页面大小")
private Integer PageSize;
@NotEmpty(message = "主题类型不能为空")
@ApiModelProperty(value = "类型,1:推荐 2:关注")
private Integer type;
......
......@@ -5,7 +5,7 @@ import com.tanpu.common.api.CommonResp;
import com.tanpu.community.api.beans.req.theme.ForwardThemeReq;
import com.tanpu.community.api.beans.qo.MainTextQo;
import com.tanpu.community.api.beans.qo.ThemeQo;
import com.tanpu.community.api.beans.req.CreateThemeReq;
import com.tanpu.community.api.beans.req.theme.CreateThemeReq;
import com.tanpu.community.api.beans.req.theme.ThemeListByTopicReq;
import com.tanpu.community.api.beans.req.theme.ThemeListReq;
import com.tanpu.community.manager.ThemeManager;
......@@ -43,13 +43,11 @@ public class ThemeController {
@ApiOperation("圈子首页-推荐/关注")
@GetMapping(value = "/list")
@ResponseBody
public List<ThemeQo> selectInterestList(@RequestBody ThemeListReq req) {
public CommonResp<List<ThemeQo>> selectInterestList(@RequestBody ThemeListReq req) {
String userId = "liujm";
if (req.getType()==1){
return themeManager.selectHotThemes(req,userId);
}else {
return themeManager.selectInterestThemes(req,userId);
}
List<ThemeQo> result= req.getType()==1?themeManager.selectHotThemes(req,userId)
:themeManager.selectInterestThemes(req,userId);
return CommonResp.success(result);
}
......
......@@ -46,9 +46,9 @@ public class TopicController {
@GetMapping(value = "/titleList")
@ApiOperation("首页顶部话题列表")
@ApiOperation("首页顶部话题标题列")
@ResponseBody
public CommonResp<List<TopicHotQo>> getHomePage(@RequestParam String topicId){
public CommonResp<List<TopicHotQo>> getTitleList(){
//todo
return CommonResp.success();
......
......@@ -6,7 +6,7 @@ import com.tanpu.community.api.beans.req.theme.ForwardThemeReq;
import com.tanpu.community.api.beans.qo.AttachmentQo;
import com.tanpu.community.api.beans.qo.MainTextQo;
import com.tanpu.community.api.beans.qo.ThemeQo;
import com.tanpu.community.api.beans.req.CreateThemeReq;
import com.tanpu.community.api.beans.req.theme.CreateThemeReq;
import com.tanpu.community.api.beans.req.theme.ThemeListByTopicReq;
import com.tanpu.community.api.beans.req.theme.ThemeListReq;
import com.tanpu.community.api.enums.BlockTypeEnum;
......@@ -105,7 +105,7 @@ public class ThemeManager {
// 返回推荐主题文章
public List<ThemeQo> selectHotThemes(ThemeListReq req, String userId) {
// TODO:推荐
List<ThemeEntity> themeEntities = themeService.selectAll();
List<ThemeEntity> themeEntities = themeService.selectAll(req.getLastId(),req.getPageSize());
List<ThemeQo> themeQos = convertEntityToQo(themeEntities, userId);
return themeQos;
}
......@@ -114,7 +114,14 @@ public class ThemeManager {
// 返回关注主题
public List<ThemeQo> selectInterestThemes(ThemeListReq req,String userId) {
List<String> fansList = followRelService.queryFansByFollowerId(userId);
List<ThemeEntity> themeEntities = themeService.selectByFans(fansList);
List<ThemeEntity> themeEntities = themeService.queryByFans(fansList,req.getLastId(),req.getPageSize());
List<ThemeQo> themeQos = convertEntityToQo(themeEntities, userId);
return themeQos;
}
public List<ThemeQo> queryByTopic(ThemeListByTopicReq req, String userId) {
//TODO
List<ThemeEntity> themeEntities = themeService.queryByTopic(req.getTopicId(),req.getLastId(),req.getPageSize());
List<ThemeQo> themeQos = convertEntityToQo(themeEntities, userId);
return themeQos;
}
......@@ -122,7 +129,7 @@ public class ThemeManager {
//返回正文
public MainTextQo getMainText(String themeId, String userId) {
ThemeEntity themeEntity = themeService.selectById(themeId);
ThemeEntity themeEntity = themeService.queryById(themeId);
if (themeEntity == null) {
throw new BizException("找不到帖子id:" + themeId);
}
......@@ -144,7 +151,7 @@ public class ThemeManager {
//转发
public void forward(ForwardThemeReq req, String userId) {
ThemeEntity targetTheme = themeService.selectById(req.getFormerThemeId());
ThemeEntity targetTheme = themeService.queryById(req.getFormerThemeId());
ThemeEntity newTheme = ThemeEntity.builder()
.content(req.getContent())
.topicId(req.getTopicId())
......@@ -187,9 +194,9 @@ public class ThemeManager {
// 屏蔽(主题)
public void blockTheme(String themeId, String userId) {
blackListService.addBlock(themeId, userId, BlockTypeEnum.THEME);
BlackListEntity selectOne = blackListService.selectOne(themeService.selectById(themeId).getAuthorId(), userId, BlockTypeEnum.USER.getCode());
BlackListEntity selectOne = blackListService.selectOne(themeService.queryById(themeId).getAuthorId(), userId, BlockTypeEnum.USER.getCode());
if (selectOne == null) {
blackListService.addBlock(themeService.selectById(themeId).getAuthorId(), userId, BlockTypeEnum.USER);
blackListService.addBlock(themeService.queryById(themeId).getAuthorId(), userId, BlockTypeEnum.USER);
}
}
......@@ -323,8 +330,5 @@ public class ThemeManager {
return start.format(DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss"));
}
public List<ThemeQo> queryByTopic(ThemeListByTopicReq req, String userId) {
//TODO
return null;
}
}
......@@ -125,7 +125,7 @@ public class TopicManager {
for (TopicEntity topic : topicEntities) {
String topicId = topic.getTopicId();
Long viewCountModify = topic.getviewCntAdjust();
List<ThemeEntity> themeEntities = themeService.selectByTopic(topicId);
List<ThemeEntity> themeEntities = themeService.queryByTopic(topicId,null,null);
List<String> themeIds = themeEntities.stream().map(ThemeEntity::getThemeId).collect(Collectors.toList());
Integer likeCountByThemeIds = collectionService.getCountByTypeAndIds(themeIds, CollectionTypeEnum.LIKE_THEME);
Integer bookCountByThemeIds = collectionService.getCountByTypeAndIds(themeIds, CollectionTypeEnum.BOOK_THEME);
......
......@@ -25,8 +25,9 @@ public class FollowRelService {
// @Cacheable(value = "tempCache", keyGenerator = "communityKeyGenerator")
public List<String> queryFansByIdolId(String idolId) {
return followRelMapper.selectList(new LambdaQueryWrapper<FollowRelEntity>()
.eq(FollowRelEntity::getFollowId, idolId))
LambdaQueryWrapper<FollowRelEntity> queryWrapper = new LambdaQueryWrapper<FollowRelEntity>()
.eq(FollowRelEntity::getFollowId, idolId);
return followRelMapper.selectList(queryWrapper)
.stream().map(FollowRelEntity::getFollowerId).collect(Collectors.toList());
}
......
package com.tanpu.community.service;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.tanpu.common.exception.BizException;
import com.tanpu.common.uuid.UuidGenHelper;
import com.tanpu.community.api.enums.DeleteTagEnum;
import com.tanpu.community.dao.entity.community.ThemeEntity;
import com.tanpu.community.dao.mapper.community.ThemeMapper;
import org.apache.commons.lang3.StringUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
......@@ -22,33 +24,61 @@ public class ThemeService {
@Autowired
private UuidGenHelper uuidGenHelper;
public void insertTheme(ThemeEntity themeEntity){
public void insertTheme(ThemeEntity themeEntity) {
themeEntity.setThemeId(uuidGenHelper.getUuidStr());
themeMapper.insert(themeEntity);
}
//根据id返回主题详情
public ThemeEntity selectById(String themeId){
public ThemeEntity queryById(String themeId) {
return themeMapper.selectById(themeId);
}
//根据话题查询主题
public List<ThemeEntity> selectByTopic(String topidId){
return themeMapper.selectList(new LambdaQueryWrapper<ThemeEntity>()
.eq(ThemeEntity::getTopicId,topidId));
public List<ThemeEntity> queryByTopic(String topidId, String lastId,Integer pageSize) {
LambdaQueryWrapper<ThemeEntity> queryWrapper = new LambdaQueryWrapper<ThemeEntity>()
.eq(ThemeEntity::getTopicId, topidId);
if (StringUtils.isNotEmpty(lastId)) {
ThemeEntity lastEntity = queryById(lastId);
if (lastEntity==null) throw new BizException("主题未找到,id:"+lastId);
queryWrapper.lt(ThemeEntity::getUpdateTime, lastEntity.getUpdateTime());
}
if (pageSize!=null){
queryWrapper.last("limit "+pageSize);
}
return themeMapper.selectList(queryWrapper);
}
//查询列表中用户的主题
public List<ThemeEntity> selectByFans(List<String> fansList) {
return themeMapper.selectList(new LambdaQueryWrapper<ThemeEntity>()
.in(ThemeEntity::getAuthorId,fansList)
.orderByDesc(ThemeEntity::getUpdateTime));
//关注的主题列表
public List<ThemeEntity> queryByFans(List<String> fansList, String lastId,Integer pageSize) {
LambdaQueryWrapper<ThemeEntity> queryWrapper = new LambdaQueryWrapper<ThemeEntity>()
.in(ThemeEntity::getAuthorId, fansList)
.orderByDesc(ThemeEntity::getUpdateTime);
if (StringUtils.isNotEmpty(lastId)) {
ThemeEntity lastEntity = queryById(lastId);
if (lastEntity==null) throw new BizException("主题未找到,id:"+lastId);
queryWrapper.lt(ThemeEntity::getUpdateTime, lastEntity.getUpdateTime());
}
queryWrapper.last("limit "+pageSize);
return themeMapper.selectList(queryWrapper);
}
//查询列表中用户的主题
public List<ThemeEntity> selectAll() {
return themeMapper.selectList(new LambdaQueryWrapper<ThemeEntity>()
.orderByDesc(ThemeEntity::getUpdateTime));
public List<ThemeEntity> selectAll(String lastId,Integer pageSize) {
LambdaQueryWrapper<ThemeEntity> queryWrapper = new LambdaQueryWrapper<ThemeEntity>()
.orderByDesc(ThemeEntity::getUpdateTime);
if (StringUtils.isNotEmpty(lastId)) {
ThemeEntity lastEntity = queryById(lastId);
if (lastEntity==null) throw new BizException("主题未找到,id:"+lastId);
queryWrapper.lt(ThemeEntity::getUpdateTime, lastEntity.getUpdateTime());
}
queryWrapper.last("limit "+pageSize);
return themeMapper.selectList(queryWrapper);
}
//查询对应话题的发表用户集合
......@@ -60,7 +90,7 @@ public class ThemeService {
public Integer getForwardCountById(String themeId) {
return themeMapper.selectCount(new LambdaQueryWrapper<ThemeEntity>()
.eq(ThemeEntity::getThemeId,themeId)
.eq(ThemeEntity::getThemeId, themeId)
.eq(ThemeEntity::getDeleteTag, DeleteTagEnum.NOT_DELETED));
}
}
......@@ -6,7 +6,7 @@ import com.tanpu.community.api.beans.qo.CommentLv2Qo;
import com.tanpu.community.api.beans.qo.CommentQo;
import com.tanpu.community.api.beans.qo.FollowQo;
import com.tanpu.community.api.beans.qo.ThemeQo;
import com.tanpu.community.api.beans.req.CreateThemeReq;
import com.tanpu.community.api.beans.req.theme.CreateThemeReq;
import com.tanpu.community.api.enums.DeleteTagEnum;
import com.tanpu.community.dao.entity.community.*;
import org.springframework.beans.BeanUtils;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment