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